Preface¶
When writing code and running commands in DSH, this is typically done by DSH’s own model through ctx.tools. If you are also using Codex CLI and want Codex to initiate tasks, read back structured results, and run acceptance commands itself, ordinary DSH tools are invisible to Codex—capabilities must leave the DSH process and be exposed to external callers in forms such as MCP.
GEB-lab/dsh-codex-mcp is a DSH host plugin running inside the DSH host process: it starts a Streamable HTTP MCP service that listens only on the loopback address locally. Codex calls MCP tools via Bearer authentication, and the plugin then launches the locally installed DSH CLI (--profile headless --json), with DSH reading and writing code, executing commands, and streaming NDJSON output. DSH is still the one writing code; Codex only dispatches tasks, parses returns, and reruns acceptance itself.
Community directory page: skillhub.cn plugin entry. The directory is an independent site with no official affiliation with DeepSeek / Hithink RoyalFlush.
What is this¶
In one sentence: an MCP bridge inside the DSH process—Codex hands development tasks to DSH headless via http://127.0.0.1:39391/mcp (default), without needing to hand-write shell wrapper scripts each time.
Maintainer: GEB-lab. License: MIT (README notes zero runtime dependencies). The current version in package.json is 0.1.1.
Call chain (excerpted from README):
Codex CLI
└─ MCP (Streamable HTTP + Bearer token) http://127.0.0.1:39391/mcp
└─ DSH host plugin dsh-codex-mcp (lives inside the DSH process)
└─ node <dsh install>/lib/bin.js --profile headless --json
└─ DSH reads/writes code, runs commands, streams NDJSON events
Why make it a plugin instead of a DSH built-in tool¶
README explanation: Regular DSH agent tools are only visible to DSH’s own model, and Codex cannot call them. The plugin starts an HTTP MCP endpoint via ctx.effect when the host loads, and closes it on unload; it implements Streamable HTTP and legacy JSON-RPC itself, without depending on the MCP SDK or @deepseek-ai/* packages, avoiding parsing extra dependencies within the profile; the child DSH path is preferentially located from @deepseek-ai/dsh’s lib/bin.js alongside the host installation, or specified via DSH_APP_ROOT / dshCli.
Core features¶
MCP tools (three)¶
| Tool | Purpose |
|---|---|
dsh_env() |
No side effects, no model token consumption; returns plugin, MCP URL/token, DSH CLI and profile, default cwd/timeout, concurrency state, and a pasteable Codex config.toml snippet |
dsh_run(task, cwd?, timeout_sec?, include_events?) |
Creates a new headless session; task is passed via stdin to avoid quoting and argv length issues; on success returns final answer, session id, cwd, exit, turn_end, token usage, step count, and duration |
dsh_resume(session_id, task, cwd?, timeout_sec?) |
Continues the conversation on the same session; cwd must match the first dsh_run, otherwise DSH refuses to start |
Result and failure semantics¶
- Structured fields include the final answer,
session,cwd,exit,turn_end, tokens per turn, steps, and duration; on failure, the stderr tail and a classified reason are attached. - The plugin returns MCP errors for the following cases: timeout, child process non-zero exit,
turn_endnotcompleted, nofinalevent received, or an empty final answer—do not take DSH’s self-reported “completed” at face value. - On timeout, it kills the process tree (Windows uses
taskkill /T /F, other platforms use the process group), to avoid leftover agents. maxConcurrentRunsdefaults to 4; excess calls fail fast rather than being silently queued.- By default it binds only to
127.0.0.1; the Bearer token is generated on first startup (32 random bytes, file permissions0600), default path$DSH_HOME/codex-mcp.token, verification uses sha256 +timingSafeEqual. - Tool descriptions support Chinese and English (
locale/en.json,locale/zh.json); the config itemlocaledefaults tozh.
Environment requirements¶
| Item | Requirement |
|---|---|
| DSH | Desktop or CLI installation, and @deepseek-ai/dsh supports --profile headless --json |
| Node | ^22.19.0 \|\| >=24.0.0 (uses the host’s bundled Node) |
| Credentials | Model API Key configured in the ~/.dsh profile (GUI Models or credential service) |
| Profile | A headless profile is required; the desktop profile does not accept --json |
Installation and activation¶
Add the plugin on the DSH side (commands from the README; note --profile desktop):
# from GitHub (recommended)
dsh plugin --profile desktop add github:GEB-lab/dsh-codex-mcp
# from a release tarball
dsh plugin --profile desktop add https://github.com/GEB-lab/dsh-codex-mcp/releases/latest/download/dsh-codex-mcp.tgz
# local checkout, for development (changes apply after a host restart)
dsh plugin --profile desktop add link:/absolute/path/to/dsh-codex-mcp
dsh plugin forwards to the package manager of the corresponding profile and selects the new bundle in dsh.profile.bundles. If HMR is enabled it loads immediately; otherwise, restart DSH.
Verify the MCP is ready:
curl -i http://127.0.0.1:39391/mcp -X POST \
-H "authorization: Bearer $(cat ~/.dsh/codex-mcp.token)" \
-H "content-type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{}}}'
Without curl, you can use the smoke script in the repo (node scripts/smoke.mjs only tests the protocol and dsh_env; adding --task consumes tokens); the script prints the applicable config.toml snippet for your machine.
Codex-side configuration¶
Edit ~/.codex/config.toml:
[mcp_servers.dsh_codex]
url = "http://127.0.0.1:39391/mcp"
http_headers = { Authorization = "Bearer <contents of $DSH_HOME/codex-mcp.token>" }
startup_timeout_sec = 30
tool_timeout_sec = 3600
enabled = true
Running codex mcp list should show dsh_codex … enabled Bearer token.
Optional: plugin configuration¶
Override dsh-codex-mcp’s config in the bundle default or ~/.dsh/profiles/<profile>/cordis.patch.yml, e.g.:
- id: dsh-codex-mcp
name: dsh-codex-mcp
config:
port: 39400
defaultCwd: 'D:\code'
Common keys: host (default 127.0.0.1; non-loopback requires allowNonLoopback: true), port (default 39391, 0 for automatic port selection), path (default /mcp), defaultTimeoutSec (default 3600), permissionMode (default danger-full-access), maxConcurrentRuns (default 4), etc.; the full table is in the “Configuration” section of the GitHub README.
Typical usage¶
In Codex, you can instruct the model: use dsh_run to make changes in a specified directory, and after it returns, let Codex run the tests itself. README example (replace paths with your environment):
Use
dsh_runto have DSH, inC:\work\proj, add typed input support tosrc/sum.mjsplus threenode:testcases; only touchsrc/andtest/. After it returns, runnode --test test\*.test.mjsyourself and report the result.
On success, the text result of dsh_run includes session: and a continuation hint, e.g.:
--- continue this session ---
dsh_resume({ "session_id": "session-1a2b3c4d-...", "task": "<next task>" })
Applicable scenarios and notes¶
Who it’s for: Users who already use both DSH (headless + configured API Key) and Codex CLI, and want to use Codex to orchestrate multi-step development, hand specific code changes to DSH, and have Codex retain the acceptance and reporting chain.
Security and permissions: The plugin runs the child headless agent with the permissions of the current DSH host process; the default permissionMode is danger-full-access. Before installation, read the repo source and the MIT license to confirm the token file and loopback-only binding policy suit your environment. Non-loopback binding requires explicit configuration and still has peer address verification (see the README “Security model” section for details).
Category: The community directory classifies this plugin as workflow.
Conclusion¶
dsh-codex-mcp anchors “Codex dispatches, DSH executes” on the local MCP loopback, using three tools and environment detection to reduce wiring costs, and provides unified failure classification for timeouts, exit codes, and empty results. For details, configuration tables, and security notes, refer to the repo README.
- Directory page: https://www.skillhub.cn/plugins/GEB-lab/dsh-codex-mcp
- GitHub: https://github.com/GEB-lab/dsh-codex-mcp