thatch
@brooswit/thatch
一个中心化的 HTTP MCP 服务器,作为 Elysia 插——件提供。许多 Claude Code 会话通过 URL 连接到同一个服务器;服务器按名称对它们进行寻址,并可将消息推送到活动会话中。
import { Elysia } from "elysia";
import { thatch, z } from "@brooswit/thatch";
const { plugin, mcp } = thatch({
identify: (req) => req.headers.get("x-connection-name"), // names the connection; null rejects it
tools: {
status: { description: "Fleet status", input: {}, handler: (_a, c) => `hello ${c.name}` },
},
});
const app = new Elysia().use(plugin).listen(3000);
// push a message into a named session — from anywhere
const d = await mcp.send("epic-kan-39", { content: "PR #296 approved", meta: { key: "KAN-39" } });
// d: { claim: "C2" } — a connected session's stream took it
// { claim: "refused", reason: "not-connected" | "no-channel-stream" | "bad-meta" | "closed-mid-send" }Claude Code 通过以下方式连接:
claude mcp add --transport http fleet http://localhost:3000/mcp --header "x-connection-name: epic-kan-39"为什么投递类型不是 void
向会话推送消息可能会以 MCP SDK 隐藏的方式失败:连接可能在它的通知流尚未接入时就被注册,这种情况下 SDK 会静默丢弃该帧。thatch 会明确地拒绝该情况(no-channel-stream),并且只有在确实存在能承载帧的流时才声明 C2。C3(已进入对话记录)和 C4(模型已阅读)是不可观测的,因此此处的 API 不会声称自己能够获得。
Related MCP server: agent-network
API
thatch(options)→{ plugin, mcp }—plugin挂载端点(默认/mcp);mcp是句柄。options:identify(req),onDuplicate("replace"默认 |"reject")、history(默认 50)、tools、path、serverInfo。mcp.connections:list()、get(name)、has(name)、count()、waitFor(name, { timeoutMs })。mcp.send(name, frame)、mcp.sendMany(names, frame)、mcp.sendAll(frame, { where? })。mcp.on("connect" | "disconnect" | "send", handler)。一个
Connection包含name、connectedAt、lastSeenAt、meta、channelReady和history。import { FakeConnection } from "@brooswit/thatch/testing"用于测试。
层次
protocol(帧、投递、方法——纯)· registry(命名连接 + 历史)· provider(发送、诚实声明)· plugin(Elysia 挂载,每个连接对应一个 MCP 服务器)· testing。
脚本
bun run check # generate load tests + typecheck + unit + load + coverage ≥90%
bun test test/unit
MCP_LIVE=1 bun test test/live # against a real Claude Code session (opt-in)This server cannot be deployed
Maintenance
Related MCP Connectors
Shared memory and mail for your AI agents. Verified with Claude Code; other MCP clients in testing.
Real-time chat for AI agents. Claude Code, Cursor, Cline and Codex join channels over MCP.
Skills, agents and memory in the cloud, plus a gateway to your other MCP servers.
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables networked Claude-to-Claude messaging over HTTP and MCP channels, allowing direct messages, broadcasts, threaded replies, and permission approvals among Claude Code instances.23MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that enables Claude Code to communicate with other Claude Code agents over HTTP, allowing users to ask questions about remote codebases or delegate coding tasks.MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for agent-to-agent communication over NATS with live session push via Claude Code Channels.MIT
- FlicenseNot gradedqualityDmaintenanceMCP server for real-time communication between Claude Code sessions via chat rooms.89 npm-