fix: re-add lightweight MCP servers section to system prompt for OpenAI compatibility#11322
fix: re-add lightweight MCP servers section to system prompt for OpenAI compatibility#11322roomote[bot] wants to merge 1 commit intomainfrom
Conversation
Reviewed all changed files, relevant type definitions ( The implementation is clean:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Related GitHub Issue
Closes: #11317
Description
This PR attempts to address Issue #11317 where OpenAI/ChatGPT models are unable to detect or call MCP tools.
Root Cause: In PR #10895, the MCP SERVERS section was removed from the system prompt when MCP tools were migrated to native tool definitions. While Claude and Gemini handle native tool definitions well on their own, OpenAI models need additional system prompt context to understand:
mcp--serverName--toolNamefunctions represent MCP server toolsSolution: Re-add a lightweight MCP servers section to the system prompt that:
mcp--git--git_log)mcp--serverName--toolNamenaming conventionThis is intentionally more lightweight than the old removed section -- no duplicated tool schemas or descriptions (already in native tool definitions), just the mapping context and server instructions that are currently missing.
Files changed:
src/core/prompts/sections/mcp-servers.ts- New lightweight MCP servers sectionsrc/core/prompts/sections/index.ts- Re-export the new sectionsrc/core/prompts/system.ts- Include the section in the prompt (only when MCP is enabled)src/core/prompts/sections/__tests__/mcp-servers.spec.ts- 11 tests covering all edge casesTest Procedure
cd src && npx vitest run core/prompts/sections/__tests__/mcp-servers.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
Feedback and guidance are welcome. This is an attempt to address the issue; the approach preserves the benefits of native tool calling (no schema duplication) while restoring contextual information that helps OpenAI models understand and use MCP tools.
Important
Re-adds a lightweight MCP servers section to the system prompt for OpenAI compatibility, including server names, tool mappings, and instructions, with tests for various scenarios.
mcp-servers.tsfor OpenAI compatibility.system.tswhen MCP is enabled.mcp-servers.spec.tsfor various scenarios including connected/disconnected servers, tool filtering, and server instructions.getMcpServersSectioninindex.ts.This description was created by
for 803a264. You can customize this summary. It will automatically update as commits are pushed.