Introduction¶
DeepSeek Harness(DSH)supports integrating Model Context Protocol(MCP)servers through plugins. When using the default @deepseek-ai/dsh-mcp-client, configured servers connect when the plugin starts, and all tool definitions are registered as native tools. This means every request carries schema bytes for a large number of tools, and servers remain resident in memory regardless of whether the model actually calls them.
dsh-mcp-lazy is a gateway plugin designed for this purpose. It exposes only a single fixed proxy tool to the frontend, starts the corresponding server only when the model calls a specific tool, and disconnects it after it becomes idle. Server metadata is cached on disk, so metadata query operations do not require starting a process.
Core Features¶
- Single proxy tool: Replaces the original N tool definitions; only one tool with a constant schema exists in the frontend.
- Lazy loading and idle disconnection: Servers start only on first use and automatically disconnect after idling.
- Disk cache: Metadata is persisted to disk, so
searchanddescribeoperations do not trigger process startup. - Configuration migration tool: Provides the CLI tool
dsh-mcp-lazy-adoptto help migrate existing configurations to the new plugin. - Token savings measurement: Provides scripts to calculate and measure token savings.
Installation¶
Use the official installation command to add the plugin to the specified configuration profile:
dsh plugin --profile <your-profile> add dsh-mcp-lazy
After installation, the plugin registers its patch layer. The server list must be defined in the profile’s cordis.patch.yml.
Usage¶
The plugin is exposed as a tool named mcp-lazy in the DSH panel. The following are several invocation patterns:
- Search tools: Search for tool names in the cache.
mcp({ search: "screenshot" })
- Get description: Retrieve the full parameter schema for a specified tool.
mcp({ describe: "take_screenshot" })
- Call a tool: Actually perform the operation; the corresponding server starts only at this point.
mcp({ tool: "take_screenshot" })
- Cross-server invocation: When multiple servers have tools with the same name, specify the target server using the
serverparameter.
mcp({ tool: "echo", server: "docs" })
- Connect to a server: Connect and refresh the cache without executing a call.
mcp({ connect: "chrome" })
- View status: View the current connection status, cache count, and cache age.
mcp({})
Configuration Example¶
Add an mcp-lazy configuration section to cordis.patch.yml:
- id: mcp-lazy
config:
servers:
- serverName: chrome
transport: stdio
command: npx
args: ['-y', 'chrome-devtools-mcp@1.6.0']
lifecycle: lazy
- serverName: docs
transport: streamable-http
url: http://127.0.0.1:3000/mcp
Notes¶
- Token savings calculation: The gateway itself consumes a fixed 1525 bytes. The plugin yields net savings only when the rendered byte size of the server tool definitions exceeds that value. If the configured servers have few or small tools, the plugin may increase overhead. It is recommended to run the measurement script to verify before enabling it.
- Node version requirement: The plugin requires Node.js
>=22.18.0. - Configuration migration: The
adoptcommand does not run automatically when the plugin starts; it must be executed manually. It reads the currently mounted configuration, marks native tool entries asdisabled: true, and appends them to the current plugin’sserverslist. - Global impact: The
adoptcommand typically disables the native configuration entry, which is usually located in thehomepatch layer (~/.dsh/cordis.patch.yml). If other configuration profiles (such asdefault,dsh-tui, orheadless) also reference that configuration but do not mount this plugin, they will lose the corresponding tool capability. - Unsupported fields: The plugin does not support the native
reconnectandfailOnStartupErrorfields. When migrating configuration, it reports an error and preserves the original entry.
Summary¶
dsh-mcp-lazy introduces a gateway layer with a fixed overhead in exchange for the ability to load MCP servers dynamically, significantly reducing token consumption per request. For scenarios with a large number of MCP tools and a need to save context space, this is a practical optimization. Before using it, ensure the tool definitions are complex enough to offset the gateway’s fixed cost.