feat(gateway): add MCP server endpoint with streamable HTTP transport (#52)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

- Install @modelcontextprotocol/sdk and zod in apps/gateway
- Create McpModule with McpService and controller at /mcp endpoint
- Implement stateful streamable HTTP transport (MCP spec 2025-03-26)
- Expose 14 tools: brain (projects/tasks/missions), memory, coord
- Require valid BetterAuth session for all MCP connections
- Per-session McpServer + StreamableHTTPServerTransport instances
- Follows same Fastify onRequest hook pattern as auth handler
- Add mcp.dto.ts with McpToolDescriptor and McpServerInfo interfaces

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-15 13:04:27 -05:00
parent a8dc498794
commit e2de76ca9f
9 changed files with 1196 additions and 11 deletions

View File

@@ -15,6 +15,7 @@
"@fastify/helmet": "^13.0.2",
"@mariozechner/pi-ai": "~0.57.1",
"@mariozechner/pi-coding-agent": "~0.57.1",
"@modelcontextprotocol/sdk": "^1.27.1",
"@mosaic/auth": "workspace:^",
"@mosaic/brain": "workspace:^",
"@mosaic/coord": "workspace:^",
@@ -47,7 +48,8 @@
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.0",
"socket.io": "^4.8.0",
"uuid": "^11.0.0"
"uuid": "^11.0.0",
"zod": "^4.3.6"
},
"devDependencies": {
"@types/node": "^22.0.0",