MCPcopy Create free account
hub / github.com/github/gh-aw / parseMCPSectionMap

Function parseMCPSectionMap

pkg/parser/mcp.go:458–471  ·  view source on GitHub ↗
(mcpSection any, toolName string)

Source from the content-addressed store, hash-verified

456}
457
458func parseMCPSectionMap(mcpSection any, toolName string) (map[string]any, error) {
459 switch v := mcpSection.(type) {
460 case map[string]any:
461 return v, nil
462 case string:
463 var mcpConfig map[string]any
464 if err := json.Unmarshal([]byte(v), &mcpConfig); err != nil {
465 return nil, fmt.Errorf("invalid JSON in mcp configuration: %w", err)
466 }
467 return mcpConfig, nil
468 default:
469 return nil, fmt.Errorf("mcp configuration must be a map or JSON string, got %T. Example:\nmcp-servers:\n %s:\n command: \"npx @my/tool\"\n args: [\"--port\", \"3000\"]", v, toolName)
470 }
471}
472
473func inferOrReadMCPType(mcpConfig map[string]any, toolName string) (string, error) {
474 if typeVal, hasType := mcpConfig["type"]; hasType {

Callers 1

ParseMCPConfigFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected