@@ -164,12 +164,13 @@ func (e *CodexEngine) RenderMCPConfig(yaml *strings.Builder, tools map[string]an
164164// renderCodexMCPConfigWithContext generates custom MCP server configuration for a single tool in codex workflow config.toml
165165// This version includes workflowData to determine if localhost URLs should be rewritten
166166func (e * CodexEngine ) renderCodexMCPConfigWithContext (yaml * strings.Builder , toolName string , toolConfig map [string ]any , workflowData * WorkflowData ) error {
167- yaml .WriteString (" \n " )
168- fmt .Fprintf (yaml , " [mcp_servers.%s]\n " , toolName )
169-
170167 // Determine if localhost URLs should be rewritten to host.docker.internal
171168 // This is needed when firewall is enabled (agent is not disabled)
172169 rewriteLocalhost := shouldRewriteLocalhostToDocker (workflowData )
170+ codexMCPLog .Printf ("Rendering TOML MCP config for custom tool: %s (rewrite_localhost=%v)" , toolName , rewriteLocalhost )
171+
172+ yaml .WriteString (" \n " )
173+ fmt .Fprintf (yaml , " [mcp_servers.%s]\n " , toolName )
173174
174175 // Use the shared MCP config renderer with TOML format
175176 renderer := MCPConfigRenderer {
@@ -180,6 +181,7 @@ func (e *CodexEngine) renderCodexMCPConfigWithContext(yaml *strings.Builder, too
180181
181182 err := renderSharedMCPConfig (yaml , toolName , toolConfig , renderer )
182183 if err != nil {
184+ codexMCPLog .Printf ("Failed to render TOML MCP config for tool %s: %v" , toolName , err )
183185 return err
184186 }
185187
@@ -191,6 +193,7 @@ func (e *CodexEngine) renderCodexMCPConfigWithContext(yaml *strings.Builder, too
191193func (e * CodexEngine ) renderCodexJSONMCPConfigWithContext (yaml * strings.Builder , toolName string , toolConfig map [string ]any , isLast bool , workflowData * WorkflowData ) error {
192194 // Determine if localhost URLs should be rewritten to host.docker.internal
193195 rewriteLocalhost := shouldRewriteLocalhostToDocker (workflowData )
196+ codexMCPLog .Printf ("Rendering JSON MCP config for gateway tool: %s (isLast=%v, rewrite_localhost=%v)" , toolName , isLast , rewriteLocalhost )
194197
195198 // Use the shared renderer with JSON format for gateway
196199 renderer := MCPConfigRenderer {
@@ -203,6 +206,7 @@ func (e *CodexEngine) renderCodexJSONMCPConfigWithContext(yaml *strings.Builder,
203206
204207 err := renderSharedMCPConfig (yaml , toolName , toolConfig , renderer )
205208 if err != nil {
209+ codexMCPLog .Printf ("Failed to render JSON MCP config for tool %s: %v" , toolName , err )
206210 return err
207211 }
208212
0 commit comments