Introduction

The philosophy of DSH is “everything is a plugin”. Developers often install multiple MCPs (Model Context Protocol) such as file, browser, and database tools. This comes with a concrete cost: even if the current problem only requires file tools, all MCP tool names, descriptions, and parameters may enter the model context window simultaneously. The more MCPs installed, the more tokens are occupied per round.

Below is an introduction to leaforbook/dsh-mcp-lazy, a DSH plugin that hides tool descriptions that are not temporarily needed and loads them only when the task requires them.

What is this

dsh-mcp-lazy (npm package name @yilinxiao/dsh-mcp-lazy) is a DSH (DeepSeek Harness) plugin for MCP lazy loading, dynamic loading tools, and the Tool Router, maintained by leaforbook. The current version is 0.5.1, licensed under MIT, and requires Node >= 20.

A one-sentence positioning: On-demand disclosure of compatible MCP tool schemas to reduce context inflation and token waste; when incompatible, it maintains a pass-through connection while explicitly lazy loading to keep connections warm.

Core Features

On-Demand Disclosure of Schemas

After the plugin intercepts compatible MCPs, it only exposes a shared routing tool mcp__router__search_and_activate to the model in a cold state. When a task requires a specific MCP, the routing tool locates it, and only then does it display the tools corresponding to that MCP.

Session-Level Hiding

Each session has an independent list of hidden tools. After the current round ends, loaded tools are hidden again; other sessions will not inherit tools loaded in the current session.

Auto-Takeover and Fail-Open

The plugin only intercepts MCPs with clear names, no conflicts, and the ability to be safely hidden and re-displayed. When encountering naming anomalies, duplicate tool names, incomplete directories, or insufficient DSH capabilities, it actively refuses to intercept, leaving tools visible as normal. This approach is known as fail-open: it prioritizes tool availability over saving fewer tokens.

Connection Layer Lazy Loading and Connection Warmth

Explicitly configured servers support two transports, stdio and streamable-http, only establishing MCP connections when needed. After the current round ends, the plugin first hides tool descriptions, and connections are retained according to warmIdleMs (default 5 minutes), allowing direct reuse for short-term re-use.

Directory Pagination and Limited Reconnection

Tool directory reading supports pagination (maxToolListPages), and there are limited automatic reconnections after unexpected disconnections (reconnectAttempts).

Installation and Activation

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

After installation, restart DSH. The plugin will automatically discover installed compatible MCPs; there is no need to fill in MCP addresses, headers, or API keys one by one.

The installation package automatically writes the manager configuration:

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

Usually, there is no need to manually modify this configuration.

Tested DSH versions are 0.1.0-rc.6, 0.1.0-rc.7, and 0.1.0-rc.8. The plugin determines whether it can be enabled based on whether DSH provides the required capabilities, rather than just checking the version number.

Typical Usage

After installation, simply ask the model normally, for example:

Help me find all PDF files larger than 10 MB in the project.

The model will first locate the file MCP through the shared router and then call its native tools. The plugin only decides “when to let the model see which tools”; the actual invocation is still completed by the original MCP.

Verify if it works by following these steps:

  1. Install and restart DSH, and create a new session.
  2. Check the cold state tool list: intercepted MCP tools should be hidden, leaving only mcp__router__search_and_activate, while normal DSH tools should still be visible.
  3. Propose a task that requires a specific MCP. After routing completes, the model should only see the tools of that MCP and be able to call them normally.
  4. Create another session; MCP tools loaded in the previous session should not appear.

After the above steps, if an MCP remains visible, it usually means it did not pass the compatibility check and is kept in its original working method, which does not mean the plugin has failed.

Explicitly Configuring Connection Layer Lazy Loading

Auto-takeover only reduces the visibility of tool descriptions on the model side and does not close third-party MCP processes. If you want a certain MCP not to connect normally and only start when needed, you can explicitly configure it as a lazy server in the cordis.patch.yml file in the config directory:

- insert:
    - id: mcp-lazy
      name: '@yilinxiao/dsh-mcp-lazy'
      config:
        transport: stdio
        serverName: filesystem
        command: npx
        args: [-y, '@modelcontextprotocol/server-filesystem', '/tmp']
        connectTimeoutMs: 30000
        discoveryTimeoutMs: 60000
        maxToolListPages: 100
        reconnectAttempts: 1
        autoActivate: false
        releaseOnTurnEnd: true
        warmIdleMs: 300000
        routingHints: [文件, 目录]

    - id: mcp-lazy
      name: '@yilinxiao/dsh-mcp-lazy'
      config:
        transport: streamable-http
        serverName: remote-api
        url: http://127.0.0.1:8000/mcp
        headers: {}
        warmIdleMs: 300000
        routingHints: [远程接口, API]

The stdio mode uses fields like command and args to describe the startup command; the streamable-http mode uses url and headers to point to the service address. Key fields include:

  • warmIdleMs: How long the connection is retained after tools are hidden (default 5 minutes). Setting to 0 disconnects immediately.
  • autoActivate: Default false. When enabled, DSH connects immediately on startup instead of on-demand.
  • releaseOnTurnEnd: Default true. Hides loaded tool descriptions after the current round ends.
  • routingHints: Keywords to help the router identify the MCP, such as business name, capability, or common name.
  • maxToolListPages and reconnectAttempts: Upper limit of directory pagination and number of automatic reconnections.

Disabling Auto-Takeover

To restore the original display behavior for all MCPs, simply disable the manager entry. Add the following to $DSH_HOME/profiles/web/cordis.patch.yml:

- id: mcp-lazy-manager
  disabled: true

Please keep this override configuration; deleting it will re-enable the manager. It only disables auto-takeover, and explicit lazy server configurations are not affected. You do not need to uninstall the npm package or modify the addresses, headers, or API keys of other MCPs.

Suitable Scenarios and Notes

Suitable for two scenarios:

  1. You have installed many MCPs and want to reduce tool descriptions entering the model context per round.
  2. You want certain MCPs not to connect normally and only start when needed, while maintaining short-term connection warmth.

Pay attention to the following before use:

  • The plugin runs with the permissions of the current dsh process; check the source code and license (MIT) before installing.
  • Auto-takeover only reduces tool descriptions on the model side and is not responsible for stopping, restarting, or proxying third-party MCP processes.
  • Tasks with tool.execution.taskSupport === 'required' are not supported; an error is returned directly when called.
  • The number of auto-reconnections is limited; after exceeding, activate needs to be called again.
  • Warm connections only exist in the current DSH process and are not written to disk; after restart, the tool directory needs to be re-read.
  • Token data is an approximation of tool description size (using cl100k_base) and cannot be directly converted to billing amounts; to calculate actual benefits, compare prompt_tokens and cache hits of similar requests.
  • Normal DSH tools will not be hidden; if conditions are not met, the plugin actively fails open and keeps things as is.
  • For third-party MCPs, the plugin only displays the original MCP registered tool definitions and does not replace the executor; permissions, auditing, retries, and process lifecycle are still handled by the original plugin.

Summary

dsh-mcp-lazy solves a specific problem: the persistent occupation of tool descriptions in the model context after installing many MCPs. Its trade-offs are also clear—on-demand disclosure for those that can be safely intercepted, pass-through for those that are uncertain. If you maintain multiple MCPs on DSH, you can give it a try.

Project address: https://github.com/leaforbook/dsh-mcp-lazy

Community directory page (independent site, no official affiliation with DeepSeek / Huanfang): https://www.skillhub.cn/plugins/leaforbook/dsh-mcp-lazy