PoC: Simulating Code Execution via MCP Meta-Tools #1118
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.
Adds an opt-in “code-mode” wrapper that fronts multiple downstream MCP servers via three meta-tools (
list_mcp_servers,list_tool_names,get_tool_implementation, pluscall_tool). Agents progressively disclose server → tool → schema, so they only load what they need.Motivation and Context
Per Anthropic's recent article on code execution providing massive token savings over MCP servers, I was curious to explore whether we might imagine emulating this file-system based code execution (listing directories & reading files to execute scripts) with MCP meta-tools (one config stores many MCP servers, and so the agent can list MCP servers, list tools, and call tools).
With the wrapper in place, linking Playwright through the MCP server drops a simple “open a site” run from 17 k tokens down to 13.7 k. Given Cursor’s 11.1 k base prompt, that’s 5.9 k tokens of overhead without the wrapper versus 2.6 k with it—a 56 % reduction (about 3.3 k tokens) while still keeping all downstream tools available. The LLM does spend a couple of extra tool calls on discovery, but the workflow mirrors “explore files → read file,” so even with many servers the prompt stays slim.
Please note: I open this PR to hear what you all think of this sort of setup. I did this fairly quickly, so there's likely cleaner approaches to accomplishing this setup. I would love to hear your thoughts and hunches around this, and whether building this out further might be worthwhile! Thanks for your thoughts :).
How Has This Been Tested?
npm run typechecknpm run testcode-config.mcp-servers.json, Playwright MCP linked to the local SDK, and the client invokinglist_mcp_servers → list_tool_names(serverId=playwright) → get_tool_implementation → call_tool.This is how I set it up:
In
~/.cursor/code-config.mcp-servers.json:In
~/.cursor/mcp.json:Breaking Changes
No breaking changes. The wrapper is opt-in and runs as its own CLI (
npm run code-mode -- --config ...). Existing SDK usage is untouched.Types of changes
Checklist
Additional context
code-config.mcp-servers.jsonto underline that it lists multiple downstream MCP servers.list_mcp_serversreturns server summaries;list_tool_namesrequiresserverIdand returns just name + short description;get_tool_implementationis the only call that returns full schemas/stubs.