lazy-mcp

作者 voicetreelab已验证

MCP proxy server with lazy loading support - reduces context usage through on-demand tool activation

109
Stars
15
Forks
Go
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/voicetreelab/lazy-mcp

快速入门

使用 lazy-mcp 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

Lazy MCP

Lazy MCP lets your agent fetch MCP tools only on demand, saving those tokens from polluting your context window.

In this example, it saved 17% (34,000 tokens) of an entire claude code context window by hiding 2 MCP tools that aren't always needed.

Welcoming open source contributions!

How it Works

Lazy MCP exposes two meta tools, which allows agents to explore a tree structure of available MCP tools and categories.

  • get_tools_in_category(path) - Navigate the tool hierarchy
  • execute_tool(tool_path, arguments) - Execute tools by path

Example Flow

1. get_tools_in_category("") → {
     "categories": {
       "coding_tools": "Development tools... use when...",
       "web_tools": "description ... instructions"
     }
   }
   
2. get_tools_in_category("coding_tools") → {
     "categories": {
       "serena": "description ... instructions",
     }
   } 

3. get_tools_in_category("coding_tools.serena") → {
     "tools": {"find_symbol": "...", "get_symbols_overview": "..."}
   }

4. execute_tool("coding_tools.serena.find_symbol", {...})
   → Lazy loads Serena server (if not already loaded)
   → Proxies request to Serena
   → Returns result

img_1.png img_2.png

Quick Start

make build
./build/structure_generator --config config.json --output testdata/mcp_hierarchy

This generates the hierarchical structure in the output folder config.json specifies, by fetching the available tools from the mcp servers specified.

Add to Claude Code:

 claude mcp add --transport stdio mcp-proxy build/mcp-proxy -- --config config.json

Configuration

Basic Config Structure

see config.json for an example.

Tool Hierarchy Structure

Tool hierarchy is defined in testdata/mcp_hierarchy/ with JSON files:

Root node (testdata/mcp_hierarchy/root.json):

Category nodes (e.g., testdata/mcp_hierarchy/github/github.json):

Tool nodes (e.g., testdata/mcp_hierarchy/github/create_issue/create_issue.json):

Command Line Options

./mcp-proxy --help

Permission Control with Claude Code Hooks

When using lazy-mcp with Claude Code, all tool calls go through execute_tool. This means traditional MCP permission rules (like mcp__github__create_issue) don't apply directly.

To control which tools require permission prompts, use Claude Code hooks.

Option 1: Claude Code Native Hook (Recommended for Claude Code)

Claude Code's PreToolUse hooks can inspect the tool_path argument and decide permission by outputting JSON:

  • Allow: Exit 0 (no output)
  • Ask: Exit 0 with {"hookSpecificOutput": {"permissionDecision": "ask", ...}}
  • Deny: Exit 0 with {"hookSpecificOutput": {"permissionDecision": "deny", ...}}

Setup

  1. Copy the example hook script:

    cp examples/hooks/check-sensitive-tools.sh ~/.claude/hooks/
    chmod +x ~/.claude/hooks/check-sensitive-tools.sh
    
  2. Configure Claude Code hooks (in ~/.claude/settings.json or project .claude/settings.local.json):

    {
      "hooks": {
        "PreToolUse": [
          {
            "matcher": "mcp__lazy-mcp__execute_tool",
            "hooks": [
              {
                "type": "command",
                "command": "~/.claude/hooks/check-sensitive-tools.sh"
              }
            ]
          }
        ]
      }
    }
    
  3. Customize sensitive tools via environment variables:

    # Tools that require permission prompts
    export LAZY_MCP_SENSITIVE_TOOLS="gmail.send_email,github.create_*,gitlab.create_*"
    
    # Tools that are completely blocked
    export LAZY_MCP_DENIED_TOOLS="*.force_delete_*"
    

Option 2: Token-Based Hook (Recommended for OpenCode / General Use)

Since not all agents support the permissionDecision JSON protocol, lazy-mcp also supports a universal "Token Hook" mechanism. This forces the agent to retry the operation after user confirmation.

How It Works

  1. First Call: Hook checks for a token. If missing, it exits with error CONFIRMATION_NEEDED and the path to the required token.
  2. Agent Response: The agent catches this error, asks the user for confirmation, and creates the token file.
  3. Retry: The agent retries the tool call. The hook finds the token, deletes it (one-time use), and allows execution.

Setup

  1. Copy the token hook script:

    cp examples/hooks/confirm-tool-token.sh /path/to/hooks/
    chmod +x /path/to/hooks/confirm-tool-token.sh
    
  2. Configure your agent to call this script before execute_tool.

Option 3: OpenCode Plugin

For OpenCode users, a TypeScript plugin is available that logs warnings for sensitive actions.

cp examples/plugins/opencode-sensitive-tools.ts .opencode/plugin/sensitive-tools-check.ts

Default Sensitive Tools

The example scripts include sensible defaults for public-facing actions:

ServerSensitive Tools
Gmailsend_email, create_draft, delete_email, trash_email
GitHubcreate_issue, create_pull_request, create_repository, push_files, create_or_update_file, create_branch, fork_repository
GitLabcreate_issue, create_merge_request, accept_merge_request, create_project, create_branch, create_or_update_file

Pattern Syntax

  • Exact match: gmail.send_email
  • Server prefix: gmail.* (all gmail tools)
  • Suffix match: *.delete_* (all delete operations)

Credits

Forked from TBXark/mcp-proxy - extended with hierarchical routing, lazy loading, and stdio support.

License

MIT License - see LICENSE

常见问题

What is lazy-mcp?

lazy-mcp is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by voicetreelab. MCP proxy server with lazy loading support - reduces context usage through on-demand tool activation. It has 109 GitHub stars.

Is lazy-mcp safe to use?

Yes. lazy-mcp passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install lazy-mcp?

Clone the repository with "git clone https://github.com/voicetreelab/lazy-mcp" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is lazy-mcp written in?

lazy-mcp is primarily written in Go. It is open-source under voicetreelab on GitHub, so you can review or fork the full source.

Are there alternatives to lazy-mcp?

Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh lazy-mcp against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

Scrapling

by D4Vinci

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

75,9137,581Python
MCP 服务器
查看详情

TrendRadar

by sansan0

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

61,65224,883Python
MCP 服务器
查看详情

context7

by upstash

Context7 Platform -- Up-to-date code documentation for LLMs and AI code editors

61,0602,938TypeScript
MCP 服务器
查看详情

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

39,9393,219C
MCP 服务器
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情