Modern 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.
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 popped destructively from the inbox queue upon retrieval.
Any 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
