Skip to main content
Glama

mcp-delegate

Claude Code(オーケストレーター)に、別のモデル(Ollama経由のローカル、またはOpenRouter経由のリモート)で実行される独立した完全なエージェントループへタスクを委任するツールを提供するMCPサーバー。独自のツールアクセス(ファイル、bashなど)を持ち、最終結果のみを返す——機能的にはネイティブのサブエージェントと同等だが、モデルに依存しない。

完全なビルド計画は mcp-subagent-delegation-plan.md を参照。個別のコミット/チェックポイントとして段階的に分かれている。

Status

フェーズ1、2、3、4が完了。

  • delegate_task — 設定済みのOpenAI互換エンドポイント(Ollama、LM Studio、vLLM、OpenRouterなど)に対する単発のチャット補完。

  • delegate_agentic_task — 委任されたモデルに、呼び出し元が指定した作業ディレクトリにスコープされた独自のツール使用ループ(read_filewrite_filerun_bash)を提供する。ツールの呼び出しを停止するか、max_iterations に達するか、timeout_seconds を超えるまで実行される。

  • list_recent_delegations — 過去の委任(どちらのツールでも)が実際に何をしたかを、ログを掘り返したり再実行したりせずに確認する。

  • get_delegation_transcriptcapture_transcript=True で実行された場合の、1回の委任の完全なメッセージ/ツール呼び出しトランスクリプト(例:モデル比較/評価実行用)。

元の計画からの逸脱: フェーズ2では agent-loop をサブプロセスとしてラップする予定だった。agent-loopはLinux/macOS/WSLのみをサポートしており、このサーバーはWindows上でネイティブに動作する必要があるため、代わりにフェーズ5の代替案として説明されているインプロセスループを構築した——同じツールインターフェースで、サブプロセス/ANSIストリッピングの複雑さがなく、agent-loopのAGPL/商用不可ライセンスを完全に回避できる。delegate/agentic.py を参照。

安全性に関する注意: working_dir は呼び出し元が指定するものであり、固定されたサンドボックスではない——委任されたモデルは、指定されたディレクトリに対して無人でファイル/bashアクセスができる。ファイルツール(read_file/write_file)は working_dir 内に留まるようにスコープされている。run_bash はそのディレクトリを cwd として実行されるが、シェルコマンドは完全にはサンドボックス化されておらず、そこから逃げ出せる可能性がある(例:cd ..)。無人モデルが読み取り、書き込み、コマンド実行を行っても問題ないディレクトリを指定すること。

ガードレールに関する注意: 元の計画のフェーズ4では、agent-loop自身のガードレール(反復上限、繰り返し検出)が有効であることを確認するよう求めていた。agent-loopを使用していないため、これは直接には適用されない——我々のループには独自の max_iterationstimeout_seconds の上限(テストで検証済み)があるが、繰り返し検出はない。2つのツール呼び出しを交互に繰り返してスタックしたモデルは、早期に検出されるのではなく max_iterations に達するまで実行される。実際にそのような事態が発生するようなら追加する価値がある。

Related MCP server: deepseek-subagent-mcp

Setup

uv sync
cp .env.example .env             # fill in DELEGATE_BASE_URL / DELEGATE_API_KEY / DELEGATE_MODEL
cp models.json.example models.json   # optional: named backends, see below

Multiple backends

両方のツールはオプションの backend パラメータを受け取り、デフォルトの DELEGATE_* 環境変数の代わりに models.json から base_url/model/api_key を参照する——例えば、同じターン内で一方の呼び出しに backend="ollama-local"、もう一方に backend="openrouter-free" を指定し、それぞれを並行して実行できる。model も指定された場合は、そのバックエンド内のモデル文字列のみを上書きする。

キーを models.json に直接書く代わりに、環境変数を参照する:

{
  "openrouter-free": {
    "base_url": "https://openrouter.ai/api/v1",
    "model": "nvidia/nemotron-nano-9b-v2:free",
    "api_key_env": "OPENROUTER_API_KEY"
  }
}

models.json.env と同じくgitignoreされている。

Concurrency

MCPツール呼び出しはすでに個別のワーカースレッドで実行されるため、追加の配管なしで並行委任が並列実行される。DELEGATE_MAX_CONCURRENCY(デフォルト4、.env.example を参照)は、両方のツール、任意のバックエンドにわたって同時に実行される委任の数を制限し、大規模なファンアウトがローカルモデルサーバーや有料APIのレート制限を圧迫するのを防ぐ。

サーバーを直接実行する(主にエラーなく起動するかを確認するのに有用——その後、MCPクライアントのためにstdioで待機する):

uv run server.py

Logging

delegate_task/delegate_agentic_task のすべての呼び出し——成功か失敗かに関わらず——はローカルのSQLiteファイル delegations.db(gitignoreされ、初回使用時に作成)に記録される: ツール、バックエンド、モデル、タスクテキスト、開始/終了時刻、反復回数、成功/失敗、切り詰められた結果/エラープレビュー、およびバックエンドが返した場合はトークン使用量。list_recent_delegations ツールで照会するか、sqlite3 delegations.db "select * from delegations order by id desc limit 20" で直接照会できる。ロギングはベストエフォートであり——ロギングの失敗で、それ以外は成功した委任が失敗することはない。

両方のツールは、バックエンドが使用量を報告した場合、戻り値の末尾に [tokens: N prompt / N completion / N total ($cost)] の行を追加する。これにより、呼び出し元のエージェントは別途 list_recent_delegations を呼び出さなくてもすぐに確認できる。

Cost tracking

pricing.json はモデル文字列 → {input_per_million, output_per_million} のUSDレートをマッピングする。呼び出しの解決されたモデルにエントリがある場合、コストは実際のトークン使用量から計算され、delegations.dbcost_usd カラム)に記録され、[tokens: ...] サフィックスに含まれる。エントリがないモデルは cost_usd = NULL が記録される——無料と見なすのではなく不明として——つまり、エントリの欠落が支出を黙って過小報告することはない。ローカルモデルは通常その理由でエントリを持たない。本当に無料のモデル(例:OpenRouterの :free モデル)は、省略される代わりに明示的な {"input_per_million": 0, "output_per_million": 0} エントリが与えられる。

.env/models.json とは異なり、pricing.json は秘密情報でも環境固有でもないため、gitignoreされるのではなく直接コミットされる。価格は変動する——同梱のファイルは、これが構築されたモデル比較ベイクオフで指定されたモデルについて、2026-08-21にOpenRouterの /api/v1/models から取得されたもの。必要に応じて再取得して編集し、モデルを追加/更新すること。

Transcript capture (model comparison / eval runs)

両方のツールは capture_transcript: bool = False を受け取る。設定すると、最終回答だけでなく、すべてのモデルメッセージ、ツール呼び出し、ツール結果を含む完全なメッセージ交換が記録され、戻り値に [delegation_id: N] サフィックスが付く。get_delegation_transcript(delegation_id) で取得できる。

これは、同じタスクを複数の異なるモデル/バックエンドで実行し、最終回答だけでなく各モデルがどのようにそこに到達したか(ツール選択、不正な形式のツール呼び出し、リトライ)を比較するために存在する——例えば、本番使用のために1つを選ぶ前に候補モデル間でベイクオフを行う場合など。通常の委任には不要な追加のロギングオーバーヘッドであるため、デフォルトではオフ。

Register with Claude Code

プロジェクトスコープの .mcp.json はすでにチェックインされている(uv run server.py)。このディレクトリでClaude Codeを再起動するか、claude mcp list を実行して delegate サーバーが認識されたことを確認し、次に簡単なプロンプトで delegate_task を呼び出すよう依頼してラウンドトリップを確認する。

Tools

  • delegate_task(prompt, model=None, system_prompt=None, backend=None, capture_transcript=False) -> str — 設定済みバックエンドに対する単発のチャット補完。

  • delegate_agentic_task(task, working_dir, model=None, max_iterations=20, timeout_seconds=600, backend=None, capture_transcript=False) -> strworking_dir にスコープされた read_file/write_file/run_bash ツールを使ったマルチステップ委任。 capture_transcript=True の場合を除き、完全なトランスクリプトではなく最終回答のみを返す。

  • list_recent_delegations(limit=20) -> list[dict] — 直近に記録された委任を新しい順で返す。

  • get_delegation_transcript(delegation_id) -> list[dict]capture_transcript=True で記録された1回の委任の完全なトランスクリプト。

delegate_task/delegate_agentic_task は、エラー(設定ミス、到達不能なエンドポイント、タイムアウト、反復上限)を例外として発生させるのではなく "Error: ..." 文字列として返す。これにより、呼び出し元のエージェントが何が問題だったかを確認できる。

Available Tools

4 tools
delegate_agentic_taskA

