# debugsaad/remote-multi-tenant-mcp-server architecture

> Architecture diagram of the GitHub repository debugsaad/remote-multi-tenant-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/debugsaad/remote-multi-tenant-mcp-server
- Repository: https://github.com/debugsaad/remote-multi-tenant-mcp-server

## Overview

This repository snapshot contains product documentation and a PostgreSQL initialization script, but no application source. The graph therefore represents the documented product architecture, not verified implementation modules; component paths are null. The README documents OAuth sign-in, authenticated tool execution, tenant data isolation, auditing, rate limiting, and resumable streams. Connections are limited to those explicit flows.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Client and Access"]
  node_client["AI Client"]
  node_gateway["MCP Gateway"]
  node_oauth["OAuth Server"]
end

subgraph group_execution["Tool Execution"]
  node_limiter["Rate Limiter"]
  node_sessions["Session Management"]
  node_dispatcher["Tool Dispatch"]
  node_domain["Domain Service"]
  node_streams["Stream Resumption"]
end

subgraph group_state["State and Persistence"]
  node_redis[("Redis")]
  node_postgres[("PostgreSQL")]
  node_tenantdata[("Private Notes and Tasks")]
end

subgraph group_oversight["Audit and Administration"]
  node_audit[("Audit Trail")]
  node_activity["Activity Review"]
  node_admin["Admin Controls"]
end

node_user(("User"))

node_client -->|"sends tool calls"| node_gateway
node_gateway -->|"challenges"| node_client
node_client -->|"discovers metadata"| node_gateway
node_user -->|"signs in"| node_oauth
node_client -->|"exchanges credentials"| node_oauth
node_gateway -->|"checks quota"| node_limiter
node_gateway -->|"touches session"| node_sessions
node_limiter -->|"consumes tokens"| node_redis
node_sessions -->|"stores session"| node_redis
node_gateway -->|"dispatches tools"| node_dispatcher
node_dispatcher -->|"invokes tools"| node_domain
node_domain -->|"reads and writes"| node_postgres
node_postgres -->|"isolates rows"| node_tenantdata
node_gateway -->|"records invocations"| node_audit
node_audit -->|"persists in"| node_postgres
node_client -->|"resumes streams"| node_streams
node_streams -->|"replays buffered events"| node_redis

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_gateway,node_oauth,node_user toneBlue
class node_limiter,node_sessions,node_dispatcher,node_domain,node_streams toneAmber
class node_redis,node_postgres,node_tenantdata toneMint
class node_audit,node_activity,node_admin toneRose
```

## Components

### Client and Access

- **AI Client**
- **MCP Gateway**
- **OAuth Server**

### Tool Execution

- **Rate Limiter**
- **Session Management**
- **Tool Dispatch**
- **Domain Service**
- **Stream Resumption**

### State and Persistence

- **Redis**
- **PostgreSQL**
- **Private Notes and Tasks**

### Audit and Administration

- **Audit Trail**
- **Activity Review**
- **Admin Controls**

### Other components

- **User**

## Connections

- AI Client → MCP Gateway: sends tool calls (evidence: `README.md`)
- MCP Gateway → AI Client: challenges (evidence: `README.md`)
- AI Client → MCP Gateway: discovers metadata (evidence: `README.md`)
- User → OAuth Server: signs in (evidence: `README.md`)
- AI Client → OAuth Server: exchanges credentials (evidence: `README.md`)
- MCP Gateway → Rate Limiter: checks quota (evidence: `README.md`)
- MCP Gateway → Session Management: touches session (evidence: `README.md`)
- Rate Limiter → Redis: consumes tokens (evidence: `README.md`)
- Session Management → Redis: stores session (evidence: `README.md`)
- MCP Gateway → Tool Dispatch: dispatches tools (evidence: `README.md`)
- Tool Dispatch → Domain Service: invokes tools (evidence: `README.md`)
- Domain Service → PostgreSQL: reads and writes (evidence: `README.md`)
- PostgreSQL → Private Notes and Tasks: isolates rows (evidence: `README.md`)
- MCP Gateway → Audit Trail: records invocations (evidence: `README.md`)
- Audit Trail → PostgreSQL: persists in (evidence: `README.md`)
- AI Client → Stream Resumption: resumes streams (evidence: `README.md`)
- Stream Resumption → Redis: replays buffered events (evidence: `README.md`)
