[PR #12520] feat: mcp-search tool for lazy loading mcp #14253

Open
opened 2026-02-16 18:19:04 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12520

State: open
Merged: No


rebased https://github.com/anomalyco/opencode/pull/8771 onto the head of dev.

Closes #8625.

What does this PR do?

Adds a new experimental.mcp_lazy config option that prevents MCP tools from being loaded into context automatically. Instead, a new mcp_search tool is provided to discover and call MCP tools on-demand.

This reduces context usage for users with many MCP servers configured. When enabled:

  • MCP tools are excluded from the tool list sent to the model

    • Instead, available MCP servers are injected into the system prompt in a compact format.
  • The mcp_search tool allows listing, searching, describing, and calling MCP tools

  • MCP servers show "Lazy" status in the /mcp dialog

The injected prompt:

<mcp_servers>
Available MCP servers: context7, firecrawl, playwright
Use mcp_search tool to discover and call tools from these servers.
</mcp_servers>

How did you verify your code works?

  • Tested with experimental.mcp_lazy: true in config
  • Verified MCP tools are not in context and mcp_search appears instead
  • Tested all operations: list, search, describe, call
  • Confirmed servers connect on-demand when calling tools

The tests were manual, there are no actual tests included here.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12520 **State:** open **Merged:** No --- rebased https://github.com/anomalyco/opencode/pull/8771 onto the head of dev. > Closes #8625. > > ### What does this PR do? > Adds a new `experimental.mcp_lazy` config option that prevents MCP tools from being loaded into context automatically. Instead, a new `mcp_search` tool is provided to discover and call MCP tools on-demand. > > This reduces context usage for users with many MCP servers configured. When enabled: > > * MCP tools are excluded from the tool list sent to the model > > * Instead, available MCP servers are injected into the system prompt in a compact format. > * The `mcp_search` tool allows listing, searching, describing, and calling MCP tools > * MCP servers show "Lazy" status in the `/mcp` dialog > > The injected prompt: > > ``` > <mcp_servers> > Available MCP servers: context7, firecrawl, playwright > Use mcp_search tool to discover and call tools from these servers. > </mcp_servers> > ``` > > ### How did you verify your code works? > * Tested with `experimental.mcp_lazy: true` in config > * Verified MCP tools are not in context and `mcp_search` appears instead > * Tested all operations: list, search, describe, call > * Confirmed servers connect on-demand when calling tools > > The tests were manual, there are no actual tests included here.
yindo added the pull-request label 2026-02-16 18:19:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14253