Skip to content

Commit a38b3f7

Browse files
authored
Merge pull request #6 from IBM/update-testing-docs-and-copilot-docs
Update testing docs, copilot docs and minor fix to servers/ also offering a servers (no /) endpoint
2 parents 973ed20 + d4b409d commit a38b3f7

File tree

6 files changed

+1081
-462
lines changed

6 files changed

+1081
-462
lines changed

DEVELOPING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ npx @modelcontextprotocol/inspector uv --directory "/home/cmihai/mcpgateway-wrap
1818

1919
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.
2020

21-
`npx -y supergateway --stdio "uvx mcp-server-git"``
21+
`npx -y supergateway --stdio "uvx run mcp-server-git"``
2222

2323
SSE endpoint: GET http://localhost:8000/sse
2424
POST messages: POST http://localhost:8000/message

docs/docs/manage/backup.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,61 @@ Use a secrets manager (e.g., AWS Secrets Manager, Azure Key Vault, or Kubernetes
6262
Run smoke tests:
6363

6464
```bash
65-
curl http://localhost:4444/tools
66-
curl http://localhost:4444/prompts
65+
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/tools
66+
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/prompts
6767
```
6868

6969
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.
122+

docs/docs/testing/basic.md

Lines changed: 129 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Gateway will listen on:
3939

4040
```bash
4141
export MCPGATEWAY_BEARER_TOKEN=$(python -m mcpgateway.utils.create_jwt_token -u admin)
42-
curl -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" https://localhost:4444/health
42+
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" https://localhost:4444/health
4343
```
4444

4545
Expected: `{"status":"ok"}`
@@ -74,17 +74,23 @@ export JSON="Content-Type: application/json"
7474
### 4. Ping JSON-RPC system
7575

7676
```bash
77-
curl -k -X POST $BASE_URL/protocol/ping \
77+
curl -s -k -X POST $BASE_URL/protocol/ping \
7878
-H "$AUTH_HEADER" -H "$JSON" \
7979
-d '{"jsonrpc":"2.0","id":1,"method":"ping"}'
8080
```
8181

82+
Expected:
83+
84+
```json
85+
{"jsonrpc":"2.0","id":1,"result":{}}
86+
```
87+
8288
---
8389

8490
### 5. Add a Peer Gateway
8591

8692
```bash
87-
curl -k -X POST $BASE_URL/gateways \
93+
curl -s -k -X POST $BASE_URL/gateways \
8894
-H "$AUTH_HEADER" -H "$JSON" \
8995
-d '{
9096
"name": "my-mcp",
@@ -98,15 +104,15 @@ curl -k -X POST $BASE_URL/gateways \
98104
List gateways:
99105

100106
```bash
101-
curl -k -H "$AUTH_HEADER" $BASE_URL/gateways
107+
curl -s -k -H "$AUTH_HEADER" $BASE_URL/gateways
102108
```
103109

104110
---
105111

106112
### 6. Add a Tool
107113

108114
```bash
109-
curl -k -X POST $BASE_URL/tools \
115+
curl -s -k -X POST $BASE_URL/tools \
110116
-H "$AUTH_HEADER" -H "$JSON" \
111117
-d '{
112118
"name": "clock_tool",
@@ -128,28 +134,59 @@ curl -k -X POST $BASE_URL/tools \
128134
### 7. Create a Virtual Server
129135

130136
```bash
131-
curl -k -X POST $BASE_URL/servers \
132-
-H "$AUTH_HEADER" -H "$JSON" \
137+
curl -s -k -X POST $BASE_URL/servers/ \
138+
-H "$AUTH_HEADER" -H "$JSON" -H 'accept: application/json' \
133139
-d '{
134140
"name": "demo-server",
135141
"description": "Smoke-test virtual server",
136-
"icon": "mdi-server",
137-
"associatedTools": ["1"]
142+
"icon": "https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png",
143+
"associatedTools": ["1"],
144+
"associatedResources": [],
145+
"associatedPrompts": []
138146
}'
139147
```
140148

149+
Expected:
150+
151+
```json
152+
{
153+
"id": 2,
154+
"name": "demo-server",
155+
"description": "Smoke-test virtual server",
156+
"icon": "https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png",
157+
"createdAt": "2025-05-28T04:28:38.554558",
158+
"updatedAt": "2025-05-28T04:28:38.554564",
159+
"isActive": true,
160+
"associatedTools": [
161+
1
162+
],
163+
"associatedResources": [],
164+
"associatedPrompts": [],
165+
"metrics": {
166+
"totalExecutions": 0,
167+
"successfulExecutions": 0,
168+
"failedExecutions": 0,
169+
"failureRate": 0,
170+
"minResponseTime": null,
171+
"maxResponseTime": null,
172+
"avgResponseTime": null,
173+
"lastExecutionTime": null
174+
}
175+
}
176+
```
177+
141178
Check:
142179

143180
```bash
144-
curl -k -H "$AUTH_HEADER" $BASE_URL/servers
181+
curl -s -k -H "$AUTH_HEADER" $BASE_URL/servers | jq
145182
```
146183

147184
---
148185

149186
### 8. Open an SSE stream
150187

151188
```bash
152-
curl -k -N -H "$AUTH_HEADER" $BASE_URL/servers/1/sse
189+
curl -s -k -N -H "$AUTH_HEADER" $BASE_URL/servers/1/sse
153190
```
154191

155192
Leave running - real-time events appear here.
@@ -159,12 +196,12 @@ Leave running - real-time events appear here.
159196
### 9. Invoke the Tool via RPC
160197

161198
```bash
162-
curl -k -X POST $BASE_URL/rpc \
199+
curl -s -k -X POST $BASE_URL/rpc \
163200
-H "$AUTH_HEADER" -H "$JSON" \
164201
-d '{
165202
"jsonrpc": "2.0",
166203
"id": 99,
167-
"method": "clock_tool",
204+
"method": "get_current_time",
168205
"params": {
169206
"timezone": "Europe/Dublin"
170207
}
@@ -175,22 +212,91 @@ Expected:
175212

176213
```json
177214
{
178-
"jsonrpc": "2.0",
179-
"id": 99,
180-
"result": {
181-
"time": "2025-05-27T14:23:01+01:00"
182-
}
215+
"content": [
216+
{
217+
"type": "text",
218+
"text": "{\n \"timezone\": \"Europe/Dublin\",\n \"datetime\": \"2025-05-28T05:24:13+01:00\",\n \"is_dst\": true\n}"
219+
}
220+
],
221+
"is_error": false
222+
}
223+
```
224+
225+
---
226+
227+
### 10. Connect to GitHub MCP Tools via SuperGateway
228+
229+
You can test the Gateway against GitHub's official `mcp-server-git` tool using [`supergateway`](https://github.com/modelcontextprotocol/supergateway).
230+
231+
Start a temporary SSE wrapper around the GitHub MCP server:
232+
233+
```bash
234+
npx -y supergateway --stdio "uvx run mcp-server-git"
235+
```
236+
237+
This starts:
238+
239+
* SSE endpoint: `http://localhost:8000/sse`
240+
* Message POST: `http://localhost:8000/message`
241+
242+
To register it with the MCP Gateway:
243+
244+
```bash
245+
export MY_MCP_TOKEN="optional-auth-header-if-needed"
246+
247+
curl -s -k -X POST $BASE_URL/gateways \
248+
-H "$AUTH_HEADER" -H "$JSON" \
249+
-d '{
250+
"name": "github-mcp",
251+
"url": "http://localhost:8000/sse",
252+
"description": "GitHub MCP Tools via SuperGateway",
253+
"auth_type": "none"
254+
}'
255+
```
256+
257+
This gives you access to GitHub's MCP tools like `get_repo_issues`, `get_pull_requests`, etc.
258+
259+
---
260+
261+
### 11. Development Testing with MCP Inspector
262+
263+
Launch a visual inspector to interactively test your Gateway:
264+
265+
```bash
266+
npx @modelcontextprotocol/inspector
267+
```
268+
269+
Once launched at [http://localhost:5173](http://localhost:5173):
270+
271+
1. Click **"Add Server"**
272+
2. Use the URL for your virtual server's SSE stream:
273+
274+
```
275+
http://localhost:4444/servers/1/sse
276+
```
277+
278+
3. Add this header:
279+
280+
```json
281+
{
282+
"Authorization": "Bearer <your-jwt-token>"
183283
}
184284
```
185285

286+
4. Save and test tool invocations by selecting a tool and sending sample input:
287+
288+
```json
289+
{ "timezone": "Europe/Dublin" }
290+
```
291+
186292
---
187293

188294
## 🧹 Cleanup
189295

190296
```bash
191-
curl -k -X DELETE -H "$AUTH_HEADER" $BASE_URL/servers/1
192-
curl -k -X DELETE -H "$AUTH_HEADER" $BASE_URL/tools/1
193-
curl -k -X DELETE -H "$AUTH_HEADER" $BASE_URL/gateways/1
297+
curl -s -k -X DELETE -H "$AUTH_HEADER" $BASE_URL/servers/1
298+
curl -s -k -X DELETE -H "$AUTH_HEADER" $BASE_URL/tools/1
299+
curl -s -k -X DELETE -H "$AUTH_HEADER" $BASE_URL/gateways/1
194300
```
195301

196302
---
@@ -205,5 +311,7 @@ This smoke test validates:
205311
* ✅ Virtual server creation
206312
* ✅ SSE subscription and live messaging
207313
* ✅ JSON-RPC invocation flow
314+
* ✅ Connecting MCP Inspector to the MCP Gateway
315+
* ✅ Connecting the official GitHub MCP server to the Gateway
208316

209317
---

0 commit comments

Comments
 (0)