Get the FREE Ultimate OpenClaw Setup Guide →

springai -gateway

Spring Boot gateway that unifies multiple MCP servers into one endpoint for AI assistants, OAuth 2.1

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio oalles-springai-mcp-gateway docker run -i springai-mcp-gateway:latest \
  --env MCP_ENDPOINT="https://<your-domain>/mcp" \
  --env AUTH_SERVER_URL="https://<your-domain>/auth" \
  --env PORT_AUTH_SERVER="9090" \
  --env PORT_MCP_GATEWAY="8080"

How to use

This MCP gateway serves as a bridge between MCP clients and the Streamable HTTP MCP server. It exposes the gateway at /mcp, supporting multiple authentication modes (no auth, OAuth 2.1 Client Credentials, and Authorization Code + PKCE). The gateway can route requests from MCP clients such as SSE-based tools (e.g., JetBrains Copilot) and standard stdio-based clients through the same endpoint. To use it, start the Authorization Server and the MCP Gateway, then obtain a Bearer token from the Authorization Server and present it with MCP requests to /mcp. The gateway validates tokens against the public issuer and supports token-based access control for mcp:read and mcp:write scopes. You can leverage Cloudflare Tunnels to expose the public endpoint at a domain, enabling ChatGPT connectors to OAuth flows and token refresh flows automatically.

How to install

Prerequisites:

  • Java JDK 17+ and Maven installed on your machine
  • Git to clone the repository
  • Optional: Docker if you plan to run via Docker image

Installation steps:

  1. Clone the repository: git clone https://github.com/oalles/springai-mcp-gateway.git cd springai-mcp-gateway

  2. Build the project (all modules): mvn -q clean package

  3. Run the Authorization Server (port 9090) and the MCP Gateway (port 8080):

    • Using Maven (in separate terminals): mvn -q -pl auth-server spring-boot:run mvn -q -pl mcp-gateway spring-boot:run
  4. Alternatively, run via Docker (if a Docker image is available): docker run -i -p 8080:8080 -p 9090:9090 springai-mcp-gateway:latest

  5. If you’re using Cloudflare Tunnels, follow the CLOUDFLARE.md instructions to set up a tunnel and route /mcp to your local gateway.

Additional notes

Tips and common issues:

  • Ensure the OAuth 2.1 issuer URL (public domain) is reachable from your clients. If using a local issuer, consider tunneling or exposing it publicly via a Cloudflare Tunnel.
  • When testing locally, you may use NO_AUTH_SSE branch for a quick integration; switch to OAUTH2.1_STREAMABLE for token-based security and to OAUTH2.1_CHATGPT_TUNNELS for PKCE + public client workflows.
  • The gateway’s /mcp endpoint supports both SSE and standard HTTP MCP communications; ensure your client is configured to target that path.
  • For ChatGPT integration, configure the OAuth client as public (no client secret) and let the connector manage tokens and refresh flows.
  • Always secure your domain with HTTPS and restrict CORS/origin settings in non-demo environments.

Related MCP Servers

Sponsor this space

Reach thousands of developers