Skip to content

Lazy/deferred loading of MCP tool definitions to reduce context usage #2167

Description

@merhovon

Is your feature request related to a problem? Please describe.
Zoo Code puts the definitions of all enabled MCP tools into the prompt. I think it does this for every request. Each tool definition uses tokens. Many MCP servers use a large part of the context window before the task starts. A large tool list can also make tool selection less accurate.

My setup:

  • Zoo Code version: 3.90.0 (baf19351)
  • Enabled MCP servers: 173
  • Tokens used at the start of a new task: 100k

Describe the solution you'd like
Add an optional setting for deferred loading of MCP tools. Claude Code has a similar function called Tool Search (see anthropics/claude-code#7336).

The function works in this way:

  1. The prompt contains only a short list of the deferred tools. Each entry has the server name, the tool name, and a short description.
  2. A built-in search tool lets the model find a tool by keyword or by exact name.
  3. The search tool loads the full schema of the tools it finds. The model can call these tools from the next turn.
  4. Zoo Code keeps the loaded tools for the rest of the task.
  5. Zoo Code does this on the client side. The function works with all providers.

Suggested configuration:

{
  "mcpServers": {
    "example-server": {
      "command": "...",
      "deferLoading": true,
      "alwaysLoadTools": ["critical_tool"]
    }
  }
}

Also add a global setting with these values: eager, deferred, and auto. Auto defers the tools when they use more than a set number of tokens. The default value stays eager. Existing users see no change.

Please keep the auto-approve settings valid for tools that Zoo Code loads on demand.

Describe alternatives you considered

  • I turn MCP servers on and off by hand for each task. This takes time, and I forget it often.
  • I allow MCP tools in only some modes. This reduces the context size, but it does not give access to all tools when I need them.
  • I use a proxy such as lazy-mcp. It shows only a few meta-tools to the client. This needs extra setup and one more program.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions