MCP ExplorerExplorer

Ailuc Mcp Proxy

@hant916on 9 months ago
1 MIT
FreeCommunity
AI Systems
Gravitee.io MCP Proxy Policy for forwarding SSE and HTTP streams.

Overview

What is Ailuc Mcp Proxy

ailuc_mcp_proxy is a policy for the Gravitee.io API Gateway that facilitates the proxying and forwarding of various data streams, including Server-Sent Events (SSE) and HTTP streams, with multiple operational modes.

Use cases

Use cases include forwarding SSE events from a remote server to clients, converting local process output to SSE events, forwarding SSE events to local processes, and proxying HTTP streams with minimal transformation.

How to use

To use ailuc_mcp_proxy, first build the project using Maven. Then, deploy the generated JAR file to the Gravitee.io plugins directory. Configure the proxy mode in JSON format according to your requirements, such as SSE to SSE, STDIO to SSE, SSE to STDIO, or HTTP stream.

Key features

Key features include SSE to SSE forwarding, STDIO to SSE forwarding, SSE to STDIO forwarding, and HTTP stream proxying, allowing for flexible data stream management.

Where to use

ailuc_mcp_proxy can be used in various fields that require real-time data streaming, such as web applications, IoT systems, and any scenario where event-driven architectures are implemented.

Content

Gravitee.io MCP Proxy Policy

This policy for Gravitee.io API Gateway 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

$ mvn clean install

Deploy

Copy the generated JAR file from the target directory to the Gravitee.io plugins directory:

$ cp target/mcp-proxy-policy-1.0.0-SNAPSHOT.zip /path/to/gravitee/plugins/

Configuration

SSE to SSE Mode

{
  "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

{
  "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

{
  "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

{
  "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.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers