Multi-LLM Gateway MCP

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.

Category
Visit Server

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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured