Architecture: How should Cloud MCP Gateway call local MCP tool handlers wi...
Documentation for Sessions
🏗️ Architecture: How should Cloud MCP Gateway call local MCP tool handlers wi...
Date: 2026-01-17
Time: 16:54:11 UTC
Session: editor2-50.6
Agent: backend
Confidence: 85%
Status: ✅ Documented
📋 Decision Context
Question:
How should Cloud MCP Gateway call local MCP tool handlers with user context?
Task: Phase 2 - Connect MCP Gateway to real tool handlers with space-scoped data
🎯 Decision Made
Chosen:
Create a bridge service in backend-ai-api that imports and wraps MCP tool handlers, injecting user context and routing to space-specific databases
Options Considered:
- Call MCP via stdio/HTTP (slow, no context injection)
- Import tool handlers directly in transport service (tight coupling)
- Create bridge service with dependency injection (clean, testable)
💭 Reasoning
MCP tool handlers are pure functions that need database connections and user context. Creating a bridge service allows us to: 1) Inject space-specific database connections, 2) Add user context to all operations, 3) Keep MCP package independent, 4) Enable testing and mocking. The transport service becomes a thin HTTP/WS wrapper around the bridge.
📁 Files Involved
apis/backend-ai-api/src/app/mcp-gateway/services/mcp-transport.service.tsMCP/mcp-gograb-ai/src/server.ts
🔗 Related
- Decision ID:
dev_1768668848138_7p5d1ks - Session: 50
- Workspace: editor2
Auto-generated by MCP Smart Consolidation