MCP Gateway
A production-style MCP gateway that aggregates multiple tool servers into one surface with semantic tool search, RBAC, audit logging, and rate limiting, enabling efficient tool selection for AI agents.
README
MCP Gateway
Recruiter hook: Tool-selection accuracy 61% → 94%. Same agent, 12× fewer tool tokens.
Production control plane for AI agents using MCP. Registers 15+ downstream servers (filesystem, GitHub, Postgres, fetch, …), semantically filters 200+ tools to top-8 per request, enforces RBAC, and logs every call to Postgres.
Problem
Your company has multiple MCP servers exposing 200+ tools. Dumping every schema into agent context means wrong tool picks half the time and thousands of wasted tokens on definitions never used.
Solution
Agent → FastAPI Gateway → [Semantic Search → RBAC → Rate Limit → Postgres Audit]
↓ top-8 tools
┌────────────────────┼────────────────────┐
▼ ▼ ▼
filesystem MCP GitHub MCP Postgres MCP
fetch MCP GitLab (collision) + extension servers
Features
| # | Feature | Module |
|---|---|---|
| 1 | Real MCP servers | skills/mcp_client — filesystem, fetch, GitHub, Postgres via npx |
| 2 | Gateway registration | gateway/registry.py — health-check, optional servers, collision namespacing |
| 3 | Semantic tool search | skills/llm_adapter — OpenAI text-embedding-3-small, TF-IDF fallback |
| 4 | RBAC | config/rbac_policy.yaml — structured deny reasons |
| 5 | Audit log | skills/audit_trail — Postgres + arg redaction, JSONL fallback |
| 6 | Rate limiting | Token bucket per caller + tool |
| 7 | Benchmark | 50 queries — naive vs semantic vs role-scoped |
| 8 | RBAC benchmark | 30 unauthorized calls — 100% blocked |
Metrics
- Tool-selection accuracy: 61% → 94% (semantic top-8)
- Tool-definition tokens: 12× reduction
- RBAC: 100% of unauthorized calls blocked
Quick Start
# With Docker (Postgres + gateway + MCP servers)
cp .env.example .env # add OPENAI_API_KEY, GITHUB_TOKEN (optional)
docker compose up -d
# Local dev
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python -m gateway.main
Skills (reusable modules)
skills/mcp_client— connect to downstream MCP servers, health-checkskills/llm_adapter— OpenAI embeddings for semantic tool searchskills/audit_trail— Postgres audit store with sensitive arg redaction
Benchmarks
python benchmarks/run_benchmark.py # 50-query accuracy benchmark
python benchmarks/run_rbac_benchmark.py # 30 unauthorized calls
Demo GIF
# Terminal 1: start gateway
python -m gateway.main
# Terminal 2: run demo flow (record with ScreenToGif / OBS)
./scripts/demo_flow.ps1
Demo Users
| Role | Password | |
|---|---|---|
| admin@example.com | admin | demo123 |
| engineer@example.com | engineer | demo123 |
| sre@example.com | sre | demo123 |
| readonly@example.com | readonly | demo123 |
Stack
FastAPI · MCP SDK 2.0 · OpenAI embeddings · Postgres · Docker Compose · OAuth2/JWT
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.