Skip to content

Commit 524c33f

Browse files
authored
Merge pull request #67 from IBM/migrate-wrapper-to-gateway-main
Add wrapper to mcpgateway directly, and add debug docs for stdio protocol
2 parents 446d1ba + 1412a56 commit 524c33f

File tree

2 files changed

+448
-0
lines changed

2 files changed

+448
-0
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,67 @@ docker run -i --name mcpgateway-wrapper \
187187
# You'll see a message similar to: Installed 21 packages in 6ms - it's now expecting input from an MCP client
188188
```
189189

190+
Testing `mcpgateway-wrapper` by hand:
191+
192+
Because the wrapper speaks JSON-RPC over stdin/stdout, you can interact with it using nothing more than a terminal or pipes.
193+
194+
```bash
195+
# Run a time server, then register it in your gateway..
196+
pip install mcp-server-time
197+
npx -y supergateway --stdio "uvenv run mcp_server_time -- --local-timezone=Europe/Dublin"
198+
199+
# Start the MCP Gateway Wrapper
200+
export MCP_AUTH_TOKEN=${MCPGATEWAY_BEARER_TOKEN}
201+
export MCP_SERVER_CATALOG_URLS=http://localhost:4444/servers/1
202+
python -m mcpgateway.wrapper
203+
```
204+
205+
**Initialize the protocol:**
206+
207+
```json
208+
# Initialize the protocol
209+
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"demo","version":"0.0.1"}}}
210+
211+
# Then after the reply:
212+
{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}
213+
214+
# Get prompts
215+
{"jsonrpc":"2.0","id":4,"method":"prompts/list"}
216+
{"jsonrpc":"2.0","id":5,"method":"prompts/get","params":{"name":"greeting","arguments":{"user":"Bob"}}}
217+
218+
# Get resources
219+
{"jsonrpc":"2.0","id":6,"method":"resources/list"}
220+
{"jsonrpc":"2.0","id":7,"method":"resources/read","params":{"uri":"https://example.com/some.txt"}}
221+
222+
# Get / call tools
223+
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
224+
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_current_time","arguments":{"timezone":"Europe/Dublin"}}}
225+
```
226+
227+
Expected:
228+
229+
```json
230+
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-03-26","capabilities":{"experimental":{},"prompts":{"listChanged":false},"resources":{"subscribe":false,"listChanged":false},"tools":{"listChanged":false}},"serverInfo":{"name":"mcpgateway-wrapper","version":"0.1.0"}}}
231+
232+
# When there's no tools
233+
{"jsonrpc":"2.0","id":2,"result":{"tools":[]}}
234+
235+
# After you add some tools and create a virtual server
236+
{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"get_current_time","description":"Get current time in a specific timezones","inputSchema":{"type":"object","properties":{"timezone":{"type":"string","description":"IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use 'America/New_York' as local timezone if no timezone provided by the user."}},"required":["timezone"]}}]}}
237+
238+
# Running the time tool:
239+
{"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"{'content': [{'type': 'text', 'text': '{\\n \"timezone\": \"Europe/Dublin\",\\n \"datetime\": \"2025-06-08T21:47:07+01:00\",\\n \"is_dst\": true\\n}'}], 'is_error': False}"}],"isError":false}}
240+
241+
```
242+
190243
### Running from a MCP Client
191244

192245
The `mcpgateway-wrapper` should be used with an MCP Client that does not support SSE. You can configure it as such.
193246

194247
Remember to replace the `MCP_SERVER_CATALOG_URL` with the actual URL of your MCP Gateway. Consider container networking - when running this via a container engine, this should represent a network accessible from Docker/Podman, ex: `http://host.docker.internal:4444/servers/1`
195248

249+
You have a number of options for running the wrapper. Docker/Podman, to run it from the container. `uvx`, `uvenv` or `pipx` to run it straight from pip. Or just running it with Python from a local directory. Adjust your command accordingly.
250+
196251
```json
197252
{
198253
"servers": {

0 commit comments

Comments
 (0)