Managing large numbers of MCP tools can overwhelm an LLM's context window. Cloudflare previously noted that representing over 2,500 API methods as individual MCP tools would require approximately 1.17 million tokens.

To address this, the Code Mode MCP approach replaces thousands of tools with just two: search() for retrieving method signatures and execute() for running JavaScript code that calls these methods.

The execute() function allows combining multiple MCP method calls into a single operation without requiring additional LLM interaction between steps. This reduces token consumption, though efficiency depends on the catalog size and frequency of searches.

To improve tool discovery, the author combines Code Mode with SKILLs. SKILLs provide the agent with concise instructions and a list of relevant MCP servers and methods to use for specific tasks, such as bug fixing or project builds.

When a user triggers a task, the agent references the SKILL to identify necessary tools. It then uses search() to fetch specific method signatures and execute() to perform actions, such as interacting with ticket systems, file servers, or Git repositories.