# dsh-agent-toolchain MCP server The same engineering-quality tools the DSH plugins expose — now available to **any MCP client** (Claude Code, Cursor, Cline, custom agents) over stdio. For Windows colleagues, use the release ZIP and double-click `setup.cmd`. It configures Claude Code, Claude Desktop and Codex, includes the runtime and native modules, and verifies a real MCP call. See [standalone installation](../docs/standalone-install.md). ## Responsiveness and diagnostics Requests carrying `_meta.progressToken` receive `notifications/progress` at dispatch, every two seconds while asynchronous work remains pending, and when the call finishes. Messages contain only the tool name, state and elapsed time; they are liveness notifications, not completion percentages. Clients without a progress token retain ordinary request/response behavior. Display depends on the MCP client. Synchronous work can delay timer notifications. `jev_decide` is an optional advisory decision tool. It sends the supplied `stateJson` and `questionsJson` to TypeSafe only when the call includes `allowRemoteData=true`; without that flag it returns immediately without a network request. Set `TYPESAFE_API_KEY` in the MCP process environment and pin `model` to `jev-1.13.0` when thresholds depend on model behavior. The tool never executes the selected action and does not replace UI approval, snapshot freshness, build verification, or evidence adjudication. Keep inputs small and 脱敏; Jev's primary language is English and its current model has known weak spots for arithmetic, dates, long irrelevant state, and adversarial content. Blocked actions, missing evidence packs and rejected writes return `isError:true` with JSON `{ok:false,errorCode,error}`. HTTP non-2xx responses remain successful transport observations; inspect their `status` separately. MCP request cancellation now aborts `http_request`, including response-body reading. Cancellation of an HTTP request does not prove that the remote server undid it. Other tools retain their existing per-operation timeouts and stop controls. `DSH_OUTPUT_MAX_TOKENS` remains opt-in. When positive, all text blocks share the estimated token budget, including a truncation notice. Truncated JSON is a valid envelope retaining machine fields such as `state`, `errorCode`, `runId` and `jobId`, with a bounded `previewText`; it is not the original complete payload. `structuredContent` is bounded independently by the same estimate, and duplicate JSON text is reduced to a reference. Tiny budgets disclose minimum metadata overhead. Images and resources remain outside this text budget; narrow large queries at their source whenever possible. `node mcp/probe.mjs --seq '[["memory_status",{}],["toolchain_status",{}]]'` executes calls in order in one session, shows progress on stderr, and stops with exit code 1 on a failed call. It does not print request arguments. Run `npm run bench:mcp -- --output bench-runs/mcp-benchmark.json` to measure startup/discovery, repeat-call latency, response size and first feedback using temporary stores and a loopback HTTP fixture. The benchmark disables environment fallback; its unconfigured UI timings are not live application timings. See [the evaluation](../docs/agent-toolchain-evaluation.md) for measurements and remaining limitations. ## Platform scope (honest) The MCP transport and the evidence spine are cross-platform, but the tool set is not: | Tools | Scope | | --- | --- | | `http_request`, `http_collection`, memory KV save/recall/forget | cross-platform (Node stdlib / HTTP only) | | `memory_index`, `memory_search`, `memory_status` | require the memory-store Node-API module built for the current platform/architecture; Windows x64 validated | | `capture_query` / `capture_append` (and the internal evidence/verify engine's API checks) | require the capture-store Node-API module built for the current platform/architecture; Windows x64 validated, Linux/macOS builds supported by the build script but not yet validated | | `capture_start` / `capture_status` / `capture_stop` / `capture_rules` / `capture_netsim` | standalone installation starts a shared loopback companion on demand; legacy DSH mode forwards to `127.0.0.1:3080`. Both reuse the same engines and routes | | `capture_intercept` | **Windows only** — edits the system hosts file and registers a SYSTEM scheduled task; works with either the standalone companion or DSH | | `build_run` | cross-platform with `engine=dotnet` (SDK-style repos); the default `engine=msbuild` is Windows/VS only | | `ui_status` / `ui_windows` / `ui_state` / `ui_drive` / `ui_flow` / `ui_replay` | **Windows only** — they drive a Windows desktop client via PowerShell + UIA | | `perf_probe` / `perf_report` | **Windows only** — window-message latency sampling of the same client | | `hang_status` / `hang_run` / `hang_stop` / `hang_packs` / `hang_pack` / `hang_analyze` / `hang_delete` | **Windows only** — hang-monitor control, evidence packs, ClrMD dump analysis | On macOS/Linux the UI-driving half is inert and `ui_status` reports `unconfigured`; the evidence spine and the dotnet build engine keep working. ## Why The toolchain's `lib/` modules are framework-free by design. This thin MCP server re-uses them directly (no duplication), so one set of battle-tested tools powers every agent, not just DeepSeek Harness. ## Tools `dev_docs_search` / `dev_docs_read`, `dev_vision_diff`, and `dev_plugin_check` add Context7 documentation, local PNG comparison, and non-executing plugin metadata checks. Full trial installation remains in the DSH precheck panel. The `dev_*` family bridges separately installed encoding, .NET skills, C# LSP and LogTimeline backends. Start with `dev_status`, then use `dev_csharp`, `dev_logs`, `dev_skills`, `dev_read` and `dev_edit`. See [development tools](../docs/development-tools.md) for configuration, bounded output, licensing and real MCP integration checks. Existing connections must reconnect before newly registered tools appear. | Tool | Backed by | Notes | | --- | --- | --- | | `build_run` | dsh-build/lib/builder.mjs | Incremental/Rebuild MSBuild with structured errors | | `ui_status` / `ui_drive` / `ui_flow` / `ui_replay` | dsh-ui-drive/lib/driver.mjs | Signed app identity, scoped approvals, desktop-state gates, action/observation records, identity-bound replay and opt-in visual fallback; guarded flows validate each action | | `perf_probe` / `perf_report` | dsh-perf/lib/perf.mjs | Window-message latency sampling: P50/P95/P99 + stall events | | `http_request` | dsh-postman/lib/http.mjs | Host-side HTTP (no CORS), non-2xx is a normal result; `{{variables}}` filled from the panel's active environment | | `http_collection` | dsh-postman/lib/collection-tool.mjs | Collections / environments / collection runner shared with the API-debug panel (`workspace.json`) | | `memory_index` / `memory_search` / `memory_save` / `memory_recall` / `memory_status` | dsh-memory/lib/memory.mjs | Vector search + cross-session KV | | `capture_query` / `capture_append` | lib/capture-store.mjs | Query/append the API-capture store — caller attribution (ViewModel→API→call-chain) + runId spine | | `capture_start` / `capture_status` / `capture_stop` | shared capture routes and engine | Live capture through standalone companion or DSH; `capture_status` also reads the local store for its double-write check | | `capture_rules` / `capture_intercept` / `capture_netsim` | dsh-api-visualizer/lib/intercept-control.mjs + shared routes | AutoResponder rules, interception and weak-network simulation through either backend | | `jev_decide` | lib/jev-client.mjs | Optional remote typed decisions; advisory only, explicit remote-data opt-in | ## Configure (Claude Code) ```bash claude mcp add --scope user dsh-agent-toolchain -- cmd /c node \mcp\server.mjs ``` Cursor / Cline: add a stdio MCP server entry with the same command. Installed as a plugin instead (see the root README), the server starts through `mcp/launch.mjs`: it installs the MCP SDK on first start when `node_modules` is missing (npm output goes to stderr — stdout is the protocol channel), then applies `~/.dsh-agent-toolchain/env.json` (`DSH_ENV_FILE` to move it, `none` to disable; a flat `{ "DSH_…": "…" }` object, string values only, `DSH_CRED_*` refused). The file **overrides** inherited variables of the same name — the same semantics as the `env` block of a `claude mcp add -e …` registration, which is what it replaces (user-level variables meant for another host would otherwise silently retarget the server). Precedence: that file > process env > user/machine environment variables; overridden key names are logged to stderr. A broken file is reported on stderr and ignored as a whole. ## Environment Same `DSH_*` variables as the plugins: | Variable | Used by | Required for | | --- | --- | --- | | `DSH_UI_PROC_NAME` / `DSH_UI_WINDOW_NAME` / `DSH_UI_CLIENT_EXE` | ui tools | driving your desktop client | | `DSH_UI_EVIDENCE_DIR` | ui tools | screenshot/evidence dir (default `~/.dsh-agent-toolchain/ui-evidence`) | | `DSH_BUILD_CLIENT_ROOT` / `DSH_BUILD_REPO_ROOT` | build_run | repo root (or pass `clientRoot`/`repoRoot` per call) | | `DSH_BUILD_PLATFORM` | build_run | override the auto-resolved platform (`x86` / `Any CPU` / …) | | `DSH_BUILD_MSBUILD` | build_run | explicit MSBuild path (auto-detect otherwise) | | `DSH_MEMORY_DIR` | memory tools | data dir (default `~/.dsh/memory`) | | `MINIMAX_CN_API_KEY` | memory_search | MiniMax embeddings (falls back to local bigram search) | | `DSH_FAILURE_CORPUS_DIR` | internal failure corpus | corpus dir (default `~/.dsh-agent-toolchain/failure-corpus`) | | `DSH_API_CAPTURE_STORE` | capture tools | capture store dir (default `~/.dsh/api-capture`, shared with the panel) | | `DSH_VERIFY_DIR` | internal verify engine | report dir (default `~/.dsh-agent-toolchain/verify-reports`) | | `DSH_FAILURE_DEDUPE_HOURS` | internal failure corpus | window in which a repeated auto-recorded failure is counted as a recurrence instead of a new record (default `24`, `0` = off) | | `DSH_ENV_FILE` | `mcp/launch.mjs`, plugin hooks | machine settings file (default `~/.dsh-agent-toolchain/env.json`) | | `DSH_CAPTURE_BACKEND` | capture controls | `standalone` uses the companion; unset preserves the original DSH host | | `DSH_CAPTURE_SERVICE_PORT` / `DSH_CAPTURE_SERVICE_DIR` | standalone companion | loopback port (default 3081), private token/log directory | | `DSH_STANDALONE` | readiness diagnostics | installer sets `1`; DSH profile deployment checks do not apply | | `TYPESAFE_API_KEY` | jev_decide | TypeSafe API key; used only when `allowRemoteData=true` | ## Run standalone Build memory indexing/search from the repository root with `npm run build:memory-store`. Keep `plugins/dsh-memory/bin/` with the checkout. KV-only operations remain implemented in JS. Build capture storage from the repository root before using capture tools or API verification: `npm run build:capture-store` (Rust plus the platform linker). The resulting module lives under `plugins/dsh-api-visualizer/bin/`; keep it with the checkout. Module loading is lazy, and missing binaries produce an explicit build instruction rather than an empty capture result. ```bash cd mcp && npm install && node server.mjs # waits for JSON-RPC on stdin ``` ## Pass the env explicitly (gotcha) The MCP SDK's `StdioClientTransport` inherits only a safe-list of variables (`PATH`, `HOME`, …) — **not** `DSH_*`. If you drive the server from your own Node script, pass `env: { ...process.env, DSH_UI_PROC_NAME: '…' }` to the transport; a client config (Claude Code `mcp-config.json`, Codex `*.config.toml`) declares the variables in its own `env` block, which is what the bench harness does. Symptom when you forget: `ui_status` reports `unconfigured`, `build_run` fails with `ENOENT: mkdir ''`. ## Safety model Same guardrails as the DSH plugins: side-effect UI actions are blocked unless `allowSideEffects=true` is passed explicitly, and the description of every side-effect tool tells the model to confirm with the human first.