File
Blob: AGENTS.md
CLAUDE.md
Commands
npm run build-- compile TypeScript todist/npm start-- run the compiled server (dist/index.js)npm run dev-- run from source withtsx(no build step)- Default port is
4100, override with--portorPORTenv var
Project structure
src/index.ts-- Express app: MCP routes, REST API, SSE, static file servingsrc/store.ts-- In-memory session + message state, EventEmitter for pub/subsrc/mcp-handler.ts-- Creates per-request MCP server withcollab_send_messageandcollab_wait_for_replytoolssrc/prompts.ts-- Generates role-specific system prompts (initiator vs. responder) with embedded tool instructions and a subagent prompt templateweb/index.html-- Single-file web UI (no build, no framework, vanilla JS + SSE)
Key design decisions
- Stateless MCP handlers: A new
McpServer+StreamableHTTPServerTransportis created per request inmcp-handler.ts. All persistent state lives inStore. - Long-poll with EventEmitter:
collab_wait_for_replyblocks up to 5 minutes viastore.waitForMessage(), which usesEventEmitterlisteners with a re-check after registration to close the race window. The HTTP server timeout is set to 0 to avoid killing these connections. - Only latest message returned:
waitForMessagereturns only the most recent delivered message (not history) to save agent context windows. - Auto-forward toggle: Messages are either delivered instantly or held as "pending" for human review/edit/reject, controlled per-session.
- Subagent prompt template:
prompts.tsincludes a copy-paste template for the wait subagent to prevent it from analyzing messages instead of relaying them verbatim.
Code style
- TypeScript strict mode, ES2022 target, Node16 module resolution
- ESM (
"type": "module"in package.json,.jsextensions in imports) - Express 5, Zod for MCP input validation
- No test framework currently set up