PM

petercha90/mcp-lazy-load

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

11 stars 3 forks 质量 63 趋势 18MIT

QQ MCP 工具会吃上下文窗口吗 ? 所有人工智能特工都装了懒货 只有一个命令.

概览

唵(引一)████╗(引一)████║██╔════╝██╔══██╗(二合引一)╚══════╝╚═╝(引一)贺. 以懒惰的加载方式将 MCP 上下文窗口符号的使用减少 90% 。 一个指令设置。 - MCP服务器在启动时将所有工具定义加载到上下文窗口——甚至在使用之前. 有了5-10个服务器,可以消耗上下文窗口的30%-50%. 通过一个单一的轻量级代理来代理您所有的 MCP 服务器, 并按需加载工具 。 然后预建工具缓存( 建议): - 添加命令读取您代理服务器已有的 MCP 配置, 将所有服务器定义保存到 ~/. mcp- lazy/ servers.json , 并仅用 mcp- lazy 代理条目替换代理配置 。 - 启动工具缓存预建, 这样您的第一个代理会话即刻开始 .

概述(AI 翻译)

{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢? ████╗,██║也. ██╔████╔██║██║,███████║也. {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢? {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢? {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?

轻而易举

한국어

将 MCP 上下文窗口符号使用减少 90 +% , 并加载懒惰 。 一个指令设置。

  • MCP服务器在启动时将所有工具定义加载到上下文窗口——甚至在使用之前. 有了5-10个服务器,可以消耗上下文窗口的30%-50%. mcp-lazy通过一个单一的轻量级代理来代理您所有的MCP服务器,根据需要加载工具.

82 tools exposed at startup

Just 2 with mcp-lazy

□ 快开始

为你的经纪人选一个:

然后预建工具缓存( 建议):

  • add 命令读取您代理商现有的 MCP 配置,将所有服务器定义保存到 ~/.mcp-lazy/servers.json , 并仅用 mcp-lazy 代理条目替换代理配置 。
  • init 预建工具缓存, 因此您的第一个代理会话立即启动 .

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

███╗ ███╗ ██████╗██████╗ ██╗ █████╗ ███████╗██╗ ██╗ ████╗ ████║██╔════╝██╔══██╗ ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝ ██╔████╔██║██║ ██████╔╝█████╗██║ ███████║ ███╔╝ ╚████╔╝ ██║╚██╔╝██║██║ ██╔═══╝ ╚════╝██║ ██╔══██║ ███╔╝ ╚██╔╝ ██║ ╚═╝ ██║╚██████╗██║ ███████╗██║ ██║███████╗ ██║ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝

mcp-lazy 🫠

한국어

Reduce MCP context window token usage by 90%+ with lazy loading. One command setup.

  • MCP servers load all tool definitions into the context window at startup — even before you use them. With 5-10 servers, this can consume 30-50% of your context window. mcp-lazy proxies all your MCP servers through a single lightweight proxy that loads tools on-demand.

82 tools exposed at startup

👇 Just 2 with mcp-lazy

Quick Start

Pick one for your agent:

npx mcp-lazy add --cursor        # Cursor
npx mcp-lazy add --antigravity   # Antigravity
npx mcp-lazy add --opencode      # Opencode
npx mcp-lazy add --all           # or all at once

Then pre-build the tool cache (recommended):

npx mcp-lazy init
  • The add command reads your agent’s existing MCP config, saves all server definitions to ~/.mcp-lazy/servers.json, and replaces the agent config with only the mcp-lazy proxy entry.

  • init pre-builds the tool cache so your first agent session starts instantly. Without it, the first session will be slightly slower while mcp-lazy discovers tools from all servers.

    Tip: Installed a new MCP server? Just re-run npx mcp-lazy add -- — no extra steps.

How It Works

Without mcp-lazy:
  Agent → MCP Server A (50 tools) + Server B (30 tools) + Server C (20 tools)
        = 100 tools loaded at startup (~67,000 tokens)

With mcp-lazy:
  Agent → mcp-lazy proxy (2 tools only, ~350 tokens)
              ↓ on-demand
         Server A / B / C (loaded only when needed)
         URL servers (Notion, Slack, etc.) via mcp-remote bridge

The proxy exposes just 2 tools:

  • mcp_search_tools — Search available tools by keyword
  • mcp_execute_tool — Execute a tool (lazy-loads the server on first call)

What add Does

  • When you run npx mcp-lazy add --, it:
  1. Reads your agent’s existing MCP server config
  2. Extracts all server definitions (stdio and URL-based)
  3. Converts URL servers (OAuth-requiring services like Notion, Slack) to stdio commands using npx mcp-remote
  4. Saves everything to ~/.mcp-lazy/servers.json
  5. Replaces the agent config with only the mcp-lazy proxy entry
  • The proxy reads from ~/.mcp-lazy/servers.json at runtime — that’s where all your server definitions live after setup.

Supported Agents

| Agent | Status |

在 GitHub 查看完整 README

安装

npx mcp-lazy add --cursor # Cursor
新手?先看 mcpskill.org 教程 →