Skip to content

Commit c6caf54

Browse files
authored
Merge pull request #12 from akihikokuroda/maestrocleanup
2 parents 970b8bb + 60cb8f8 commit c6caf54

File tree

6 files changed

+35
-75
lines changed

6 files changed

+35
-75
lines changed

internal/commands/create.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ import (
1414
type CreateCommand struct {
1515
*BaseCommand
1616
agentsFile string
17+
mcpServerURI string
1718
}
1819

1920
// NewCreateCommand creates a new create command
2021
func NewCreateCommand() *cobra.Command {
22+
var mcpServerURI string
23+
2124
cmd := &cobra.Command{
2225
Use: "create AGENTS_FILE",
2326
Short: "Create agents from a configuration file",
@@ -29,11 +32,13 @@ func NewCreateCommand() *cobra.Command {
2932
createCmd := &CreateCommand{
3033
BaseCommand: NewBaseCommand(options),
3134
agentsFile: args[0],
35+
mcpServerURI: mcpServerURI,
3236
}
3337

3438
return createCmd.Run()
3539
},
3640
}
41+
cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)")
3742

3843
return cmd
3944
}
@@ -83,15 +88,8 @@ func (c *CreateCommand) createAgentsFromYAML(agentsYaml []common.YAMLDocument) e
8388
// For now, we'll just print a message
8489
c.Console().Ok("Creating agents from YAML configuration")
8590

