Documentation
Architecture

MCP Servers and Deferred Tool Loading

How Andromity keeps Model Context Protocol (MCP) tool schemas out of every request, so connecting many servers doesn't fill the context window.

This page explains the design. To connect a server, see MCP Servers.

The problem

An MCP tool's input schema (parameters, types, enums and descriptions) can run to hundreds of tokens. Sending every connected tool's schema as a function definition on every request means three or four servers can add tens of thousands of tokens to each turn, before any of your code is in context.

Deferred tools

Andromity sends only its own core tools as function definitions. MCP tools are deferred:

  1. When a server connects, Andromity calls tools/list and caches each tool's name, description and input schema.
  2. In the system prompt, each MCP tool appears as one line: its full name and description, inside an <available-deferred-tools> block. Schemas are not included.
  3. When the agent needs a tool, it calls the built-in, read-only list_tools tool with search and include_description=True to read that tool's parameters from the cache.
  4. The agent calls the tool by name (mcp__<server>__<tool>). Andromity routes the call to the server with tools/call, after the usual approval checks.
sequenceDiagram
    participant LLM as Model
    participant Agent as Andromity
    participant MCP as MCP server

    Agent->>MCP: tools/list (on connect)
    MCP-->>Agent: Tool names, descriptions, schemas (cached)
    Agent->>LLM: Core tools + one line per MCP tool
    LLM->>Agent: list_tools(search="create_issue", include_description=true)
    Agent-->>LLM: Schema from the cache
    LLM->>Agent: mcp__github__create_issue({...})
    Agent->>MCP: tools/call
    MCP-->>Agent: Result
    Agent->>LLM: Tool result

What it costs

The prompt still carries one line per tool, and descriptions are not shortened, so cost grows with the number of tools and the length of their descriptions. The VS Code context indicator reports it as MCP & deferred tools. The saving is the schemas: they enter the conversation only for tools the agent actually looks up.

Trade-offs

  • The agent needs an extra list_tools call before using an MCP tool for the first time in a conversation.
  • Arguments are passed to the server as the model wrote them. The server validates them and returns an error the model can correct.
  • The cached schema is refreshed when the server reconnects, so restart a server after updating it.