Back to KB
Difficulty
Intermediate
Read Time
8 min

CLI vs MCP: guía para agentes en producción

By Codcompass Team··8 min read

Beyond the Protocol War: Architecting Efficient Agent Tooling in Production

Current Situation Analysis

The rapid adoption of AI agents in production environments has exposed a critical architectural blind spot: context window economics. Early agent frameworks treated tool integration as a simple connectivity problem, leading teams to adopt standardized protocols like the Model Context Protocol (MCP) without accounting for token budgeting. The industry narrative positioned MCP as a universal bridge, but production telemetry revealed a different reality. Tool schema injection, capability negotiation, and result wrapping consume disproportionate context resources before an agent executes a single meaningful operation.

This problem is frequently misunderstood because protocol standardization is conflated with operational efficiency. Engineering teams assume that a unified interface automatically reduces complexity. In practice, the upfront metadata payload of MCP servers directly competes with the model's reasoning capacity. When an agent connects to a single GitHub MCP server, it ingests approximately 55,000 tokens representing 93 distinct tool definitions. Adding two more servers (e.g., Slack and a database connector) can consume over 70% of a 200K token context window purely in protocol metadata. This leaves insufficient space for user prompts, conversation history, and intermediate reasoning steps.

The severity of this issue was formally acknowledged by Anthropic's engineering team in November 2025. Their internal benchmarks confirmed that schema overload and intermediate result serialization directly inflate API costs and increase latency. The acknowledgment shifted the conversation from protocol preference to resource allocation. Teams now recognize that tooling architecture must be treated as a constrained optimization problem, balancing token efficiency, execution speed, authentication requirements, and composability.

WOW Moment: Key Findings

The following comparison isolates the operational trade-offs between three dominant tooling strategies. The data reflects production telemetry and vendor-published benchmarks.

ApproachContext OverheadExecution LatencyEnterprise Auth Readiness
CLI / Shell Execution~0 tokens (pre-trained knowledge)Low (direct process spawn)Limited (relies on host credentials)
Standard MCPHigh (~55k+ tokens per server)Medium-High (handshake + schema parse)Native (OAuth, dynamic client registration)
MCP + Code ExecutionLow (~98% reduction vs standard)Medium (sandbox compilation + batch calls)Native (inherits MCP auth layer)

Why this matters: The table demonstrates that there is no universally optimal interface. CLI execution leverages the model's pre-existing training data, eliminating schema injection entirely. Standard MCP provides robust authentication and multi-tenant governance but imposes a heavy context tax. The Code Execution pattern, validated by Anthropic's engineering team, decouples tool discovery from execution, allowing agents to write short scripts that invoke MCP tools within a sandbox. This hybrid approach preserves enterprise security while reducing token consumption from ~150,000 to ~2,000 in benchmark scenarios. Architecting for production requires routing tasks to the interface that aligns with the current token budget and security boundary.

Core Solution

Building a production-ready agent tooling layer requires a routing architecture that evaluates task characteristics before selecting an execution strategy. The following implementation demonstrates a TypeScript-based router that dynamically delegates to CLI, MCP, or Code Execution sandboxes.

Architecture Rationale

  1. Separation of Concerns: Tool execution should not be tightly coupled to the agent's reasoning loop. A dedicated routing layer isolates proto

🎉 Mid-Year Sale — Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register — Start Free Trial

7-day free trial · Cancel anytime · 30-day money-back