MCP Gateway
A generic MCP gateway that exposes any HTTP-based SQL portal as LLM-friendly MCP tools and standard REST endpoints, serving both human users and AI agents simultaneously.
README
MCP Gateway
A generic, semantic MCP gateway exposing any HTTP-based SQL portal as both LLM-friendly MCP tools and standard REST endpoints. Designed from the ground up to serve human users (via UI/API) and AI agents simultaneously.
uv run main.py
uv run chainlit run chatbot.py -w
Architecture
+------------------+
| Human User |
+--------+---------+
|
| HTTP / REST
v
+---------+ MCP +------------------+ HTTP +------------------+
| AI +------>| FastAPI App +------>| SQL HTTP Portal |
| (Agent) | | (Semantic Layer) | (SQL) | |
+---------+ +--------+---------+ +------------------+
^ |
| |
+--- from_fastapi() ---+
(FastMCP Auto-maps tools)
Core Design Principles (LLM & Human Best Practices)
- Semantic Layer Abstraction: No raw CRUD endpoints. Expose high-level intent routes (
/search-tables,/top,/explore) to reduce LLM cognitive load and simplify frontend code. - Strict Explict Identification: Every route enforces a clean, action-oriented
operation_id(query_sql,search_tables). FastMCP maps these directly into clear tool names for the LLM. - Intent-Driven Documentation: Docstrings explicitly declare when and why to use the endpoint (
"""Semantic table search."""), acting directly as LLM prompt steering. - Strict Typing via Enums: Restrict input options using Pydantic Enums to eliminate LLM parameter hallucinations.
- Server-Side Data Aggregation: Compute metrics and perform table joins inside Python to save LLM context window tokens and prevent API call chaining.
Pros & Cons
Advantages
- DRY Codebase: Single source of truth. One FastAPI setup automatically serves both humans (REST) and AI (MCP).
- AI-First Performance: Fastembed vector search and server-side constraints (
FORBIDDENkeywords, limits) keep the LLM fast, secure, and accurate. - Low Footprint: No heavy local database or native drivers required; works over standard HTTP.
Disadvantages
- Path Parameter Blindness: Complex dynamic routes like
/distinct/{table}/{column}require the LLM to successfully call/search-tablesfirst to discover valid values. - Tight Coupling: Aligning REST routes to serve both human UX and LLM token-efficiency can require design trade-offs for heavily nested data.
AI
# if : full python agent (use openrouter)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install aider-chat --python 3.12 --force
uv tool install specify-cli
specify init mcp-gateway --integration claude --ignore-agent-tools
aider --model openrouter/nvidia/nemotron-3-ultra-550b-a55b:free --no-auto-commits --test-cmd pytest
# else : npm agent (like claude code but zen)
sudo apt update && sudo apt install -y nodejs npm
sudo npm install -g @opencode/cli
sudo npm install -g @fission-ai/openspec@latest
openspec init --tools opencode
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.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
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.