fix: re-add lightweight MCP servers section to system prompt for OpenAI compatibility #11323
+225
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #11317
Description
This PR attempts to address Issue #11317 where OpenAI models (e.g., GPT-5.2) fail to call MCP tools.
Root Cause: In PR #10895, the MCP SERVERS section was removed from the system prompt. While Claude and Gemini models can infer tool usage from native function definitions alone, OpenAI models need more explicit system prompt context about available MCP servers and the
mcp--serverName--toolNamenaming convention.Solution: Re-adds a lightweight MCP SERVERS section to the system prompt that includes:
mcp--serverName--toolNamenaming convention explanationinstructionsfield)This intentionally does NOT duplicate tool schemas or descriptions (already provided via native tool definitions), keeping the prompt compact while giving models the context they need.
Files Changed
src/core/prompts/sections/mcp-servers.ts- New lightweight MCP servers section generatorsrc/core/prompts/sections/index.ts- Re-exports the new sectionsrc/core/prompts/system.ts- Includes the new section in the system promptsrc/core/prompts/sections/__tests__/mcp-servers.spec.ts- 14 tests covering all edge casesTest Procedure
cd src && npx vitest run core/prompts/sections/__tests__/mcp-servers.spec.ts(14 tests passing)cd src && npx vitest run core/prompts/(207 tests passing across 20 test files, zero regressions)Feedback and guidance are welcome.
Pre-Submission Checklist
Documentation Updates
Additional Notes
This is a minimal, targeted fix. The new MCP section is only included when the mode has access to MCP tools and there are connected servers with enabled tools.
Important
Re-adds lightweight MCP SERVERS section to system prompt for OpenAI compatibility, including naming conventions and server lists, without duplicating tool schemas.
mcp-servers.ts: New section generator for MCP servers.system.ts: Integrates new section into system prompt.mcp-servers.spec.ts: 14 tests for edge cases.mcp-servers.spec.ts.This description was created by
for 1a418f7. You can customize this summary. It will automatically update as commits are pushed.