Code execution lets an AI agent write and run a script against an API, combining many data operations into one execution instead of making one tool call at a time. section 3.3.5
The approach trades broader execution capability for lower context overhead:
- Fetch, filter, and summarize a hundred records in one script run rather than returning every intermediate result to the context window. section 3.3.5
- Reduce the cost of full tool exposure, where unused tool definitions consume tokens and compete with the task for attention. section 3.3.5
- Treat the API as a capability boundary and expose only what the task requires, rather than assuming every connected tool belongs in context. section 3.3.5
Batching a data request
An agent can write one API-backed script that fetches a hundred records, filters them, and summarizes the result, replacing a hundred sequential tool calls and their accumulated outputs. section 3.3.5
Figure 3.5 MCP Governance layers - the agent communicates through an MCP Gateway (enforcing auth and policies), which routes to an MCP Proxy (aggregating multiple servers into a curated toolset), which connects to individual MCP servers registered in a central catalog. Each layer adds security and reduces context noise.

The governance-layer diagram situates code execution within a controlled capability path alongside authentication, policy enforcement, server aggregation, and tool curation. section 3.3.5



