You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supergateway runs a MCP stdio-based servers over SSE (Server-Sent Events) with one command. This is useful for remote access, debugging, or connecting to SSE-based clients when your MCP server only speaks stdio.
You should see previously registered tools and templates.
70
+
71
+
72
+
---
73
+
74
+
## 🧬 Understanding the Database Schema
75
+
76
+
MCP Gateway uses a relational database (e.g. SQLite or PostgreSQL) to persist all registered entities and track tool/server usage. When session storage is configured as `CACHE_TYPE=database`, it also persists active user sessions and streamed message content.
77
+
78
+
---
79
+
80
+
### Key Tables
81
+
82
+
| Table | Purpose |
83
+
|-------|---------|
84
+
|`tools`| Stores registered tools, including schemas and auth configs |
85
+
|`tool_metrics`| Tracks execution stats per tool (latency, success/fail) |
86
+
|`resources`| Stores static or dynamic URI-based resources |
87
+
|`resource_metrics`| Logs usage of resources (access count, latency, etc.) |
88
+
|`resource_subscriptions`| Tracks SSE client subscriptions to resources |
89
+
|`prompts`| Jinja2 prompt templates with input arguments |
90
+
|`prompt_metrics`| Usage metrics for each prompt |
91
+
|`servers`| Virtual servers that group tools/resources under an SSE stream |
92
+
|`server_metrics`| Invocation stats per server |
93
+
|`gateways`| External federated MCP servers added by the admin |
94
+
|`mcp_sessions`| Persistent session registry when using `CACHE_TYPE=database`|
95
+
|`mcp_messages`| Persisted streamed content (text/image/etc.) tied to sessions |
96
+
|`*_association` tables | Many-to-many mapping between tools/resources/prompts and their servers/gateways |
97
+
98
+
---
99
+
100
+
### Session and Message Tables
101
+
102
+
These only appear when session/messaging backend is set to `database`:
103
+
104
+
-**`mcp_sessions`**: Each record is an open session ID (used for SSE streams and client context).
105
+
-**`mcp_messages`**: Stores streamed messages (text, image, resource) linked to a session—useful for debugging or offline playback.
106
+
107
+
You can query active sessions:
108
+
109
+
```sql
110
+
SELECT session_id, created_at FROM mcp_sessions ORDER BY created_at DESC;
111
+
```
112
+
113
+
Or inspect message content (JSON-encoded):
114
+
115
+
```sql
116
+
SELECT content FROM mcp_messages WHERE session_id ='abc123';
117
+
```
118
+
119
+
---
120
+
121
+
These tables are cleaned automatically when session TTLs expire, but can also be purged manually if needed.
0 commit comments