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

Method renderCodexJSONMCPConfigWithContext

pkg/workflow/codex_mcp.go:228–256  ·  view source on GitHub ↗

renderCodexJSONMCPConfigWithContext generates custom MCP server configuration in JSON format for gateway This is used to generate the JSON config file that the MCP gateway reads

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

Source from the content-addressed store, hash-verified

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
228func (e *CodexEngine) renderCodexJSONMCPConfigWithContext(yaml *strings.Builder, toolName string, toolConfig map[string]any, isLast bool, workflowData *WorkflowData) error {
229 // Determine if localhost URLs should be rewritten to host.docker.internal
230 rewriteLocalhost := shouldRewriteLocalhostToDocker(workflowData)
231 codexMCPLog.Printf("Rendering JSON MCP config for gateway tool: %s (isLast=%v, rewrite_localhost=%v)", toolName, isLast, rewriteLocalhost)
232
233 // Use the shared renderer with JSON format for gateway
234 renderer := MCPConfigRenderer{
235 Format: "json",
236 IndentLevel: " ",
237 RewriteLocalhostToDocker: rewriteLocalhost,
238 GuardPolicies: deriveWriteSinkGuardPolicyFromWorkflow(workflowData),
239 }
240
241 yaml.WriteString(" \"" + toolName + "\": {\n")
242
243 err := renderSharedMCPConfig(yaml, toolName, toolConfig, renderer)
244 if err != nil {
245 codexMCPLog.Printf("Failed to render JSON MCP config for tool %s: %v", toolName, err)
246 return err
247 }
248
249 if isLast {
250 yaml.WriteString(" }\n")
251 } else {
252 yaml.WriteString(" },\n")
253 }
254
255 return nil
256}

Callers 1

RenderMCPConfigMethod · 0.95

Calls 4

renderSharedMCPConfigFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected