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

Method RenderMCPConfig

pkg/workflow/copilot_mcp.go:18–42  ·  view source on GitHub ↗

RenderMCPConfig generates MCP server configuration for Copilot CLI

(yaml *strings.Builder, tools map[string]any, mcpTools []string, workflowData *WorkflowData)

Source from the content-addressed store, hash-verified

16
17// RenderMCPConfig generates MCP server configuration for Copilot CLI
18func (e *CopilotEngine) RenderMCPConfig(yaml *strings.Builder, tools map[string]any, mcpTools []string, workflowData *WorkflowData) error {
19 copilotMCPLog.Printf("Rendering MCP config for Copilot engine: mcpTools=%d", len(mcpTools))
20
21 // Create the Copilot CLI config directory under the runtime $HOME. The Copilot CLI
22 // resolves its config dir as ~/.copilot, which is /home/runner/.copilot on standard
23 // GitHub-hosted runners but may differ on self-hosted or containerized runners.
24 // HOME is a standard POSIX environment variable inherited from the runner's parent
25 // process and passed through to shell steps; other generators (mcp_setup_generator.go,
26 // copilot_engine.go session-state) rely on it the same way.
27 yaml.WriteString(" mkdir -p \"$HOME/.copilot\"\n")
28
29 // Copilot uses JSON format with type and tools fields, and inline args
30 return renderStandardJSONMCPConfig(yaml, renderStandardJSONMCPConfigOptions{
31 tools: tools,
32 mcpTools: mcpTools,
33 workflowData: workflowData,
34 configPath: "$HOME/.copilot/mcp-config.json",
35 includeCopilotFields: true,
36 inlineArgs: true,
37 renderCustom: func(yaml *strings.Builder, toolName string, toolConfig map[string]any, isLast bool) error {
38 return e.renderCopilotMCPConfigWithContext(yaml, toolName, toolConfig, isLast, workflowData)
39 },
40 filterTool: copilotMCPToolFilter,
41 })
42}
43
44// renderCopilotMCPConfigWithContext generates custom MCP server configuration for Copilot CLI
45// This version includes workflowData to determine if localhost URLs should be rewritten

Calls 3

PrintfMethod · 0.45