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

Function newDebugOAuthLoginCmd

cmd/root/debug_oauth.go:156–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154}
155
156func newDebugOAuthLoginCmd() *cobra.Command {
157 var flags debugFlags
158
159 cmd := &cobra.Command{
160 Use: "login <agent-file> <mcp-name>",
161 Short: "Perform OAuth login for a remote MCP server",
162 Args: cobra.ExactArgs(2),
163 RunE: func(cmd *cobra.Command, args []string) (commandErr error) {
164 ctx := cmd.Context()
165 telemetry.TrackCommand(ctx, "debug", []string{"oauth", "login"})
166 defer func() {
167 telemetry.TrackCommandError(ctx, "debug", []string{"oauth", "login"}, commandErr)
168 }()
169
170 agentFile := args[0]
171 mcpName := args[1]
172
173 // Load the agent config to find the MCP server URL.
174 agentSource, err := config.Resolve(agentFile, flags.runConfig.EnvProvider())
175 if err != nil {
176 return err
177 }
178
179 cfg, err := config.Load(ctx, agentSource)
180 if err != nil {
181 return err
182 }
183
184 serverURL, err := findMCPRemoteURL(cfg, mcpName)
185 if err != nil {
186 return err
187 }
188
189 w := cmd.OutOrStdout()
190 fmt.Fprintf(w, "Starting OAuth login for %s (%s)...\n", mcpName, serverURL)
191
192 if err := mcp.PerformOAuthLogin(ctx, serverURL); err != nil {
193 return fmt.Errorf("OAuth login failed: %w", err)
194 }
195
196 fmt.Fprintf(w, "✅ OAuth login successful for %s\n", serverURL)
197 return nil
198 },
199 }
200
201 addRuntimeConfigFlags(cmd, &flags.runConfig)
202
203 return cmd
204}
205
206// findMCPRemoteURL looks up the remote URL for the named MCP server in the config.
207// It matches by name (top-level mcps key or toolset name), by URL substring,

Callers 1

newDebugOAuthCmdFunction · 0.85

Calls 9

TrackCommandFunction · 0.92
TrackCommandErrorFunction · 0.92
ResolveFunction · 0.92
LoadFunction · 0.92
PerformOAuthLoginFunction · 0.92
findMCPRemoteURLFunction · 0.85
addRuntimeConfigFlagsFunction · 0.85
ContextMethod · 0.80
EnvProviderMethod · 0.80

Tested by

no test coverage detected