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:

  1. Call MCP via stdio/HTTP (slow, no context injection)
  2. Import tool handlers directly in transport service (tight coupling)
  3. 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


🔗 Related


Auto-generated by MCP Smart Consolidation