dsh-session-inject
Bridges Hermes (an MCP client) into DeepSeek Harness: it lets Hermes send a user turn directly to one specific live dsh session — using that session's own model, tools, working directory, permission preset and context — and read back the reply. Exposes tools for listing live sessions, injecting/steering prompts (with queue-vs-steer delivery and bounded waits), polling submission status and phases, recovering lost submissions by session, and creating new sessions (with optional cwd, preset, provider and model).
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
dsh-session-inject
English | 简体中文
A DeepSeek Harness (dsh) plugin that opens a loopback MCP endpoint. Any MCP client — Hermes,
for example — can send a user turn to one specific live dsh session and read back the reply to
that turn.
The session handles the turn itself, with its own model, tools, working directory, permission preset and context. No subagent is spawned.
Hermes ──MCP over HTTP (127.0.0.1:3090)──▶ dsh plugin ──sessionController.prompt──▶ target session
◀──────────── reply_text / phase / submission_id ─────────────┘Table of contents
Related MCP server: dsh-web-bridge-mcp
Why this plugin exists
Author's note. I keep one long-lived dsh session per project. Weeks of decisions, the file layout, the approaches already ruled out — all of it lives in that session.
My first approach was the conventional one: dispatch the work to a subagent. It failed in two ways, every time.
The parent agent takes over. When a dispatch finishes, the parent session wakes up on the completion notice. It holds the whole project history and its own opinions, so it starts "improving" the result: it rewrote a checklist I had already approved, replaced a verified screenshot with one of its own, edited files the worker had just delivered. Work that came back correct was altered by the agent that was only supposed to be supervising. I call it 添油加醋 — adding seasoning to a dish that was already right.
The subagent lacks context, and you pay full price for it. A child starts from a narrow prompt. It knows none of the project's conventions, so every dispatch needed a hand-written
CONTEXT.md, and the answers were technically correct but blind to the design around them. It is also a brand-new conversation, so its prefix cache starts at zero: the same instruction is charged as uncached input every time. The long-lived session that already holds that context re-reads it at cache-hit prices — measured on this setup, about 99% hit from the second request inside one session, and 77–82% across long project sessions.
What I wanted instead was simpler: send the instruction to the session that already knows the project, and let it do the work — same memory, same understanding of the code, warm cache. No child agent in between, and no supervisor rewriting the output.
Where it came from. This started with
dsh-hermes-link — the original Hermes ↔ dsh
bridge (@tianbuyu-wwx/dsh-hermes-link 0.6.11, written for dsh 0.1.5-rc.2) — and its dsh 0.2.x
compatibility fork guiyinrenshi/dsh-hermes-link
(published unscoped as dsh-hermes-link, 0.8.6). Both dispatch work by spawning a subagent, and a
continuable child wakes the parent session when it finishes: exactly the behaviour described above.
I first tried to fix it in place, with a session_prompt tool that routed text through
ctx.subagents.sendMessage/prompt. The Host rejects that for root sessions
(UNAUTHORIZED: send_message requires another agent in the subagent tree), because the subagent API
is scoped to the subagent tree by design. That is why this is a separate plugin: it uses the
session-controller API instead, touches none of dsh-hermes-link's files, and either project can be
removed without disturbing the other.
How it works. The plugin submits a normal user turn to the session timeline, using the same Host command as the Web GUI's send button:
// @deepseek-ai/dsh-api-session-controller (dsh 0.2.x)
@Remote('prompt')
async prompt(request: SessionPromptRequest, signal: AbortSignal): Promise<SessionPromptValue>
// SessionPromptRequest { requestId, sessionId, mode: 'queue' | 'steer', content, clientTimeZone? }That is why the text behaves like something you typed: same queue, same permissions, same tools. The
reply is collected from the session's own event stream. Source excerpts are in
docs/api-evidence.md.
Features
Runs in the session, not in a child. The injected text arrives as a
source.kind = "user"message, and the session answers with its own model, tools, cwd and context.Five MCP tools —
sessions_list,session_inject,inject_status,submissions_list,session_create— over JSON-RPC 2.0 (initialize,ping,tools/list,tools/call).A wait that never loses the handle.
wait_msis capped at 240 s, below the 300 s MCP client timeout, and every response — errors included — carries asubmission_id.Recoverable. If a response is lost,
submissions_listfinds the submission again by session. Records are persisted, so after a dsh restart an old id returnsphase: "orphaned"with its last known state instead ofunknown.Observable.
phase,idle_ms,last_event_typeandsteps_seencome from the session's event stream (turn/start,step/start,tool/call,assistant/message,turn/end), so "thinking", "running a tool" and "dead" can be told apart.Optional SSE progress.
notifications/progressevery 8 s when the client sendsparams._meta.progressToken; verified against the official SDK.No runtime dependencies. Loopback only, optional Bearer token.
Requirements
Item | Requirement |
dsh | 0.2.x (uses |
Node | 22.13 or newer — the runtime bundled with dsh already satisfies this |
Hermes | optional; any MCP client with server support works |
Network | loopback only; by default the listener never binds outside |
Quickstart
# 1) install into one or more dsh profiles
dsh plugin --profile web add /path/to/dsh-session-inject
dsh plugin --profile desktop add /path/to/dsh-session-inject
# 2) make sure the bundle is listed (dsh plugin add does not always write it)
# ~/.dsh/profiles/<profile>/package.json -> dsh.profile.bundles += "dsh-session-inject"
# 3) restart dsh (the plugin loads in-process), then check
curl -s http://127.0.0.1:3090/health
# 4) point Hermes at it
hermes mcp add dsh-session-inject --url http://127.0.0.1:3090/mcp/session-inject
# prompts: "require authentication?" -> n "enable all tools?" -> y
# 5) reload MCP in Hermes (/reload-mcp) or start a new sessionThe full walkthrough — a second machine, Linux commands, a verification checklist and
troubleshooting — is in docs/INSTALL.md.
MCP tools
Tool | Arguments | Result |
| — |
|
|
|
|
|
|
|
|
| summary rows, newest first |
|
|
|
session_id is optional on session_inject; without it, the first live session is used.
Wait semantics
Omit
wait_msand the call waitsdefaultWaitMs(3000). Pass0to return as soon as the turn is admitted.A value above
maxWaitMs(240000) is capped, not rejected:{ ok: true, status: "running", wait_capped: true, requested_ms, effective_ms, submission_id }.A capped wait is not an error. The turn keeps running; poll
inject_statusorsubmissions_list.submission_idis present in every response, includingE_INVALID_SPEC,E_UNKNOWN_SESSION,E_NO_LIVE_SESSIONandE_INJECT_FAILED.
Phases
phase | meaning |
| waiting behind another submission for the same session ( |
| admitted, with recent events from the session |
| admitted, but no event for longer than |
| reply captured ( |
| admission rejected, or the turn ended |
| record left by a previous dsh process; the last known state is returned, never |
Recommended long-task sequence
Hermes' MCP client timeout is fixed at 300 s, so track the id instead of holding one long request open:
session_inject(wait_ms=0) -> submission_id immediately
then every 10-30 s:
inject_status(submission_id) -> phase / idle_ms / reply_preview
submissions_list(session_id) -> recovers the id if the first response was lost
until phase == "done" -> reply_textConfiguration
Override these in the profile's cordis.patch.yml (~/.dsh/profiles/<profile>/cordis.patch.yml),
not in the plugin's own file:
- id: dsh-session-inject
name: 'dsh-session-inject'
config:
port: 3090
host: '127.0.0.1'Key | Default | Meaning |
|
| loopback listener |
| env | when set, requests must send |
|
| cap on |
|
| wait applied when |
|
|
|
|
| interval of SSE |
|
| durable snapshots; |
|
| age at which persisted records are pruned on startup |
|
| internal ceiling for one submission |
|
|
|
|
| test-only switch for the full-log scan |
Security
Loopback only. The default bind is
127.0.0.1, with no CORS and no TLS. Never bind it to a LAN interface or port-forward it: this plugin types into a session on your behalf.Token. Without one, any local process can inject prompts. On a shared machine set
DSH_SESSION_INJECT_TOKENand send the Bearer header from the client.Irreversible by design. Injected text stays in the timeline like a human message and cannot be recalled. Injecting does not change the session's model, permissions or tool set.
No existing dsh security setting is modified, and no dsh core file is patched.
Limits
contentis limited to 32000 characters per injection.queueis serialized per session.steeris not queued, and still reports the shared turn's final message.Persisted records keep a
reply_previewof up to 200 characters, not the full reply; read the session timeline for the complete text.sessions_listreports live agents only. Cold sessions are not resumed just to be listed, so right after a dsh restart the list can be empty until the UI re-opens a session.One dsh profile per port: two profiles cannot both hold
3090.
Troubleshooting
Symptom | Cause / fix |
nothing listens on 3090 | plugin missing from |
Hermes shows no tools |
|
| the client cached the pre-0.3 tool list; reload MCP |
| that id is not a running session (fresh restart, UI not restored yet); wait a moment or call |
stuck in | the target session is busy with another turn |
| long thinking or a long tool call; |
More: docs/INSTALL.md.
Project layout
index.mjs Host plugin entry (Cordis loader row)
lib/server.mjs MCP JSON-RPC HTTP server, 5 tools, SSE progress
lib/session-api.mjs sessionController.prompt / turn wait / live session list
lib/records.mjs submission registry, phases, queueing, persistence
cordis.patch.yml bundle patch (loader insert + defaults)
install.ps1 Windows helper (register + ensure the bundle entry)
examples/ Hermes-side curl examples (sh / ps1)
tools/ verification, evidence capture, benchmarks
docs/ install guide, API evidence, delivery report, historyDevelopment
npm install # for tools/ only; the official MCP SDK is a devDependency
npm run test:smoke # health + tools/list + a short inject
npm run test:mcp # full handshake with the official SDK client
npm run test:wait # wait_ms capping (240 s)
npm run test:recover # hard disconnect -> submissions_list -> done
npm run test:stall # stalled detection
npm run test:progress # SSE progress notificationsThe plugin itself has no runtime dependencies.
Documentation
Doc | Content |
install on another machine (Windows and Linux), verification checklist, troubleshooting | |
how an agent or MCP client should drive the endpoint: recipes, phases, error handling | |
the dsh source excerpts this plugin builds on | |
delivery report: API investigation, acceptance results, per-version changes | |
release notes | |
the task briefs used to build v0.2 and v0.3 |
Related projects
Tianbuyu-wwx/dsh-hermes-link — the original Hermes ↔ dsh dispatch bridge (
@tianbuyu-wwx/dsh-hermes-link0.6.11, for dsh 0.1.5-rc.2).guiyinrenshi/dsh-hermes-link — its dsh 0.2.x compatibility fork (npm:
dsh-hermes-link, 0.8.6), the dispatch model described above.
Both spawn a subagent per dispatch. This plugin deliberately does not; it drives an existing session instead. The two can coexist — neither reads or modifies the other's files.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables AI clients to send prompts to a local Codex App Server via MCP, returning text responses and supporting persistent session reuse.-
- AlicenseAqualityBmaintenanceEnables MCP clients like Codex to delegate coding tasks to DeepSeek Harness, reusing the same Web-visible session for feedback and keeping the conversation in the Harness Web UI.101MIT
- AlicenseNot gradedqualityBmaintenanceEnables 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
- AlicenseNot gradedqualityBmaintenanceLets an external MCP client drive a running DeepSeek Harness instance: list its sessions, create or continue a session in a chosen workspace with an instruction, and wait for the finished answer. It also carries the instance's questions and approval decisions back to the caller, so a delegated turn never deadlocks waiting for a human.MIT