deepseek-subagent-mcp
deepseek-subagent-mcp
Claude Code、Codex、またはその他のMCPクライアントに、独自のサブエージェントにタスクを委任するのと同じ方法で、DeepSeek Harnessエージェントを委任できるようにします。
MCP(Model Context Protocol)は、コーディングエージェントが外部ツールを読み込むための標準規格です。DeepSeek HarnessはDeepSeekのオープンソースエージェントランタイムであり、ファイルツールとシェルツールを備えたループ内のモデルで、2026年8月にMITライセンスでリリースされました。このサーバーはその間に位置し、別のプロセスでHarnessエージェントを実行し、開始、監視、継続、停止のための6つのツールを公開します。
子エージェントは独自のコンテキストウィンドウを持っています。それがポイントです——自己完結型のタスクを渡すと、ファイルを処理しながら独自のトークンを消費し、結果が返ってきます(トランスクリプトではなく)。
要件
Python 3.11以降
platform.deepseek.com のDeepSeek APIキー
Apple Silicon搭載のmacOS 14以上、またはx86-64またはarm64のLinux
Node.jsのインストールは不要です。Harnessランタイムは、deepseek-harness-sdk ホイール内に自己完結型の実行可能ファイルとして同梱されています。そのホイールがプラットフォームの制限にもなっています——macosx_14_0_arm64、manylinux_2_28_x86_64、manylinux_2_28_aarch64 のみを公開し、それ以外はありません。そのため、Windows、Intel Mac、macOS 13ではまったくインストールできません。
Related MCP server: DSH Crew
インストール
uvx --from git+https://github.com/gaztrabisme/deepseek-subagent-mcp deepseek-subagent-mcpClaude Code
プロジェクト内の .mcp.json、または全プロジェクト用の ~/.claude.json に追加します:
{
"mcpServers": {
"deepseek-subagent": {
"command": "uvx",
"args": [
"--from", "git+https://github.com/gaztrabisme/deepseek-subagent-mcp",
"deepseek-subagent-mcp"
],
"env": {
"DEEPSEEK_API_KEY": "sk-...",
"DSA_WORKSPACE": "/path/to/your/project"
}
}
}
}Codex
~/.codex/config.toml に追加します:
[mcp_servers.deepseek-subagent]
command = "uvx"
args = ["--from", "git+https://github.com/gaztrabisme/deepseek-subagent-mcp", "deepseek-subagent-mcp"]
env = { DEEPSEEK_API_KEY = "sk-...", DSA_WORKSPACE = "/path/to/your/project" }ツール
ツール | 機能 |
| 新しいサブエージェントをタスクで開始します。 |
| 実行が完了するまでブロックし、結果を返します。 |
| 既存のエージェントに、元のセッション内で追加の作業を送信します。 |
| このサーバーが所有する全エージェントを、状態、コスト、実行履歴とともに表示します。 |
| エージェントを停止し、そのプロセスを解放します。 |
| エージェントが実際に行ったこと——ツール呼び出し、メッセージ、ターンの終了、生の応答。 |
実行はデフォルトで非同期です。コーディングタスクには数分かかることがあり、MCPクライアントは個々のツール呼び出しにタイムアウトを設定するためです。dsh_delegate は作業がキューに入れられるとすぐに戻ります。dsh_await が待機を行い、その間の進捗を報告します。短いタスクの場合は、dsh_delegate に wait_seconds を渡して2回目の呼び出しを省略できます。
各 dsh_delegate は1つのエージェントを作成し、1つのランタイムプロセスと1つの永続化されたセッションを保持します。dsh_continue はそのセッションに再入するため、子エージェントは以前のターンをコンテキストに保持したままになります。
すべての委任は、どのようにチェックされるかを明示する
dsh_delegate は verification 引数を必要とします。これはタスクが完了したことを証明するコマンドです。
dsh_delegate(task="Fix the failing date parser", verification="pytest -q tests/test_dates.py")サーバーはそのコマンド自体を、子エージェントが終了した後、エージェントのワークスペースで実行します。子エージェントが自身のテスト結果を報告することは主張であり、終了コードは事実です。エージェントが時期尚早に勝利を宣言することは、よく文書化された障害モードです。
結果 | 状態 |
コマンドが0で終了 |
|
コマンドが失敗、タイムアウト、または未指定 |
|
コマンドは、子エージェント自身の呼び出しを実行前にゲートするのと同じポリシーによって分類されます。呼び出し元は別のエージェントであり、プロンプトインジェクションを受ける可能性があるため、「呼び出し元が要求したから」は許可とはなりません。チェックするものが本当にない場合は verification="true" を渡します。明示的な嘘は、暗黙のデフォルトよりも優れています。
返されるもの
完全なトランスクリプトを返すサブエージェントは、自身の目的を無効にします。子エージェントの回答が DSA_SUMMARY_TOKENS より大きい場合、同じセッション内でさらに1ターンとして、7つのセクションからなる引き継ぎサマリーに置き換えるように求められます:目標、制約と優先事項、進捗、主要な決定、次のステップ、関連ファイル、クリティカルコンテキスト。それがMCPの境界を越えるものです。
すでに上限以下の回答はそのまま返され、余分なターンは消費されません。生の応答は常に保持されます:dsh_transcript(run_id, raw=True)。
監視付き実行
子エージェントのツール呼び出しは、実行前にゲートされます。ランタイム内の PreToolUse フックが、提案された各呼び出しをこのサーバーに渡し、許可または拒否を回答します。拒否された呼び出しは、理由を伴うブロックされたツール結果としてモデルに返され、モデルは適応します。
決定論的分類器が最初に判断し、ほとんどの呼び出しを処理します。ファイルの読み取り、ls、grep、バージョン管理の読み取り、ワークスペースの独自コードとテストの実行は、モデルを介さずに許可されます。特権コマンド、ワークスペース外の削除、フェッチからシェルへのパイプ、SSHキーや .env に触れるものはすべて即座に拒否されます——無害に見える動詞でも同様です。なぜなら cat ~/.ssh/id_rsa は秘密に適用される読み取り専用ツールだからです。分類器が分類できないものだけがエスカレーションされます。
エスカレーションは、クライアントがサポートする最良の階層で実行され、起動時に解決され、dsh_list によって報告されます:
階層 | 決定者 | 要件 |
| 設定するレビュアープロセス |
|
| MCPクライアントのモデル | クライアントが |
| クライアント内のあなた | クライアントが |
| なし——エスカレーションは拒否 | 常に利用可能 |
無人での実行。 Claude Codeは elicitation をアドバタイズし、sampling はアドバタイズしません。そのため、デフォルトではすべてのエスカレーションが人を中断します——あなたが他のことをしている間に動作することを意図したエージェントには間違っています。DSA_SUPERVISOR=agent を設定すると、代わりにローカルレビュアーがその席に配置されます:
DSA_SUPERVISOR=agent # nothing prompts a human
DSA_SUPERVISOR_CMD="claude -p --model sonnet" # any CLI reading a prompt on stdinレビュアーは同じ構造化された事実を受け取り、最初の行で ALLOW または DENY を回答します。それ以外はすべて拒否です。これにはサブプロセスとエスカレーションあたり約8秒のコストがかかり、そのCLIがログインしている任意のアカウントのトークンを消費します。
レビュアーは判断であり、境界ではありません。 cp note.txt $TMPDIR/copy.txt というコマンドがあり、事実が宛先を解決不能と正しく報告している場合、Claudeのレビュアーは $TMPDIR が「ワークスペースが存在するのと同じOSテンポラリルートである」と推論して許可しました。書き込みはワークスペースの外側に到達しました。その種の呼び出しは、現在ではレビュアーが見る前にルールによって拒否されます——これは適切な役割分担です。ルールが境界を守り、レビュアーはその内部のグレーゾーンを処理します。
すべての階層はクローズドフェイル(閉じた状態で失敗)です。到達不能なスーパーバイザー、タイムアウト、不正なリクエスト、またはどちらの機能もサポートしないクライアントは、すべて拒否を生成し、承認は決して行われません。
ラダーは一度選択されるのではなく、順に試行されます。エラーを起こす階層は次の階層にフォールスルーします。そのため、sampling をドロップするクライアント(2026-07-28仕様改訂で非推奨、現在も動作中)は、すべてを拒否する代わりにあなたに尋ねるようにダウングレードされます。タイムアウトする階層はフォールスルーしません。未回答の質問は「ノー」であり、別のチャネルで再度尋ねても待機時間が倍になるだけです。
DSA_SUPERVISOR=off を設定すると、ゲートを完全に無効にできます。
スーパーバイザーに表示されるのは構造化された事実であり、子エージェントの散文ではありません。ツール、各パイプラインセグメントのプログラム、コマンドが名前を付けるすべてのパスにワークスペースの内側か外側かのフラグが付いています。子エージェントはコマンドとその正当性の両方を記述し、自身の主張を主張できる子エージェントはそうします。静的に解決できないパス($TMPDIR/out.txt など)は、推測されるのではなく未解決として報告され、外側としてカウントされます。
examples/claude_supervisor.py は、実際のClaudeに対してこのパターン全体を実行します。sampling を自分でアドバタイズしないクライアント向けです:
DEEPSEEK_API_KEY=sk-... uv run python examples/claude_supervisor.py上限とコスト
委任されたエージェントはループ内であなたの資金を消費するため、4つの独立した上限がそれを制限し、すべての実行は使用量を報告します。
上限 | 調整項目 | 強制方法 |
実行あたりの経過時間 |
| ランタイムを強制終了 |
実行あたりの総トークン数 |
| ランタイムを強制終了 |
実行あたりのモデル呼び出し回数 |
| ランタイムを強制終了 |
同一の繰り返しツール呼び出し |
| ランタイムを強制終了 |
ワイヤ上でのターン途中のキャンセルはないため、すべての停止はプロセス強制終了です。上限による強制終了は、実行自体が報告した内容よりも常に優先されます。強制終了されたプロセスの出力が成功として読まれることはありません。
dsh_delegate、dsh_await、dsh_list はすべてトークン使用量——入力、出力、キャッシュ読み取りと書き込み、ステップ数——を、プロバイダーが報告したものから合計して報告します。ステップごとの入力は意図的に合計されます。各リクエストは再送信されたプレフィックス全体に課金されるため、合計が委任の実際のコストです。
トレースとその活用方法
すべての委任は2つのレコードを残します。
子エージェントのランタイムは、自身の永続ログ——すべてのツール呼び出しとその引数、すべてのフック呼び出しとその終了コード、期間、判定テキスト、ステップごとのトークン使用量——を <session root>/<workspace>/<session>/session.jsonl.zstd に書き込みます。
このサーバーは自身の側を <session root>/trace.jsonl に追記します。各判定とその階層、レイテンシ、スーパーバイザーに表示された事実、各完了実行とその検証結果と使用量、各蒸留ターンが実際に生成した文字数対トークン数の比率。長さのみで、テキストは含まれません。トレースは測定用であり、ソースのコピーを保持するためのものではありません。DSA_TRACE を設定して移動するか、DSA_TRACE=off で無効にします。
uv run python scripts/trace_report.py # reads .dsh-sessions/trace.jsonlこのレポートは、デフォルトが推測された質問に答えます。分類器がどの程度の頻度でエスカレーションし、何に対してエスカレーションするか、DSA_CHARS_PER_TOKEN が観測値と一致するかどうか、DSA_MAX_STEPS と DSA_TURN_TOKEN_BUDGET が実際の使用状況に対してどの位置にあるか。このプロジェクトでの最初の実行では、pwd && ls がモデルにエスカレーションされていることが判明しました——読み取り専用リストがすでに知っていることを知らされるために11秒とモデル呼び出し1回——これは現在、ポリシーによって3分の1ミリ秒で解決されています。
設定
すべての設定はサーバープロセスの環境変数です。
変数 | デフォルト | 意味 |
| — | 必須。子ランタイムに渡されます。 |
| DeepSeekの公開API | プロキシやセルフホストエンドポイントを指定します。 |
|
| 委任作業用のモデルID。 |
| サーバーの作業ディレクトリ | 子プロセスが読み書きするディレクトリ。 |
|
| 同時に許可されるアクティブエージェント数。各エージェントはプロセスを保持します。 |
|
| セッションログが書き込まれる場所。 |
| プロバイダのデフォルト | 子プロセスへのリクエストごとの出力上限。 |
| 未設定 | 1回の実行が強制終了されるまでに消費できるトークンの総数。 |
|
| 1回の実行が強制終了されるまでに行えるモデル呼び出し回数。 |
|
| 同一のツール呼び出しが行われた場合、暴走として実行が強制終了される回数。 |
|
| 実行が強制終了され、失敗と報告されるまでの秒数。 |
|
| アイドル状態のエージェントが回収され、追い出されるまでの秒数。 |
|
| エージェントが回収された後も読み取り可能な状態で保持される完了済み実行数。 |
|
| このサイズを超える結果は、子プロセスに要約が要求されます。 |
|
| その上限に使用される変換率。このワークロードでは3.54と測定されています。 |
|
| 検証コマンドが実行可能な秒数。実行の残り期限によって上限が決まります。 |
|
|
|
|
|
|
|
| 判定を待つ秒数。超過すると拒否されます。 |
|
|
|
|
|
|
|
| 作業予算の圧縮はこれに対して測定されます。 |
|
| 1回のbash呼び出しに対するエグゼキュータレベルの制限。 |
| なし | 1回のランタイムリクエストを待機する秒数。 |
|
| 実行ごとに保持されるアクティビティ行数。 |
|
| サーバーのログレベル。stderrのみに書き込まれます。 |
|
| 決定と実行のトレース。 |
| バンドルされた構成 | パス、または上流の最小構成の場合は |
|
| 構成によって登録されるプロバイダルート。 |
これに依存する前に知っておくべき制限事項
これらはHarness SDKのワイヤプロトコルに由来するものであり、ここでの選択によるものではありません。
ファイルシステムのサンドボックスはbashをカバーしません。
dsh-fs-sandboxはモデルのwrite/editツールを作業ディレクトリに制限しますが、dsh-bash-sandboxはバンドルされたランタイム実行可能ファイルに含まれていないため、bash自体は制限されません。スーパーバイザーがこれをカバーします。スーパーバイザーは実行の上流で、bashを含むすべてのツールをゲートします。DSA_SUPERVISOR=offの場合、bashにはまったく境界がありません。ブランチやスクラッチディレクトリを指定してください。サンドボックスはファイルへの影響のみを制限します — ネットワーク、プロセス、システムコールは制限しません。また、
workspace-writeは作業ディレクトリのルートに加えて/tmpも許可します。キャンセルはプロセスを強制終了します。 ワイヤ上にターン途中のキャンセルはないため、
dsh_cancelはランタイムを終了します。すでに書き込まれた編集はディスクに残り、セッションはその後再開できません。回収されたエージェントのセッションは消えますが、その結果は消えません。
DSA_IDLE_TIMEOUTの後、プロセスは解放されます。dsh_awaitとdsh_transcriptはその完了済み実行に対して引き続き機能しますが、dsh_continueは機能しません。セッションはプロセスが存続する限り存続します。 セッションごとのクローズはないため、エージェントの履歴とともにメモリが増加します。使い終わったエージェントはキャンセルしてください。
上流は開発者プレビューです。
deepseek-harness-sdkは==0.1.0rc7に固定されています。1週間のうちに2つのリリース候補が出荷されました。ワイヤが変更されることを想定してください。
開発
uv sync
uv run pytest # 153 tests, no API key, no network
uv run ruff check .
uv run deepseek-subagent-mcp # starts on stdio; a client drives itライブテストには実際のキーとトークンコストが必要です。pytestでは収集されません。
DEEPSEEK_API_KEY=sk-... uv run python tests/smoke_task.py # the product works
DEEPSEEK_API_KEY=sk-... uv run python tests/smoke_result.py # distillation and the archive
DEEPSEEK_API_KEY=sk-... uv run python tests/smoke_supervisor.py # the gate works
DEEPSEEK_API_KEY=sk-... uv run python tests/smoke_escalation.py # both escalation tiers
DEEPSEEK_API_KEY=sk-... uv run python tests/smoke_limits.py # reaper and deadline
DEEPSEEK_API_KEY=sk-... uv run python tests/smoke_mcp.py # all six toolsCLAUDE.md にはアーキテクチャと上流の制約が記載されています。wiki/ には決定記録と測定結果が記載されています。
ライセンス
MIT.
Available Tools
6 toolsdsh_awaitA
Wait for a run to finish and return its result.
Safe to call repeatedly. If the run is still going when wait_seconds elapses, this returns the current state rather than an error. Runs whose agent has since been reaped are still readable — their results are archived.
Args: run_id: The run to wait on, from dsh_delegate or dsh_continue. wait_seconds: Maximum time to block. Use a longer value for big tasks.
Inputs: run_id (required), wait_seconds. Returns: object
dsh_cancelA
Stop a subagent and release its runtime process.
The harness protocol has no mid-turn cancel, so this kills the child process. Any in-flight run is reported as cancelled, and file edits it already made stay on disk. Cancelling ends the session: its context cannot be resumed, so start a new agent rather than continuing this one.
Args: agent_id: Agent to stop.
Inputs: agent_id (required). Returns: object
dsh_continueA
Send follow-up work to an existing subagent, in its original session.
The child keeps the full context of its earlier turns, so refer to prior work directly ("the migration you just wrote"). Work is queued: if the agent is mid-run, this message runs after it.
Args: agent_id: Agent to continue, from dsh_delegate or dsh_list. message: The follow-up instruction. verification: Command proving this follow-up is done. Omit to skip verification for this turn; the run then reports completed_unverified. wait_seconds: Block up to this long for the run to finish. 0 returns at once.
Inputs: message (required), agent_id (required), verification, wait_seconds. Returns: object
dsh_delegateA
Start a new DeepSeek Harness subagent on a task.
Returns immediately with an agent_id and run_id unless wait_seconds is set. Each call creates a fresh agent with its own runtime process and session; use dsh_continue to give more work to an agent that already exists.
Args: task: What to do, with a clear definition of done. The child cannot ask you clarifying questions, so state the acceptance criteria. verification: The shell command that proves the task is done, run by this server in the workspace after the child finishes — e.g. "pytest -q" or "npm test && npm run lint". Its exit code decides whether the run is reported completed or completed_unverified. Pass "true" if there is genuinely nothing to check. workspace: Directory the child reads and writes. Relative paths resolve against the server's configured workspace. Defaults to that workspace. instructions: Optional standing guidance prepended to the task, e.g. coding conventions or files to leave alone. model: DeepSeek model id. Defaults to the server's configured model. name: Human label for this agent, shown in dsh_list. wait_seconds: Block up to this long for the run to finish. 0 returns at once.
Inputs: task (required), verification (required), name, model, +3 more. Returns: object
dsh_listA
List every subagent this server owns, with its state, cost, and run history.
Inputs: no named parameters. Returns: object
dsh_transcriptA
Show what a subagent actually did during a run.
Returns the tail of its activity log — tool calls, assistant messages, turn endings. Use this to check progress on a long run, or to understand a failure. Returns live data while the run is still going.
Args: run_id: The run to inspect. limit: How many of the most recent activity lines to return. raw: Also return the child's full uncapped response. dsh_delegate returns a distilled version when the answer is large; this is where the original text lives.
Inputs: run_id (required), raw, limit. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct lifecycle operation: list, delegate, await, continue, cancel, and transcript. There is no overlap in purpose, and the descriptions clearly delineate when to use each.
All tools use the 'dsh_' prefix with clear verb names (list, delegate, await, continue, cancel, transcript). The pattern is consistent, though 'dsh_transcript' is a noun rather than a verb, which is a minor deviation.
Six tools cover the full lifecycle of subagent management without redundancy. This is well-scoped for the server's purpose.
The surface covers the complete lifecycle: create (delegate), monitor (await, transcript), extend (continue), and terminate (cancel), plus listing. No obvious gaps exist for managing subagents.
Maintenance
Related MCP Connectors
Hand off work between AI agents in any tool. Start Devin or Cursor cloud and share memory.
AI-powered spec-to-task decomposition and execution orchestration for coding agents.
Run commands, code and file operations for AI agents in Cloud Hypervisor microVM sandboxes.
Coordination hub for AI coding agents: message teammates, ask humans, audit every event.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables Codex to delegate coding tasks to a persistent DeepSeek Harness agent that can read repositories, edit files, and run tests, while letting users follow up, monitor progress, and interrupt the work.66 npm5MIT
- AlicenseNot gradedqualityAmaintenanceEnables Claude Code, Codex, Antigravity and Grok to dispatch tasks to DeepSeek Harness agents as native subagents with live progress, tier and effort presets, workspace guardrails, a jobs board, and a vision/image-generation bridge for text-only models.354 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables hosts like Claude Code, Codex, Antigravity and Grok to dispatch work to DeepSeek Harness agents as native subagents with live progress, tier/effort presets, escalation, workspace guardrails and a jobs board. It also bridges multimodal capability into the text-only harness, letting workers read images and generate them.354 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables hosts like Claude Code, Codex, Antigravity and Grok to dispatch tasks to DeepSeek Harness agents that appear as native subagents with live progress and token stats. It provides tier and effort selection, escalation and dispatch guardrails, a jobs board, in-host or standalone worker sessions, plus a multimodal bridge that lends text-only models vision and image generation.354 npmMIT