Skip to content

Commit 6fe9d7b

Browse files
committed
Cleanup translate pr
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 27616d0 commit 6fe9d7b

File tree

9 files changed

+144
-1605
lines changed

9 files changed

+144
-1605
lines changed

docker/translate.Dockerfile

Lines changed: 0 additions & 124 deletions
This file was deleted.

docs/docs/using/.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
nav:
22
- index.md
33
- mcpgateway-wrapper.md
4+
- mcpgateway-translate.md
45
- Clients: clients
56
- Agents: agents
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# MCP Gateway StdIO to SSE Bridge (`mcpgateway-translate`)
2+
3+
`mcpgateway-translate` is a lightweight bridge that connects a JSON-RPC server
4+
running over StdIO to an HTTP/SSE interface, or consumes a remote SSE stream
5+
and forwards messages to a local StdIO process.
6+
7+
Supported modes:
8+
9+
1. StdIO to SSE – serve a local subprocess over HTTP with SSE output
10+
2. SSE to StdIO – subscribe to a remote SSE stream and forward messages to a local process
11+
12+
---
13+
14+
## Features
15+
16+
| Feature | Description |
17+
|---------|-------------|
18+
| Bidirectional bridging | Supports both StdIO to SSE and SSE to StdIO |
19+
| Keep-alive frames | Emits `keepalive` events every 30 seconds |
20+
| Endpoint bootstrapping | Sends a unique message POST endpoint per client session |
21+
| CORS support | Configure allowed origins via `--cors` |
22+
| OAuth2 support | Use `--oauth2Bearer` to authorize remote SSE connections |
23+
| Health check | Provides a `/healthz` endpoint for liveness probes |
24+
| Logging control | Adjustable log verbosity with `--logLevel` |
25+
| Graceful shutdown | Cleans up subprocess and server on termination signals |
26+
27+
---
28+
29+
## Quick Start
30+
31+
### Expose a local StdIO server over SSE
32+
33+
```bash
34+
mcpgateway-translate \
35+
--stdio "uvenv run mcp-server-git" \
36+
--port 9000
37+
```
38+
39+
Access the SSE stream at:
40+
41+
```
42+
http://localhost:9000/sse
43+
```
44+
45+
### Bridge a remote SSE endpoint to a local process
46+
47+
```bash
48+
mcpgateway-translate \
49+
--sse "https://corp.example.com/mcp" \
50+
--oauth2Bearer "your-token"
51+
```
52+
53+
---
54+
55+
## Command-Line Options
56+
57+
```
58+
mcpgateway-translate [--stdio CMD | --sse URL | --streamableHttp URL] [options]
59+
```
60+
61+
### Required (one of)
62+
63+
* `--stdio <command>`
64+
Start a local process whose stdout will be streamed as SSE and stdin will receive backchannel messages.
65+
66+
* `--sse <url>`
67+
Connect to a remote SSE stream and forward messages to a local subprocess.
68+
69+
* `--streamableHttp <url>`
70+
Not implemented in this build. Raises an error.
71+
72+
### Optional
73+
74+
* `--port <number>`
75+
HTTP server port when using --stdio mode (default: 8000)
76+
77+
* `--cors <origins>`
78+
One or more allowed origins for CORS (space-separated)
79+
80+
* `--oauth2Bearer <token>`
81+
Bearer token to include in Authorization header when connecting to remote SSE
82+
83+
* `--logLevel <level>`
84+
Logging level (default: info). Options: debug, info, warning, error, critical
85+
86+
---
87+
88+
## HTTP API (when using --stdio)
89+
90+
### GET /sse
91+
92+
Streams JSON-RPC responses as SSE. Each connection receives:
93+
94+
* `event: endpoint` – the URL for backchannel POST
95+
* `event: keepalive` – periodic keepalive signal
96+
* `event: message` – forwarded output from subprocess
97+
98+
### POST /message
99+
100+
Send a JSON-RPC message to the subprocess. Returns HTTP 202 on success, or 400 for invalid JSON.
101+
102+
### GET /healthz
103+
104+
Health check endpoint. Always responds with `ok`.
105+
106+
---
107+
108+
## Example Use Cases
109+
110+
### 1. Browser integration
111+
112+
```bash
113+
mcpgateway-translate \
114+
--stdio "uvenv run mcp-server-git" \
115+
--port 9000 \
116+
--cors "https://myapp.com"
117+
```
118+
119+
Then connect the frontend to:
120+
121+
```
122+
http://localhost:9000/sse
123+
```
124+
125+
### 2. Connect remote server to local CLI tools
126+
127+
```bash
128+
mcpgateway-translate \
129+
--sse "https://corp.example.com/mcp" \
130+
--oauth2Bearer "$TOKEN" \
131+
--logLevel debug
132+
```
133+
134+
---
135+
136+
## Notes
137+
138+
* Only StdIO to SSE and SSE to StdIO bridging are implemented.
139+
* Any use of `--streamableHttp` will raise a NotImplementedError.

0 commit comments

Comments
 (0)