mcp-agent-bridge

mcp-agent-bridge

A local MCP server that provides shared, real-time context across multiple AI agents via WebSocket and MCP resource notifications, enabling collaborative workspaces, memory, tasks, and messaging.

Category
访问服务器

README

mcp-agent-bridge

A local MCP server that gives any number of AI agents — Claude Code, OpenCode, Codex, Hermes, OpenClaw, or any MCP-compatible client — a shared, real-time context across windows and sessions.

Every write (memory, message, task, artifact) is instantly pushed to all other connected agents via WebSocket and MCP resource notifications. No polling required.


Features

  • Named contexts — create isolated workspaces (hackathon, my-project, review) and choose which one each agent joins
  • Real-time push — WebSocket + MCP notifications/resources/updated on every state change
  • Any agent type — works with Claude Code, OpenCode, Codex, Hermes, OpenClaw, or anything that speaks MCP
  • Shared memory — key/value store scoped per context
  • Tasks — create, assign, and track tasks across agents
  • Messaging — direct messages and broadcast within a context
  • Artifacts — share code, plans, JSON, markdown between agents
  • Discussions — threaded brainstorm threads per topic
  • Sessions — orchestrated multi-agent collaboration sessions
  • Persistent — all state is written to JSON files and survives restarts

Quick Start

git clone https://github.com/YOUR_USERNAME/mcp-agent-bridge
cd mcp-agent-bridge
npm install
npm start

Server runs on http://localhost:3721.


Client Configuration

Claude Code

Add to ~/.claude.json:

{
  "mcpServers": {
    "agent-bridge": {
      "type": "http",
      "url": "http://localhost:3721/mcp"
    }
  }
}

OpenCode

Add to ~/.config/opencode/opencode.json:

{
  "mcp": {
    "agent-bridge": {
      "type": "remote",
      "url": "http://localhost:3721/mcp",
      "enabled": true
    }
  }
}

Any MCP client (Streamable HTTP)

Endpoint: http://localhost:3721/mcp

Legacy SSE clients

Endpoint: http://localhost:3721/sse

WebSocket (real-time events, no MCP required)

const ws = new WebSocket("ws://localhost:3721/ws");
ws.on("message", (data) => console.log(JSON.parse(data)));

Auto-start (macOS launchd)

Create ~/Library/LaunchAgents/com.mcp-agent-bridge.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.mcp-agent-bridge</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/bin/node</string>
    <string>/path/to/mcp-agent-bridge/server.js</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>StandardOutPath</key>
  <string>/tmp/mcp-agent-bridge.log</string>
  <key>StandardErrorPath</key>
  <string>/tmp/mcp-agent-bridge.log</string>
</dict>
</plist>
launchctl load ~/Library/LaunchAgents/com.mcp-agent-bridge.plist

Usage

1. Register your agent

Always call identify first. Optionally join a context immediately.

identify("claude", session_label="window-2", context="my-project")

2. Create and join contexts

create_context("hackathon", description="Weekend project")
join_context("hackathon")

All subsequent operations (memory, tasks, messages, etc.) are scoped to hackathon.

3. Share memory in real-time

set_memory("stack", "Next.js + Postgres")
get_memory()

Any other agent in the same context receives a notifications/resources/updated push and a WebSocket event instantly.

4. Send messages

send_message("opencode", "DB schema is ready, check artifacts")
read_messages()
broadcast("Starting code review now")

5. Coordinate with tasks

create_task("Write API routes", "Implement /api/notes CRUD", assigned_to="codex")
list_tasks(filter="mine")
update_task("<id>", status="done", notes="All routes covered with tests")

6. Share code and plans

save_artifact("db-schema", "<SQL>", type="code", language="sql")
get_artifact("db-schema")

7. Check context status

list_contexts()       # all workspaces + who's in them
context_status()      # your current context summary
agent_status()        # all agents grouped by context

MCP Tools Reference

Context Management

Tool Description
create_context(name, description?) Create a named workspace
list_contexts() List all contexts with active agents and stats
join_context(name) Switch to a context — all ops become scoped to it
leave_context() Return to default context
delete_context(name, confirm: true) Delete context and all its data
context_status() Show current context, peers, memory/task counts

Identity

Tool Description
identify(agent_name, session_label?, context?) Register this session; optionally join a context

Memory

Tool Description
set_memory(key, value, tags?) Write to shared memory — peers notified instantly
get_memory(key?, tag?) Read one key or list all (optionally filter by tag)
delete_memory(key) Remove a key

Messaging

Tool Description
send_message(to, content, metadata?) Direct message to an agent in context
read_messages(mark_read?, include_read?) Read your inbox
broadcast(content) Send to all agents in context

Tasks

Tool Description
create_task(title, description, assigned_to, priority?) Create and assign a task
list_tasks(filter?) List tasks (all, mine, pending, in_progress, done, blocked)
update_task(id, status?, notes?) Update status or add progress notes

Artifacts

Tool Description
save_artifact(name, content, type, language?, description?) Save code/text for sharing
get_artifact(name) Retrieve an artifact
list_artifacts(type?) List all artifacts

Discussion

Tool Description
add_to_discussion(topic, content) Add to a named thread
get_discussion(topic?) Read a thread or all threads

Session / Orchestration

Tool Description
start_session(goal, context?) Start a collaborative session; peers notified
get_session() Get active session details
end_session(summary?) End the session

Status & Events

Tool Description
agent_status() All connected agents grouped by context
get_events(since?, type?, limit?) Poll event log since a timestamp

MCP Resources

All resources are live — reading them always returns current state. Agents receive notifications/resources/updated when the underlying data changes.

URI Content
agent-bridge://contexts/{context}/memory Shared memory for a context
agent-bridge://contexts/{context}/tasks Tasks for a context
agent-bridge://contexts/{context}/session Active session
agent-bridge://contexts/{context}/discussion Discussion threads
agent-bridge://contexts/{context}/artifacts Shared artifacts
agent-bridge://contexts/{context}/messages/{agent} Agent inbox

WebSocket Protocol

Connect to ws://localhost:3721/ws.

On connect — receive a full state snapshot:

{
  "type": "snapshot",
  "data": {
    "contexts": [{ "name": "default", "active_agents": [], "memory": {}, "tasks": [] }]
  },
  "timestamp": "2026-03-26T..."
}

Events pushed on every mutation:

{ "type": "memory_updated", "context": "hackathon", "data": { "key": "stack", "updated_by": "claude" }, "timestamp": "..." }
{ "type": "message_sent",   "context": "hackathon", "data": { "from": "claude", "to": "opencode" }, "timestamp": "..." }
{ "type": "task_created",   "context": "hackathon", "data": { "title": "...", "assigned_to": "codex" }, "timestamp": "..." }
{ "type": "agent_connected","context": "hackathon", "data": { "agent": "hermes" }, "timestamp": "..." }

Commands you can send:

{ "type": "ping" }
{ "type": "subscribe_events_since", "since": "2026-03-26T10:00:00Z", "context": "hackathon" }

REST API

Endpoint Description
GET /health Server status, all contexts, connected agents
GET /contexts List all contexts with active agents and stats
GET /contexts/:name Context details including memory and tasks

Data Storage

All state is persisted to ./data/:

data/
  contexts_meta.json     — registry of all context names + metadata
  ctx_default.json       — state for the "default" context
  ctx_hackathon.json     — state for the "hackathon" context
  ctx_my-project.json    — ...

Each context file contains memory, tasks, messages, artifacts, session, discussion, and events.


Supported Agent Types

Any MCP client works. Tested with:

  • Claude Code (Anthropic)
  • OpenCode (open source)
  • Codex CLI (OpenAI)

And any client you register via identify("your-agent-name").


License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选