Skip to content

Commit 167ad89

Browse files
committed
add tool create command
Signed-off-by: Akihiko Kuroda <[email protected]>
1 parent 97783bc commit 167ad89

File tree

3 files changed

+69
-11
lines changed

3 files changed

+69
-11
lines changed

internal/commands/create.go

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,64 @@ func (c *CreateCommand) createAgentsFromYAML(agentsYaml []common.YAMLDocument) e
146146
}
147147

148148
// createMCPToolsFromYAML creates MCP tools from the YAML configuration
149-
func (c *CreateCommand) createMCPToolsFromYAML(agentsYaml []common.YAMLDocument) error {
150-
// In the Python implementation, this calls create_mcptools from maestro.mcptool
151-
// We'll need to implement the equivalent functionality in Go
152-
149+
func (c *CreateCommand) createMCPToolsFromYAML(toolsYaml []common.YAMLDocument) error {
153150
// For now, we'll just print a message
154151
c.Console().Ok("Creating MCP tools from YAML configuration")
155152

156-
// TODO: Implement the actual MCP tool creation logic
157-
// This would involve:
158-
// 1. Parsing the tool definitions
159-
// 2. Creating the tool instances
160-
// 3. Registering them with the system
153+
// Get MCP server URI
154+
serverURI, err := common.GetMCPServerURI("")
155+
// serverURI, err := common.GetMaestroMCPServerURI(c.mcpServerURI)
156+
if err != nil {
157+
if common.Progress != nil {
158+
common.Progress.StopWithError("Failed to get MCP server URI")
159+
}
160+
return err
161+
}
162+
163+
if common.Verbose {
164+
fmt.Printf("Connecting to MCP server at: %s\n", serverURI)
165+
}
166+
167+
// Create MCP client
168+
client, _ := common.NewMCPClient(serverURI)
169+
if err != nil {
170+
if common.Progress != nil {
171+
common.Progress.StopWithError("Failed to create MCP client")
172+
}
173+
return err
174+
}
175+
defer client.Close()
176+
177+
if common.Progress != nil {
178+
common.Progress.Update("Executing create tools...")
179+
}
180+
181+
// Call the run_workflow tool
182+
tool_strings, err := common.YamlToString(toolsYaml)
183+
if err != nil {
184+
fmt.Println("tool file error")
185+
}
186+
187+
params := map[string]interface{}{
188+
"tools": tool_strings,
189+
}
190+
191+
result, err := client.CallMCPServer("create_tools", params)
192+
if err != nil {
193+
if common.Progress != nil {
194+
common.Progress.StopWithError("Create tool failed")
195+
}
196+
return err
197+
}
198+
199+
if common.Progress != nil {
200+
common.Progress.Stop("Create tools completed successfully")
201+
}
202+
203+
if !common.Silent {
204+
fmt.Println("OK")
205+
}
206+
fmt.Println(result)
161207

162208
return nil
163209
}

src/commands.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ var agentCmd = &cobra.Command{
352352
Short: "Manage agents",
353353
Long: `Manage agent including creating, and serving.`,
354354
Aliases: []string{"agent"},
355-
Example: ` maestro create agents.yaml
356-
maestro agent create agents.yaml`,
355+
Example: ` maestro agent create agents.yaml
356+
maestro agent serve agents.yaml`,
357357
}
358358

359359
// Workflow commands - run, serve, deploy
@@ -367,6 +367,15 @@ var workflowCmd = &cobra.Command{
367367
maestro workflow deploy agents.yaml workflow.yaml`,
368368
}
369369

370+
// Tool commands - create
371+
var toolCmd = &cobra.Command{
372+
Use: "tool",
373+
Short: "Manage tools",
374+
Long: `Manage tool including creating.`,
375+
Aliases: []string{"tool"},
376+
Example: ` maestro tool create tools.yaml`,
377+
}
378+
370379
// CustomResource commands - create
371380
var customResourceCmd = &cobra.Command{
372381
Use: "customresource",

src/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ A command-line interface for working with Maestro configurations.`,
124124
)
125125
rootCmd.AddCommand(agentCmd)
126126
rootCmd.AddCommand(workflowCmd)
127+
rootCmd.AddCommand(toolCmd)
127128
rootCmd.AddCommand(customResourceCmd)
128129
rootCmd.AddCommand(metaAgentCmd)
129130
rootCmd.AddCommand(vdbCmd)
@@ -163,6 +164,8 @@ A command-line interface for working with Maestro configurations.`,
163164
workflowCmd.AddCommand(commands.NewRunCommand())
164165
workflowCmd.AddCommand(commands.NewDeployCommand())
165166

167+
toolCmd.AddCommand(commands.NewCreateCommand())
168+
166169
customResourceCmd.AddCommand(commands.NewCreateCrCommand())
167170

168171
// Chunking

0 commit comments

Comments
 (0)