Sandbox
@theognis1002/mcp-gateway

MCP gateway and registry for agent tools

MCP Gateway is a central hub for exposing tools, resources, and prompts to MCP-compatible agents. It adds authentication, rate limiting, server discovery, logging, and transport bridging so agents can use services through one controlled entry point.

41 starsโ€ข10 forksโ€ขGoโ€ขUpdated 6mo ago
Who it's for

Builders who want their MCP agents to reach internal APIs and services through one managed gateway.

What it delivers

You can expose existing services to agents without wiring each one up by hand, while keeping access and activity visible.

What it does

REST to MCP translation

Wraps HTTP services as MCP tools with schema validation.

Server discovery and namespaces

Finds MCP servers automatically and groups them into isolated namespaces.

Authentication and policy controls

Supports JWT, OAuth2, OIDC, RBAC, API keys, and rate limiting.

Multi-protocol transport bridge

Handles JSON-RPC 2.0, WebSocket, SSE, streamable HTTP, and stdio.

Logging and auditing

Records requests, responses, sessions, and security events with metrics and alerts.

Virtual MCP servers

Builds virtual servers on top of REST APIs and other services.

How to get it

  1. 1Fast development with backend in Docker and frontend running locally
    # Terminal 1: Start backend services
    make dev
    
    # Terminal 2: Start frontend locally (much faster)
    cd apps/frontend
    bun install
    bun run dev

README

MCP Gateway

CI Go Version License Go Report Card codecov Security PRs Welcome

A production-ready API gateway for Model Context Protocol (MCP) servers, providing enterprise-grade infrastructure with authentication, logging, rate limiting, server discovery, and multi-protocol transport support.

๐Ÿš€ Quick Start

Get the entire MCP Gateway stack running with a single command:

# Clone the repository
git clone https://github.com/mcp-gateway/mcp-gateway.git
cd mcp-gateway

# Copy env vars
cp .env.example .env

# Option 1: Using Docker Compose directly
docker compose up --build

# Option 2: Using Makefile (automatically detects docker compose vs docker-compose)
make setup

Access the application:

  • Backend: http://localhost:8080
  • Frontend: http://localhost:3000
  • Admin user: admin@admin.com / qwerty123

Architecture

The MCP Gateway is designed with a modular architecture for scalability and maintainability:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      Users      โ”‚    โ”‚    AI Agents    โ”‚    โ”‚     AI Agents   โ”‚
โ”‚   (Web/Mobile)  โ”‚    โ”‚    (External)   โ”‚    โ”‚    (Internal)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚                      โ”‚                      โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                   โ”‚    MCP Gateway    โ”‚
                   โ”‚                           โ”‚
                   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                   โ”‚  โ”‚   Security Layer    โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข JWT Auth          โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข RBAC & Policies   โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข API Key Mgmt      โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Rate Limiting     โ”‚  โ”‚
                   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                   โ”‚                           โ”‚
                   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                   โ”‚  โ”‚     Middleware      โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Content Filtering โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Audit Logging     โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข CORS & Headers    โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Request Tracking  โ”‚  โ”‚
                   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                   โ”‚                           โ”‚
                   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                   โ”‚  โ”‚   Core Services     โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Server Discovery  โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Namespace Manager โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Transport Proxy   โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Virtual Servers   โ”‚  โ”‚
                   โ”‚  โ”‚ โ€ข Logging & Metrics โ”‚  โ”‚
                   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚                      โ”‚                      โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ namespace-1 โ”‚        โ”‚ namespace-2 โ”‚        โ”‚ namespace-3 โ”‚
    โ”‚             โ”‚        โ”‚             โ”‚        โ”‚             โ”‚
    โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚        โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚        โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚
    โ”‚โ”‚MCP Server โ”‚โ”‚        โ”‚โ”‚MCP Server โ”‚โ”‚        โ”‚โ”‚Virtual    โ”‚โ”‚
    โ”‚โ”‚     A     โ”‚โ”‚        โ”‚โ”‚     C     โ”‚โ”‚        โ”‚โ”‚Server A   โ”‚โ”‚
    โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚        โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚        โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
    โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚        โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚        โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚
    โ”‚โ”‚MCP Server โ”‚โ”‚        โ”‚โ”‚MCP Server โ”‚โ”‚        โ”‚โ”‚Virtual    โ”‚โ”‚
    โ”‚โ”‚     B     โ”‚โ”‚        โ”‚โ”‚     D     โ”‚โ”‚        โ”‚โ”‚Server B   โ”‚โ”‚
    โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚        โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚        โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Features

๐Ÿ” Security & Authentication

  • Authentication - Secure authentication (JWT, OAuth2, OIDC) with RBAC
  • API Key Management - Role-based access control with fine-grained permissions
  • Rate Limiting - IP-based limiting with Redis backing and memory fallback
  • Content Filtering - PII detection, regex patterns, and custom filters

