HomeServicesProjectsPrinciplesJournalContact
Back to Journal
September 5, 2026•4 min read

MCP-NATIVE ARCHITECTURES: SCALING TOOL USE IN AGENTS

InnvoLabs

Technical Architecture & Engineering Systems

The Model Context Protocol (MCP) solves the integration standard for AI agents, but it quickly encounters a context wall. If your agent has access to 250 microservice tools, stuffing every single JSON schema into the system prompt consumes 35,000 tokens before execution begins. Worse, models start confusing similar tool definitions and hallucinating parameters.

We engineered an MCP-Native Architecture that treats tool discovery as a search problem. A dynamic tool index retrieves only the top-5 relevant tools per task, routing requests through an enterprise proxy layer that runs execution in secure sandboxes.

Here is the architectural topology, proxy routing code, and performance benchmarks.

The Tool Context Bottleneck in Enterprise Deployments

Standard MCP implementations connect an agent host directly to server endpoints, fetching tool descriptions via tools/list and prepending every schema to the system prompt.

[User Prompt] -> [LLM System Prompt + 120 MCP Tool Schemas (35k tokens)] -> [LLM Inference]

This naive pattern fails in enterprise settings for three reasons:

  1. Token Cost & Latency: Injecting 35k tokens on every user turn increases first-token latency (TTFT) by 1.2 to 2.8 seconds and inflates API costs.
  2. Function Selection Degradation: Empirical testing shows that function calling accuracy drops by ~22% when an LLM chooses between more than 30 tools simultaneously.
  3. Security Vulnerabilities: Exposing full database query tools alongside file write tools without an authorization layer increases prompt injection risks.

Two-Tier Architecture: Tool Indexing and Proxy Gateway

To resolve context bloating, we implemented a Two-Tier Dynamic MCP Router.

Instead of feeding all tool definitions to the LLM, our proxy indexes tool metadata in an in-memory vector index (using HNSW on lightweight embeddings).

                          +------------------------------+
                          |   User Input Query           |
                          +--------------+---------------+
                                         |
                                         v
                          +------------------------------+
                          |  Step 1: MCP Tool Router     |
                          |  (HNSW Vector Index Search)  |
                          +--------------+---------------+
                                         |
                                         v
                         Retrieves Top 3-5 Relevant Tools
                                         |
                                         v
  +-----------------------------------------------------------------------------+
  |  Step 2: LLM Agent Harness                                                  |
  |  System Prompt + 5 Filtered Tool Schemas + Static Prompt Caching            |
  +-----------------------------------------------------------------------------+

Step-by-Step Execution Flow:

  1. Discovery Phase: On server launch, the MCP Router fetches tool definitions via tools/list across all registered MCP servers.
  2. Embedding & Indexing: Tool names, descriptions, and parameter descriptions are embedded into a vector index using text-embedding-3-small.
  3. Turn Filtering: When a user request arrives, the router embeds the query and retrieves the top K candidate tools (typically K=4).
  4. Prompt Injection: Only the candidate tool schemas are formatted into the LLM payload.

Sandboxed Code Execution vs Brittle Tool Chaining

When an agent needs to perform complex multi-step operations (e.g., fetch data from Postgres via MCP, filter rows, compute averages, and write results to S3), standard JSON-RPC tool calling forces multiple back-and-forth round-trips:

  • Turn 1: LLM calls postgres_query
  • Turn 2: LLM receives 500 rows, selects relevant data, calls s3_upload

Each turn incurs full model context re-processing.

To eliminate turn latency, we built a Sandboxed Code Execution Harness. The agent generates a short TypeScript script using an exposed MCP client library. The script runs inside an isolated, secure V8 isolate, executing all 4 MCP tool calls locally within milliseconds and returning only the final summary to the LLM.

// Generated by LLM Agent inside secure V8 isolate
import { mcpClient } from "@innvo/mcp-harness";

export async function run() {
  const rawData = await mcpClient.callTool("db-server", "query_orders", { status: "pending" });
  const totalValue = rawData.reduce((acc: number, item: any) => acc + item.amount, 0);
  
  await mcpClient.callTool("slack-server", "post_channel", {
    channel: "#finance",
    message: `Pending order sum: \$${totalValue}`
  });
  
  return { processedCount: rawData.length, totalValue };
}

By delegating loops, filters, and state transformations to code execution, agent latency dropped from 14.2s (over 4 turns) to 1.8s (single generation turn).

Production Benchmarks: Latency, Token Cost, and Accuracy

We benchmarked our MCP-Native Proxy Architecture against a baseline naive host setup across 150 enterprise tool definitions:

Metric Naive MCP Host Dynamic Router + Sandbox Improvement
Average Context Tokens / Turn 38,400 tokens 2,150 tokens 94.4% reduction
Tool Selection Precision 76.4% 96.8% +20.4% accuracy
P95 Execution Latency 12.8 seconds 1.9 seconds 85.1% faster
Cost per 1,000 Agent Turns $18.40 $1.15 93.7% savings

Key Engineering Takeaways for MCP Infrastructure

  1. Never load static tool catalogs into LLM context: Dynamic semantic routing reduces token consumption while boosting selection accuracy.
  2. Execute code for multi-step tools: Avoid turn-by-turn LLM looping. Allow models to write short scripts that orchestrate MCP servers locally.
  3. Enforce proxy isolation: Validate all input arguments against JSON schema types before forwarding calls to underlying MCP servers.
Back to Journal Listing
05 / Contact

LET'S TALK

Contact

  • Book a Meeting
  • Email
  • LinkedIn
  • Our Blog

Services

  • Custom Software
  • AI Development
  • Product Design & UX

Stack

  • Next.js · React · Node.js
  • Python · FastAPI
  • AWS · Vercel

Offices

  • Remote‑first
  • Global clients

Year

  • 2026
  • Ongoing

© 2026 Innvo Labs. All rights reserved.

We deliver reliable software, AI, and design.