diff --git a/internal/commands/create.go b/internal/commands/create.go index 09fc797..4368227 100644 --- a/internal/commands/create.go +++ b/internal/commands/create.go @@ -14,10 +14,13 @@ import ( type CreateCommand struct { *BaseCommand agentsFile string + mcpServerURI string } // NewCreateCommand creates a new create command func NewCreateCommand() *cobra.Command { + var mcpServerURI string + cmd := &cobra.Command{ Use: "create AGENTS_FILE", Short: "Create agents from a configuration file", @@ -29,11 +32,13 @@ func NewCreateCommand() *cobra.Command { createCmd := &CreateCommand{ BaseCommand: NewBaseCommand(options), agentsFile: args[0], + mcpServerURI: mcpServerURI, } return createCmd.Run() }, } + cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)") return cmd } @@ -83,15 +88,8 @@ func (c *CreateCommand) createAgentsFromYAML(agentsYaml []common.YAMLDocument) e // For now, we'll just print a message c.Console().Ok("Creating agents from YAML configuration") - // TODO: Implement the actual agent creation logic - // This would involve: - // 1. Parsing the agent definitions - // 2. Creating the agent instances - // 3. Registering them with the system - // Get MCP server URI - // serverURI, _ := common.GetMCPServerURI(mcpServerURI) - serverURI, err := common.GetMCPServerURI("") + serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI) if err != nil { if common.Progress != nil { common.Progress.StopWithError("Failed to get MCP server URI") diff --git a/internal/commands/deploy.go b/internal/commands/deploy.go index 0874021..7bf8d8e 100644 --- a/internal/commands/deploy.go +++ b/internal/commands/deploy.go @@ -24,10 +24,12 @@ type DeployCommand struct { streamlit bool autoPrompt bool env []string + mcpServerURI string } // NewDeployCommand creates a new deploy command func NewDeployCommand() *cobra.Command { + var mcpServerURI string deployCmd := &DeployCommand{} cmd := &cobra.Command{ @@ -75,6 +77,11 @@ func NewDeployCommand() *cobra.Command { return err } + deployCmd.mcpServerURI, err = cmd.Flags().GetString("mcp-server-uri") + if err != nil { + return err + } + return deployCmd.Run() }, } @@ -86,6 +93,7 @@ func NewDeployCommand() *cobra.Command { cmd.Flags().Bool("docker", false, "Deploy to Docker") cmd.Flags().Bool("streamlit", false, "Deploy as Streamlit application (default)") cmd.Flags().Bool("auto-prompt", false, "Run prompt by default if specified") + cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)") return cmd } @@ -145,8 +153,7 @@ func (c *DeployCommand) deployToTarget(target string, env string) error { c.Console().Ok("Deploying workflow to Kubernetes") // Get MCP server URI - // serverURI, _ := common.GetMCPServerURI(mcpServerURI) - serverURI, err := common.GetMCPServerURI("") + serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI) if err != nil { if common.Progress != nil { common.Progress.StopWithError("Failed to get MCP server URI") diff --git a/internal/commands/meta_agents.go b/internal/commands/meta_agents.go index da1e311..ebbfac6 100644 --- a/internal/commands/meta_agents.go +++ b/internal/commands/meta_agents.go @@ -79,8 +79,5 @@ func (c *MetaAgentsCommand) runMetaAgents() error { return fmt.Errorf("failed to start meta-agents: %w", err) } - // Store the process ID for later cleanup - // TODO: Store the process ID somewhere for the clean command to use - return nil } diff --git a/internal/commands/run.go b/internal/commands/run.go index 1b02f65..02fa28d 100644 --- a/internal/commands/run.go +++ b/internal/commands/run.go @@ -19,11 +19,13 @@ type RunCommand struct { agentsFile string workflowFile string prompt bool + mcpServerURI string } // NewRunCommand creates a new run command func NewRunCommand() *cobra.Command { var prompt bool + var mcpServerURI string cmd := &cobra.Command{ Use: "run [AGENTS_FILE] WORKFLOW_FILE", @@ -47,6 +49,7 @@ func NewRunCommand() *cobra.Command { agentsFile: agentsFile, workflowFile: workflowFile, prompt: prompt, + mcpServerURI: mcpServerURI, } return runCmd.Run() @@ -54,6 +57,7 @@ func NewRunCommand() *cobra.Command { } cmd.Flags().BoolVar(&prompt, "prompt", false, "Reads a user prompt and executes workflow with it") + cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)") return cmd } @@ -184,11 +188,6 @@ func (c *RunCommand) Run() error { // Extract output from the result output := result["result"].(*common.MCPResponse) - // TODO: Extract output from the workflow result - // This would involve: - // 1. Getting the steps from the workflow - // 2. Finding the last step that produced a result - // 3. Using that result as the output // Log the workflow run response := "" @@ -239,8 +238,7 @@ func (c *RunCommand) runWorkflow(workflow common.YAMLDocument, agents []common.Y c.Console().Ok("Running workflow") // Get MCP server URI - // serverURI, _ := common.GetMCPServerURI(mcpServerURI) - serverURI, err := common.GetMCPServerURI("") + serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI) if err != nil { if common.Progress != nil { common.Progress.StopWithError("Failed to get MCP server URI") @@ -305,14 +303,5 @@ func (c *RunCommand) runWorkflow(workflow common.YAMLDocument, agents []common.Y // logWorkflowRun logs the workflow run func (c *RunCommand) logWorkflowRun(logger *common.Logger, workflowID, workflowName, prompt, output string, modelsUsed []string, status string, startTime, endTime time.Time, durationMs int) { - // In the Python implementation, this calls logger.log_workflow_run() - // We'll need to implement the equivalent functionality in Go - - // For now, we'll just print a message c.Console().Ok(fmt.Sprintf("Workflow %s completed with status: %s", workflowID, status)) - - // TODO: Implement the actual logging logic - // This would involve: - // 1. Creating a log entry - // 2. Writing it to the log file } diff --git a/internal/commands/serve.go b/internal/commands/serve.go index 89e90c0..a6aa6bc 100644 --- a/internal/commands/serve.go +++ b/internal/commands/serve.go @@ -19,6 +19,7 @@ type AgentServeCommand struct { agentName string host string port int + mcpServerURI string } type WorkflowServeCommand struct { @@ -27,10 +28,12 @@ type WorkflowServeCommand struct { workflowFile string host string port int + mcpServerURI string } // NewServeCommand creates a new serve command func NewAgentServeCommand() *cobra.Command { + var mcpServerURI string agentServeCmd := &AgentServeCommand{} cmd := &cobra.Command{ @@ -69,6 +72,7 @@ func NewAgentServeCommand() *cobra.Command { return fmt.Errorf("invalid port number: %s", portStr) } } + agentServeCmd.mcpServerURI = mcpServerURI return agentServeCmd.Run() }, @@ -77,11 +81,13 @@ func NewAgentServeCommand() *cobra.Command { cmd.Flags().String("agent-name", "", "Specific agent name to serve (if multiple in file)") cmd.Flags().String("host", "127.0.0.1", "Host to bind to") cmd.Flags().String("port", "8000", "Port to serve on") + cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)") return cmd } // NewServeCommand creates a new serve command func NewWorkflowServeCommand() *cobra.Command { + var mcpServerURI string workflowServeCmd := &WorkflowServeCommand{} cmd := &cobra.Command{ @@ -116,6 +122,7 @@ func NewWorkflowServeCommand() *cobra.Command { return fmt.Errorf("invalid port number: %s", portStr) } } + workflowServeCmd.mcpServerURI = mcpServerURI return workflowServeCmd.Run() }, @@ -124,6 +131,7 @@ func NewWorkflowServeCommand() *cobra.Command { cmd.Flags().String("agent-name", "", "Specific agent name to serve (if multiple in file)") cmd.Flags().String("host", "127.0.0.1", "Host to bind to") cmd.Flags().String("port", "8000", "Port to serve on") + cmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)") return cmd } @@ -159,8 +167,7 @@ func (c *WorkflowServeCommand) serveWorkflow() error { c.Console().Print(fmt.Sprintf("Serving workflow at %s:%d\n", c.host, c.port)) // Get MCP server URI - // serverURI, _ := common.GetMCPServerURI(mcpServerURI) - serverURI, err := common.GetMCPServerURI("") + serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI) if err != nil { if common.Progress != nil { common.Progress.StopWithError("Failed to get MCP server URI") @@ -275,8 +282,7 @@ func (c *AgentServeCommand) getAgentFramework() (string, error) { // serveContainerAgent serves a container agent func (c *AgentServeCommand) serveContainerAgent() error { // Get MCP server URI - // serverURI, _ := common.GetMCPServerURI(mcpServerURI) - serverURI, err := common.GetMCPServerURI("") + serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI) if err != nil { if common.Progress != nil { common.Progress.StopWithError("Failed to get MCP server URI") @@ -362,8 +368,7 @@ func (c *AgentServeCommand) serveContainerAgent() error { // serveFastAPIAgent serves a FastAPI agent func (c AgentServeCommand) serveFastAPIAgent() error { // Get MCP server URI - // serverURI, _ := common.GetMCPServerURI(mcpServerURI) - serverURI, err := common.GetMCPServerURI("") + serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI) if err != nil { if common.Progress != nil { common.Progress.StopWithError("Failed to get MCP server URI") diff --git a/internal/common/mcp_client.go b/internal/common/mcp_client.go index db17041..6008610 100644 --- a/internal/common/mcp_client.go +++ b/internal/common/mcp_client.go @@ -37,14 +37,6 @@ type MCPError struct { Message string `json:"message"` } -// DatabaseInfo represents information about a vector database -type DatabaseInfo struct { - Name string `json:"name"` - Type string `json:"type"` - Collection string `json:"collection"` - DocumentCount int `json:"document_count"` -} - // normalizeURL ensures the URL has a protocol prefix and MCP endpoint func normalizeURL(url string) string { // If it already has a protocol, just ensure it has the /mcp endpoint @@ -64,8 +56,8 @@ func normalizeURL(url string) string { return "http://" + url + ":8030/mcp" } -// getMCPServerURI gets the MCP server URI from environment variable or command line flag -func GetMCPServerURI(cmdServerURI string) (string, error) { +// getMaestroMCPServerURI gets the Maestro MCP server URI from environment variable or command line flag +func GetMaestroMCPServerURI(cmdServerURI string) (string, error) { // Load .env file if it exists if _, err := os.Stat(".env"); err == nil { if err := godotenv.Load(); err != nil { @@ -76,10 +68,10 @@ func GetMCPServerURI(cmdServerURI string) (string, error) { var serverURI string if cmdServerURI != "" { serverURI = cmdServerURI - } else if envURI := os.Getenv("MAESTRO_KNOWLEDGE_MCP_SERVER_URI"); envURI != "" { + } else if envURI := os.Getenv("MAESTRO_MAESTRO_MCP_SERVER_URI"); envURI != "" { serverURI = envURI } else { - serverURI = "localhost:8030" // Default + serverURI = "localhost:8040" // Default } return normalizeURL(serverURI), nil @@ -227,31 +219,3 @@ func (c *MCPClient) Close() error { } return nil } - -// CreateVectorDatabase calls the create_vector_database_tool on the MCP server -func (c *MCPClient) CreateVectorDatabase(dbName, dbType, collectionName string) error { - params := map[string]interface{}{ - "input": map[string]interface{}{ - "db_name": dbName, - "db_type": dbType, - "collection_name": collectionName, - }, - } - - response, err := c.CallMCPServer("create_vector_database_tool", params) - if err != nil { - return err - } - - // Check for error in response - if response.Error != nil { - return fmt.Errorf("MCP server error: %s", response.Error.Message) - } - - // The response should be a success message - if response.Result == nil { - return fmt.Errorf("no response from MCP server (check server at %s)", c.baseURL) - } - - return nil -}