Two Tools Instead of 2,500 API Methods: How to Keep an Agent from Burning 1.17 Million Tokens of Context
MCP is a way to connect external services to an AI agent, but descriptions of hundreds of methods flood the context, which is the model's working memory. Cloudflare's 2,500 API methods would take up roughly 1.17 million tokens (units of text). Code Mode leaves the agent with two tools: search() finds a method, and execute() runs a chain of calls as code. To keep the model from forgetting to search, the author added SKILLs, short instructions that name the methods to use.
AI-processed from Habr AI; edited by Hamidun News
Imagine hiring an assistant and reading them the instructions for all 2,500 buttons on a remote before every task. The work never gets done, because they tire of listening. That is roughly what happens to AI agents when many services are connected through MCP (Model Context Protocol, a standard by which an agent calls external tools).
The description of each method goes into the context, that is, the model's working memory, and it is measured in tokens: units of text that are billed and that cap the size of a request. The developer behind the Habr write-up ran into this on two tasks at once: setting up a personal agent called Nanabot, and writing an MCP server to manage the company's products. His recipe combines Code Mode MCP with SKILLs.
The problem with hundreds of tools
In a standard MCP setup, the MCP client passes the model descriptions of all connected tools. Cloudflare has more than 2,500 API methods, and by the company's estimate, describing them all as MCP tools would take about 1.17 million tokens. This is Cloudflare's own estimate, not a measurement by the article's author.
The company proposed Code Mode MCP. Instead of thousands of tools, the agent gets two. The first, search(), finds the methods it needs and returns their signatures (names, parameters, and required fields) based on a query. The second, execute(), runs JavaScript code that calls those methods. A single execute() call can combine several operations and return the result, and the language model does not have to be consulted after each step.
The article gives a simple example: the agent is told "open example.com and take a screenshot." Through search() it finds navigate_page and take_screenshot, then opens the page and captures the frame with a single script. No new request goes to the model between those two steps. An important caveat: the article presents searching an array of tools as one of the options for an aggregator. Cloudflare, for example, searches operations in an OpenAPI specification.
The scheme has weak spots too. The savings are not guaranteed: repeated searches and loading signatures also spend tokens. The size of the gain depends on the size of the catalog, how often searches happen, and the number of calls. An accurate estimate requires measurements on specific tasks. In addition, the model sometimes fails to find the method it needs, and sometimes does not realize it should search at all.
How SKILLs close the gap
Cloudflare recommends using SKILLs alongside MCP: a SKILL tells the agent when and which capabilities to apply. The author followed the same path. He hid many MCP servers behind Code Mode, so the model sees a single server with search and execution. In the SKILL he wrote a brief list of the needed servers and methods, without full descriptions.
A working example is the bugfix-process SKILL. The user writes: "Fix bug 731 in the two-server repository, current branch, run the two_jar_java17 build." The agent then proceeds as follows:
- it sees a short description of the SKILL in its persistent context and understands that it applies;
- it reads the SKILL itself and learns the order of steps and the servers ticket_mcp, samba_mcp, filesystem_mcp, git_mcp, codex_mcp, and jenkins_mcp;
- through search() it requests signatures only for the methods it needs, such as get_ticket or download_attachment;
- through execute() it collects the ticket, comments, attachments, and logs from Samba into the tickets/731/ folder;
- it commits only that folder, so the materials do not mix with the future fix;
- it launches Codex via start_task, waits for the result, checks the diff, and pushes the fix to the repository;
- it runs Jenkins and sets the ticket status to Resolve or In Progress, then writes a report to result.fixed.md or result.in-progress.md.
There is one more saving here. Large logs and attachments sit on disk and never pass through the main agent's context. Codex reads them from the given path and takes only what it needs. The main agent acts as an organizer and delegates the programming itself.
Three layers of context and limitations
The resulting architecture looks like three layers. The persistent context holds the short SKILL descriptions and the two Code Mode tools. A SKILL is loaded when it matches the task and holds the algorithm and method names. Code Mode fetches the full signatures on demand and performs the calls. Previously the choice was between two bad options: load everything and spend tokens, or hide everything and hope the model guesses right. Now there is a third.
Limitations remain. The model may still fail to pick the right SKILL, make a mistake when searching for a method, or write incorrect JavaScript. Not every chain can be collapsed into a single call: sometimes the agent has to parse an intermediate result and make a new decision. The author does not give savings figures for his own scenarios, only the estimate that they are "likely."
The practical takeaway for teams: if you have many internal tools (tickets, CI, git, file storage), do not describe all of them in the system prompt. Describe the processes in short SKILLs, and give the agent search over signatures and execution of scripts. Before adopting this, measure token usage on real tasks, or you will have to take the benefit on faith.
- Dec 2, 2026Ai2 Releases MolmoWeb2 Web Agents: 27B Model Solves 75.3% of Tasks
- Dec 2, 2026Amazon Releases Ergo Open Weights for Coding: 1.1 Trillion Parameters and 2,200 Tokens per Second
- Dec 2, 2026OpenAI Opens Dots Agent to ChatGPT Plus Subscribers With 10,000+ Plugins
- Dec 2, 2026FSK Group Has Launched 395 AI Agents in Six Months, with a 97.7% Success Rate
Key Questions Answered
What are the key details on The problem with hundreds of tools?
In a standard MCP setup, the MCP client passes the model descriptions of all connected tools. Cloudflare has more than 2,500 API methods, and by the company's estimate, describing them all as MCP tools would take about 1.17 million tokens. This is Cloudflare's own estimate, not a measurement by the article's author. The company proposed Code Mode MCP. Instead of thousands of tools, the agent gets two.
How SKILLs close the gap?
Cloudflare recommends using SKILLs alongside MCP: a SKILL tells the agent when and which capabilities to apply. The author followed the same path. He hid many MCP servers behind Code Mode, so the model sees a single server with search and execution. In the SKILL he wrote a brief list of the needed servers and methods, without full descriptions. A working example is the bugfix-process SKILL.
What are the key details on Three layers of context and limitations?
The resulting architecture looks like three layers. The persistent context holds the short SKILL descriptions and the two Code Mode tools. A SKILL is loaded when it matches the task and holds the algorithm and method names. Code Mode fetches the full signatures on demand and performs the calls. Previously the choice was between two bad options: load everything and spend tokens, or hide everything and hope the model guesses right. Now there is a third. Limitations remain.
Free 2-Day Vibecoding & AI Agents Intensive
Day 1: the autonomous Hermes + DeepSeek AI agent — vibecoding and development on par with Claude Code / Codex / Gemini. Led by Jemal Hamidun, Head of AI at Alpina Digital and academic supervisor at MIPT. Right after you register with our bot Nika: the recording + 11 materials from the previous intensive.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
