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

Method renderCodexMCPConfigWithContext

pkg/workflow/codex_mcp.go:200–224  ·  view source on GitHub ↗

renderCodexMCPConfigWithContext generates custom MCP server configuration for a single tool in codex workflow config.toml This version includes workflowData to determine if localhost URLs should be rewritten

(yaml *strings.Builder, toolName string, toolConfig map[string]any, workflowData *WorkflowData)

Source from the content-addressed store, hash-verified

198// renderCodexMCPConfigWithContext generates custom MCP server configuration for a single tool in codex workflow config.toml
199// This version includes workflowData to determine if localhost URLs should be rewritten
200func (e *CodexEngine) renderCodexMCPConfigWithContext(yaml *strings.Builder, toolName string, toolConfig map[string]any, workflowData *WorkflowData) error {
201 // Determine if localhost URLs should be rewritten to host.docker.internal
202 // This is needed when firewall is enabled (agent is not disabled)
203 rewriteLocalhost := shouldRewriteLocalhostToDocker(workflowData)
204 codexMCPLog.Printf("Rendering TOML MCP config for custom tool: %s (rewrite_localhost=%v)", toolName, rewriteLocalhost)
205
206 yaml.WriteString(" \n")
207 fmt.Fprintf(yaml, " [mcp_servers.%s]\n", toolName)
208
209 // Use the shared MCP config renderer with TOML format
210 renderer := MCPConfigRenderer{
211 IndentLevel: " ",
212 Format: "toml",
213 RewriteLocalhostToDocker: rewriteLocalhost,
214 GuardPolicies: deriveWriteSinkGuardPolicyFromWorkflow(workflowData),
215 }
216
217 err := renderSharedMCPConfig(yaml, toolName, toolConfig, renderer)
218 if err != nil {
219 codexMCPLog.Printf("Failed to render TOML MCP config for tool %s: %v", toolName, err)
220 return err
221 }
222
223 return nil
224}
225
226// renderCodexJSONMCPConfigWithContext generates custom MCP server configuration in JSON format for gateway
227// This is used to generate the JSON config file that the MCP gateway reads

Callers 1

RenderMCPConfigMethod · 0.95

Calls 4

renderSharedMCPConfigFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected