Tool design and context efficiency — Cheat Sheet
MCP Engineering course · M4
The printable companion to lesson L15. Every tool you expose takes space in the model's context and competes for its attention. This sheet separates the levers that are part of MCP (current spec 2026-07-28, they work with any compliant host) from the techniques that belong to a host or model platform, and gives each published figure with its correct attribution.
What changed in V2: the earlier version of this sheet credited the 150,000 → 2,000 token figure to Programmatic Tool Calling (it belongs to Anthropic's "Code execution with MCP" post), presented Tool Search as a generic MCP technique (it is a Claude Developer Platform feature), and cited video timestamps. All corrected below. The "many tools vs code" debate is in the companion guided reading.
Why many tools hurt
- Tool definitions (name, description, input schema) are usually placed in the model's context before any work begins. Raw intermediate results pile up too if the model chains call after call.
- Illustration from Anthropic's "Advanced tool use" post (2025-11-24): five MCP servers with 58 tools consumed about 55K tokens before a conversation started.
- Context is not only money: with many similar descriptions, the model picks the wrong tool more often.
Levers that are part of MCP (current, 2026-07-28)
They live in your server, so they help every compliant host:
| Lever | What to do |
|---|---|
| Curate | A few task-level tools, not one per endpoint (L11: three tools; the admin DELETE stayed out). |
| Name and describe precisely | Names SHOULD be 1–128 characters from A-Z a-z 0-9 _ - ., unique per server. Put constraints in the schema (enums, ranges, patterns) instead of long prose. |
| Return structure | Declare an outputSchema and return structuredContent, plus the JSON as a text block for compatibility. |
| Point, don't paste | Return a resource_link to large data instead of inlining it. |
| Paginate | Paginate list results. |
| Deterministic order | Servers SHOULD return tools/list in a stable order (client caching, prompt-cache hits). |
| Cache hints | tools/list results carry ttlMs and cacheScope. |
| Scope by authorization | tools/list MAY return only the tools the caller's granted scopes permit. |
- Roadmap, not shipped: progressive discovery (clients learn tools as they need them) is a priority area on the official roadmap (updated 2026-08-22). Do not present it as available.
- Optional extension: Skills over MCP is an official, opt-in extension for structured agent-workflow instructions.
Techniques that belong to the host or API (host-specific)
| Technique | What it does | Figure and source |
|---|---|---|
Tool Search Tool with defer_loading: true (Claude Developer Platform, beta header advanced-tool-use-2025-11-20) | Loads tool definitions on demand; can defer a whole MCP server through an mcp_toolset setting | About 77K → about 8.7K tokens of tool context in Anthropic's example ("Advanced tool use", 2025-11-24) |
| Programmatic Tool Calling (same platform, same beta) | The model writes code that calls tools; intermediate results stay out of context | Average usage 43,588 → 27,297 tokens, a 37% reduction on complex research tasks (same post) |
| Code execution with MCP (an agent-harness pattern) | MCP tools are presented as code files; the agent loads only what it needs and moves data in code | 150,000 → 2,000 tokens (98.7%) for one Google Drive to Salesforce example ("Code execution with MCP", 2025-11-04) |
Two attribution traps:
- 150K → 2K belongs to "Code execution with MCP". That post never uses the term "Programmatic Tool Calling".
- 37% belongs to Programmatic Tool Calling: a different measurement on a different task. Do not add or swap them.
The safety rule that is not optional
Running model-written code needs a sandbox. The code-execution post says it "requires a secure execution environment with appropriate sandboxing", which adds operational overhead and security considerations that direct tool calls avoid. Never run that code loose; limit egress and secrets (L14).
A decision method (rules of thumb, not measured thresholds)
- Start with a handful of explicit, task-level tools. Most servers never need more.
- Measure the size of your
tools/listand watch for wrong-tool choices in your host's traces. - If the catalog must grow, first use the MCP levers: merge similar tools, tighten schemas, link instead of inlining, scope tools by authorization.
- If your host offers deferred loading, enable it for big catalogs. That is a host setting, not a change to your server.
- Move to code execution only for multi-step, data-heavy flows, and only with a sandbox.
Practice: measure your tool budget (lab-l11)
With the L11 lab running (./run.sh serve), save as tool_budget.py in lab-l11/ and run .venv/bin/python tool_budget.py twice:
import asyncio, json
from mcp import Client
async def main() -> None:
async with Client("http://127.0.0.1:8000/mcp") as client:
tools = (await client.list_tools()).tools
total = 0
for t in tools:
size = len(json.dumps(t.model_dump(by_alias=True, exclude_none=True)))
total += size
print(f"{t.name:15} {size:5} chars")
print(f"TOTAL {total} chars, {len(tools)} tools, order: {[t.name for t in tools]}")
asyncio.run(main())
Expected on the unmodified lab (2026-11-26): search_items 1401, get_item 839, reserve_stock 917, TOTAL 3157 chars, and the same order: list on both runs (deterministic ordering). Characters are only a rough proxy for tokens, but good enough to compare designs.
Quick glossary
- Tool catalog: the
tools/lista server returns; its size costs context in most hosts. ttlMs/cacheScope: freshness and sharing hints on list results (2026-07-28).- Progressive discovery: a roadmap item, not a shipped feature.
- Tool Search Tool /
defer_loading: a Claude Developer Platform feature (beta), not part of MCP. - Programmatic Tool Calling: the same platform's feature where the model writes code that calls tools.
- Code execution with MCP: an agent-harness pattern that presents MCP tools as code files.
- Sandbox: an isolated environment that limits what executed code can touch.
To remember
- More tools ≠ more power. Definitions and intermediate results both cost context.
- MCP levers first: curate, tight schemas, structured output,
resource_link, pagination, deterministic order, cache hints. - Tool Search and Programmatic Tool Calling are platform features, not MCP.
- 150K → 2K = Code execution with MCP; 37% = Programmatic Tool Calling. Never swap them.
- Model-written code requires a sandbox.
Turning Point Academy · MCP Engineering course · Module 4 · Lesson 15 (L15) · V2, spec 2026-07-28