Skip to content

Commit d327413

Browse files
authored
Merge pull request #4 from IBM/add-testing-docs
Add testing documentation
2 parents 7d2cc6f + e31124a commit d327413

File tree

6 files changed

+236
-3
lines changed

6 files changed

+236
-3
lines changed

docs/docs/.pages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ nav:
44
- "🧰 Using": using
55
- "🚀 Deployment": deployment
66
- "🛡️ Manage": manage
7-
- "🧪 Development": development
7+
- "💻 Development": development
8+
- "🧪 Testing": testing

docs/docs/deployment/ibm-code-engine.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ ibmcloud ce secret create --name mcpgw-redis-url \
365365
ibmcloud ce application update --name "$IBMCLOUD_CODE_ENGINE_APP" \
366366
--env-from-secret mcpgw-redis-url \
367367
--env CACHE_TYPE=redis
368-
````
368+
```
369369
370370
### Choosing the right Redis size
371371

docs/docs/testing/.pages

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
title: Testing
2+
nav:
3+
- index.md
4+
- basic.md

docs/docs/testing/basic.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# MCP Gateway - Basic
2+
3+
Test script for MCP Gateway development environments.
4+
Verifies API readiness, JWT auth, Gateway/Tool/Server lifecycle, and RPC invocation.
5+
6+
---
7+
8+
## 🔧 Environment Setup
9+
10+
### 0. Bootstrap `.env`
11+
12+
```bash
13+
cp .env.example .env
14+
```
15+
16+
---
17+
18+
### 1. Start the Gateway
19+
20+
```bash
21+
make podman podman-run-ssl
22+
# or
23+
make venv install serve-ssl
24+
```
25+
26+
Gateway will listen on:
27+
28+
* Admin UI → [https://localhost:4444/admin](https://localhost:4444/admin)
29+
* Swagger → [https://localhost:4444/docs](https://localhost:4444/docs)
30+
* ReDoc → [https://localhost:4444/redoc](https://localhost:4444/redoc)
31+
32+
---
33+
34+
## 🔑 Authentication
35+
36+
### 2. Generate and export tokens
37+
38+
#### Gateway JWT (for local API access)
39+
40+
```bash
41+
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
43+
```
44+
45+
Expected: `{"status":"ok"}`
46+
47+
#### Remote gateway token (peer)
48+
49+
```bash
50+
export MY_MCP_TOKEN="sse-bearer-token-here..."
51+
```
52+
53+
#### Optional: local test server token (GitHub MCP server)
54+
55+
```bash
56+
export LOCAL_MCP_URL="http://localhost:8000/sse"
57+
export LOCAL_MCP_TOOL_URL="http://localhost:9000/rpc"
58+
```
59+
60+
---
61+
62+
### 3. Set convenience variables
63+
64+
```bash
65+
export BASE_URL="https://localhost:4444"
66+
export AUTH_HEADER="Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN"
67+
export JSON="Content-Type: application/json"
68+
```
69+
70+
---
71+
72+
## 🧪 Smoke Tests
73+
74+
### 4. Ping JSON-RPC system
75+
76+
```bash
77+
curl -k -X POST $BASE_URL/protocol/ping \
78+
-H "$AUTH_HEADER" -H "$JSON" \
79+
-d '{"jsonrpc":"2.0","id":1,"method":"ping"}'
80+
```
81+
82+
---
83+
84+
### 5. Add a Peer Gateway
85+
86+
```bash
87+
curl -k -X POST $BASE_URL/gateways \
88+
-H "$AUTH_HEADER" -H "$JSON" \
89+
-d '{
90+
"name": "my-mcp",
91+
"url": "https://link-to-remote-mcp-server/sse",
92+
"description": "My MCP Servers",
93+
"auth_type": "bearer",
94+
"auth_token": "'"$MY_MCP_TOKEN"'"
95+
}'
96+
```
97+
98+
List gateways:
99+
100+
```bash
101+
curl -k -H "$AUTH_HEADER" $BASE_URL/gateways
102+
```
103+
104+
---
105+
106+
### 6. Add a Tool
107+
108+
```bash
109+
curl -k -X POST $BASE_URL/tools \
110+
-H "$AUTH_HEADER" -H "$JSON" \
111+
-d '{
112+
"name": "clock_tool",
113+
"url": "'"$LOCAL_MCP_TOOL_URL"'",
114+
"description": "Returns current time",
115+
"request_type": "POST",
116+
"integration_type": "MCP",
117+
"input_schema": {
118+
"type": "object",
119+
"properties": {
120+
"timezone": { "type": "string" }
121+
}
122+
}
123+
}'
124+
```
125+
126+
---
127+
128+
### 7. Create a Virtual Server
129+
130+
```bash
131+
curl -k -X POST $BASE_URL/servers \
132+
-H "$AUTH_HEADER" -H "$JSON" \
133+
-d '{
134+
"name": "demo-server",
135+
"description": "Smoke-test virtual server",
136+
"icon": "mdi-server",
137+
"associatedTools": ["1"]
138+
}'
139+
```
140+
141+
Check:
142+
143+
```bash
144+
curl -k -H "$AUTH_HEADER" $BASE_URL/servers
145+
```
146+
147+
---
148+
149+
### 8. Open an SSE stream
150+
151+
```bash
152+
curl -k -N -H "$AUTH_HEADER" $BASE_URL/servers/1/sse
153+
```
154+
155+
Leave running - real-time events appear here.
156+
157+
---
158+
159+
### 9. Invoke the Tool via RPC
160+
161+
```bash
162+
curl -k -X POST $BASE_URL/rpc \
163+
-H "$AUTH_HEADER" -H "$JSON" \
164+
-d '{
165+
"jsonrpc": "2.0",
166+
"id": 99,
167+
"method": "clock_tool",
168+
"params": {
169+
"timezone": "Europe/Dublin"
170+
}
171+
}'
172+
```
173+
174+
Expected:
175+
176+
```json
177+
{
178+
"jsonrpc": "2.0",
179+
"id": 99,
180+
"result": {
181+
"time": "2025-05-27T14:23:01+01:00"
182+
}
183+
}
184+
```
185+
186+
---
187+
188+
## 🧹 Cleanup
189+
190+
```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
194+
```
195+
196+
---
197+
198+
## ✅ Summary
199+
200+
This smoke test validates:
201+
202+
* ✅ Gateway JWT auth
203+
* ✅ Peer Gateway registration with remote bearer
204+
* ✅ Tool registration and RPC wiring
205+
* ✅ Virtual server creation
206+
* ✅ SSE subscription and live messaging
207+
* ✅ JSON-RPC invocation flow
208+
209+
---

docs/docs/testing/index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 🧪 Testing MCP Gateway
2+
3+
This section contains guides for testing your MCP Gateway deployment.
4+
5+
## 🔹 Basic Smoke Test
6+
7+
Use the [Basic Smoke Test](basic.md) to verify:
8+
9+
- JWT token generation and authentication
10+
- Gateway registration
11+
- Tool registration
12+
- Server creation and event streaming
13+
- Tool invocation via JSON-RPC
14+
15+
This test is ideal for validating local development environments or freshly deployed test instances.
16+
17+
---
18+
19+
For additional scenarios (e.g., completion APIs, multi-hop toolchains), expand the test suite as needed.

docs/docs/using/clients/openwebui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Start the MCP Gateway to expose its tools via OpenAPI endpoints. For example:
2525

2626
```bash
2727
uv run mcpgateway
28-
````
28+
```
2929

3030
Ensure that the MCP Gateway is accessible at a known URL, such as `http://localhost:4444`.
3131

0 commit comments

Comments
 (0)