Skip to content

Commit aaf66ed

Browse files
committed
check args before use in mcp
if no subcommands given print usage
1 parent 718ec6d commit aaf66ed

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

cmd/src/mcp.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,26 @@ func mcpMain(args []string) error {
2727
return err
2828
}
2929

30+
if len(args) == 0 {
31+
fmt.Println("\nThe 'mcp' command exposes MCP tools as subcommands for agents to use.")
32+
fmt.Println("\nUSAGE:")
33+
fmt.Printf(" src mcp list-tools List available tools\n")
34+
fmt.Printf(" src mcp <tool-name> schema View the input/output schema of a tool\n")
35+
fmt.Printf(" src mcp <tool-name> <flags> Invoke a tool with the given flags\n")
36+
fmt.Printf(" src mcp <tool-name> -h List the available flags of a tool\n")
37+
return nil
38+
}
39+
3040
subcmd := args[0]
3141
if subcmd == "list-tools" {
3242
fmt.Println("The following tools are available:")
3343
for name := range tools {
34-
fmt.Printf(" %s\n", name)
44+
fmt.Printf(" %s\n", name)
3545
}
3646
fmt.Println("\nUSAGE:")
37-
fmt.Printf(" • Invoke a tool\n")
38-
fmt.Printf(" src mcp <tool-name> <flags>\n")
39-
fmt.Printf("\n • View the Input / Output Schema of a tool\n")
40-
fmt.Printf(" src mcp <tool-name> schema\n")
41-
fmt.Printf("\n • List the available flags of a tool\n")
42-
fmt.Printf(" src mcp <tool-name> -h\n")
43-
fmt.Printf("\n • View the Input / Output Schema of a tool\n")
44-
fmt.Printf(" src mcp <tool-name> schema\n")
47+
fmt.Printf(" src mcp <tool-name> schema View the input/output schema of a tool\n")
48+
fmt.Printf(" src mcp <tool-name> <flags> Invoke a tool with the given flags\n")
49+
fmt.Printf(" src mcp <tool-name> -h List the available flags of a tool\n")
4550
return nil
4651
}
4752

0 commit comments

Comments
 (0)