Delegate a multi-step task to a model with its own tool-use loop (read_file, write_file, run_bash) scoped to working_dir. Runs until the model stops calling tools, hits max_iterations, or exceeds timeout_seconds. Returns only the final answer, not the full transcript.

The delegated model gets unattended file/bash access within working_dir for the duration of the call - point it at a directory you're comfortable it can read, write, and execute commands in.

Args: task: The task instruction to give the delegated model. working_dir: Directory the model's tools are scoped to. model: Override just the model string for this call. max_iterations: Stop after this many tool-call rounds. timeout_seconds: Wall-clock budget for the whole task. backend: Named backend from models.json (base_url/model/api_key) to use instead of the default DELEGATE_* env vars. model, if also given, overrides the model within that backend. capture_transcript: Log every model message and tool call/result for later retrieval via get_delegation_transcript, instead of just the final answer. Off by default; useful when comparing models (e.g. a bake-off) rather than for routine use.

ParametersJSON Schema
NameRequiredDescriptionDefault
taskYes
modelNo
backendNo
working_dirYes
max_iterationsNo
timeout_secondsNo
capture_transcriptNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description fully carries the behavioral disclosure burden. It clearly states that the delegated model gets unattended read/write/execute access within working_dir, that only the final answer is returned, that there are termination conditions, and that transcript capture is opt-in. This is comprehensive and honest about side effects and limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Despite being long, the description is tightly structured: a core behavior paragraph, a safety warning, then a bulleted Args list. Every sentence earns its place, and the most important info (what it does, termination, permissions) is front-loaded. No fluff or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex delegation tool with 7 parameters, no annotations, and a dangerous access profile, the description covers all critical aspects: scope, termination, access level, return value, optional transcript capture, and backend override. The existence of an output schema is acknowledged but not required to detailed since it says returns only the final answer. Nothing an agent needs to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description is the only source of parameter meaning. It explains every parameter in the Args block, including the nuanced interplay between model and backend (backend as a base_url/model/api_key bundle, and that `model` overrides within that backend). This fully compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise verb and resource: 'Delegate a multi-step task to a model with its own tool-use loop...'. It clearly states the operation's scope (working_dir) and distinguishes itself from tools like get_delegation_transcript by explaining that it returns only the final answer, not the full transcript. This is a specific, unambiguous definition that lets an agent know exactly what it does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains the conditions under which the delegated model stops (no more tool calls, max_iterations, timeout_seconds) and warns about unattended file/bash access. It also suggests capture_transcript for comparison scenarios, indirectly routing to get_delegation_transcript. However, it does not explicitly contrast with delegate_task or state when to choose this tool over that sibling, leaving some inference to the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

delegate_taskA

Delegate a single-shot task to a configured OpenAI-compatible model (e.g. local Ollama or OpenRouter) and return its text response verbatim.

Args: prompt: The task/question to send to the delegated model. model: Override just the model string for this call. system_prompt: Optional system prompt to steer the delegated model. backend: Named backend from models.json (base_url/model/api_key) to use instead of the default DELEGATE_* env vars. model, if also given, overrides the model within that backend. capture_transcript: Log the full message exchange for later retrieval via get_delegation_transcript. Off by default; useful when comparing models (e.g. a bake-off) rather than for routine use.

ParametersJSON Schema
NameRequiredDescriptionDefault
modelNo
promptYes
backendNo
system_promptNo
capture_transcriptNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries the behavioral burden. It discloses the side-effect of transcript capture, the verbatim return behavior, and backend/model override semantics. It does not discuss latency, cost, or authentication, but those are not critical for selecting or invoking this tool correctly.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is organized with a front-loaded summary followed by a clear Args block. Every parameter is explained in one or two lines, and there is no redundant or filler content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-shot delegation tool, the description covers purpose, parameter semantics, backend resolution, and the return behavior. With an output schema present and sibling context available, no critical invocation detail is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, but the description fully documents all five parameters, including the relationship between backend and model, overriding behavior, and the opt-in nature of capture_transcript. This completely compensates for the schema gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool 'Delegate a single-shot task to a configured OpenAI-compatible model' and 'return its text response verbatim.' The 'single-shot' qualifier distinguishes it from the sibling delegate_agentic_task, though it does not explicitly name that sibling.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives concrete guidance on when to use capture_transcript ('when comparing models, e.g. a bake-off') and when not ('rather than for routine use'), and explains backend selection versus DELEGATE_* env vars. It does not explicitly describe when to choose delegate_task over delegate_agentic_task, but context signals and the 'single-shot' phrasing provide reasonable guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_delegation_transcriptA

