dsh-headless-mcp
README.md
# dsh-headless-mcp
**Give any agent a DeepSeek executor.**
English | [中文](README.zh.md)
A small MCP server that delegates coding tasks to **DeepSeek Harness (DSH)** headless sessions.
No DSH desktop, no web host, no plugin install - just Node and a DeepSeek API key.
The DSH runtime is resolved automatically: a local `dsh` CLI if present, otherwise
the pinned `@deepseek-ai/dsh` npm package through `npm exec`.
[](https://github.com/Stormlittleliu/dsh-headless-mcp/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/dsh-headless-mcp)
[](LICENSE)
[](package.json)
> Community project, not an official DeepSeek Harness product. It uses DSH's public
> headless profile; the agent, tools, skills, and permissions are DSH's, not reimplemented here.
> Runtime strategy (self-build / prebuilt / embedded fallback):
> [RUNTIME-STRATEGY.md](RUNTIME-STRATEGY.md). Staged execution plan:
> [EXECUTION-PLAN.md](EXECUTION-PLAN.md).
## Why this exists
DSH already has excellent MCP bridges such as
[`dsh-as-mcp`](https://github.com/xiseliuli/dsh-as-mcp),
[`harness-relay-mcp`](https://github.com/tonytanglab/deepseek-harness-relay-mcp), and
[`deepseek-harness-for-codex`](https://github.com/Seann0824/deepseek-harness-for-codex).
They run a DSH **host** and surface **visible sessions** in the UI.
That is the right tool when a human is watching.
`dsh-headless-mcp` is for the other case: a planner or agent needs a DeepSeek
executor in CI, on a server, in a container, or in any environment where no DSH
desktop/web host is running.
- **Headless** - spawns `dsh --profile headless` per call, persisted session optional.
- **Small** - one npm package, two runtime dependencies, no build step.
- **Planner/executor contract** - plan JSON schema, scout context pack, independent acceptance.
- **Observable** - local usage ledger records which agents use DSH, how, and what it cost.
- **Auditable** - transcripts of reasoning, tool calls, and results are readable.
- **Proxy-aware** - DSH's own proxy policy applies when proxy variables reach it.
## Quick start
```bash
npx -y dsh-headless-mcp
```
That starts the MCP server on stdio. Point any MCP client at it:
The first executor call may download the pinned DSH runtime once (npm cache); later
calls reuse it. Run `npx -y --package=dsh-headless-mcp dsh-headless runtime status`
to see which backend is selected.
### Codex
```toml
# ~/.codex/config.toml
[mcp_servers.dsh_headless]
command = "npx"
args = ["-y", "dsh-headless-mcp"]
tool_timeout_sec = 3600
startup_timeout_sec = 30
default_tools_approval_mode = "approve"
```
Then restart Codex (MCP servers are read at process start) and ask it to
"delegate implementation to DeepSeek via dsh-headless-mcp".
### Claude Code
```json
{
"mcpServers": {
"dsh-headless": {
"command": "npx",
"args": ["-y", "dsh-headless-mcp"]
}
}
}
```
### Cursor
```json
{
"mcpServers": {
"dsh-headless": {
"command": "npx",
"args": ["-y", "dsh-headless-mcp"]
}
}
}
```
More examples: [examples/](examples/). The `skills/plan-exec/SKILL.md` file contains
a planner/executor skill for Codex and Claude-style skill systems.
## One core, many plugin ecosystems
The same MCP server ships a generated face for each plugin system, so an agent
browsing Codex, Claude Code, Cursor, or the portable Agent Plugins format can find
and install it without knowing the npm name.
| Ecosystem | Install |
|---|---|
| Codex plugin | `codex plugin marketplace add Stormlittleliu/dsh-headless-mcp`<br>`codex plugin add dsh-headless-mcp@dsh-headless` |
| Claude Code plugin | `claude plugin marketplace add Stormlittleliu/dsh-headless-mcp`<br>`claude plugin install dsh-headless-mcp@dsh-headless` |
| Cursor | submit the repo at <https://cursor.com/marketplace/publish>, or load `integrations/cursor` locally |
| Portable Agent Plugins | point a compatible client at `integrations/agent-plugins` |
| Any MCP client | use the `mcpServers` config above |
| DSH ecosystem | no plugin needed; use the `dsh-headless` CLI / MCP config |
Marketplace catalogs live at the repository root (`.agents/plugins/`,
`.claude-plugin/`, `.cursor-plugin/`). The faces are generated from one metadata
source:
```bash
npm run integrations:build
npm run integrations:check
```
See [integrations/README.md](integrations/README.md) for the layout and how to add
another ecosystem.
## Tools
| Tool | What it does |
|---|---|
| `dsh_execute` | Run one self-contained task; optional `session_id` to continue. |
| `dsh_run_plan` | Validate a plan, execute it, optionally run its acceptance command. |
| `dsh_scout` | Read-only reconnaissance; returns a bounded `CONTEXT.md` context pack. |
| `dsh_sessions` | List persisted headless DSH sessions. |
| `dsh_transcript` | Render a session or run directory as readable markdown. |
| `dsh_usage` | Query the local usage ledger (by agent, tool, day). |
| `dsh_runtime` | Report the DSH backend or bootstrap the pinned runtime. |
| `dsh_doctor` | Check `dsh`, credentials, permissions, proxy, ledger. |
Tool descriptions include the phrases a planner searches for: *delegate implementation
to DeepSeek*, *planner needs an executor*, *headless DSH*.
## Plan -> execute -> verify
`dsh_run_plan` takes the same JSON shape a planner produces:
```json
{
"goal": "Add pagination to the list endpoint without changing the response shape.",
"steps": [
{ "id": 1, "title": "Update handler", "action": "Read src/list.ts and add offset/limit parsing...", "files": ["src/list.ts"] },
{ "id": 2, "title": "Add tests", "action": "Cover default, limit-only, offset-only, and out-of-range cases.", "files": ["test/list.test.ts"] }
],
"acceptance": ["npm test -- list"],
"risks": ["Existing callers may rely on the full response body."]
}
```
The executor treats the plan as authoritative, reports deviations, and the server
independently runs `acceptance` (pass `verify` explicitly) so a self-report is never
the only evidence.
## Usage ledger
Every executor/scout call appends one line to `~/.dsh-headless/ledger.jsonl`:
```json
{
"schema": "dsh-headless-mcp/ledger/v1",
"ts": "2026-11-29T...Z",
"agent": { "name": "Codex", "version": "0.167.0" },
"tool": "dsh_run_plan",
"cwd": "E:\\repo",
"permission": "workspace-write",
"taskHash": "sha256:...",
"taskChars": 4200,
"sessionId": "session-...",
"outcome": "ok",
"wallSeconds": 99,
"usage": { "inputTokens": 0, "outputTokens": 0 },
"verify": { "ok": true, "exitCode": 0 },
"runDir": "~/.dsh-headless/runs/..."
}
```
Ask an agent to call `dsh_usage` to answer "which agents use this DSH instance,
what do they run, what is the success rate, and where do tokens go?". The CLI has
the same view:
```bash
npx -y --package=dsh-headless-mcp dsh-headless usage summary
npx -y --package=dsh-headless-mcp dsh-headless usage events --limit 20
```
Privacy defaults:
- Task text is **not** stored; only a SHA-256 hash and length.
- Set `DSH_HEADLESS_LOG_TASKS=1` to store a 500-character redacted preview.
- The ledger is local-only. No telemetry is sent.
- Credentials are never written.
The ledger format is documented in [docs/ledger.md](docs/ledger.md) and published as
an open JSON Schema so other DSH tools can emit compatible events.
## Requirements
- Node.js **>= 22.19** for the bridge. The automatic npm bootstrap needs
**>= 24.9** because that is the engine range of `@deepseek-ai/dsh`; with an older
Node, point `DSH_CLI` at a locally installed DSH instead.
- No manual DSH install is required: local `dsh` is used when present, otherwise the
pinned npm runtime is fetched on first use. Set `DSH_CLI` to override.
- `DEEPSEEK_API_KEY`, or `refs.DEEPSEEK_API_KEY` in `~/.dsh/.credentials.yaml`.
The server resolves the backend in this order: `--dsh-cli` / `DSH_CLI` -> common
install paths -> `dsh` on `PATH` -> pinned npm bootstrap.
## Configuration
| Environment variable | Default | Meaning |
|---|---|---|
| `DSH_CLI` | auto | Path to `dsh`/`dsh.cmd` |
| `DSH_HOME` | `~/.dsh` | DSH home (credentials, sessions) |
| `DEEPSEEK_API_KEY` | from DSH credentials | DeepSeek API key |
| `DSH_HEADLESS_HOME` | `~/.dsh-headless` | Runs and ledger root |
| `DSH_HEADLESS_RUNS` | `$DSH_HEADLESS_HOME/runs` | Per-run logs |
| `DSH_HEADLESS_LEDGER` | `$DSH_HEADLESS_HOME/ledger.jsonl` | Usage ledger |
| `DSH_HEADLESS_LOG_TASKS` | unset | `1` stores redacted task previews |
| `DSH_HEADLESS_CLIENT` | auto | Fallback caller name outside MCP |
| `DSH_HEADLESS_BOOTSTRAP` | enabled | `0` disables the npm runtime bootstrap |
| `DSH_HEADLESS_FORCE_NPX` | unset | `1` ignores local `dsh` and forces the npm backend |
| `DSH_HEADLESS_RUNTIME_DIR` | `~/.dsh-headless/runtime` | Cache for prebuilt runtimes |
Proxy variables (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`) are honored by DSH when
they reach the child process. MCP clients often sanitize child environments; set
them explicitly in the server config if needed.
## Security
DSH runs with the permission preset you pass (`workspace-write` by default). The
executor is an autonomous agent inside that workspace: it can edit files and run
commands. Do not point it at a workspace you would not let an agent modify.
The server injects `DEEPSEEK_API_KEY` only into the child process, never logs it,
and binds no network port in v0.1 (stdio only). See [SECURITY.md](SECURITY.md).
## Compatibility
- DSH 0.2.x headless profile.
- Windows, macOS, Linux.
- MCP clients that support stdio servers (Codex, Claude Code, Cursor, custom).
- No DSH plugin API or private service is used; only the public `dsh` CLI.
## How it compares
| | dsh-headless-mcp | dsh-as-mcp | harness-relay-mcp | dsh-exec |
|---|---|---|---|---|
| Needs DSH host | **no** | yes | yes | desktop |
| MCP server | **yes** | yes | yes | no (CLI/HTTP) |
| Visible session in DSH UI | no | yes | yes | yes |
| Usage ledger across agents | **yes** | per-session | partial | no |
| Best for | CI, remote, headless agents | local visible work | control plane | terminal + sidebar |
## Development
```bash
npm install
npm test
npm run check
npm run pack:check
```
Tests use a mock `dsh` CLI, so they need no API key and no network.
## License
MIT. Not affiliated with DeepSeek. "DeepSeek Harness" and "DSH" refer to the
upstream project at <https://github.com/deepseek-ai/deepseek-harness>.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues