Skip to main content
Glama

dsh-deepseek-mcp (v2.5.0)

Brain (Antigravity / Frontier LLM) × Hands (Persistent DeepSeek Worker Pool)
A production-grade Stdio MCP Server that turns DeepSeek Harness (dsh --profile sdk) into a warm, stateful, parallelizable worker pool for Google Antigravity, Claude Code, Cursor, and any MCP-compatible host.

Version MCP SDK Backend License: MIT


✨ Why dsh-deepseek-mcp?

Frontier orchestrator models (like Gemini / Claude inside Google Antigravity) excel at system architecture, cross-module reasoning, and final integration—but burning their context window and quota on leaf tasks, boilerplate generation, or 40-step tool loops is slow and expensive.

dsh-deepseek-mcp implements the Brain × Worker Shunt Architecture without any reverse-proxying or ToS hacks:

  1. 🔥 Persistent Warm Session Pool (sessionKey + 98%+ KV Cache Hit)
    Backed by DSH's official dsh --profile sdk JSON-RPC runtime. Subtasks sharing the same sessionKey reuse the exact same warm DeepSeek agent process and memory—achieving >98% KV Cache hit rates (¥0.02 / 1M tokens off-peak!). Unrelated tasks use a new key (or omit it) for zero context contamination.

  2. ⚡ True Server-Side Parallel Fan-Out (delegate_parallel)
    Dispatch up to 16 independent leaf tasks in a single MCP tool call. Distinct sessionKeys execute concurrently across multiple dsh --profile sdk workers; identical sessionKeys automatically serialize through an initPromise + turn mutex lock to share memory safely.

  3. ⏱️ Three-Tier Wall-Clock Anti-Runaway Timer (15m / 25m / 30m)
    Tames runaway agent loops with a three-stage ladder:

    • Warn (warnMs, default 15 min): Injects a live steering nudge via JSON-RPC to start converging.

    • Force Wrap-Up (forceMs, default 25 min): Commands the worker to stop all new tool calls immediately and output its final summary.

    • Hard Timeout (timeoutMs, default 30 min): Terminates the worker and its entire Windows/POSIX subprocess tree (taskkill /T /F), returning timedOut: true.

  4. 🚀 pureText Fast Generation Mode & Configurable reasoningEffort
    Set pureText: true for pure code/SVG/text generation tasks to forbid the worker from running unnecessary local shell/browser self-verification loops—cutting latency from 10+ minutes to ~30 seconds. Supports per-call reasoningEffort (low | high | max).

  5. 💰 Real-Time Token & Cost Accounting (usage / batchUsage)
    Intercepts live assistant/message token meter events from the DSH SDK stream and returns exact uncachedInputTokens, cacheReadTokens, outputTokens, automatic Beijing Peak/Off-Peak detection (isOffPeak), and real-time RMB cost (estimatedCostCNY).


Related MCP server: Multi-Model Broker

🏗️ Architecture

User Request
  │
  ▼
Google Antigravity / Orchestrator LLM ("The Brain")
  ├─ Global Rule (`delegate-to-dsh.md`): Triage complexity
  │    ├─ Simple / Leaf Task ──────► `delegate_task(tier: "flash")`
  │    └─ Complex Architecture ────► Brain designs contract & decomposes
  │                                  ├─► `delegate_parallel(tasks: [...], maxConcurrency: 4)`
  │                                  └─► Brain integrates, verifies & delivers
  ▼
MCP Server: `dsh-deepseek-mcp` (Stdio JSON-RPC)
  ├─ Race-free LRU Session Pool (`POOL_MAX=4`, `POOL_TTL=30m`, `MAX_TURNS=40`)
  ├─ Windows Path Normalization (`D:\agy` === `d:/agy`)
  ├─ 3-Tier Timer Ladder (`warnMs` -> `forceMs` -> `timeoutMs` + Process Tree Kill)
  └─ Real-Time Stream Token & RMB Cost Meter
  ▼
