Agent Link

io.github.mikusnuzv0.5.1更新于 Oct 8, 2026

Bidirectional AI agent collaboration — spawn and communicate with any agent CLI

已验证STDIO仅桌面AI & MLDeveloper Tools

概览

AI 生成的概览

让 AI 编码代理以子进程方式启动其他代理 CLI,互相提问与回答,并收集它们的结果。

功能
提供工具来启动指定的代理 CLI(Claude Code、Codex、Gemini、Aider 或自定义命令),并附带任务和可选上下文,如文件、错误信息、意图或 git diff。spawn_agents 可并行运行多个代理并返回汇总结果。reply 用于回答被启动代理的追问,kill_agent 中止会话,list_agents 和 get_status 显示已安装的 CLI 与活动会话。
适用场景
适合主编码代理卡住、需要不同模型给出第二意见或代码审查,或需要把独立子任务分给多个代理并行处理时。只需在宿主代理上安装本服务器,被启动的代理只是普通 CLI 子进程。
运行要求
通过 stdio 在本地运行,通常使用 npx agent-link-mcp。每个要协作的代理 CLI 都需单独安装并完成认证(例如 claude login、codex login、Gemini 的登录提示,或为 Aider 设置 OPENAI_API_KEY/ANTHROPIC_API_KEY)。自定义代理可写入 ~/.agent-link/config.json,路径可用 AGENT_LINK_CONFIG 覆盖。
安装前请注意
被启动的代理会以你传入的工作目录作为本地子进程运行,因此可以读取和修改该项目中的文件;上下文选项可能包含 git diff 输出。代理 CLI 可能消耗付费 API 额度或订阅用量,默认超时长达一小时会让会话持续运行。凭据属于各个 CLI,而非本服务器。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Agent Link,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

agent-link-mcp

[npm version] [License: MIT]

English | 한국어

MCP server for bidirectional AI agent collaboration. Spawn and communicate with any AI coding agent CLI — Claude Code, Codex, Gemini, Aider, and more.

When to Use

  • Stuck on a bug? — Your agent tried twice and failed. Let it ask another agent for a fresh perspective.
  • Need a second opinion? — Get code review or architectural advice from a different AI model.
  • Cross-model strengths — Use Claude for planning, Codex for execution, Gemini for research.
  • Parallel work — Spawn multiple agents to tackle independent subtasks simultaneously.
  • Rubber duck debugging — Have one agent explain the problem to another and get back a solution.

Use Cases

Get Help When Stuck

Your primary agent keeps failing on the same issue? Ask another agent:

# Claude Code is stuck on a TypeScript error it can't resolve.# It spawns Codex for a second opinion:
spawn_agent("codex", "This TypeScript error keeps appearing. How do I fix it?", {  error: "Type 'string' is not assignable to type 'number'",  files: ["src/utils.ts"]})

Cross-Agent Code Review

Have another model review your agent's code changes:

spawn_agent("claude", "Review these changes for bugs and edge cases", {  files: ["src/api.ts", "src/handler.ts"],  intent: "Code review before merge"})

Multi-Agent Pipeline

Build a pipeline where agents handle different stages:

# Agent 1: Researchspawn_agent("gemini", "Find the best approach for WebSocket reconnection")
# Agent 2: Implementation (using Agent 1's advice)spawn_agent("codex", "Implement WebSocket reconnection with exponential backoff", {  files: ["src/ws-client.ts"]})
# Agent 3: Reviewspawn_agent("claude", "Review this implementation for production readiness", {  files: ["src/ws-client.ts"]})

Bidirectional Collaboration

Agents can ask questions back. The host answers, and work continues:

Host: spawn_agent("codex", "Add caching to the API layer")Codex: [QUESTION] Should I use Redis or in-memory cache?Host: reply("codex-a1b2c3", "Use Redis, we have it in our docker-compose")Codex: [RESULT] Added Redis caching with 5-minute TTL...

Why

AI coding agents get stuck sometimes. Instead of waiting for you, they can ask another agent for help. agent-link-mcp lets any MCP-compatible agent spawn other agent CLIs as collaborators, exchange questions, and get results back — all through standard MCP tools.

  • One-side install — only the host agent needs this MCP server. Spawned agents are just CLI subprocesses.
  • Bidirectional — the host can ask questions to the spawned agent, and the spawned agent can ask questions back.
  • Any agent — works with any CLI that accepts a prompt and returns text. Built-in profiles for Claude, Codex, Gemini, and Aider.
  • Multi-agent — spawn multiple agents simultaneously for parallel collaboration.

Prerequisites

agent-link-mcp spawns other AI agents as CLI subprocesses. You need to install and authenticate the agent CLIs you want to collaborate with:

AgentInstallAuth
Claude Codenpm install -g @anthropic-ai/claude-codeclaude login
Codexnpm install -g @openai/codexcodex login
Gemini CLInpm install -g @google/gemini-cliRun gemini and follow the sign-in prompt
Aiderpip install aider-chatSet OPENAI_API_KEY or ANTHROPIC_API_KEY

You only need the ones you plan to use. agent-link-mcp auto-detects which CLIs are installed.

Install

bash
# Claude Codeclaude mcp add agent-link npx agent-link-mcp
# Codexcodex mcp add agent-link npx agent-link-mcp
# Any MCP clientnpx agent-link-mcp

Note: Only the agent you're working in needs this MCP server installed. The other agents are spawned as subprocesses — they don't need agent-link-mcp.