86-
// TODO: Implement the actual agent creation logic
87-
// This would involve:
88-
// 1. Parsing the agent definitions
89-
// 2. Creating the agent instances
90-
// 3. Registering them with the system
91-
9291
// Get MCP server URI
93-
// serverURI, _ := common.GetMCPServerURI(mcpServerURI)
94-
serverURI, err := common.GetMCPServerURI("")
92+
serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI)
9593
if err != nil {
9694
if common.Progress != nil {
9795
common.Progress.StopWithError("Failed to get MCP server URI")

internal/commands/deploy.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ type DeployCommand struct {
2424
streamlit bool
2525
autoPrompt bool
2626
env []string
27+
mcpServerURI string
2728
}
2829

2930
// NewDeployCommand creates a new deploy command
3031
func NewDeployCommand() *cobra.Command {
32+
var mcpServerURI string
3133
deployCmd := &DeployCommand{}
3234

3335
cmd := &cobra.Command{
@@ -75,6 +77,11 @@ func NewDeployCommand() *cobra.Command {
7577
return err
7678
}
7779

80+
deployCmd.mcpServerURI, err = cmd.Flags().GetString("mcp-server-uri")
81+
if err != nil {
82+
return err
83+
}
84+
7885
return deployCmd.Run()
7986
},
8087
}
@@ -86,6 +93,7 @@ func NewDeployCommand() *cobra.Command {
8693
cmd.Flags().Bool("docker", false, "Deploy to Docker")
8794
cmd.Flags().Bool("streamlit", false, "Deploy as Streamlit application (default)")
8895
cmd.Flags().Bool("auto-prompt", false, "Run prompt by default if specified")
96+
cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)")
8997

9098
return cmd
9199
}
@@ -145,8 +153,7 @@ func (c *DeployCommand) deployToTarget(target string, env string) error {
145153
c.Console().Ok("Deploying workflow to Kubernetes")
146154

147155
// Get MCP server URI
148-
// serverURI, _ := common.GetMCPServerURI(mcpServerURI)
149-
serverURI, err := common.GetMCPServerURI("")
156+
serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI)
150157
if err != nil {
151158
if common.Progress != nil {
152159
common.Progress.StopWithError("Failed to get MCP server URI")

internal/commands/meta_agents.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,5 @@ func (c *MetaAgentsCommand) runMetaAgents() error {
7979
return fmt.Errorf("failed to start meta-agents: %w", err)
8080
}
8181

82-
// Store the process ID for later cleanup
83-
// TODO: Store the process ID somewhere for the clean command to use
84-
8582
return nil
8683
}

internal/commands/run.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ type RunCommand struct {
1919
agentsFile string
2020
workflowFile string
2121
prompt bool
22+
mcpServerURI string
2223
}
2324

2425
// NewRunCommand creates a new run command
2526
func NewRunCommand() *cobra.Command {
2627
var prompt bool
28+
var mcpServerURI string
2729

2830
cmd := &cobra.Command{
2931
Use: "run [AGENTS_FILE] WORKFLOW_FILE",
@@ -47,13 +49,15 @@ func NewRunCommand() *cobra.Command {
4749
agentsFile: agentsFile,
4850
workflowFile: workflowFile,
4951
prompt: prompt,
52+
mcpServerURI: mcpServerURI,
5053
}
5154

5255
return runCmd.Run()
5356
},
5457
}
5558

5659
cmd.Flags().BoolVar(&prompt, "prompt", false, "Reads a user prompt and executes workflow with it")
60+
cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)")
5761

5862
return cmd
5963
}
@@ -184,11 +188,6 @@ func (c *RunCommand) Run() error {
184188

185189
// Extract output from the result
186190
output := result["result"].(*common.MCPResponse)
187-
// TODO: Extract output from the workflow result
188-
// This would involve:
189-
// 1. Getting the steps from the workflow
190-
// 2. Finding the last step that produced a result
191-
// 3. Using that result as the output
192191

193192
// Log the workflow run
194193
response := ""
@@ -239,8 +238,7 @@ func (c *RunCommand) runWorkflow(workflow common.YAMLDocument, agents []common.Y
239238
c.Console().Ok("Running workflow")
240239

241240
// Get MCP server URI
242-
// serverURI, _ := common.GetMCPServerURI(mcpServerURI)
243-
serverURI, err := common.GetMCPServerURI("")
241+
serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI)
244242
if err != nil {
245243
if common.Progress != nil {
246244
common.Progress.StopWithError("Failed to get MCP server URI")
@@ -305,14 +303,5 @@ func (c *RunCommand) runWorkflow(workflow common.YAMLDocument, agents []common.Y
305303

306304
// logWorkflowRun logs the workflow run
307305
func (c *RunCommand) logWorkflowRun(logger *common.Logger, workflowID, workflowName, prompt, output string, modelsUsed []string, status string, startTime, endTime time.Time, durationMs int) {
308-
// In the Python implementation, this calls logger.log_workflow_run()
309-
// We'll need to implement the equivalent functionality in Go
310-
311-
// For now, we'll just print a message
312306
c.Console().Ok(fmt.Sprintf("Workflow %s completed with status: %s", workflowID, status))
313-
314-
// TODO: Implement the actual logging logic
315-
// This would involve:
316-
// 1. Creating a log entry
317-
// 2. Writing it to the log file
318307
}

internal/commands/serve.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type AgentServeCommand struct {
1919
agentName string
2020
host string
2121
port int
22+
mcpServerURI string
2223
}
2324

2425
type WorkflowServeCommand struct {
@@ -27,10 +28,12 @@ type WorkflowServeCommand struct {
2728
workflowFile string
2829
host string
2930
port int
31+
mcpServerURI string
3032
}
3133

3234
// NewServeCommand creates a new serve command
3335
func NewAgentServeCommand() *cobra.Command {
36+
var mcpServerURI string
3437
agentServeCmd := &AgentServeCommand{}
3538

3639
cmd := &cobra.Command{
@@ -69,6 +72,7 @@ func NewAgentServeCommand() *cobra.Command {
6972
return fmt.Errorf("invalid port number: %s", portStr)
7073
}
7174
}
75+
agentServeCmd.mcpServerURI = mcpServerURI
7276

7377
return agentServeCmd.Run()
7478
},
@@ -77,11 +81,13 @@ func NewAgentServeCommand() *cobra.Command {
7781
cmd.Flags().String("agent-name", "", "Specific agent name to serve (if multiple in file)")
7882
cmd.Flags().String("host", "127.0.0.1", "Host to bind to")
7983
cmd.Flags().String("port", "8000", "Port to serve on")
84+
cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)")
8085
return cmd
8186
}
8287

8388
// NewServeCommand creates a new serve command
8489
func NewWorkflowServeCommand() *cobra.Command {
90+
var mcpServerURI string
8591
workflowServeCmd := &WorkflowServeCommand{}
8692

8793
cmd := &cobra.Command{
@@ -116,6 +122,7 @@ func NewWorkflowServeCommand() *cobra.Command {
116122
return fmt.Errorf("invalid port number: %s", portStr)
117123
}
118124
}
125+
workflowServeCmd.mcpServerURI = mcpServerURI
119126

120127
return workflowServeCmd.Run()
121128
},
@@ -124,6 +131,7 @@ func NewWorkflowServeCommand() *cobra.Command {
124131
cmd.Flags().String("agent-name", "", "Specific agent name to serve (if multiple in file)")
125132
cmd.Flags().String("host", "127.0.0.1", "Host to bind to")
126133
cmd.Flags().String("port", "8000", "Port to serve on")
134+
cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)")
127135
return cmd
128136
}
129137

@@ -159,8 +167,7 @@ func (c *WorkflowServeCommand) serveWorkflow() error {
159167
c.Console().Print(fmt.Sprintf("Serving workflow at %s:%d\n", c.host, c.port))
160168

161169
// Get MCP server URI
162-
// serverURI, _ := common.GetMCPServerURI(mcpServerURI)
163-
serverURI, err := common.GetMCPServerURI("")
170+
serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI)
164171
if err != nil {
165172
if common.Progress != nil {
166173
common.Progress.StopWithError("Failed to get MCP server URI")
@@ -275,8 +282,7 @@ func (c *AgentServeCommand) getAgentFramework() (string, error) {
275282
// serveContainerAgent serves a container agent
276283
func (c *AgentServeCommand) serveContainerAgent() error {
277284
// Get MCP server URI
278-
// serverURI, _ := common.GetMCPServerURI(mcpServerURI)
279-
serverURI, err := common.GetMCPServerURI("")
285+
serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI)
280286
if err != nil {
281287
if common.Progress != nil {
282288
common.Progress.StopWithError("Failed to get MCP server URI")
@@ -362,8 +368,7 @@ func (c *AgentServeCommand) serveContainerAgent() error {
362368
// serveFastAPIAgent serves a FastAPI agent
363369
func (c AgentServeCommand) serveFastAPIAgent() error {
364370
// Get MCP server URI
365-
// serverURI, _ := common.GetMCPServerURI(mcpServerURI)
366-
serverURI, err := common.GetMCPServerURI("")
371+
serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI)
367372
if err != nil {
368373
if common.Progress != nil {
369374
common.Progress.StopWithError("Failed to get MCP server URI")

internal/common/mcp_client.go

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ type MCPError struct {
3737
Message string `json:"message"`
3838
}
3939

40-
// DatabaseInfo represents information about a vector database
41-
type DatabaseInfo struct {
42-
Name string `json:"name"`
43-
Type string `json:"type"`
44-
Collection string `json:"collection"`
45-
DocumentCount int `json:"document_count"`
46-
}
47-
4840
// normalizeURL ensures the URL has a protocol prefix and MCP endpoint
4941
func normalizeURL(url string) string {
5042
// If it already has a protocol, just ensure it has the /mcp endpoint
@@ -64,8 +56,8 @@ func normalizeURL(url string) string {
6456
return "http://" + url + ":8030/mcp"
6557
}
6658

67-
// getMCPServerURI gets the MCP server URI from environment variable or command line flag
68-
func GetMCPServerURI(cmdServerURI string) (string, error) {
59+
// getMaestroMCPServerURI gets the Maestro MCP server URI from environment variable or command line flag
60+
func GetMaestroMCPServerURI(cmdServerURI string) (string, error) {
6961
// Load .env file if it exists
7062
if _, err := os.Stat(".env"); err == nil {
7163
if err := godotenv.Load(); err != nil {
@@ -76,10 +68,10 @@ func GetMCPServerURI(cmdServerURI string) (string, error) {
7668
var serverURI string
7769
if cmdServerURI != "" {
7870
serverURI = cmdServerURI
79-
} else if envURI := os.Getenv("MAESTRO_KNOWLEDGE_MCP_SERVER_URI"); envURI != "" {
71+
} else if envURI := os.Getenv("MAESTRO_MAESTRO_MCP_SERVER_URI"); envURI != "" {
8072
serverURI = envURI
8173
} else {
82-
serverURI = "localhost:8030" // Default
74+
serverURI = "localhost:8040" // Default
8375
}
8476

8577
return normalizeURL(serverURI), nil
@@ -227,31 +219,3 @@ func (c *MCPClient) Close() error {
227219
}
228220
return nil
229221
}
230-
231-
// CreateVectorDatabase calls the create_vector_database_tool on the MCP server
232-
func (c *MCPClient) CreateVectorDatabase(dbName, dbType, collectionName string) error {
233-
params := map[string]interface{}{
234-
"input": map[string]interface{}{
235-
"db_name": dbName,
236-
"db_type": dbType,
237-
"collection_name": collectionName,
238-
},
239-
}
240-
241-
response, err := c.CallMCPServer("create_vector_database_tool", params)
242-
if err != nil {
243-
return err
244-
}
245-
246-
// Check for error in response
247-
if response.Error != nil {
248-
return fmt.Errorf("MCP server error: %s", response.Error.Message)
249-
}
250-
251-
// The response should be a success message
252-
if response.Result == nil {
253-
return fmt.Errorf("no response from MCP server (check server at %s)", c.baseURL)
254-
}
255-
256-
return nil
257-
}

0 commit comments

Comments
 (0)