Agent MCP Federation
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 MCP Federation
A starter repository for self-hosted MCP servers that let agents hand off tasks and exchange replies. Each operator configures the agents they trust. Peers connect directly over HTTPS and identify their skills through an agent card.
The local agent uses MCP over stdio. Its server uses MCP Streamable HTTP to send a task to a peer. The receiver stores the task in SQLite, and its agent reads the inbox and replies. Use the same threadId for follow-up tasks. MCP transport specification
Alice agent ── stdio ── Alice MCP ── HTTPS/MCP ── Bob MCP ── stdio ── Bob agent
│
SQLite inboxRun the two-agent demo
Requires Node.js 24.2+ and npm.
npm ci
npm run check
npm testThe integration test starts two local MCP listeners and two stdio MCP processes. They exchange tasks in both directions in one thread and recover a reply after the receiver listener restarts. The test also checks retries, conflicting IDs, peer isolation and missing credentials. It uses temporary databases and local HTTP.
Related MCP server: Durebak
Deploy on Cloudflare Workers
Each deployment has an agent card, a peer list and a D1 inbox. The included Wrangler config uses a placeholder database ID. Copy it to wrangler.agent.local.jsonc and set the Worker name, vars.FEDERATION_CONFIG, and the D1 name and ID. Keep the D1 binding named DB. FEDERATION_CONFIG has the same agent and peers fields as the Node.js config. Peer URLs must use HTTPS.
npm ci
npx wrangler login
npx wrangler d1 create agent-mcp-inboxCopy the database ID from Wrangler into your local config. Use a separate database per agent. Set the secret names in secrets.required to include OWNER_TOKEN and the token names referenced by your peer configuration. Put the values in a private JSON file outside the repository. Use a random base64url token for each owner and direction as described below. An owner token grants all six agent tools, including access to the inbox and the ability to send tasks.
npx wrangler d1 migrations apply DB --remote --config wrangler.agent.local.jsonc
npm run deploy:worker -- --config wrangler.agent.local.jsonc --secrets-file /path/to/private-secrets.jsonEndpoint | Credential | Tools |
| Incoming token issued to this peer |
|
|
| All six agent tools listed below |
Use the Worker's https://…workers.dev URL or a custom domain. Both routes accept MCP Streamable HTTP with bearer authentication. Peers send tasks to the configured /mcp URL. The operator's agent uses /agent/mcp and supplies the owner token through an environment variable.
codex mcp add federation --url https://YOUR-WORKER.workers.dev/agent/mcp --bearer-token-env-var FEDERATION_OWNER_TOKENSet FEDERATION_OWNER_TOKEN in the environment that starts Codex. Each peer keeps using the same agent-mcp-federation/1 wire protocol, including peers running the Node.js version.
To verify two live deployments, set MCP_ALPHA_URL, MCP_BETA_URL, MCP_ALPHA_OWNER_TOKEN, and MCP_BETA_OWNER_TOKEN and run npm run smoke:workers. The script sends synthetic tasks in both directions using a single thread, checks retries and reads each stored reply. Set MCP_ALPHA_ID and MCP_BETA_ID if the configured agent IDs differ from alpha and beta.
Publish on your own host
Use this repository as a GitHub template, or clone it to your server. Run
npm ci.Copy config.example.json to
config.json. Set a unique localagent.id, describe its skills, and add each peer's ID and HTTPS MCP URL.Generate two independent tokens per pair. Alice sends with
ALICE_TO_BOBand receives withBOB_TO_ALICE. Bob sets those names in reverse in his peer configuration. Exchange the values over a private channel. Keep the token values in a private environment file or in your service's secret store.node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))"Run the peer listener. Keep the SQLite file on persistent local storage in a directory writable only by the service account. A relative database path resolves from the config file's directory.
node --env-file=/etc/agent-mcp/peer.env src/index.ts serve /etc/agent-mcp/config.jsonPoint DNS at the host and put the listener behind your HTTPS reverse proxy. This Caddy example serves just the peer endpoint. The default Node listener is on
127.0.0.1:8787.alice.example.net { @peer path /mcp reverse_proxy @peer 127.0.0.1:8787 respond 404 }Share your endpoint and agent ID with peers. Add their mirrored configuration to authorize the connection. Use
get_peer_cardfrom your local agent to verify the connection.
Connect a local MCP client
Configure your client's stdio server to launch Node with the same config and secret environment as the peer listener. The two processes share the inbox file on the same host. A Codex configuration looks like this:
[mcp_servers.federation]
command = "node"
args = ["--env-file=/etc/agent-mcp/peer.env", "/opt/agent-mcp-federation/src/index.ts", "agent", "/etc/agent-mcp/config.json"]For local development, the equivalents are npm run serve -- config.json and node src/index.ts agent config.json, with the required token environment variables already set. Use Node directly as the stdio command so stdout contains only MCP messages.
Local tool | Use |
| List configured peer IDs. |
| Read a peer's declared skills. |
| Send a message to a peer and get its task and thread IDs. |
| Read pending work or page through inbound thread history. |
| Save the reply to an inbound task. |
| Poll the receiver for the reply to a sent task. |
Example handoff. Ask Alice to look up Bob's skills and send him a short review request. Bob's agent checks list_inbox, completes the review within its local permissions, and calls reply_task with the sender and task IDs. Alice polls get_task_result and uses the returned threadId with a new task ID if she needs a follow-up. An agent can consult multiple configured peers by repeating this workflow.
Interoperate with another implementation
The peer endpoint exposes these tools using MCP structuredContent. Authenticate each request with the bearer token the receiving operator configured for the sender.
Peer tool | Input | Result |
| Empty object |
|
|
|
|
|
|
|
The card's protocol is agent-mcp-federation/1. Task and thread IDs are UUIDs. Messages and replies are 1 to 4,000 characters after trimming. A result is pending or replied, and contains reply only when the receiver has answered. An identical resend returns the existing result. Reusing an ID for a different message or thread fails. If using your own client, generate and persist both IDs before sending, so a lost response can be retried safely. Tool errors use MCP isError and structuredContent.error.
Operating model
Start with trusted peers. Each receiver maps a directional token to one peer and scopes task lookup to that sender. The public HTTPS endpoint exposes the three peer tools. Local inbox access and replies are available over stdio.
Your agent or scheduler chooses when to check the inbox and what to do with messages. Treat peer content as external input and keep approval for side effects with the local operator.
The listener stores message and reply text in SQLite. Back up the database and set a retention policy appropriate for your data. This starter keeps completed tasks for replay and caps each peer at 100 pending tasks.
Each installation has a static list of peers. Exchange endpoint URLs directly with other operators. Use
allowLoopbackHttp: trueonly for local tests.
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
Headless task management for bots, apps and AI agents. Remote MCP server, OAuth or access token.
Remote MCP server for The Colony — a social network for AI agents (posts, DMs, search, marketplace).
Hosted MCP server for task-first delegation to remote workstations and workers.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables coding agents in different editors and MCP clients to share messages, project context, notes, task ownership, handoffs, and advisory file claims through a local SQLite-backed coordination server. Supports MCP stdio, MCP Streamable HTTP, a JSON HTTP API, and a local CLI for multi-project agent collaboration.MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding-agent sessions on the same machine to collaborate locally and durably by exchanging requests, replies, and task results through an authenticated loopback server with SQLite-backed storage, joined via CLI or an MCP stdio bridge. It also handles message delivery by priority and wait time, deduplicates idempotent sends, enforces task versioning, and preserves artifacts by content hash.12 npmApache 2.0
- AlicenseBqualityBmaintenanceEnables MCP-capable coding agents to discover peers, send messages, and read inboxes through a small self-hosted relay on your LAN or VPN, including role-based fan-out to teams. Incoming messages can wake idle agent sessions so one agent can hand work to another and get the result back without human typing.7252 npm10Apache 2.0
- AlicenseAqualityBmaintenanceEnables two coding agents to exchange tasks, results and bounded goal-driven conversations through a shared local SQLite database over MCP stdio, with atomic claims, expiring leases and optional headless dispatch. It keeps everything local, using no network service and payload-safe diagnostics.8MIT