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

Function ExtractMCPConfigurations

pkg/parser/mcp.go:60–100  ·  view source on GitHub ↗

ExtractMCPConfigurations extracts MCP server configurations from workflow frontmatter

(frontmatter map[string]any, serverFilter string)

Source from the content-addressed store, hash-verified

58
59// ExtractMCPConfigurations extracts MCP server configurations from workflow frontmatter
60func ExtractMCPConfigurations(frontmatter map[string]any, serverFilter string) ([]RegistryMCPServerConfig, error) {
61 mcpLog.Printf("Extracting MCP configurations with filter: %s", serverFilter)
62 var configs []RegistryMCPServerConfig
63
64 addSafeOutputsConfig(frontmatter, serverFilter, &configs)
65 addSafeJobsConfig(frontmatter, serverFilter, &configs)
66 addMCPScriptsConfig(frontmatter, serverFilter, &configs)
67
68 // Get mcp-servers section from frontmatter
69 mcpServersSection, hasMCPServers := frontmatter["mcp-servers"]
70 if !hasMCPServers {
71 mcpLog.Print("No mcp-servers section found, checking for built-in tools")
72 // Process built-in MCP tools from tools section (github, playwright)
73 if err := extractBuiltinMCPTools(frontmatter, serverFilter, &configs); err != nil {
74 return nil, err
75 }
76 mcpLog.Printf("Extracted %d MCP configurations total", len(configs))
77 return configs, nil // No mcp-servers configured, but we might have safe-outputs and built-in tools
78 }
79
80 mcpServers, ok := mcpServersSection.(map[string]any)
81 if !ok {
82 return nil, fmt.Errorf("mcp-servers section must be a map, got %T. Example:\nmcp-servers:\n my-server:\n command: \"npx @my/tool\"\n args: [\"--port\", \"3000\"]", mcpServersSection)
83 }
84
85 // Process built-in MCP tools from tools section (github, playwright)
86 if err := extractBuiltinMCPTools(frontmatter, serverFilter, &configs); err != nil {
87 return nil, err
88 }
89
90 // Process custom MCP servers from mcp-servers section
91 mcpLog.Printf("Processing %d custom MCP servers", len(mcpServers))
92 customConfigs, err := parseCustomMCPServerConfigs(mcpServers, serverFilter)
93 if err != nil {
94 return nil, err
95 }
96 configs = append(configs, customConfigs...)
97
98 mcpLog.Printf("Extracted %d MCP configurations total", len(configs))
99 return configs, nil
100}
101
102func addSafeOutputsConfig(frontmatter map[string]any, serverFilter string, configs *[]RegistryMCPServerConfig) {
103 safeOutputsSection, hasSafeOutputs := frontmatter["safe-outputs"]

Callers 8

InspectWorkflowMCPFunction · 0.92
loadWorkflowMCPConfigsFunction · 0.92
ScanWorkflowsForMCPFunction · 0.92
spawnMCPInspectorFunction · 0.92
TestArgsFieldFunction · 0.92
TestVersionFieldFunction · 0.92

Calls 8

addSafeOutputsConfigFunction · 0.85
addSafeJobsConfigFunction · 0.85
addMCPScriptsConfigFunction · 0.85
extractBuiltinMCPToolsFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by 4

TestArgsFieldFunction · 0.74
TestVersionFieldFunction · 0.74