agent-mesh
Provides a messaging multiplexer for agents using Redis streams, allowing Claude Code to send, receive, and ping other agents through MCP tools.
README
agent-mesh
Project-agnostic inter-agent messaging multiplexer via Redis Streams, with an MCP server for Claude Code integration. Any number of agents can send, receive, and ping each other over a shared Redis instance — no direct agent-to-agent connections required.
One-shot setup on a new machine
Open Claude Code and paste the prompt from SETUP_PROMPT.md.
Claude will install agent-mesh, start Redis, configure the MCP server, and patch your ~/.claude/CLAUDE.md — no manual steps.
Quick start
# Start Redis
docker-compose up -d
# Install (editable)
pip install -e .
# Verify
agent-mesh who
CLI usage
# Send a message (appears on group stream + private stream of target)
agent-mesh send cortex "hello from watchdog" --from watchdog
# Send privately (only private stream of target, no group echo)
agent-mesh send cortex "private note" --from watchdog --private
# Send and track reply expectation in pending ledger
agent-mesh send cortex "please respond" --from watchdog --expect-reply --within 120
# Listen (blocks up to --timeout seconds, default 60, returns on first DIRECT message)
agent-mesh listen watchdog --timeout 30
# Persistent monitor daemon (singleton via flock)
agent-mesh monitor watchdog
# Ping
agent-mesh ping cortex --from watchdog
# Request/reply roundtrip
agent-mesh request cortex "what time is it?" --from watchdog
# (on cortex side) agent-mesh reply mesh:reply:<nonce> "it is noon" --from cortex
# Registry
agent-mesh register cortex --role "main implementer"
agent-mesh who
# Pending ledger
agent-mesh pending watchdog
MCP server setup
stdio mode (default — recommended for Claude Code)
Add to your Claude Code MCP config (e.g. .claude/settings.json):
{
"mcpServers": {
"agent-mesh": {
"command": "agent-mesh",
"args": ["serve"],
"env": {
"AGENT_MESH_REDIS_URL": "redis://localhost:6379/0"
}
}
}
}
HTTP/SSE mode
agent-mesh serve --http --port 8765
Add to MCP config:
{
"mcpServers": {
"agent-mesh": {
"url": "http://localhost:8765/sse"
}
}
}
Available MCP tools
| Tool | Description |
|---|---|
mesh_send |
Send a message to an agent |
mesh_ping |
Ping an agent and measure latency |
mesh_who |
List all registered agents |
mesh_register |
Register an agent in the registry |
mesh_listen_once |
Wait for one message on a private stream |
mesh_request |
Send a request and wait for a reply |
mesh_pending |
List pending reply-expected entries |
Architecture
Streams layout
mesh:group — broadcast; all agents see all messages
mesh:to_<name> — private stream per agent
mesh:pong:<nonce> — ephemeral ping/pong rendezvous
mesh:reply:<nonce> — ephemeral request/reply rendezvous
mesh:gate:audit — rate gate audit log
All streams are capped at 2000 entries (approximate MAXLEN).
Registry
Agents self-register via agent-mesh register <name> or mesh_register MCP tool. Each entry is a Redis key mesh:registry:<name> with a 180s TTL — the monitor daemon renews the lease on each listen iteration. agent-mesh who scans all registry keys and prints live agents.
Rate gate
A fixed-window counter (mesh:gate:rate:<sender>-><target>) limits sends to AGENT_MESH_GATE_LIMIT per 10s window. In observe mode (default) over-limit sends are logged to the audit stream but still delivered. Set AGENT_MESH_GATE_ENFORCE=1 to hard-deny.
Notify log + harness monitor integration
Every DIRECT message received by do_listen is appended to ~/.cache/agent-mesh/notify-<name>.log. The Claude Code harness Monitor tool can watch this file as a waker — add a persistent Monitor on the notify log in your agent's Session-Init to wake the agent on incoming messages without polling.
Pending ledger
--expect-reply sends append an entry to ~/.cache/agent-mesh/pending-<sender>.jsonl. The monitor loop calls check_overdue on each idle iteration: overdue entries trigger exponential re-pings (30/60/120/240s backoff) and escalation to watchdog after 4 tries.
Config env vars
| Variable | Default | Description |
|---|---|---|
AGENT_MESH_REDIS_URL |
redis://localhost:6379/0 |
Redis connection URL |
AGENT_MESH_PREFIX |
mesh |
Stream key prefix |
AGENT_MESH_GATE_ENFORCE |
0 |
Set to 1 to hard-deny over-rate sends |
AGENT_MESH_GATE_LIMIT |
40 |
Max sends per sender→target per 10s window |
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。