Persistent `dsh --profile sdk` Worker Processes
  ├─ `flash` tier: `auto/deepseek-v4.1-flash`
  └─ `max` tier:   `trae-cn/deepseek-v4.1-flash-max` (1M Context)

🛠️ Exposed MCP Tools

Tool Name

Description

delegate_task

Delegate a single task to a DeepSeek worker. Supports task, cwd, context, sessionKey, tier (flash|max), pureText (boolean), reasoningEffort (low|high|max), fresh, warnMs, forceMs, timeoutMs. Returns full answer, toolCalls, elapsedMs, usage, and sessionUsage.

delegate_parallel

Fan out an array of tasks concurrently on the server (maxConcurrency default 4, max 16). Returns ordered per-task results (answer untruncated) plus aggregated batchUsage token & RMB cost summary.

pool_status

Inspect active warm sessions in the pool (key, sessionId, turns, busy, idleMs, and cumulative sessionUsage).

worker_info

Inspect server version (2.5.0), tier model mappings, timer defaults, and pool status.

reset_session

Evict and kill the process tree for a specific sessionKey (or clear the entire pool if omitted).

echo

Quick connectivity health check.


🚀 Quick Start

1. Prerequisites

  • Node.js >= 18

  • DeepSeek Harness (@deepseek-ai/dsh) installed with an sdk profile configured (~/.dsh/profiles/sdk).

2. Install Dependencies

git clone https://github.com/773Archer/dsh-deepseek-mcp.git
cd dsh-deepseek-mcp
npm install

3. Register in Google Antigravity (mcp_config.json)

Add dsh-deepseek to ~/.gemini/config/mcp_config.json (or ~/.gemini/antigravity/mcp_config.json):

{
  "mcpServers": {
    "dsh-deepseek": {
      "command": "node",
      "args": ["D:/path/to/dsh-deepseek-mcp/server.mjs"],
      "env": {
        "POOL_MAX": "4",
        "PARALLEL_MAX": "4",
        "DEFAULT_WORKSPACE_CWD": "d:/agy"
      }
    }
  }
}

Copy delegate-to-dsh.md to ~/.gemini/config/rules/delegate-to-dsh.md so Antigravity automatically triages tasks, reuses sessionKeys within the same workflow, and fans out leaf tasks via delegate_parallel.


🧪 Real-World Benchmark: 245 KB Single-File SVG Animation

In a live benchmark orchestrating a 245 KB multi-country picture-in-picture SVG animation ("Pelican cycling around the world inside hanging Polaroid photos with dynamic camera tracking"):

  • 4 specialized DeepSeek workers ran in parallel (svg-pelican-hero, svg-photo-1-2, svg-photo-3-4, svg-frames-studio).

  • Total Token Throughput: 6,413,000 Tokens (100,537 uncached input + 5,869,824 KV cache read + 442,639 output & reasoning tokens).

  • KV Cache Hit Rate: 98.32%

  • Total Official API Cost (Off-Peak): ¥1.99 CNY (~$0.27 USD)!


✅ Built-In Verification Suite

Run the included self-tests and E2E suites to verify your local DSH SDK runtime:

# 1. Warm session memory reuse & token meter self-test
npm run selftest

# 2. Hard wall-clock timeout self-test (scaled to 1.2s)
npm run test:timeout

# 3. 3-tier timer ladder self-test (3s warn -> 6s force -> 25s cap)
npm run test:ladder

# 4. Full MCP stdio E2E suites
npm run test:e2e
npm run test:reuse
npm run test:parallel

⚙️ Environment Variables

Variable

Default

Description

DSH_NODE

process.execPath

Path to Node.js binary used to spawn dsh

DSH_BIN

~/nodejs/node_modules/@deepseek-ai/dsh/lib/bin.js

Path to @deepseek-ai/dsh/lib/bin.js

DSH_WORKER_PROFILE

sdk

DSH profile name

DEFAULT_WORKSPACE_CWD

d:\agy or process.cwd()

