Pi spent much of the past year leaving MCP out of its coding agent, even as the protocol became standard across developer tools. Its creator, Mario Zechner, had a concrete reason for resisting it. When he measured the context cost of popular browser-automation servers, Chrome DevTools MCP alone took up roughly 18,000 tokens, or about 9% of a 200,000-token context window, before the agent had done anything useful.MCP is now built into Pi, but connecting a server doesn’t put all of its tools in front of the model. Pi leaves those definitions out of the prompt and uses Codemode to find tools as needed, call them from JavaScript and return only the useful output.Measuring MCP’s context costZechner spelled out the problem last November. Playwright MCP needed about 13,700 tokens to describe its 21 tools, or 6.8% of a 200,000-token window, and each additional server added more overhead. He was also bothered by what happened after a tool was called. “MCP servers also aren’t composable,” he wrote. “Results returned by an MCP server have to go through the agent’s context to be persisted to disk or combined with other results.”“Results returned by an MCP server have to go through the agent’s context to be persisted to disk or combined with other results.”His answer was Bash and a handful of scripts. The model already knew how to use them, so there was little reason to teach it another large tool interface. His CLI-based browser tools needed only a 225-token README, and their output could be piped into another command, filtered or saved to disk without first passing through the model. Extensions such as pi-mcp-adapter brought MCP to Pi before it became a native feature in Pi 1.0.Pi changed MCP insteadEarendil, which acquired Pi earlier this year, says MCP has matured enough to justify a second look, though the company’s explanation for the reversal points to something more practical. “The reason we brought MCP into the core is not just about how MCP has changed, but also because we found that the changes it would require were generally useful,” Earendil wrote. “The reason we brought MCP into the core is not just about how MCP has changed, but also because we found that the changes it would require were generally useful,”Pi was already using the same idea with Jev, putting Codemode — its version of the code mode pattern — between the model and its tools. MCP could use that architecture instead of exposing every tool directly to the model.Codemode handles tool discoveryCodemode runs inside a QuickJS sandbox without Node APIs, file system, network access or timers. Scripts can call Pi’s tools and models, run operations concurrently and process the results before returning anything to the model.By default, Pi keeps an MCP server’s tools out of the model’s context. The system prompt gets a one-line description of each server, while the agent uses Codemode to find and call the tools it needs.Developers can change that behavior with toolExposure. On the same server, Pi can expose some tools directly, leave others behind Codemode or block them entirely. A GitHub setup, for example, might expose search_code, keep get_* behind Codemode and block delete_*.Per-tool exposure controlsCodemode has a 3,000-token default budget for tool declarations; anything beyond it stays discoverable. Pi 1.0 also reduced Codemode’s overall footprint. Codemode has a 3,000-token default budget for tool declarations; anything beyond it stays discoverable. According to the release notes, a GPT-5.6 request with the default tools and Codemode fell from roughly 5,300 prompt tokens to 3,300 after Pi shortened the Codemode description, moved model API documentation out of the prompt and stopped repeating declarations for tools scripts could already access. MCP tools using the default exposure don’t count toward that 3,000-token budget.Pi 1.0 doesn’t resolve Earendil’s broader complaints about MCP, including composability. Codemode gives Pi a way to support the protocol without adopting the approach Zechner objected to in the first place.The post One MCP server used 18,000 tokens before doing anything. Here’s the workaround. appeared first on The New Stack.