๐Ÿข Server & Namespace Management

  • Dynamic Discovery - Automatic MCP server discovery and registration
  • Namespaces - Group servers with isolated namespaces for internal & external usage
  • Health Monitoring - Server health checks with automated failover and recovery
  • Public Endpoints - Auto-generated REST APIs for namespace access

๐Ÿ”Œ Multi-Protocol Transport

  • JSON-RPC 2.0 - Standard synchronous RPC over HTTP
  • WebSocket - Full-duplex bidirectional communication
  • Server-Sent Events - Real-time server-to-client streaming
  • Streamable HTTP - Official MCP protocol implementation
  • STDIO - Command-line interface bridge

๐ŸŒ Service Virtualization

  • Protocol Support - REST APIs, GraphQL (coming soon), gRPC (coming soon)
  • MCP Integration - Transform any HTTP service into MCP tools with schema validation
  • Example Integrations - Internal API docs, microservers, etc.

๐Ÿ“Š Logging, Auditing & Metrics

  • Audit Trails - Complete request/response logging with security event tracking
  • Performance Metrics - Real-time monitoring with health checks and alerting
  • External Integration - AWS CloudWatch, file-based logging, and custom exporters
  • Session Tracking - Live session management with detailed interaction logs

๐Ÿ› ๏ธ Development

Quick Development Setup

Fast development with backend in Docker and frontend running locally:

# Terminal 1: Start backend services
make dev

# Terminal 2: Start frontend locally (much faster)
cd apps/frontend
bun install
bun run dev

Essential Commands

# Development
make dev              # Start backend services (postgres, redis, backend)
make setup            # Complete setup (DB + admin + orgs + namespaces)
make start            # Production-ready local setup with services
make stop             # Stop all services
make clean            # Stop and remove all data
make logs             # View service logs
make help             # Show all available commands

# Database Operations
make migrate          # Run database migrations
make migrate-down     # Rollback migrations
make migrate-status   # Show migration status
make db-shell         # Open PostgreSQL shell

# Testing & Quality
make test             # Run all tests
make lint             # Run linters

# Build & Utilities
make build            # Build containers
make rebuild          # Rebuild and restart containers
make shell            # Open shell in backend container
make bash             # Open bash in backend container

Troubleshooting

Docker Compose Issues:

# The Makefile automatically detects your Docker Compose version
# Check what it's using:
make help  # Will work with either docker-compose or docker compose

# Manual check:
docker compose version    # Modern v2
docker-compose version    # Legacy v1

# If you get "command not found":
# Install Docker Desktop (includes Compose v2) or standalone Compose

Common Issues:

  • Port conflicts: Stop other services on ports 8080, 3000, 5432, 6379
  • Permission denied: Ensure Docker daemon is running
  • Build failures: Try make clean then make setup

๐Ÿค Contributing

  1. Fork the repository
  2. Run make dev to start backend services
  3. Run frontend locally: cd apps/frontend && bun run dev
  4. Make your changes
  5. Run make test and make lint
  6. Submit a Pull Request

Please see our Contributing Guidelines for details.

Code of Conduct

This project follows the Contributor Covenant Code of Conduct.

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

๐Ÿ”’ Security

Security is a top priority. Please review our Security Policy and report vulnerabilities responsibly.

๐Ÿ™ Acknowledgments


Built with โค๏ธ for the MCP community

โญ Star us on GitHub โ€ข ๐Ÿ› Report Bug โ€ข ๐Ÿ’ก Request Feature

Files in the repo

Repository payloadโ€ข25 top-level entries
  • .claude
  • .cursor
  • .github
  • apps
  • docs
  • logs
  • scripts
  • .air.toml
  • .dockerignore
  • .env.example
  • .gitattributes
  • .gitignore
  • .go-version
  • .pre-commit-config.yaml
  • CLAUDE.md
  • CONTRIBUTING.md
  • docker-compose.dev.yml
  • docker-compose.yml
  • go.mod
  • go.sum
  • LICENSE
  • Makefile
  • railway.toml
  • README.md
  • SECURITY.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph โ€” average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code โ€” use any LLM (Claude, Gemini, Grok, DeepSeek, Ollamaโ€ฆ) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300ยตs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up โ€” it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k
t8y2/dbxConnectors

20 MB lightweight cross-platform database client for 90+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | ่ฝป้‡็บง่ทจๅนณๅฐๆ•ฐๆฎๅบ“็ฎก็†ๅทฅๅ…ท๏ผŒๆ”ฏๆŒ MySQLใ€PostgreSQLใ€SQLiteใ€Redisใ€MongoDBใ€่พพๆขฆ็ญ‰ 90+ ๆ•ฐๆฎๅบ“๏ผŒๆไพ›ๆกŒ้ข็ซฏใ€Dockerใ€CLIใ€ๅ†…็ฝฎ AI ๅŠฉๆ‰‹ๅ’Œ MCP Serverใ€‚

19k