Multi-LLM Gateway MCP
An MCP server that functions as an intelligent gateway for multiple LLM backends including OpenAI, Claude, and Ollama. It supports automatic provider fallback, streaming responses via Server-Sent Events, and real-time monitoring for robust AI integration.
README
MCP Server
Multi-LLM Gateway para mcp.observabilidadebrasil.org
Um servidor MCP (Model Context Protocol) que atua como gateway inteligente para mΓΊltiplos backends LLM, com suporte a streaming, rate limiting, e monitoramento.
ποΈ Arquitetura
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β nginx (SSL + Rate Limit) β
β mcp.observabilidadebrasil.org β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Server (FastAPI) β
β Port 9200 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββ βββββββββββ βββββββββββ βββββββββββ β
β β OpenAI β β Claude β β Ollama β β Custom β β
β β Providerβ β Providerβ β Providerβ β Providerβ β
β ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ β
β β β β β β
β ββββββββββββββ΄βββββββββββββ΄βββββββββββββ β
β β β
β ββββββββββββΌβββββββββββ β
β β LLM Router β β
β β (load balance, β β
β β fallback, routing) β β
β βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Features
- Multi-LLM Backend: Suporte a OpenAI, Anthropic Claude, Ollama (local), e providers customizados
- Streaming SSE: Respostas em tempo real via Server-Sent Events
- Rate Limiting: ProteΓ§Γ£o contra abuso (nginx + aplicaΓ§Γ£o)
- Fallback AutomΓ‘tico: Se um provider falhar, tenta o prΓ³ximo
- Monitoramento: Dashboard separado de requests, mΓ©todos, e abuse
- Health Checks: Endpoints de saΓΊde para cada provider
- Docker Ready: Deploy simplificado com Docker Compose
π¦ InstalaΓ§Γ£o
Requisitos
- Python 3.11+
- nginx (para produΓ§Γ£o)
- Docker (opcional)
Desenvolvimento Local
# Clonar repositΓ³rio
git clone https://github.com/tgosoul2019/mcp.git
cd mcp
# Criar virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Instalar dependΓͺncias
pip install -e ".[dev]"
# Configurar variΓ‘veis de ambiente
cp .env.example .env
# Editar .env com suas API keys
# Rodar servidor
python -m mcp_server
ProduΓ§Γ£o (VPS)
# No servidor
cd /dados
git clone https://github.com/tgosoul2019/mcp.git
cd mcp
# Setup
./scripts/setup.sh
# Iniciar serviΓ§o
sudo systemctl start mcp-server
βοΈ ConfiguraΓ§Γ£o
VariΓ‘veis de Ambiente
# Server
MCP_HOST=127.0.0.1
MCP_PORT=9200
MCP_DEBUG=false
# LLM Providers (configure apenas os que usar)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
OLLAMA_BASE_URL=http://localhost:11434
# Default Provider
MCP_DEFAULT_PROVIDER=openai
# Rate Limiting (aplicaΓ§Γ£o)
MCP_RATE_LIMIT_REQUESTS=100
MCP_RATE_LIMIT_WINDOW=60
# Logging
MCP_LOG_LEVEL=INFO
MCP_LOG_FILE=/var/log/mcp/mcp.log
π API Endpoints
Chat Completion
POST /v1/chat/completions
Content-Type: application/json
{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello!"}
],
"stream": true,
"provider": "openai" # opcional, usa default se omitido
}
Health Check
GET /health
GET /health/providers
Metrics
GET /metrics
π Monitoramento
O MCP tem seu prΓ³prio dashboard de monitoramento separado do KCP:
- URL:
https://mcp.observabilidadebrasil.org/admin/monitor - Requests por provider
- LatΓͺncia mΓ©dia
- Taxa de erros
- IPs mais ativos
- Abuse detection
π³ Docker
# Build
docker build -t mcp-server .
# Run
docker run -d \
--name mcp-server \
-p 9200:9200 \
-e OPENAI_API_KEY=sk-... \
mcp-server
π Estrutura do Projeto
mcp/
βββ mcp_server/
β βββ __init__.py
β βββ __main__.py
β βββ app.py # FastAPI app
β βββ config.py # ConfiguraΓ§Γ΅es
β βββ router.py # LLM Router
β βββ providers/
β β βββ __init__.py
β β βββ base.py # Abstract Provider
β β βββ openai.py
β β βββ anthropic.py
β β βββ ollama.py
β βββ middleware/
β β βββ __init__.py
β β βββ rate_limit.py
β β βββ logging.py
β βββ monitor/
β βββ __init__.py
β βββ collector.py # MΓ©tricas
β βββ dashboard.py # UI
βββ infra/
β βββ nginx/
β β βββ mcp.conf
β βββ systemd/
β β βββ mcp-server.service
β βββ docker/
β βββ Dockerfile
β βββ docker-compose.yml
βββ scripts/
β βββ setup.sh
β βββ deploy.sh
βββ tests/
βββ pyproject.toml
βββ .env.example
βββ README.md
π LicenΓ§a
MIT
π Links
- ProduΓ§Γ£o: https://mcp.observabilidadebrasil.org
- RepositΓ³rio: https://github.com/tgosoul2019/mcp
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.