GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: Lazy/dynamic loading for mcp tools · Issue #8277 · anomalyco/opencode

[FEATURE]: Lazy/dynamic loading for mcp tools #8277

New issue
Copy link
New issue
Copy link
Closed
Closed
[FEATURE]: Lazy/dynamic loading for mcp tools#8277
Copy link
Assignees
thdxr
Labels
discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Description

@DhruvAtreja
DhruvAtreja
opened on Jan 13, 2026
Issue body actions

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

When multiple MCP servers are enabled, all tool definitions load into the agent's context at session startup. A single MCP server like GitHub can add 15-20k+ tokens just for tool schemas. With several MCPs enabled, context bloat can exceed 50k tokens before the user even sends a message. This is even mentioned in the docs: https://opencode.ai/docs/mcp-servers/

Solution

Lazy loading pattern: Instead of loading full tool schemas at startup, we:

Show a lightweight index in the system prompt with server names and tool names only (~150 tokens vs ~1.5k)
Provide a mcp_load_tools meta-tool that loads specific tools on-demand
The agent loop naturally picks up newly loaded tools on the next iteration
Example Flow

System prompt shows:
"playwright (20 tools): browser_snapshot, browser_click, browser_navigate, ..."

User: "Take a screenshot of google.com"

Agent calls: mcp_load_tools("playwright", ["browser_navigate", "browser_snapshot"])
→ Tools loaded into session state

Agent calls: playwright_browser_navigate({ url: "https://google.com/" })
Agent calls: playwright_browser_snapshot()

Related

  • Addresses: Option to Enable / Disable MCP Servers (via TUI) #514, Enable/Disable MCP server by Mode #1101, Feature Request: Global default tools configuration for agents #2888, [feature request]: ability to dynamic turn on mcp server for specific agent #2953, [FEATURE]: Option to deny MCP tools by default #3612, [FEATURE]: Allow to enable MCP on a per-agent basis #5373, [FEATURE]: Provider/Model-specific MCP servers #6024
Reacted by 657, Marco Michely, platem, Surge, Utkarsh Patil, Derek Pearson, Levi Zitting, rqdmap, GammelSami, Lukas Zorich and 32 more

Activity

  1. DhruvAtreja
    added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 13, 2026
  2. github-actions
    assigned
    thdxr
    on Jan 13, 2026
  3. github-actions commented on Jan 13, 2026

    @github-actions
    github-actionsBot
    on Jan 13, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • [FEATURE]: Support MCP-CLI for on-demand loading of MCP tools for reduced token consumption #7406: Support MCP-CLI for on-demand loading of MCP tools for reduced token consumption
    • [FEATURE]: Let LLM enable MCP on demand, default all MCPs off #7466: Let LLM enable MCP on demand, default all MCPs off

    Both of these issues address similar concerns about lazy/dynamic loading of MCP tools to reduce token consumption and context bloat.

    Feel free to ignore if your specific case differs from these proposals.

  4. KenjiPcx commented on Jan 16, 2026

    @KenjiPcx
    KenjiPcx
    on Jan 16, 2026
    More actions

    I think you could also just tie in MCP loaders into skills as they are loaded since skills are already lazy loaded

  5. leandro-ferreira-creditas commented on Jan 16, 2026

    @leandro-ferreira-creditas
    leandro-ferreira-creditas
    on Jan 16, 2026
    More actions

    Anthropic did this with Claude Code. A very clever solution that mixes MCP search, dynamic tool update on the fly, and MCP Automatic Trigger.

    Reacted by Derek Pearson, Dhruv Atreja, Stanislav U., Karim Bellioum and Prakhar Yadav
  6. platem commented on Jan 16, 2026

    @platem
    platem
    on Jan 16, 2026
    More actions

    +1, that's a great idea, it would clear up the context window well allowing for higher quality outputs.

  7. famitzsy8 commented on Jan 18, 2026

    @famitzsy8
    famitzsy8
    on Jan 18, 2026
    More actions

    Implementing a Claude Code style Tool Search Tool on this fork

    Reacted by Eric Guo
    Reacted by Eric Guo
  8. dennisrutjes-1 commented on Jan 19, 2026

    @dennisrutjes-1
    dennisrutjes-1
    on Jan 19, 2026
    More actions

    you can just vibe code a mcp-tool that does the searching, I coded deno with typescript mcp-tool with it's own mcp server config and let agent just search for that in tool skill definition works like a charm. It is also able to generate tools and register them in folder for local/repo re use

    Image
  9. famitzsy8 commented on Jan 19, 2026

    @famitzsy8
    famitzsy8
    on Jan 19, 2026
    More actions

    Concretely discussing this issue (for MCP as well as built-in tools) in #9461

  10. TheOutdoorProgrammer commented on Feb 6, 2026

    @TheOutdoorProgrammer
    TheOutdoorProgrammer
    on Feb 6, 2026
    More actions

    Hey — thanks for filing this! There are several open issues requesting essentially the same thing (tool search / deferred tool loading / lazy MCP loading). To consolidate discussion and improve visibility, it'd be great if this could be closed in favor of #8625 which has the most thumbs up on the topic. Consolidating makes it easier for maintainers to see community demand in one place.

    Related issues tracking the same feature:

    • [FEATURE]: Claude-style Tool Search Tool Implementation in OpenCode #9461
    • [Feature Request] MCP Tool Search - Lazy Loading for 85% Token Reduction #9350
    • [FEATURE]: Lazy/dynamic loading for mcp tools #8277

    Semi related issues that would compliment this (for visibility):

    • [FEATURE]: Filter which tools are loaded from MCP servers (includeTools/excludeTools) #7399

    I've rebased #8771 here. I've been running it for a few days its working amazing. Looking forward to this being part of OpenCode.

  11. Arrmlet commented on Feb 20, 2026

    @Arrmlet
    Arrmlet
    on Feb 20, 2026
    More actions

    Hello I've coded this tool. Lazy MCP tool loading, works with any provider: https://github.com/Arrmlet/dehydrator

    Reacted by Prakhar Yadav
  12. bold84
    added a commit that references this issue on Apr 5, 2026

    feat: lazy MCP loading with session-scoped activation

    5843965
  13. github-actions commented on Apr 22, 2026

    @github-actions
    github-actionsBot
    on Apr 22, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  14. github-actions
    closed this as completedon Apr 22, 2026
  15. omarwaly-ai commented on Jun 25, 2026

    @omarwaly-ai
    omarwaly-ai
    on Jun 25, 2026
    More actions

    Thanks for suggesting the feature, actually i faced the same issue not only with MCPs, but also with built-in tools too that inject 6k -7k tokens in each request.
    I create a single file plugin OpenCode Lazy Loading that loads tools and MCPs on demand once per request with ZERO tokens for MCPs and ~323 tokens built-in tools

    Setup Before After Saved
    12 built-in tools ~6,900 tokens ~323 tokens ~95%
    Chrom Devtool MCP ~17,900 tokens ZERO tokens ~100%
    12 built-in + Chrom Devtool MCP ~24,800 tokens ~323 tokens ~98.7%

    Reducing opencode's total tokens for default opencode setup from ~10k to ~3.7K

    Feel free to try it here: https://github.com/omarwaly-ai/opencode-lazy-loading

    Reacted by Eric Guo, Tien Bac Nguyen and Padure Sergio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.