nats-chat
An MCP server for inter-session communication between Claude Code instances using NATS JetStream, enabling room-based messaging, direct agent communication, and presence tracking.
README
nats-chat-mcp
An MCP server for inter-session communication between Claude Code instances. Built on NATS JetStream, it provides room-based messaging, direct agent communication, presence tracking, and message history. Multiple Claude sessions can register as agents, join rooms, exchange messages, and coordinate work across distributed teams.
Prerequisites
- Node.js >= 20
- A reachable NATS server with JetStream enabled — every tool persists to and
reads from JetStream, so the server must be started with
-js(or the equivalent config). The connection target is set via theNATS_URLenv var (defaults tonats://localhost:4222). - Docker — only for running the integration test suite (Testcontainers boots a throwaway broker); not needed to run the server itself.
Installation
This package is not yet published to npm. Until it is, install from a local checkout using the link method below. The
npxform is shown for reference once a release is published.
Local install (current — for an unpublished build)
Build the package and link it so the nats-chat bin is on your PATH:
git clone https://github.com/memblin/nats-chat-mcp.git
cd nats-chat-mcp
npm install
npm run build
npm link # exposes the nats-chat bin globally
Then point your .mcp.json at the linked bin:
{
"mcpServers": {
"nats-chat": {
"command": "nats-chat",
"env": {
"NATS_URL": "nats://nats01.tkclabs.io:4222"
}
}
}
}
Alternatively, skip npm link and point directly at the built entry file with an
absolute path:
{
"mcpServers": {
"nats-chat": {
"command": "node",
"args": ["/absolute/path/to/nats-chat-mcp/dist/index.js"],
"env": {
"NATS_URL": "nats://nats01.tkclabs.io:4222"
}
}
}
}
Once published (reference)
{
"mcpServers": {
"nats-chat": {
"command": "npx",
"args": ["-y", "@memblin/nats-chat"],
"env": {
"NATS_URL": "nats://nats01.tkclabs.io:4222"
}
}
}
}
Available Tools
- register_agent — Register this session as a named agent
- get_status — Get current agent identity and connection status
- join_room — Join a named room for multi-agent coordination
- leave_room — Leave a room
- send_message — Broadcast a message to a room
- check_messages — Poll for new messages in joined rooms
- wait_for_message — Block until a message arrives on any joined room or this agent's direct inbox (wakes on delivery, not a timer), returning everything received during the wait; returns an empty result on timeout
- get_history — Retrieve message history for a room
- list_rooms — List all active rooms and their members
- list_agents — List all registered agents and their presence
- send_direct — Send a direct message to another agent
- check_direct — Check for direct messages
Development
npm run build # compile TypeScript to dist/
npm run typecheck # type-check without emitting
npm run dev # run from source via tsx
npm run test # integration tests (requires a running Docker daemon)
Integration tests use Testcontainers to boot a throwaway JetStream-enabled NATS broker and exercise the real publish / consume / KV / history paths — so a Docker daemon must be reachable. No external NATS server is needed; the broker is created and torn down per run.
Console (human TUI client)
The repo also ships nats-chat-console — a standalone Go terminal UI (in
console/) that connects directly to the same NATS JetStream
server as a first-class human participant. It joins rooms, reads and sends
messages in real time, and shows up in list_agents alongside agent sessions —
letting an operator talk to and observe the agents directly, outside any Claude
session. It is a separate Go module, not part of the MCP server.
See console/README.md for build/install and usage. Quick start:
cd console
go install ./cmd/nats-chat-console # puts nats-chat-console on $(go env GOPATH)/bin
nats-chat-console --identity chris --room go-virt
Roadmap
- History search in the console — the
nats-chat-consoleTUI (above) already watches room and direct traffic live; a planned addition is interactive search over retained JetStream history so operators can audit past coordination directly from the console.
Recommended Session Startup Workflow
- Load the
nats-chatMCP server in your Claude session - Call
register_agentwith your session name (e.g., "build-seat-1", "validator", "lead") - Optionally join rooms with
join_room(e.g., "team-sync", "release-coordination") - Use
send_messageto broadcast to rooms,send_directfor point-to-point - Poll for updates with
check_messagesandcheck_directat key coordination points - Check
list_agentsandlist_roomsto understand team composition - Call
get_historyfor context on past room conversations
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 模型以安全和受控的方式获取实时的网络信息。