leaforbook/dsh-mcp-lazy

Plugin插件 Native原生 ⭐ 4 MIT Notifications & Remote通知与远程

Lazy on-demand MCP bridge for DeepSeek Harness

Project Overview项目介绍

This is a purpose-built plugin for DeepSeek Harness (DSH) that reduces the number of tokens consumed per model turn by lazy loading MCP tool schemas. When a user installs many MCP servers into DSH, all tool descriptions are normally sent to the model every turn even if most are unused. This plugin hides unused tool schemas by default, and only loads the schemas for tools that are actually needed for the current task. To install the plugin, you run the dsh plugin --profile web add @yilinxiao/dsh-mcp-lazy command, then restart DSH. The plugin automatically detects already installed compatible MCPs, so no extra manual configuration is required.

When you start a new session after installation, only a single routing tool mcp__router__search_and_activate is visible to the model, all compatible MCP tools are hidden by default. When your task requires a tool from a specific MCP, the routing tool automatically locates the correct MCP, loads only that MCP’s tool schemas into the current session, and lets the model call the required tool. After the current turn completes, the loaded tool schemas are hidden again, and the state of loaded tools is isolated between different sessions. Any MCP that fails the compatibility check is left unchanged and remains visible, so you never lose access to tools due to this plugin.

dsh-mcp-lazy is released under the open-source MIT license, and it has been tested to work with DSH versions 0.1.0-rc.6, 0.1.0-rc.7, and 0.1.0-rc.8. Independent testing shows it can reduce the number of tokens used for tool descriptions by between 88% and 95%, depending on the number and size of installed MCPs. It supports two modes: automatic takeover of compatible MCPs and explicit configuration of on-demand connection for specific MCPs. If you want to disable automatic takeover, you just add a disabled flag to the plugin’s manager entry in your DSH configuration, no uninstall required. It does not support task-based MCP tools that require explicit execution support, and idle connections are only kept warm in the running DSH process.

这是一个专门为 DeepSeek Harness(DSH)开发的原生插件,核心功能是通过按需披露 MCP 工具 schema 减少对话过程中的 Token 消耗。当用户安装了大量 MCP 工具时,该插件会默认隐藏暂时不用的工具说明,只在任务需要时加载对应工具,安装方式为执行 dsh plugin 命令,安装后重启 DSH 即可生效,插件会自动发现已安装的兼容 MCP,无需额外配置。

使用时无需额外手动操作,新会话启动后,仅保留一个路由工具,兼容 MCP 的工具默认全部隐藏。当任务需要调用某款 MCP 工具时,路由工具会自动找到对应 MCP 并仅加载该 MCP 的工具说明供模型使用,当前轮结束后工具会再次隐藏,不同会话之间工具加载状态相互隔离,不兼容的 MCP 会保持原样,不会影响正常使用。

本插件采用 MIT 许可证开源,兼容 DSH 0.1.0 rc6 到 rc8 版本,测试显示对常用 MCP 可减少 88% 到 95% 的工具说明 Token 消耗。它支持自动接管兼容 MCP 和显式配置懒连接两种模式,可通过禁用配置条目关闭自动接管,不支持需要任务支持的工具型 MCP,连接保温仅存在于当前 DSH 进程。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add @yilinxiao/dsh-mcp-lazy

把 leaforbook/dsh-mcp-lazy 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

DSH MCP Lazy(@yilinxiao/dsh-mcp-lazy)

这是一个给 DeepSeek Harness(DSH) 使用的插件。

一句话说明它的用途:MCP 装得越多,模型每轮都要读取的工具说明就越多;这个插件会先把暂时用不到的工具说明藏起来,需要时再加载,从而减少 Token 消耗。

当前版本:0.5.1

它解决了什么问题

假设你在 DSH 里装了文件、浏览器、数据库等多个 MCP。即使当前问题只需要文件工具,所有 MCP 的工具名称、说明和参数也可能一起进入模型上下文,白白占用 Token。

安装本插件后:

  1. 新会话开始时,兼容 MCP 的大量工具不会全部出现。在这些被接管的 MCP 工具中,模型只会看到一个路由工具:mcp__router__search_and_activate。
  2. 当任务需要某个 MCP 时,路由工具会找到它,并只向当前会话显示这个 MCP 的工具。
  3. 当前轮结束后,这些工具会再次隐藏,下一轮不用重复携带。
  4. 其他会话不会继承本会话已经加载的工具。

这个过程叫做 Schema 按需披露。这里的 Schema 可以简单理解为“模型调用工具前必须阅读的工具说明书”。

普通 DSH 工具不会被隐藏。不符合要求、无法安全接管的 MCP 也会保持原样,因此不会为了节省 Token 影响工具使用。

安装

dsh plugin --profile web add @yilinxiao/dsh-mcp-lazy

安装后重启 DSH 即可。插件会自动发现已经安装的兼容 MCP,不需要逐个填写 MCP 地址、请求头或密钥。

源码和版本记录在 GitHub。

装完以后怎么用

正常向模型提问即可,不需要手动操作插件。

例如你可以说:

帮我找出项目里所有超过 10 MB 的 PDF 文件。

模型会先通过共享路由找到文件 MCP,再调用它的原生工具。插件只负责决定“什么时候让模型看到哪些工具”,真正的工具调用仍由原 MCP 完成。

安装包会自动加入下面这条 manager 配置:

- insert:
    - id: mcp-lazy-manager
      name: '@yilinxiao/dsh-mcp-lazy'
      config:
        mode: manager

通常不需要手动修改它。

能节省多少 Token

节省量取决于你装了多少 MCP,以及它们的工具说明有多长。MCP 越多、工具越复杂,效果通常越明显。

0.4.0 的显式懒加载模式曾对三个常见 MCP 的工具说明做过统一测量:

MCP 原来常驻的工具 使用插件后的冷态工具 工具说明 Token 减少
Chrome DevTools MCP 1.7.0 29 个 2 个控制工具 4,585 → 200,减少 95.6%
Playwright MCP 0.0.79 24 个 2 个控制工具 3,452 → 195,减少 94.4%
Filesystem MCP 2026.7.10 14 个 2 个控制工具 1,694 → 190,减少 88.8%
合计 67 个 6 个控制工具 9,727 → 581,减少 94.0%

0.5.0 的自动接管测试中,冷态工具说明从 404 Token 降到 63 Token,减少了 84.4%。测试里的工具说明较短,大型 MCP 通常能省下更多绝对 Token。

这里的百分比只表示“工具说明”缩小了多少,不代表整次请求或账单一定下降同样的比例。聊天记录、系统提示和用户输入仍会占用 Token。

查看完整的 Token 计算示例

以上面三个 MCP 为例,工具说明每轮少了约 9,146 Token。如果请求中还有其他上下文,整次输入大约会变成:

其他上下文 原总输入 使用插件后 约减少 整次输入降幅
0 Token 9,727 581 9,146 94.0%
10,000 Token 19,727 10,581 9,146 46.4%
50,000 Token 59,727 50,581 9,146 15.3%
100,000 Token 109,727 100,581 9,146 8.3%

这些数据使用 cl100k_base 对相同格式的工具说明进行比较,只适合观察前后差异,不等同于 DeepSeek 的精确计费 Token。要核算实际收益,请比较同类请求的 prompt_tokens 和缓存命中数据。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-session-actions 下一个 Next dsh-weixin →