MCPcopy Index your code
hub / github.com/docker/docker-agent / newMCPCmd

Function newMCPCmd

cmd/root/mcp.go:23–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21}
22
23func newMCPCmd() *cobra.Command {
24 var flags mcpFlags
25
26 cmd := &cobra.Command{
27 Use: "mcp <agent-file>|<registry-ref>",
28 Short: "Start an agent as an MCP (Model Context Protocol) server",
29 Long: "Start an MCP server that exposes the agent via the Model Context Protocol. By default, uses stdio transport. Use --http to start a streaming HTTP server instead. Use --attach to expose a running TUI's session instead of an agent file.",
30 Example: ` docker-agent serve mcp ./agent.yaml
31 docker-agent serve mcp ./team.yaml
32 docker-agent serve mcp agentcatalog/pirate
33 docker-agent serve mcp ./agent.yaml --http --listen 127.0.0.1:9090
34 docker-agent serve mcp --attach`,
35 Args: cobra.MaximumNArgs(1),
36 RunE: flags.runMCPCommand,
37 }
38
39 cmd.PersistentFlags().StringVarP(&flags.agentName, "agent", "a", "", "Name of the agent to run (all agents if not specified)")
40 cmd.PersistentFlags().BoolVar(&flags.http, "http", false, "Use streaming HTTP transport instead of stdio")
41 cmd.PersistentFlags().StringVarP(&flags.listenAddr, "listen", "l", "127.0.0.1:8081", "Address to listen on")
42 cmd.PersistentFlags().StringVar(&flags.attach, "attach", "", "Attach to a running TUI run by pid, address, or session id (or empty for the most recent)")
43 cmd.PersistentFlags().Lookup("attach").NoOptDefVal = "latest"
44 cmd.PersistentFlags().StringVar(&flags.runConfig.MCPToolName, "tool-name", "", "Override the MCP tool identifier clients call (defaults to agent name); only valid when exposing a single agent")
45 cmd.PersistentFlags().DurationVar(&flags.runConfig.MCPKeepAlive, "mcp-keepalive", 0, "Interval between MCP keep-alive pings (e.g. 30s); 0 disables keep-alive")
46 addRuntimeConfigFlags(cmd, &flags.runConfig)
47
48 return cmd
49}
50
51func (f *mcpFlags) runMCPCommand(cmd *cobra.Command, args []string) (commandErr error) {
52 ctx := cmd.Context()

Callers 1

newServeCmdFunction · 0.85

Calls 2

addRuntimeConfigFlagsFunction · 0.85
LookupMethod · 0.45

Tested by

no test coverage detected