@@ -17,10 +17,21 @@ var mcpFlagSet = flag.NewFlagSet("mcp", flag.ExitOnError)
1717
1818func init () {
1919 commands = append (commands , & command {
20- flagSet : mcpFlagSet ,
21- handler : mcpMain ,
20+ flagSet : mcpFlagSet ,
21+ handler : mcpMain ,
22+ usageFunc : mcpUsage ,
2223 })
2324}
25+
26+ func mcpUsage () {
27+ fmt .Println ("The 'mcp' command exposes MCP tools as subcommands for agents to use." )
28+ fmt .Println ("\n USAGE:" )
29+ fmt .Println (" src mcp list-tools List available tools" )
30+ fmt .Println (" src mcp <tool-name> schema View the input/output schema of a tool" )
31+ fmt .Println (" src mcp <tool-name> <flags> Invoke a tool with the given flags" )
32+ fmt .Println (" src mcp <tool-name> -h List the available flags of a tool" )
33+ }
34+
2435func mcpMain (args []string ) error {
2536 apiClient := cfg .apiClient (nil , mcpFlagSet .Output ())
2637
@@ -30,21 +41,21 @@ func mcpMain(args []string) error {
3041 return err
3142 }
3243
44+ if len (args ) == 0 {
45+ mcpUsage ()
46+ return nil
47+ }
48+
3349 subcmd := args [0 ]
3450 if subcmd == "list-tools" {
3551 fmt .Println ("The following tools are available:" )
3652 for name := range tools {
37- fmt .Printf (" • %s\n " , name )
53+ fmt .Printf (" %s\n " , name )
3854 }
3955 fmt .Println ("\n USAGE:" )
40- fmt .Printf (" • Invoke a tool\n " )
41- fmt .Printf (" src mcp <tool-name> <flags>\n " )
42- fmt .Printf ("\n • View the Input / Output Schema of a tool\n " )
43- fmt .Printf (" src mcp <tool-name> schema\n " )
44- fmt .Printf ("\n • List the available flags of a tool\n " )
45- fmt .Printf (" src mcp <tool-name> -h\n " )
46- fmt .Printf ("\n • View the Input / Output Schema of a tool\n " )
47- fmt .Printf (" src mcp <tool-name> schema\n " )
56+ fmt .Println (" src mcp <tool-name> schema View the input/output schema of a tool" )
57+ fmt .Println (" src mcp <tool-name> <flags> Invoke a tool with the given flags" )
58+ fmt .Println (" src mcp <tool-name> -h List the available flags of a tool" )
4859 return nil
4960 }
5061 tool , ok := tools [subcmd ]
@@ -64,7 +75,7 @@ func mcpMain(args []string) error {
6475 if err := flags .Parse (flagArgs ); err != nil {
6576 return err
6677 }
67- mcp .DerefFlagValues (vars )
78+ mcp .DerefFlagValues (flags , vars )
6879
6980 if err := validateToolArgs (tool .InputSchema , args , vars ); err != nil {
7081 return err
0 commit comments