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:
- When a server connects, Andromity calls
tools/listand caches each tool's name, description and input schema. - 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. - When the agent needs a tool, it calls the built-in, read-only
list_toolstool withsearchandinclude_description=Trueto read that tool's parameters from the cache. - The agent calls the tool by name (
mcp__<server>__<tool>). Andromity routes the call to the server withtools/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 resultWhat 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_toolscall 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.