đź“‹ Table of Contents
Jump to any section (18 sections available)
📹 Watch the Complete Video Tutorial
📺 Title: The end of MCP for ai agents?
⏱️ Duration: 485
👤 Channel: Arseny Shatokhin
🎯 Topic: End Mcp Agents
đź’ˇ This comprehensive article is based on the tutorial above. Watch the video for visual demonstrations and detailed explanations.
In a groundbreaking shift that’s redefining how we build AI agents, a recent blog post from Entropic has challenged the long-standing dominance of Model Context Protocol (MCP) as the go-to abstraction for connecting AI agents to external tools. Even more striking? One developer had already implemented Entropic’s proposed alternative—code-based execution—just a week before the post dropped, witnessing a 98% reduction in token usage, significantly better results, and dramatically improved autonomy.
This article dives deep into that pivotal insight, unpacking every detail from the transcript to deliver a comprehensive, actionable guide on why and how to move beyond MCP-based agents. Whether you’re building enterprise-grade AI systems or experimenting with autonomous workflows, understanding this paradigm shift is essential.
What Are MCPs? The Original Vision for AI-Agent Tool Integration
Model Context Protocol (MCP) was introduced as an open standard designed to connect AI agents to external systems. At its core, an MCP is essentially just an API built for AI agents rather than human developers.
Technically, there’s little difference between a traditional API and an MCP. The key innovation wasn’t the protocol itself, but its adoption as an industry-wide standard. This standardization allowed developers to implement MCP once in their agent and instantly unlock access to a rich ecosystem of pre-built integrations.
Why MCPs Gained Popularity
MCPs solved a critical collaboration problem:
- Developers could share tools seamlessly across teams and projects.
- Agents could theoretically interact with any MCP-compliant service without custom integration.
- Tool discovery and reuse became significantly easier.
However, as adoption scaled, so did the limitations—especially around performance, cost, and autonomy.
The Core Problem: MCPs Consume Excessive Tokens
Despite their promise, MCPs introduce two major sources of token bloat that degrade agent performance and inflate costs:
1. Tool Definition Overload in Context Window
When you connect an agent to an MCP server, it typically includes 20–30 distinct tools, each with detailed descriptions, parameters, and usage instructions. Most developers don’t stop at one MCP—they often connect five or six MCP servers simultaneously.
Even if the agent only needs to use one tool, it receives the full context of all available tools from all connected MCPs. This leads to:
- Increased token costs (more input tokens = higher API bills)
- Higher latency (larger context = slower processing)
- More hallucinations (noise in context confuses the model)
2. Intermediate Tool Results Flood the Context
When an agent calls a tool—like retrieving a transcript from Google Drive—the full result (e.g., 50,000+ tokens) is often dumped directly into the context window. Worse, large documents can even exceed context limits.
But here’s the catch: the agent rarely needs the entire output. It might only require the first paragraph of a transcript or a specific data field. Yet with MCPs, there’s no built-in mechanism to filter or stream partial results.
The Solution: Code Execution Over MCP Abstraction
Entropic’s alternative—and the approach the speaker independently validated—is to replace MCP-based tool calling with direct code execution. Instead of describing tools in natural language for the model to interpret, you give the agent the ability to import and execute real code on demand.
How the New Architecture Works
The proposed structure organizes tools as actual code files in a hierarchical folder system:
- Create a root
tools/directory - Inside, create a subfolder for each MCP server (e.g.,
salesforce/,google-drive/) - Inside each subfolder, place individual tools as TypeScript files (e.g.,
getTranscript.ts,createTicket.ts)
When the agent needs to use a tool, it simply:
- Imports the relevant TypeScript file
- Executes the function with required parameters
This eliminates the need to preload all tool definitions into the context window.
Key Benefit #1: Drastic Token Reduction (98% Less!)
By switching to code execution, the agent no longer receives:
- Descriptions of unused tools
- Full raw outputs from intermediate steps
Instead, it only processes the minimal code needed to perform a task. In the speaker’s real-world test, this led to a 98% reduction in token consumption—a massive win for cost efficiency and scalability.
Key Benefit #2: Selective Data Handling Without Full Reads
With code execution, agents can manipulate data without reading it all. For example:
“It doesn’t even have to read the content of the transcript. It can simply take this transcript and without even reading it, send it to Salesforce MCP server.”
This is achieved by treating data as variables or files. The agent can:
- Save large outputs to the file system
- Pass file paths or references between functions
- Extract only needed snippets via code (e.g.,
transcript.substring(0, 200))
This avoids context window overflow and keeps processing lean.
Key Benefit #3: Progressive Disclosure at Scale
Traditional MCPs hit a hard ceiling: you can’t connect too many tools without overwhelming the context window. Code execution removes this limit entirely.
Now, you can provide your agent with thousands of tools across hundreds of MCP servers. When it needs a specific capability, it can:
- Use a search tool to discover which MCP folder contains the right function
- Dynamically import only the relevant tool
This “progressive disclosure” model mimics how humans work—we don’t memorize every tool; we look up what we need when we need it.
Key Benefit #4: Enhanced Data Privacy for Enterprise Use
Enterprise clients often refuse to expose sensitive data (e.g., customer emails, financial records) to third-party LLM providers like OpenAI or Anthropic. MCPs inherently violate this principle—every API response passes through the model’s context.
With code execution, you can build a privacy harness directly into your tool functions. For example:
// Modified getSheet.ts
function getSheet(sheetId) {
const rawData = fetchFromGoogleSheets(sheetId);
return anonymizeEmails(rawData); // e.g., "user@example.com" → "user@***.com"
}
Now, sensitive data never reaches the LLM—only sanitized, anonymized results do. This satisfies strict compliance and security requirements.
Key Benefit #5: State Persistence and Self-Evolving Skills
This is described as the “most game-changing benefit” of the code-based approach. Agents can now:
- Identify a missing capability
- Generate a new function to fulfill it
- Save that function as a .ts file in the appropriate tool folder
- Reuse it in future tasks
This enables agent evolution over time—a concept closely aligned with Anthropic’s recent “skills” framework. The agent isn’t static; it builds its own library of competencies.
Real-World Example: From Transcript to Salesforce Without Reading
Consider this workflow:
- Agent needs to send a Google Drive transcript to Salesforce
- Instead of fetching the full transcript into context, it calls
getTranscript.ts - The function saves the transcript to a local file (e.g.,
/tmp/transcript.txt) - Agent then calls
sendToSalesforce.ts, passing the file path - Salesforce tool reads the file directly—no LLM involvement
Result: Zero token cost for the transcript content, no hallucination risk, and faster execution.
Limitations of the Code Execution Approach
Despite its advantages, this paradigm isn’t without trade-offs:
1. Reduced Reliability Due to Code Generation
Every tool call now requires the agent to generate syntactically correct code. A single typo or logic error can break the workflow. While modern LLMs are excellent coders, they’re not infallible—especially with complex APIs or edge cases.
2. Increased Infrastructure Overhead
You must provide a secure sandbox environment where the agent can:
- Execute arbitrary code safely
- Access external APIs without exposing your network
- Manage file I/O and state persistence
Setting up this sandbox requires significant engineering effort—containerization, permission controls, logging, and error handling. However, the speaker notes their platform already offers this infrastructure for users.
When to Still Use MCPs: Simpler Use Cases
Code execution isn’t a universal replacement. MCPs still make sense for:
- Simple, low-complexity tasks (e.g., creating a customer support ticket)
- Scenarios with no data transformation needs
- Prototyping or MVP development where sandbox setup isn’t feasible
As the speaker clarifies: “For customer support where the API isn’t that complex and you don’t need to do any transformations, you just need to send a ticket—it definitely still makes sense.”
Why Code Execution Aligns with AI’s Strengths
The fundamental insight is this: AI agents have become exceptionally good at generating code. Over the past two years, models like GPT-4, Claude 3, and others have demonstrated near-human-level programming ability.
Given this, layering additional abstractions (like MCP descriptions) on top of code is redundant—and counterproductive. Each abstraction:
- Reduces agent autonomy
- Increases cognitive load on the model
- Introduces translation errors between natural language and API specs
Letting agents write and run code directly leverages their core competency.
Step-by-Step: Transitioning from MCP to Code Execution
Here’s how to implement this approach in your own projects:
| Step | Action | Details |
|---|---|---|
| 1 | Create tool directory structure | tools/salesforce/createTicket.ts, tools/google-drive/getFile.ts, etc. |
| 2 | Implement each tool as a standalone function | Include error handling, auth, and data sanitization (e.g., email anonymization) |
| 3 | Set up a secure execution sandbox | Use Docker, firewalls, and API gateways to isolate agent code |
| 4 | Modify agent prompt | Instruct it to “import and call functions from the tools directory” instead of describing tool usage |
| 5 | Add a search/discovery tool | Helps agent locate the right function when thousands of tools exist |
| 6 | Enable skill persistence | Allow agent to write new .ts files to the tools directory when it invents a new capability |
Performance Metrics: What to Expect
Based on the speaker’s real-world implementation:
| Metric | MCP Approach | Code Execution Approach | Improvement |
|---|---|---|---|
| Token Usage | High (full tool defs + full outputs) | Minimal (only code imports) | 98% reduction |
| Result Quality | Moderate (hallucinations common) | High (deterministic code execution) | Significantly better |
| Autonomy | Limited (relies on pre-defined tools) | High (can create new skills) | Greatly enhanced |
| Latency | High (large context processing) | Low (focused execution) | Noticeably faster |
Future Outlook: The End of MCP Agents?
While MCPs won’t disappear overnight, the trajectory is clear. For complex, data-intensive, or enterprise-grade AI agents, code execution is rapidly becoming the superior architecture.
This shift also aligns with broader industry trends:
- Anthropic’s “skills” framework
- Open-source agent frameworks embracing code-as-tools (e.g., LangChain, LlamaIndex)
- Rise of agentic development platforms with built-in sandboxes
Practical Next Steps for Developers
If you’re ready to move beyond MCPs:
- Audit your current agent tools: Identify which require full data reads vs. partial access
- Start small: Convert one high-token MCP tool to a TypeScript function
- Implement a sandbox: Use open-source solutions like Firecracker or platform offerings
- Add privacy guards: Anonymize PII in tool outputs before they reach the LLM
- Enable skill creation: Allow your agent to write new functions to disk
Conclusion: Autonomy Through Code, Not Abstraction
The core philosophy is simple: stop abstracting away code from AI agents. They excel at generating and reasoning about code—so let them.
By replacing MCPs with direct code execution, you unlock:
- 98% lower token costs
- Enterprise-grade privacy
- Unlimited tool scalability
- Self-improving agent capabilities
Yes, it requires more infrastructure. Yes, code generation isn’t perfect. But the payoff—truly autonomous, efficient, and evolving AI agents—is worth it.
As the speaker concludes: “Every single abstraction that you add to your agent significantly reduces the autonomy of that agent. And the primary reason of having an agent in the first place is so that it could autonomously execute your tasks for you.”
The era of bloated, context-heavy MCP agents is ending. The future belongs to lean, code-native agents that think in functions, not descriptions.

