# Quickstart — Run local Medusa Hub
npx medusa-mcp startModern AI development agents (e.g., Cursor, Windsurf, Claude Desktop, TangleClaw) are highly effective inside a single repository but remain entirely isolated from each other. When a project spans multiple microservices, repositories, or environments:
- Context Fragmentation: AIs are blind to changes, schemas, or errors occurring in adjacent workspaces.
- Manual Routing: Developers become "human routers," copy-pasting code fragments, error logs, and state updates between separate AI sessions.
- Consensus Debt: Redundant tasks or multi-repo builds cannot be coordinated or validated collectively.
Medusa is a decentralized workspace coordination and communication layer built on top of the Model Context Protocol (MCP) and WebSockets. It bridges independent IDEs, CLI tools, and background processes, allowing AI agents to coordinate, share context, and delegate tasks autonomously.
Medusa operates in two concurrent tiers:
- The Bridge Layer (Node.js Hub): Runs a local WebSocket server (port
3101) and HTTP server (port3009) allowing IDE listeners and custom clients to register, send direct/broadcast messages, and receive real-time updates. - The Swarm Layer (Python A2A Mesh): A decentralized mesh of A2A nodes (port
3200+) communicating via a secure gossip consensus mesh to replicate task ledgers, manage auctions, and share learned project constraints.
The power of Medusa is best demonstrated by how the TangleClaw ecosystem natively integrates it to achieve true autonomous swarm behavior:
- Cross-Workspace Code Review: TangleClaw instances working in separate repositories can inspect each other's code. For example, a
PrawductStewardagent in one session can analyze a commit made by a peer in theMedusaworkspace, identify an architectural flaw, and send a highly detailed, asynchronous bug report over the Medusa mesh without stepping on the active branch or interrupting the user. - Global Roadmap Synchronization: When a TangleClaw session completes a major feature "Train", it broadcasts a
shared_doc_updatedevent for theROADMAP_STATE.mdfile via Medusa. All other active sessions instantly receive the payload, fetch the updated roadmap, and align their context to the new state. - Non-Destructive Terminal Peeking: Using Medusa's
/peekAPI, a frontend TangleClaw agent can remotely peek into a backend agent's activetmuxpane. This allows the frontend agent to pause its own execution until it confirms the backend server has finished compiling and is actively listening for requests.
flowchart TD
subgraph Workspaces [IDE Workspace Layer]
TC[TangleClaw Workspace] <-->|WS / HTTP API| Hub
M[Medusa Workspace] <-->|WS / HTTP API| Hub
end
subgraph Hub [Medusa Hub - Node.js Server]
HTTP[HTTP API :3009]
WS[WebSocket Server :3101]
Queue[Store-and-Forward Inbox]
end
subgraph Mesh [A2A Swarm Layer - Python Mesh]
A2A_3200[A2A Node 1 :3200] <-->|Gossip Protocol| A2A_3202[A2A Node 2 :3202]
A2A_3200 <-->|SQLite Sync| DB1[(Ledger Database)]
A2A_3202 <-->|SQLite Sync| DB2[(Ledger Database)]
end
Hub <-->|HMAC Signed API| A2A_3200
Medusa enforces cryptographic signatures for all API calls. Set a secure A2A_SECRET in your shell profile:
export A2A_SECRET="your-secure-random-secret-string"Important
The server and CLI commands will fail closed on startup if A2A_SECRET is unset or blank.
Start the local coordination Hub and its primary A2A Swarm Node:
node bin/medusa.js medusa startThis launches:
- Protocol API:
http://localhost:3009 - Dashboard:
http://localhost:8181 - WebSocket Server:
ws://localhost:3101 - Primary A2A Node:
http://localhost:3200
Direct messages are routed in real-time to active WebSocket workspaces. If the recipient is registered but currently offline, the message is queued in the Hub's store-and-forward inbox.
curl -X POST -H "Content-Type: application/json" \
-H "X-Medusa-Secret: $A2A_SECRET" \
-d '{
"from": "medusa-4af02e0e",
"to": "tangleclaw-53e1c6fb",
"message": "Hello from the Medusa workspace!"
}' http://localhost:3009/messages/directWorkspaces polling for queued messages or retrieving backlog state on startup can request them from their mailbox:
curl -s http://localhost:3009/messages/workspace/tangleclaw-53e1c6fbNote: Direct messages are not removed from the inbox automatically. Clients must explicitly acknowledge messages using POST /messages/ack.
Consumers can remotely check the state of another workspace (e.g. idle, busy, blocked at a prompt) without sending a message or altering its execution:
curl -s http://localhost:3009/workspaces/tangleclaw-53e1c6fb/peekThis safely fetches the target's status and the tail of their terminal output for debugging cross-agent stalls.
You can query the live telemetry of the Hub, including its uptime, connected workspaces, A2A mesh connection status, and its Auto-Updater state:
curl -s http://localhost:3009/healthMedusa includes a native, non-disruptive Auto-Updater. The Hub polls the GitHub Releases API hourly for new versions. When a new release is found (and the .tar.gz asset is attached), it will:
- Broadcast a system warning to all connected workspaces via WebSockets.
- Wait for safe states (all workspaces must report
idle). - Hot-swap the binaries by downloading and extracting the release.
- Gracefully exit the process (allowing
launchctl, PM2, or Docker to automatically reboot it into the new version).
You can also trigger a manual update check via the CLI:
node bin/medusa.js updateAny custom script, client tool, or IDE extension can speak directly to the Medusa Hub over WebSockets:
- Connection URL:
ws://127.0.0.1:3101 - Registration Request:
Send a
registerpacket immediately after connecting:{ "type": "register", "workspaceId": "your-workspace-unique-id" } - Registration Acknowledgment:
The Hub responds with confirmation:
{ "type": "registered", "workspaceId": "your-workspace-unique-id", "connectionId": "conn-123456789", "message": "WebSocket connection established for real-time messaging" } - Queue Draining: Immediately following registration, the Hub pushes all pending offline backlog messages stored in the mailbox.
- Incoming Message Envelope:
Messages are delivered using the standard
new_messageenvelope:{ "type": "new_message", "messageId": "msg-uuid-string", "message": { "id": "msg-uuid-string", "type": "direct", "from": "sender-workspace-id", "to": "your-workspace-unique-id", "message": "Message content here...", "timestamp": "2026-07-10T01:18:25.193Z" } }
To prevent request tampering and replay attacks:
- HMAC Signatures: Outbound requests are signed with
HMAC-SHA256using theA2A_SECRET. - Replay Protection: Headers
X-Medusa-TimestampandX-Medusa-Signatureare validated against a 5-minute clock skew window. - Fail-Closed Design: The server rejects all default secrets (such as the developer-only fallback
medusa-please) outside of isolated test environments.
Run the full testing matrix to verify build integrity:
# Run Node.js Hub Tests
cd src/medusa && npm test
# Run Python Swarm Tests
cd src/a2a_node && npm run test:pythonMedusa v1.0.0 | Report Issues | Security Policy