Safe fallback workspace when cwd is omitted

PARALLEL_MAX

4

Default concurrency for delegate_parallel (1–16)

POOL_MAX

max(4, PARALLEL_MAX)

Maximum warm sessions retained in the LRU pool

POOL_TTL_MS

1800000 (30 min)

Idle session TTL before automatic eviction

MAX_TURNS

40

Maximum turns per session before automatic recycle

DELEGATE_WARN_MS

900000 (15 min)

Tier-1 gentle convergence reminder threshold

DELEGATE_FORCE_MS

1500000 (25 min)

Tier-2 forced wrap-up threshold

DELEGATE_TIMEOUT_MS

1800000 (30 min)

Tier-3 hard kill timeout threshold


📄 License

MIT

Available Tools

6 tools
delegate_parallelA

一次把"一个任务拆出的多条子任务"并发外包给 DeepSeek worker(服务端并发 + 并发上限,统一返回全文及汇总 Token 账单)。每条可单独配 sessionKey/tier/cwd/pureText/reasoningEffort/超时;共享同一 sessionKey 的条目会自动排队串行并共享上下文,不同 key 才是真并行。

Inputs: tasks (required), maxConcurrency.

delegate_taskA

把可独立完成的子任务交给 DeepSeek worker(同步返回,附带实时 Token 消耗与人民币费用估算)。同轮任务/同批子任务传相同 sessionKey 复用会话;无关新任务换新 key 或省略(每次全新、不污染)。纯文本/代码生成任务可传 pureText:true 禁用工具调用以大幅提速省 Token。

Inputs: task (required), cwd, tier, fresh, +7 more.

echoA

连通性自检:回显输入文本。

Inputs: text (required).

pool_statusA

查看会话池(哪些 key 常驻、多少轮、空闲多久、累计消耗多少 Token 与费用)。

Inputs: no named parameters.

reset_sessionA

丢弃会话池会话并清理进程树。传 sessionKey 只清该 key;不传清全部。

Inputs: sessionKey.

worker_infoA

返回 worker 配置、难度档、三级计时与会话池状态(排障用)。

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 6 tools

    Disambiguation3/5

    delegate_task vs delegate_parallel, reset_session, and echo are clearly distinct, but worker_info and pool_status overlap since worker_info also claims to return 会话池状态. The descriptions hint at a troubleshooting vs detailed-view split, yet an agent could easily pick the wrong one when it just wants pool state.

    Naming Consistency3/5

    Names mix three styles: verb_noun (reset_session, delegate_task, delegate_parallel), noun_status/info (worker_info, pool_status), and a bare verb (echo). All are readable and snake_case, but there is no single predictable pattern for an agent to extrapolate from.

    Tool Count5/5

    Six tools is well-scoped for a delegation server: two task-execution tools, two status/introspection tools, a reset, and a health check. Each tool has a distinct role and none feels padded or missing.

    Completeness4/5

    The delegation lifecycle (single task, parallel batch, session reuse, pool inspection, reset, connectivity check) is covered, with cost/token reporting folded into returns. The main gap is no explicit cancel/abort for an in-flight delegation, forcing reliance on timeouts.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Lets any MCP-capable coding harness (Cursor, Claude Code, Codex, Gemini CLI, VS Code/Copilot, opencode, and others) hand a self-contained task to a real, isolated DeepSeek Harness process that works in a chosen workspace with its own context window, model, and toolchain, then returns the final answer. Exposes task submission with time estimates and acceptance criteria, status polling with live progress and process-tree telemetry, graceful cancel and forced kill of whole process trees, and a health probe reporting concurrency, deadlines, and recent jobs.
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Codex to hand off coding tasks to a locally running DeepSeek Harness Desktop Host over MCP, reusing the Host's configured model and runtime and returning a session ID for status checks, incremental event streaming, waiting, and cancellation.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP clients to hand tasks to DeepSeek Harness as an execution subagent, creating sessions, submitting work, waiting for results, and retrieving outputs.
      7
      MIT