MCPcopy Create free account
hub / github.com/docker/docker-agent / findMCPRemoteURL

Function findMCPRemoteURL

cmd/root/debug_oauth.go:209–257  ·  view source on GitHub ↗

findMCPRemoteURL looks up the remote URL for the named MCP server in the config. It matches by name (top-level mcps key or toolset name), by URL substring, or returns the only remote MCP if there is exactly one.

(cfg *latest.Config, name string)

Source from the content-addressed store, hash-verified

207// It matches by name (top-level mcps key or toolset name), by URL substring,
208// or returns the only remote MCP if there is exactly one.
209func findMCPRemoteURL(cfg *latest.Config, name string) (string, error) {
210 // Collect all remote MCP URLs with their identifiers.
211 type mcpEntry struct {
212 label string
213 url string
214 }
215 var all []mcpEntry
216
217 for k, m := range cfg.MCPs {
218 if m.Remote.URL != "" {
219 all = append(all, mcpEntry{label: k, url: m.Remote.URL})
220 }
221 }
222 for _, agent := range cfg.Agents {
223 for _, ts := range agent.Toolsets {
224 if ts.Type == "mcp" && ts.Remote.URL != "" {
225 label := ts.Name
226 if label == "" {
227 label = ts.Remote.URL
228 }
229 all = append(all, mcpEntry{label: label, url: ts.Remote.URL})
230 }
231 }
232 }
233
234 // Exact match by name/label.
235 for _, e := range all {
236 if e.label == name {
237 return e.url, nil
238 }
239 }
240
241 // Exact match by URL.
242 for _, e := range all {
243 if e.url == name {
244 return e.url, nil
245 }
246 }
247
248 // Build helpful error.
249 var labels []string
250 for _, e := range all {
251 labels = append(labels, e.label)
252 }
253 if len(labels) > 0 {
254 return "", fmt.Errorf("MCP %q not found; available: %v", name, labels)
255 }
256 return "", fmt.Errorf("MCP %q not found; no remote MCPs found in config", name)
257}

Callers 1

newDebugOAuthLoginCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected