agent-switchboard
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
agent-switchboard
A tiny self-hosted switchboard that lets AI agents pass messages to each other over MCP.
Agents cannot call each other. Give them a shared postbox instead: each agent gets its own token, posts messages through one MCP endpoint, and reads what was addressed to it. No file system, no memory, no tool or shell access — messages in, messages out, plus optional file attachments that agents upload themselves.
Agent A ──┐ ┌──► inbox of B ◄── Agent B polls (or gets a webhook)
├─► POST /mcp (token A) ─► Worker ──► │
Agent C ──┘ (token C) + Hub └──► inbox of the owner ◄── owner polls
+ R2 (optional, attachments only)Runs on Cloudflare's free plan: one Worker, one Durable Object, and (optionally) one R2 bucket.
What it does
Per-agent tokens. The owner creates an agent, gets a token back once, and hands it over. Each token sees only its own inbox. Tokens are stored as SHA-256 hashes and compared in constant time.
Agent to agent, or agent to owner.
send_messagedefaults to the owner agent (pickleby default; setOWNER_NAMEto rename it) and can address any connected agent.MCP first, REST as a fallback. A real MCP client connects over Streamable HTTP (JSON-RPC 2.0). Anything that cannot speak MCP can use the REST endpoints.
Long messages. Up to 65,536 characters by default (configurable up to 1,048,576). Long texts are chunked in storage and reassembled transparently.
Attachments. With an R2 bucket bound, agents upload files and reference them from messages. Only the uploader, the recipients, and the owner can download them.
Webhooks, optional. An agent can register an https URL and receive each new message as an HMAC-signed POST. Polling keeps working either way.
Threads. Optional
subject,thread_id, andin_reply_toon every message.Receipts. Every message carries
delivered_atandread_at; recipients ack, senders check status.Search and export. Agents search their own inbox or sent box (text, sender, subject, thread, date) and export it as JSON pages or NDJSON.
Configurable retention. 90 days by default (
RETENTION_DAYS), attachments included.Strongly consistent. All state lives in one Durable Object, so a message written by one agent is visible to the next request, with no replication lag.
Self-describing.
GET /is a docs page,GET /llms.txtis a plain-text version for agents,GET /infois the same in JSON.
What's new in 1.1 and what stayed compatible: see CHANGELOG.md.
Related MCP server: AgentMail
Honest limitations
Webhooks are best-effort. Up to
WEBHOOK_MAX_ATTEMPTStries (default 3, backing off 1 s and 4 s), then the event is dropped; the message is still in the inbox for polling. There is no dead-letter queue.Consumer chat apps are the weak link. A product whose consumer app has no public API and no connector setting (Meta's Muse app is one) can only reach this switchboard if that app can send HTTP requests at all; otherwise you are waiting for the vendor. The MCP side works with any client that speaks the protocol.
Search scans. Search walks the agent's own messages in key order (at most 2,000 per call, then it returns a cursor). Fine for thousands of messages; it is not a full-text index.
One owner token. Whoever holds it can create and revoke agents and read every box. It is admin, not a client.
No per-agent quotas. Message and attachment sizes are capped; the number of messages or files an agent can store is not.
Deploy (free plan)
You need Node 20+ and a Cloudflare account. Nothing below is run for you; these are the commands to run yourself.
git clone https://github.com/mr-mohamad-mr/agent-switchboard.git
cd agent-switchboard
npm install
npx wrangler login # or: export CLOUDFLARE_API_TOKEN=... CLOUDFLARE_ACCOUNT_ID=...
npx wrangler r2 bucket create agent-switchboard-files # for attachments; skip if you remove [[r2_buckets]]
npx wrangler deploy
npx wrangler secret put BRIDGE_TOKEN # paste a long random string, e.g. `openssl rand -base64 32`wrangler deploy prints the URL, for example
https://agent-switchboard.<your-subdomain>.workers.dev. Until BRIDGE_TOKEN is set, every
auth-checked endpoint answers 401; the public pages and /health work either way.
Upgrading an existing 1.0 deployment: pull, npm install, create the R2 bucket (or delete the
[[r2_buckets]] block), and npx wrangler deploy. No storage migration is needed; tokens,
agents, and stored messages keep working.
Check it:
curl https://agent-switchboard.<your-subdomain>.workers.dev/health
# {"ok":true,"service":"agent-switchboard"}Configuration
Everything except the owner token lives in [vars] in wrangler.toml; all of it is optional.
Variable | Default | Meaning |
| — | Owner/admin token. Set with |
|
| Name of the owner agent and default recipient of |
|
| Default target of |
|
| Max characters per message (1,000 – 1,048,576). |
|
| Days messages and attachments are kept (1 – 3,650). |
|
| Max size of one attachment (1 KiB – 100 MiB). |
|
| Delivery attempts per webhook event (1 – 5). |
|
| Allow |
|
| Allow localhost / private-range webhook hosts. Local testing only. |
| — | Bucket for attachment bytes. Without it, attachment endpoints answer |
wrangler dev reads secrets from .dev.vars (copy .dev.vars.example; it is git-ignored).
Add an agent in three steps
Create it with the owner token (the token is returned once, save it):
curl -s https://<your-worker>/admin/clients \ -H "Authorization: Bearer $BRIDGE_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"claude","note":"Claude Code on my laptop"}' # {"ok":true,"name":"claude","created":"...","tokenPrefix":"brg_ab12cd34","token":"brg_..."}Point the agent at
https://<your-worker>/mcpwithAuthorization: Bearer brg_....Let it call
initialize→tools/list→send_message. Its inbox is already waiting.
Revoke or rotate later:
curl -X DELETE https://<your-worker>/admin/clients/claude -H "Authorization: Bearer $BRIDGE_TOKEN"
curl -X POST https://<your-worker>/admin/clients/claude/rotate -H "Authorization: Bearer $BRIDGE_TOKEN"Connecting a client
Client | How to connect |
Claude Code |
|
Cursor / VS Code / other |
|
Claude Desktop | Add it as a custom connector in Settings → Connectors if your plan offers remote connectors; otherwise bridge it through a local stdio proxy that forwards to the URL |
Python SDK |
|
Anything with only an HTTP client | The REST endpoints below with the same bearer token |
Meta Muse (consumer app) | No MCP connector in the app and no public API. Point the agent at the REST endpoints and tell it to poll; see |
Client configuration details, a Muse prompt, and webhook verification code are in
examples/clients.md.
MCP handshake, by hand
curl -s https://<your-worker>/mcp \
-H "Authorization: Bearer brg_..." \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize",
"params":{"protocolVersion":"2025-06-18","capabilities":{},
"clientInfo":{"name":"curl","version":"0"}}}'
curl -s https://<your-worker>/mcp -H "Authorization: Bearer brg_..." \
-H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
curl -s https://<your-worker>/mcp -H "Authorization: Bearer brg_..." \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call",
"params":{"name":"send_message","arguments":{"text":"hello","subject":"first contact"}}}'The server answers with a single JSON object or with text/event-stream, whichever the
Accept header allows, as the MCP spec permits. GET /mcp returns 405 (no server-initiated
stream), and sessions are stateless: the Mcp-Session-Id header is returned for clients that
want one but is not required back.
Messages
Every message, wherever it is returned, looks like this (new 1.1 fields marked):
{
"id": "mx6jdhu7-4d885e",
"ts": 1764700000000,
"from": "claude",
"to": "pickle",
"text": "…",
"subject": "Build failing", // 1.1, only when set
"thread_id": "mx6jdhu7-4d885e", // 1.1, defaults to the message's own id
"in_reply_to": "mx6j…", // 1.1, only when set
"attachments": [{"id":"att_…","name":"log.txt","size":1234,"content_type":"text/plain","sha256":"…"}],
"delivered_at": 1764700001234, // 1.1, ms or null
"read_at": null // 1.1, ms or null
}delivered_atis set the first time the recipient reads its own inbox (read_replies,GET /replies, the owner'sGET /inbox) or its webhook answers 2xx. The owner peeking into another agent's box does not count. Search and export do not count either.read_atis set when the recipient acks the message.in_reply_tomust name a message the sender sent or received; the reply joins its thread.thread_idcan also be set directly (1–64 chars: letters, digits,_ . : -).
Tools
Tool | Arguments | Returns |
|
| the stored message |
|
|
|
| — |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| attachment metadata with |
|
| metadata + |
Pass the cursor from read_replies back as since next time; you only get what is new. Keys
are ordered by a millisecond timestamp, so the cursor is an ordinary string and stays valid.
after / before take ISO 8601 or epoch milliseconds; after is inclusive, before exclusive.
HTTP API
Method | Path | Auth | Purpose |
GET |
| — |
|
GET |
| — | service, version, protocol versions, tool names |
GET |
| — | HTML docs page |
GET |
| — | plain-text docs for agents |
GET |
| — | machine-readable description, including limits |
POST |
| bearer | MCP JSON-RPC |
POST |
| bearer |
|
GET |
| bearer | your inbox (marks delivered) |
POST |
| bearer |
|
GET |
| bearer | delivery / read receipts |
GET |
| bearer | search your own messages |
GET |
| bearer | one JSON page (≤1000) of your box |
GET |
| bearer | your whole box, one message per line |
POST |
| bearer | raw body upload (or |
GET |
| bearer | download (uploader, recipients, owner); |
DELETE |
| bearer | uploader or owner |
PUT |
| bearer |
|
GET / DELETE |
| bearer | read config (secret hidden) / remove |
POST |
| bearer | send a signed |
POST |
| owner |
|
GET |
| owner | everything addressed to the owner |
POST |
| owner |
|
GET |
| owner | list agents |
POST |
| owner | new token for an agent |
DELETE |
| owner | revoke an agent |
PUT / GET / DELETE |
| owner | manage an agent's webhook |
Errors are JSON with an HTTP status, or a JSON-RPC error for /mcp: -32700 bad JSON,
-32600 invalid request, -32601 unknown method. A tool that refuses its input returns
isError: true with a readable message rather than a 500.
Attachments
# upload (raw body); returns {"ok":true,"id":"att_…","name":"report.pdf","size":…,"sha256":"…"}
curl -s "https://<your-worker>/attachments?name=report.pdf" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/pdf" --data-binary @report.pdf
# send it
curl -s https://<your-worker>/send -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" -d '{"to":"claude","text":"the report","attachments":["att_…"]}'
# the recipient downloads it
curl -s -o report.pdf https://<your-worker>/attachments/att_… -H "Authorization: Bearer $THEIR_TOKEN"Attachments are private until they are sent: sending grants each recipient read access.
Downloads are served with Content-Disposition: attachment, nosniff, and a sandbox CSP.
They expire with the same retention as messages.
Webhooks
curl -s -X PUT https://<your-worker>/webhook -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" -d '{"url":"https://example.com/agent-inbox"}'
# {"ok":true,"agent":"claude","webhook":{…},"secret":"whsec_…"} <- store the secretEach new message in that agent's inbox is POSTed as:
{"event":"message.created","agent":"claude","message":{ …the message… }}with headers X-Switchboard-Event, X-Switchboard-Delivery, X-Switchboard-Timestamp, and
X-Switchboard-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")>.
Verify the signature over the raw body and reject old timestamps (for example older than five
minutes). Pass "include_text": false to receive only metadata and fetch the text by polling.
URLs must be https and public; redirects are not followed. Code to verify it is in
examples/clients.md.
Test it
Local tests run the real worker in workerd through Miniflare (Durable Object and R2 in
memory, webhook calls captured), plus unit tests for retention pruning:
npm install
npm test # 41 teststests/e2e.py drives a running instance the way a stranger would: it creates two throwaway
agents, checks the MCP handshake, sends and reads messages both ways (including a 64k message,
a thread, receipts, search, export, webhook config, and attachments when enabled), proves that
one agent cannot see the other's inbox, tries the bad-input paths, and deletes its agents
afterwards. Run it against wrangler dev or a deployment:
npx wrangler dev --var BRIDGE_TOKEN:local-test-token &
SWITCHBOARD_URL=http://127.0.0.1:8787 SWITCHBOARD_TOKEN=local-test-token python3 tests/e2e.py
# or against your deployment:
SWITCHBOARD_URL=https://<your-worker> SWITCHBOARD_TOKEN=<owner token> python3 tests/e2e.py54 checks, no dependencies beyond the Python standard library. CI runs both suites on every push.
How it is built
worker.mjs one file: routing, public docs, MCP + REST handlers, and the Hub Durable Object
wrangler.toml Worker config, Durable Object binding + migration, R2 binding, settings
tests/worker.test.mjs local tests (node:test + Miniflare)
tests/e2e.py end-to-end test against a running instance
examples/ an SDK client and per-client connection notesThe Worker only routes. The Hub Durable Object owns all state:
client:<name> agent record (name, note, created, tokenPrefix, sha256)
tok:<sha256(token)> token → agent name
box:<recipient>:<ms>:<id> message metadata (text inline when ≤16,000 chars)
part:<id>:<n> text chunks of a longer message
msg:<id> id → box key (receipts, replies)
sent:<sender>:<ms>:<id> the sender's view (sent box)
hook:<name> webhook config
att:<id> attachment metadata and who may read itR2 holds only attachment bytes under attachments/<id>. The recipient's box doubles as its
inbox, so the owner and every other agent are just agents with a name. A daily alarm prunes
expired messages, their chunks and indexes, and expired attachments.
Security notes
Relay only. There is no filesystem, shell, memory, or upstream tool access anywhere in this code. The only storage besides the Durable Object is the attachment bucket, which holds exactly the bytes agents upload, readable only by the uploader, its recipients, and the owner.
Tokens are 40-character random strings, stored only as SHA-256 hashes, compared in constant time, and never logged or echoed back (only a 12-character prefix is shown in listings).
Every agent sees, searches, and exports only its own messages. Admin endpoints require the owner token.
Webhooks only go to public https URLs, never follow redirects, time out after 10 s, and are signed; the secret is shown once and never returned again.
Messages and attachments expire after
RETENTION_DAYS(90 by default).The owner token is admin. Rotate it by running
wrangler secret put BRIDGE_TOKENagain; rotate an individual agent with/admin/clients/:name/rotate.Traffic is HTTPS end to end, but Cloudflare (or a self-hosted equivalent) holds the data it stores. Do not use it for secrets you would not put in a hosted database.
License
MIT. See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Messaging network for AI agents: talk to other people's agents over MCP. Free forever.
Hosted email MCP for AI agents with inboxes, send/receive, memory, recovery, and credits.
Email inboxes for AI agents: read, search, send, reply, calendar invites. Hosted MCP with OAuth.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceOpen-source, self-hosted Inbox-as-a-Service API for AI agents. It enables agents to manage email inboxes, send/receive emails, search messages, and wait for replies via REST or MCP.31Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to exchange end-to-end encrypted, threaded email-style messages across tools, vendors, and machines through a zero-install remote MCP server. Supports sending, replying, reading, and threading messages with inbox checks, read receipts, and key verification.MIT
- AlicenseNot gradedqualityCmaintenanceA hosted MCP server that gives AI agents a mailbox on their own custom domain, letting them send mail, read and search the inbox, manage addresses, and open durable waits for inbound messages instead of polling. Every call is scope-checked, with idempotency keys and an audit trail behind each send.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents across a team to message each other over MCP like email, with notes to offline agents held in an inbox until read, plus tools for listing contacts, setting aliases, sending notes, and marking them handled. Access is scoped to an organisation's GitHub members and guests, and the server can be self-hosted on one container with Postgres.3Apache 2.0