Tools

spawn_agent

Spawn an agent and send it a task.

json
{  "agent": "codex",  "task": "Refactor this function for better performance",  "context": {    "files": ["src/utils.ts"],    "error": "TypeError: Cannot read property 'x' of undefined",    "intent": "Performance improvement"  },  "model": "o3",  "timeoutMs": 7200000}
ParameterTypeDefaultDescription
agentstringrequiredAgent name ("claude", "codex", "gemini", "aider")
taskstringrequiredTask description
contextobject—Optional { files, error, intent, diff }. diff: true includes git diff output. diff: "staged" for staged only.
cwdstringcwdWorking directory for the agent process
modelstring—Model to use (e.g. "o3", "gpt-5.4", "claude-sonnet-4", "gemini-2.5-pro"). Passed via --model flag.
thinkingstring—Thinking/reasoning depth; supported values depend on the selected CLI and model. Claude: --effort, Codex: -c model_reasoning_effort, Aider: --reasoning-effort.
retrybooleanfalseAuto-retry on failure (up to 3 attempts).
escalatebooleanfalseOn retry, automatically increase thinking level. Requires retry: true.
timeoutMsnumber3600000Timeout in ms. Default: 1 hour.

Returns one of:

  • { status: "done", agentId: "codex-a1b2c3", result: "..." } — task completed
  • { status: "waiting_for_reply", agentId: "codex-a1b2c3", question: "..." } — agent needs clarification
  • { error: "...", agentId: "codex-a1b2c3" } — something went wrong

spawn_agents

Run multiple agents in parallel. Returns all results together.

json
{  "agents": [    { "agent": "codex", "task": "Review for bugs", "context": { "diff": true } },    { "agent": "claude", "task": "Review for security", "context": { "diff": true } }  ],  "cwd": "/path/to/project"}

Returns { summary: { total, succeeded, failed, waiting }, results: [...] }.

reply

Answer a spawned agent's question and continue the conversation.

json
{  "agentId": "codex-a1b2c3",  "message": "Yes, you can remove the side effects"}

kill_agent

Abort a running agent session.

json
{  "agentId": "codex-a1b2c3"}

list_agents

List available agent CLIs.

json
{  "agents": [    { "name": "claude", "command": "claude", "source": "auto", "available": true },    { "name": "codex", "command": "codex", "source": "auto", "available": true },    { "name": "gemini", "command": "gemini", "source": "auto", "available": false }  ]}

get_status

Get active agent sessions.

json
{  "sessions": [    { "agentId": "codex-a1b2c3", "agent": "codex", "status": "waiting_for_reply", "startedAt": "..." }  ]}

How It Works

You (using Claude Code)  ↓"Ask Codex to help with this refactoring"  ↓Claude Code → spawn_agent("codex", task, context)  ↓agent-link-mcp server → spawns `codex` CLI as subprocess  ↓Codex processes the task...  ↓Codex: "[QUESTION] Should I remove the side effects?"  ↓agent-link-mcp → parses response → returns to Claude Code  ↓Claude Code → reply("codex-a1b2c3", "Yes, remove them")  ↓agent-link-mcp → re-invokes Codex with accumulated context  ↓Codex: "[RESULT] Refactoring complete. Here's what I changed..."  ↓Claude Code receives the result and continues working

Configuration

Auto-detection

agent-link-mcp automatically detects installed agent CLIs:

AgentCLI Command
Claude Codeclaude
Codexcodex
Geminigemini
Aideraider

Custom agents

Add custom agents via config file at ~/.agent-link/config.json:

json
{  "agents": {    "codex": {      "command": "/usr/local/bin/codex",      "args": ["--full-auto"],      "promptFlag": null,      "outputFormat": "text"    },    "my-local-llm": {      "command": "ollama",      "args": ["run", "codellama"],      "promptFlag": null,      "outputFormat": "text"    }  }}

Override config path with AGENT_LINK_CONFIG environment variable.

Model Selection

You can specify which model the spawned agent should use via the model parameter:

# Use a specific model for Codexspawn_agent("codex", "Debug this issue", { model: "o3" })
# Use a specific model for Claudespawn_agent("claude", "Review this code", { model: "claude-sonnet-4" })

The model name is passed to the agent CLI via its --model flag. If omitted, the agent uses its default model.

Thinking / Reasoning Depth

Control how deeply the agent reasons with the thinking parameter:

# High reasoning for complex debuggingspawn_agent("codex", "Debug this race condition", { thinking: "high" })
# Max effort for Claudespawn_agent("claude", "Architect a new auth system", { thinking: "max" })
AgentFlagValues
Claude--effortlow, medium, high, max
Codex-c model_reasoning_effortModel-dependent, e.g. low, medium, high, xhigh
Aider--reasoning-effortlow, medium, high

If omitted, the agent uses its default reasoning level.

Timeout

Default timeout is 1 hour (3,600,000ms). You can override per-call:

# 2 hour timeout for complex tasksspawn_agent("codex", "Refactor the entire auth system", { timeoutMs: 7200000 })

Conversation Protocol

Spawned agents receive instructions to format their responses:

  • [QUESTION] ... — needs clarification from the host agent
  • [RESULT] ... — task completed

If the agent doesn't follow the format, the entire output is treated as a result.

License

MIT

来源:README.md,提交 2ea9ef5

工具

0
工具元数据尚未被收录。

版本历史

1
  1. v0.5.1最新Oct 8, 2026