Content
# Gravitee.io MCP Proxy Policy
This policy for [Gravitee.io API Gateway](https://gravitee.io) enables proxying and forwarding of various data streams, including Server-Sent Events (SSE) and HTTP streams with multiple operating modes.
## Features
- **SSE to SSE Forwarding**: Proxy SSE events from a remote SSE server to clients
- **STDIO to SSE Forwarding**: Convert local process output to SSE events for clients
- **SSE to STDIO Forwarding**: Forward received SSE events to a local process
- **HTTP Stream Proxying**: Direct HTTP stream forwarding with minimal transformation
## Build
```bash
$ mvn clean install
```
## Deploy
Copy the generated JAR file from the `target` directory to the Gravitee.io plugins directory:
```bash
$ cp target/mcp-proxy-policy-1.0.0-SNAPSHOT.zip /path/to/gravitee/plugins/
```
## Configuration
### SSE to SSE Mode
```json
{
"mcp-proxy": {
"proxyMode": "SSE_TO_SSE",
"remoteHost": "events.example.com",
"remotePort": 443,
"secureConnection": true,
"headers": [
{
"name": "Authorization",
"value": "Bearer TOKEN"
}
],
"keepAliveSeconds": 30
}
}
```
### STDIO to SSE Mode
```json
{
"mcp-proxy": {
"proxyMode": "STDIO_TO_SSE",
"command": "python generate_events.py",
"environmentVars": [
{
"name": "EVENT_INTERVAL",
"value": "1000"
},
{
"name": "MAX_EVENTS",
"value": "100"
}
],
"keepAliveSeconds": 30
}
}
```
### SSE to STDIO Mode
```json
{
"mcp-proxy": {
"proxyMode": "SSE_TO_STDIO",
"command": "node process_events.js",
"environmentVars": [
{
"name": "LOG_LEVEL",
"value": "info"
},
{
"name": "OUTPUT_DIR",
"value": "/tmp/events"
}
]
}
}
```
### HTTP Stream Mode
```json
{
"mcp-proxy": {
"proxyMode": "HTTP_STREAM",
"remoteHost": "stream.example.com",
"remotePort": 8080,
"secureConnection": false,
"headers": [
{
"name": "X-API-Key",
"value": "your-api-key"
}
]
}
}
```
## Configuration Properties
| Property | Description | Type | Default | Required |
|----------|-------------|------|---------|----------|
| proxyMode | Proxy mode (SSE_TO_SSE, STDIO_TO_SSE, SSE_TO_STDIO, HTTP_STREAM) | enum | SSE_TO_SSE | Yes |
| remoteHost | Remote server hostname | string | - | Yes (for SSE_TO_SSE and HTTP_STREAM) |
| remotePort | Remote server port | integer | 8080 | No |
| command | Local command to execute | string | - | Yes (for STDIO modes) |
| headers | Custom HTTP headers | array | [] | No |
| environmentVars | Environment variables for local process | array | [] | No |
| keepAliveSeconds | Keep-alive timeout in seconds | integer | 15 | No |
| secureConnection | Use HTTPS | boolean | false | No |
## How It Works
### SSE to SSE Mode
The policy forwards requests to a remote SSE server and proxies the SSE events back to the client. It maintains proper SSE formatting and sends keep-alive messages when configured.
### STDIO to SSE Mode
The policy executes a local process, captures its stdout, and converts each line to an SSE event that is sent to the client. This allows any command-line tool to become an SSE source.
### SSE to STDIO Mode
The policy receives SSE events from clients, extracts the data, and forwards it to a local process via stdin. The process can then process the events as needed.
### HTTP Stream Mode
The policy directly forwards HTTP streams between client and remote server with minimal transformation. This is useful for streaming APIs that don't follow the SSE format.
## Limitations
- The SSE modes require proper SSE events in the standard format
- Local process execution requires appropriate permissions on the gateway host
- Large volumes of events may impact gateway performance
## Troubleshooting
For troubleshooting, check the Gravitee Gateway logs. The policy uses the following logger names:
- `io.gravitee.policy.sse.MCPProxyPolicy`
- `io.gravitee.policy.sse.handlers.SSEToSSEHandler`
- `io.gravitee.policy.sse.handlers.StdioToSSEHandler`
- `io.gravitee.policy.sse.handlers.SSEToStdioHandler`
- `io.gravitee.policy.sse.handlers.HttpStreamHandler`
- `io.gravitee.policy.sse.utils.MCPUtils`
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Connection Info
You Might Also Like
MarkItDown MCP
MarkItDown-MCP is a lightweight server for converting various URIs to Markdown.
Context 7
Context7 MCP provides up-to-date code documentation for any prompt.
Continue
Continue is an open-source project for seamless server management.
semantic-kernel
Build and orchestrate intelligent AI agents with Semantic Kernel.
Github
The GitHub MCP Server connects AI tools to manage repositories, issues, and...
Playwright
A lightweight MCP server for browser automation using Playwright, enabling...