Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions internal/commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down
11 changes: 9 additions & 2 deletions internal/commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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()
},
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 0 additions & 3 deletions internal/commands/meta_agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
21 changes: 5 additions & 16 deletions internal/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -47,13 +49,15 @@ func NewRunCommand() *cobra.Command {
agentsFile: agentsFile,
workflowFile: workflowFile,
prompt: prompt,
mcpServerURI: mcpServerURI,
}

return runCmd.Run()
},
}

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
}
Expand Down Expand Up @@ -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 := ""
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
17 changes: 11 additions & 6 deletions internal/commands/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AgentServeCommand struct {
agentName string
host string
port int
mcpServerURI string
}

type WorkflowServeCommand struct {
Expand All @@ -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{
Expand Down Expand Up @@ -69,6 +72,7 @@ func NewAgentServeCommand() *cobra.Command {
return fmt.Errorf("invalid port number: %s", portStr)
}
}
agentServeCmd.mcpServerURI = mcpServerURI

return agentServeCmd.Run()
},
Expand All @@ -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{
Expand Down Expand Up @@ -116,6 +122,7 @@ func NewWorkflowServeCommand() *cobra.Command {
return fmt.Errorf("invalid port number: %s", portStr)
}
}
workflowServeCmd.mcpServerURI = mcpServerURI

return workflowServeCmd.Run()
},
Expand All @@ -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
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
44 changes: 4 additions & 40 deletions internal/common/mcp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Loading