Full message transcript (every model message and tool call/result) for one delegation, if it was run with capture_transcript=True. Get the id from list_recent_delegations. Returns an error string if no transcript was captured for that id.

Args: delegation_id: The id field from a list_recent_delegations row.

ParametersJSON Schema
NameRequiredDescriptionDefault
delegation_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden. It discloses the error condition for missing transcripts, which is the key behavioral nuance. It does not explicitly state read-only semantics, but that is reasonably implied for a retrieval tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, with two clear sentences and a brief args section. No redundant or filler content; it efficiently conveys all necessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given there is an output schema (as indicated in context), the description need not explain return formats. It covers the essential context: the source of the id, the capture condition, and error behavior. This makes it complete for a single-parameter retrieval tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The parameter delegation_id is explained beyond the schema: it is the id from a list_recent_delegations row. This provides actionable meaning on how to obtain the correct value, enhancing the bare integer type definition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns the full transcript for a delegation, using a specific verb ('get') and resource ('transcript'). It is distinct from siblings (list_recent_delegations lists, delegate_task delegates), so no ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly notes the precondition (capture_transcript=True), the error behavior when no transcript exists, and instructs to obtain the delegation_id from list_recent_delegations. This gives clear when-to-use guidance and differentiates it from alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_recent_delegationsA

List the most recent delegate_task / delegate_agentic_task calls (backend, model, task, duration, iterations, success, token usage, USD cost if the model has a pricing.json entry, truncated result), most recent first. Answers "what did the delegated model actually do" without re-running anything.

Args: limit: Max number of records to return (default 20).

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full behavioral disclosure burden. It discloses the read-only nature (without re-running), sorting (most recent first), truncation of results, and conditional cost reporting. It does not mention pagination or error behavior, but for a simple read-only listing tool these are minor omissions; the disclosed traits exceed typical descriptions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is moderately concise, listing the returned fields in a parenthetical that is useful but slightly dense. The core purpose is stated upfront, and the parameter doc is separated. It could be tightened by moving the field list to a separate line, but it remains efficient and well-organized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has one optional parameter, no annotations, and an output schema (not provided). The description covers the return semantics (fields, ordering, truncation, cost condition) and the read-only intent. Given the simplicity, nothing essential for correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for the single parameter 'limit'. It does so explicitly: 'Max number of records to return (default 20).' This adds full semantic meaning beyond the bare schema field, making the tool usable without additional inference.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists recent delegate_task / delegate_agentic_task calls, enumerates the returned fields (backend, model, task, duration, iterations, success, token usage, USD cost, truncated result), and specifies ordering (most recent first). It also states the intended purpose—answering what a delegated model actually did—which distinguishes it from sibling tools that create delegations or fetch full transcripts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies a clear use case for inspecting prior delegations without re-running them, but it does not explicitly contrast with siblings like get_delegation_transcript or delegate_task. It lacks explicit when-not-to-use guidance, though the mention of 'without re-running anything' strongly suggests a read-only inspection context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observeddelegate_agentic_task
    • First observeddelegate_task
    • First observedget_delegation_transcript
    • First observedlist_recent_delegations

TDQS

A4.7/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a distinct purpose: delegate_task for single-turn, delegate_agentic_task for multi-step with tool use, list_recent_delegations for querying history, and get_delegation_transcript for retrieving full logs. No overlap.

Naming Consistency5/5

All tool names follow a consistent snake_case verb_noun pattern (delegate_task, delegate_agentic_task, list_recent_delegations, get_delegation_transcript), with clear action prefixes.

Tool Count5/5

Four tools precisely cover the core delegation workflow: create a delegation (two variants), list delegations, and inspect a transcript. No unnecessary extras.

Completeness5/5

The tool set covers creating delegations, retrieving summaries, and fetching full transcripts. No update/delete is needed for delegation records, so the surface is complete for its purpose.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables Claude to delegate tasks to external coding agents (Codex or Antigravity) for independent reviews, separate quota usage, and async processing.
    6
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables AI coding agents like Claude Code or Codex to delegate tasks to a DeepSeek Harness subagent with its own context window, providing tools for task delegation, result waiting, continuation, and supervision with sandboxed execution.
    6
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables delegating coding tasks to a pi agent as a steerable background worker, allowing mid-run redirection, follow-ups, and keeping the delegate's context isolated from your main conversation.
    12
    12
    16
    MIT