Skip to main content
Glama
README.md
# DSH MCP for Codex

Let Codex hand tasks to the **DeepSeek Harness (DSH)** agent already installed on your machine, and read the answer back.

- **Zero dependencies** — the MCP server uses only Node built-ins
- **No install assumptions** — discovers DSH Desktop (including custom install dirs, via the Windows uninstall registry) or a `dsh` CLI on PATH
- **No re-implementation** — DSH keeps its own model route, tools, skills, and sandbox; Codex keeps its own conversation
- **Continuable** — replay the returned `session` through `dsh_continue`

```
Codex ──(MCP)── dsh-mcp ──(stdio)── dsh --profile headless ── DSH agent
```

[中文说明](README.zh.md)

## Install

```sh
# A. Codex plugin marketplace
codex plugin marketplace add lcs331/dsh-codex-bridge
codex plugin add dsh@dsh-codex-bridge

# B. from source
git clone https://github.com/lcs331/dsh-codex-bridge.git
codex mcp add dsh -- node /abs/path/dsh-codex-bridge/bin/dsh-mcp.mjs
```

The npm package is not published yet. After it is published, a one-line `npx` installation can be added here.

## Credentials (the usual snag)

The headless profile **disables DSH's credential store**, so a headless run never reads the keys saved by the Desktop UI. It looks them up in this order:

1. the launch environment
2. `<task cwd>/.env`
3. `$DSH_HOME/.env`

**Recommended: pass the key through the environment that launches Codex.** For example, set it in PowerShell and start Codex from that same shell:

```powershell
$env:DEEPSEEK_API_KEY = "sk-..."
codex
```

Setting the variable in another shell after Codex is already running will not update its environment. Do not copy secrets out of DSH Desktop credential files. The MCP server passes only runtime essentials, `DSH_HOME`, and the configured model credential variables to the DSH child process; it does not pass the full Codex environment.

**No key yet?** Create one at <https://platform.deepseek.com> (API Keys) and provide it through the launch environment, or point `OPENCODE_GO_API_KEY` at a third-party route and set `DSH_MCP_PATCH` to the overlay that registers that provider. The same overlay is applied to headless tasks and ACP session continuations.

DSH also reads `<task cwd>/.env` and `$DSH_HOME/.env`; those files store keys in plain text. Prefer the launch environment to avoid creating another plaintext copy.

**One-off, nothing on disk:** `$env:DEEPSEEK_API_KEY = "sk-..."` before launching Codex.

Run `dsh_doctor` first on a new machine; it reports the discovered installation and whether a credential is reachable.

## Tools

| Tool | Purpose |
|---|---|
| `dsh_list_workspaces` | List project folders registered in DSH and their workspace ids |
| `dsh_list_sessions` | List session ids and saved titles in one selected DSH workspace |
| `dsh_task` | One self-contained task, fresh DSH session, returns the final answer |
| `dsh_continue` | Continue a DSH session; for an open Desktop session it waits for the completion report |
| `dsh_get_result` | Read a pending or completed report from an open DSH Desktop session |
| `dsh_doctor` | Report the discovered installation and credential status |

Call `dsh_list_workspaces` to select a DSH project folder. Pass its `workspace_id` to `dsh_task`; the registered folder becomes the working directory. To continue, call `dsh_list_sessions` with that `workspace_id`, then pass both the same `workspace_id` and a listed `session_id` to `dsh_continue`. New tasks use DSH's headless profile. For an open Desktop conversation, the optional DSH-side companion in `desktop-host/` routes the message through the live Agent as a user message, so it appears in the existing DSH UI without competing for ACP's session write lock. Install it from **DSH Desktop → Settings → Plugins** by adding the local bundle directory `<path-to-this-repo>/desktop-host`, then restart DSH to load it. The Electron app exclusively manages the `desktop` profile, so the `dsh plugin --profile desktop add ...` CLI command is rejected. The bridge binds only to loopback and uses a random local bearer token stored under `$DSH_HOME/plugins/dsh-codex-bridge/`; the token is never returned by an MCP tool. In `auto` mode, `dsh_continue` uses only the Desktop companion and never falls back to ACP. If the companion or target session is unavailable, it stops without competing for a possible UI write lock. Set `transport: "acp"` explicitly only after closing the session in DSH Desktop, or use `transport: "desktop"` to require visible delivery. ACP keeps the saved permission and directory settings; permission requests are rejected because MCP has no interactive approval UI. Session listings include ids, saved titles, and archive state; they read only the title projection and do not return conversation contents. Existing direct `cwd` calls remain supported.

For an open Desktop session, `dsh_continue` waits for the matching DSH completion event and returns the assistant report in Codex. If the wait limit expires, use `dsh_get_result` with the returned `request_id`. Reports stay in the local DSH companion process for up to 30 minutes and are capped at 64 KiB. The bridge associates a report after it sees the exact submitted user message ID and content; when DSH omits the ID, it accepts an exact-content echo. Duplicate echoes of the same message are ignored. A distinct user message before completion still marks the result ambiguous instead of guessing.

`dsh_task` arguments: `task` (required), `workspace_id`, `cwd`, `permission_mode` (`read-only` | `workspace-write` | `danger-full-access` | `auto` | `plan`), `add_dirs`, `timeout_sec`, `session_id`.

DSH cannot see the Codex conversation, so every task must restate its goal, constraints, target directory, and the evidence you want back.

## Safety

- `permission_mode` defaults to `workspace-write`: edits stay inside `cwd`
- new headless tasks use approval policy `never` (headless has no approval UI; `ask` would block forever). ACP continuations preserve the saved DSH session permissions, but permission requests are rejected because MCP has no interactive approval UI.
- the Desktop companion can only route to a live DSH agent; the MCP result confirms acceptance, while DSH's generated reply appears in the DSH UI
- a timed-out run is killed and **already-written files are not rolled back**
- raw DSH stderr is omitted from tool results by default; set `DSH_MCP_DEBUG` to include truncated diagnostics on failure

## Compatibility

- Node ≥ 20 (tested on 24)
- Verified on Windows 11 + DSH Desktop 2.0.24-next (`@deepseek-ai/dsh` 0.2.2-rc.5) + Codex CLI 0.172.0
- macOS/Linux discovery is implemented but **untested**

## Development

```sh
node --test                      # run the test suite
node scripts/build-plugin.mjs    # regenerate both vendored plugin bundles before publishing
```

## License

MIT

TDQS

A4.1/5.0

Scored across 6 tools

Disambiguation4/5

Most tools have clearly distinct roles: listing workspaces, listing sessions, delegating, continuing, reading results, and diagnosing. The main overlap is dsh_task versus dsh_continue, since dsh_task can accept a session_id while dsh_continue is the dedicated continuation tool; descriptions clarify the intended split, but the boundary is not perfectly sharp.

Naming Consistency3/5

All names share the dsh_ prefix and snake_case, which aids recognition. However, the set is not consistently verb_noun: dsh_task and dsh_doctor are noun-like, while dsh_continue is verb-only, so the pattern is mixed but still readable.

Tool Count5/5

Six tools is well-scoped for a DSH integration. Each tool covers a distinct lifecycle step: workspace discovery, session discovery, delegation, continuation, result retrieval, and diagnostics.

Completeness4/5

Core delegation lifecycle is covered: discovering workspaces and sessions, submitting tasks, continuing sessions, retrieving results, and diagnosing the installation. Minor gaps exist around cancellation, session cleanup, or explicit task-status listing, but agents can work around them.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues