Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
DSH_BINNoPath to @deepseek-ai/dsh/lib/bin.jsauto-detected
DSH_MCP_LOGNosilent / info / debugsilent
DSH_MCP_STATENoConversation registry, survives restarts<repo>/.state/conversations.json
DSH_MCP_PROFILENoDSH profile to drivedsh-mcp
DSH_MCP_MAX_LIVENoHow many conversation processes to keep alive at once (0 = unlimited). Going over the cap reaps the least recently used one (a running turn is never reaped) — bounded memory, locks kept where it matters. Use 4 when memory is tight, 0 on a big machine. To free everything at once: dsh_release(all=true)8
DSH_MCP_RUNS_DIRNoRoot for async completion sentinels (<this>/<conversation_id>/<run_id>.json)<state file dir>/runs
DSH_MCP_LOCKS_DIRNoHolder registrations for the write lock. All instances must agree on this value, or they cannot see each other's registrations and will misread each other as an unidentifiable holder (a GUI) and refuse to preempt<state file dir>/locks
DSH_MCP_LOG_STDERRNo1 forwards DSH's raw stderr
DSH_MCP_PERMISSIONNoDefault tier for dsh_startdanger-full-access
DSH_MCP_IDLE_TTL_MSNoHow long a conversation may sit idle before its DSH process is reaped. 0 means never reap (the default): the server keeps holding the write lock, so the GUI cannot take it — opening the conversation there is read-only and still works. Cost: one resident DSH process per conversation (measured ~120 MB). Set a millisecond value (e.g. 300000) to save memory and accept that the lock can be taken0
DSH_MCP_LOCK_STALE_MSNoHow long without a heartbeat before a holder counts as lost (and becomes auto-preemptible by dsh_takeover)90000
DSH_MCP_SENTINEL_TTL_MSNoStartup pruning age for sentinels; 0 disables pruning604800000
DSH_MCP_REASONING_EFFORTNoDefault reasoning effortmax
DSH_MCP_LIST_PROBE_TTL_MSNoCache lifetime for dsh_list's on-disk probe (the probe spawns a DSH process and takes ~1 s)10000
DSH_MCP_PROMPT_TIMEOUT_MSNoWait bound for wait=true only; on expiry the turn merely moves to the background0
DSH_MCP_REGISTER_WORKSPACENoproject / all / 0project
DSH_MCP_APPROVAL_TIMEOUT_MSNoHow long a pending approval waits300000
DSH_MCP_SENTINEL_INCLUDE_REASONINGNo1 writes result.thinking into the sentinel (breaks the never-on-disk guarantee)

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

这个服务把 DeepSeek Harness (DSH) 当作一个可长期共事的编码 agent 来驱动。 DSH 自己有文件读写、shell、搜索、技能、子代理等全套工具;你给它目标,它自己决定怎么做。 本服务只暴露下面这些 dsh_* 工具。

【三个 id 的关系(务必分清)】

  • conversation_id —— 长期会话。可反复派活,历史完整保留。进程只是缓存:被回收或崩溃后, 下次派活会自动 resume 复活,对话不丢。适合"这个项目一直用这个会话"。

  • run_id —— 一次派活的记录。dsh_send 每次返回一个,用它验收那一次的结果。

  • cursor —— dsh_read 的增量游标,用来观察某个会话当前吐出的内容。

【标准流程】

  1. dsh_start(cwd, ...) 建会话。cwd 必须是已存在的绝对路径。

  2. dsh_send(conversation_id, prompt) 默认不阻塞:立刻返回 run_id + sentinel_file。 想原地等结果才传 wait=true。

  3. 之后按需: dsh_status(conversation_id) 还在跑吗?跑到哪了?写锁在谁手上? dsh_read(conversation_id, cursor) 中途看它当前吐出的内容(增量) dsh_get(conversation_id, run_id) 验收:取那一次派活的完整结果

  4. dsh_interject / dsh_interrupt 跑偏了就插话改口 / 直接打断

  5. dsh_release 交还会话(释放写锁,之后仍可 resume)

  6. dsh_takeover 写锁被别人占着时的抢占(见下)

【写锁:一个会话同一时刻只能有一个写者】 DSH 的会话目录有跨进程写锁,持有者活着就永不过期,且没有 API 能直接夺走。所以:

  • 本服务为"保持对话"让一个 DSH 进程常驻 → 期间用户自己的 DSH GUI 打不开这个会话,反之亦然。

  • 撞上 "session ... is already owned by an active write handle"(可能被 ACP 包装成笼统的 "Internal error")时不要盲目重试:先 dsh_status 看 lock_holder 字段,它会是: self / stale-mcp(本服务自己的孤儿,可安全抢占)/ live-mcp(另一个 dsh-mcp 实例)/ none(多半是你自己的 GUI 正开着它)

  • 要拿回写锁: · stale-mcp → dsh_takeover 直接抢占(会自动杀掉那个孤儿子进程); · live-mcp → 先在那边 dsh_release;确实要夺再 dsh_takeover(force=true); · none(GUI 持有)→ 本服务绝不杀(那会把用户的整个界面连同正在看的对话一起杀掉)。 请用户在那个窗口里关掉该会话后重试,或重启 dsh web。

  • 操作铁律:本服务驱动的会话不要在 DSH GUI 里打开(★实测:光是"点开"这个动作就会被 dsh web 拿走写锁,而且切走也不释放 —— 点开一次,这个会话在整个 web 生命周期内就归 GUI,要重启 dsh web 才能还回来)。要看进度用 dsh_read 或哨兵文件;真要在 GUI 里看,先 dsh_release。

【异步完成:跑完自动通知,别傻等也别狂轮询】 每一个回合结束时都会原子写出一个哨兵文件(无论成功、失败、被取消;也无论是 dsh_send 还是 dsh_interject —— 一个回合 = 一个哨兵,没有例外)。dsh_send 的返回里直接给 sentinel_file; 若某次调用没给,路径就是 状态目录/runs/<conversation_id>/<run_id>.json 。三种收活姿势:

  • 首选(真·跑完通知,不占轮次):用你自己的后台任务等这个文件出现。文件一到,宿主就唤醒你, 你再读文件即得结果。示例(Bash;直接用返回里的 sentinel_file_posix,别手工转换路径): sent="$sentinel_file_posix" dl=$(( $(date +%s)+2100 )); until [ -f "$sent" ]; do [ $(date +%s) -ge $dl ] && { echo TIMEOUT; exit 1; }; sleep 2; done; echo DONE 读文件即可拿到 status 和 result;不受内存窗口限制、也扛本服务重启。文件里 status=error 表示失败。

  • 想阻塞拿结果 → 传 wait=true;即使等超时也不会丢结果:返回会变成收据(still_running + sentinel_file), 回合继续跑,结果照常由哨兵送达。

  • 临时查一下 → dsh_get(conversation_id, run_id) / dsh_status / dsh_read。 本服务不会主动给你发 MCP 通知(协议上只应答请求);"跑完通知"就是靠哨兵文件 + 你的后台等待任务实现的。 多会话并发安全:哨兵路径按 conversation_id 分目录,不同会话的 run 各写各的、不串台;每个 run 起一个独立的 等待任务即可,各自完成、各自唤醒你。哨兵是一次性闩锁:即便 run 在你启动等待任务之前就已完成,[ -f ] 也会立刻为真。

【选择建议】

  • 任务可能超过一两分钟 → 用 wait=false。MCP 工具调用是阻塞的,傻等会把你自己卡住。

  • 会话在忙时不要再 dsh_send:想改口用 dsh_interject,想停用 dsh_interrupt, 想把话留到本轮结束后说用 dsh_interject(mode='queue')。

  • 思考内容默认隐藏(只返回字数/耗时统计)。确实需要时传 reasoning='full',但很占上下文。

  • 权限档默认 danger-full-access(零摩擦)。分析不信任样本(恶意软件、来路不明 dump)时用 read-only:沙箱只读 + 审批一律拒绝。

  • 思考深度默认 max;想省钱可在 dsh_start 传 reasoning_effort 调低。

  • 想并行:开多个会话,dsh_list(only_running=true) 看谁在跑,再轮流 dsh_read。

【不要做】

  • 不要用 dsh_send 去"执行一条命令"。DSH 是 agent,请给它目标而不是命令; 它自己会选工具、分步骤、必要时派子代理。

  • 不要把 DSH 内部的工具名(read/pwsh/glob 等)当成本服务的工具——本服务只有 dsh_* 这些。

  • 不要假设回合秒回。长任务请走 wait=false + 事后验收。

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}

Tools

Functions exposed to the LLM to take actions

NameDescription
dsh_startA

新建一个 DSH 会话(一个可长期共事的编码 agent)。会话活在磁盘上,进程只是缓存;进程被回收或崩溃后会自动用 ACP session/resume 复活,对话不丢。返回 conversation_id 与对话标题。建好后用 dsh_send 派活。

dsh_sendA

向会话派一个任务。默认不阻塞(wait=false):立即返回 run_id + sentinel_file,回合在后台跑,跑完自动通知你 —— 你继续做别的事,也永远不用担心任务被"超时"打断。想原地等结果就显式传 wait=true(可配 timeout_ms;到期只会转后台,不会取消回合)。【超时不会毁掉任务】wait=true 到达 timeout_ms 仍没跑完时,本工具不会报错、也不会取消回合,而是自动降级为后台:返回 run_id + sentinel_file,回合继续跑完,结果稍后由哨兵文件通知。(timeout_ms=0 表示一直等。)所以任何时候你都能拿到结果,不用怕"超时了白干"。等待模式与后台模式都在回合结束时原子落地一个含最终结果的小文件——推荐用后台任务(Bash run_in_background + until [ -f sentinel_file ])等它,跑完自动通知你,无需轮询;文件出现后读它即得结果,或用 dsh_get(conversation_id, run_id) 验收,dsh_read 可中途看输出。默认隐藏思考内容(只返回正文 + 思考统计)。若会话正在忙,本工具会报错——改用 dsh_interject 插话,或用 dsh_interrupt 先打断。

dsh_listA

列出会话及其运行状态,用来掌控多个会话实例。state: running(正在跑回合)/ idle(进程活着但空闲)/ detached(进程没开,可 resume 复活)。running 的会话会带上已跑时长、当前正在执行的工具、本轮已产出字数。数据来自两路合并:本服务持有的 + DSH 磁盘上尚未打开的(DSH 的 session/list 会排除已打开的会话)。想只看正在跑的,传 only_running=true;想看某个会话当前吐出的内容,接着用 dsh_read。

dsh_readA

读会话的运行期输出(游标式增量)——用它可以看到"正在跑的会话"当前吐出了什么,不必等回合结束。典型用法:dsh_list(only_running) 找到在跑的会话 → 反复 dsh_read 并回传上次的 cursor,就能像切换窗口一样轮流观察多个会话。输出缓冲只在内存里且有界(环形,满则丢最旧),服务/进程退出即消失;思考内容不进缓冲——只有 include_reasoning=true 时才会附带"当前正在跑那一轮"的实时思考。

dsh_getA

查看单个会话的详情;带 run_id 时取那一次派活的最终结果(异步模式的验收入口)。不传 run_id 则取最近一次回合。返回:标题、工作区、权限档、状态、轮数、token 用量、上下文压力、待决审批,以及该回合的完整结果(正文/工具/用量/错误)。

dsh_interjectA

插话:会话正在跑某个回合时往里补一句话。两种模式——interject(默认)打断当前回合并立刻改口;queue 不打断,等本轮自然结束后紧接着说。会话空闲时等同于一次普通 dsh_send。说明:ACP 明确拒绝并发 prompt,所以做不到"让模型在同一个回合里即时改向";interject 是它的实用等价物(取消 + 立刻开新回合,历史完整保留)。

dsh_interruptA

中断会话当前正在进行的回合(ACP 原生 session/cancel,走的就是用户手动按停止那条路径)。会话本身保持完好,可以立刻继续派新任务。

dsh_takeoverA

抢占会话的写锁(DSH 的写锁是跨进程内核信号量,持有者活着就不过期,没有 API 能直接夺走——唯一手段是杀掉持有者进程,所以本工具会先判定持有者是谁):① 若锁其实空着,正常 resume 即可,不会杀任何东西;② 若持有者是本服务自己留下的孤儿进程(MCP 崩了/重启了,子进程还活着握着锁)→ 自动杀掉并接管,安全;③ 若持有者是另一个活着的 dsh-mcp 实例 → 默认拒绝,传 force=true 才夺;④ 若持有者无法识别(多半是你自己的 DSH GUI 正开着这个会话)→ 绝不杀(那会连你的界面和正在看的对话一起杀掉),只报告,请你在那个窗口里关掉该会话后重试。注意:杀掉正在跑回合的持有者会中断那一轮(会话日志记为 interrupted),会话本体不受损。

dsh_releaseA

释放会话占用的 DSH 进程(释放写锁,让用户能在自己的 DSH GUI 里打开同一个会话)。会话本体留在磁盘上,之后仍可 resume;forget=true 才会从注册表里摘掉。★ 用完了想一次性腾内存就传 all=true(默认"永不回收"下每个会话约 120MB,全放掉即立刻归零,之后随时 resume)。

dsh_approval_decideA

裁决一个待决审批(仅当会话的 on_approval=ask 时会出现)。用于把 DSH 的越权/提权请求交给调用方决定,既不一律放行也不一律拒绝。

dsh_statusA

轻量状态查询:会话是否活着、是否在忙、待决审批数、最近一次回合的结果。

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A3.9/5.0

Scored across 11 tools

Disambiguation4/5

Most tools have sharply distinct purposes: start/send/interrupt/interject/takeover/release map to different lifecycle actions, and send vs read vs get are separated by blocking mode, streaming cursor, and final result retrieval. The main overlaps are dsh_status vs dsh_get (both report liveness, pending approvals, and last-round result) and dsh_interrupt vs dsh_interject (interject = cancel + new turn), but the descriptions explicitly disambiguate these cases.

Naming Consistency4/5

All 11 tools share a uniform dsh_ prefix with snake_case and mostly verb-first or clear action names (dsh_start, dsh_send, dsh_list, dsh_read, dsh_get, dsh_release, dsh_interrupt). Minor deviations are dsh_approval_decide (noun_verb order) and dsh_status (state rather than action), but the pattern remains predictable.

Tool Count4/5

Eleven tools is well within the healthy range and matched to a session-lifecycle domain with real complexity (async runs, locks, approvals). A couple of tools are arguably redundant (dsh_status largely duplicates a subset of dsh_get), so it is slightly heavier than strictly necessary.

Completeness4/5

The surface covers the full session lifecycle: create, dispatch, observe (list/read/get/status), steer (interject/interrupt), lock management (takeover/release), and approvals. Gaps are minor: deletion and registry removal are only reachable via a forget flag on dsh_release, and there is no tool to configure session settings such as on_approval or permission level, which the descriptions reference.

Maintenance

ActivityStale
ResponsivenessNo recent community issues