Skip to main content
Glama
kvochkin-dev

MCP Gateway

MCP Gateway


MCP Gateway — production-ready Model Context Protocol gateway for Russian LLMs: a unified interface to GigaChat and YandexGPT with automatic fallback, personal data anonymization per 152-FZ, and 86% savings on tokens.

Connect any MCP client (Hermes Agent, Claude Code, Cursor, n8n) — and get access to Russian models through a single endpoint. Stack: FastAPI, MCP SDK, GigaChat API, YandexGPT API.


✨ Features

Feature

Description

🔀 Multi-provider

GigaChat (primary) + YandexGPT (fallback) + Ollama (local)

🛡️ 152-FZ

Built-in detection and anonymization of personal data: phone, INN, passport, SNILS, address

💰 86% savings

GigaChat ~200₽/M tokens vs YandexGPT ~1,455₽/M tokens

🔄 Auto-fallback

Seamless provider switching on errors and rate-limit (429)

🐳 Docker Ready

Full Docker Compose for one-command deployment

💚 Health Checks

Monitoring endpoints and systemd service with auto-start


Related MCP server: MCP LLM Generator v2

🏗️ Architecture

flowchart TB
    classDef client fill:#eef2f7,stroke:#4a5568,stroke-width:1.5px
    classDef gateway fill:#edf2f7,stroke:#4a5568,stroke-width:1.5px
    classDef llm fill:#e2e8f0,stroke:#4a5568,stroke-width:1.5px

    subgraph Client["👤 Клиент"]
        Agent["🤖 MCP-клиент<br>Hermes Agent / Claude Code / n8n"]
    end
    class Client client

    subgraph Gateway["⚙️ MCP Gateway (FastAPI, port 8000)"]
        MCP["MCP Server<br>5 tools"]
        Anon["🛡️ Анонимизатор ПД<br>152-ФЗ"]
        Fallback["🔀 Fallback-оркестратор"]
        MCP --> Anon --> Fallback
    end
    class Gateway gateway

    subgraph Providers["🧠 LLM-провайдеры"]
        Giga["GigaChat<br>~200₽/M токенов"]
        Yandex["YandexGPT<br>~1 455₽/M токенов"]
        Ollama["Ollama<br>локально, 0₽"]
    end
    class Providers llm

    Agent --> MCP
    Fallback -->|"основной"| Giga
    Fallback -.->|"fallback"| Yandex
    Fallback -.->|"fallback"| Ollama

🚀 Quick Start

# Клонирование
git clone https://github.com/kvochkin-dev/mcp-gateway.git
cd mcp-gateway

# Настройка окружения
cp .env.example .env
# Впишите свои API-ключи в .env

# Запуск через Docker
docker-compose up -d

# Или напрямую
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python app.py

📋 API Endpoints

Method

Path

Description

GET

/health

Service and provider status

GET

/docs

Swagger UI

POST

/mcp

MCP interface (tools)

Health Check

curl http://localhost:8000/health
{
  "status": "healthy",
  "gigachat": "connected",
  "yandexgpt": "connected",
  "anonymizer": "ready"
}

🔐 Configuration

All secrets are stored in .env (file excluded from git):

GIGACHAT_CLIENT_ID=***
GIGACHAT_CLIENT_SECRET=***
YANDEXGPT_API_KEY=***
YANDEXGPT_FOLDER_ID=***

🧪 Tests

pytest tests/ -v

13/13 tests passed — provider clients, fallback logic, personal data anonymizer.


📁 Project Structure

mcp-gateway/
├── app.py                  # FastAPI + MCP сервер
├── src/
│   ├── clients/            # GigaChat, YandexGPT клиенты
│   └── anonymizer/         # 152-ФЗ анонимизация ПД
├── scripts/
│   └── mcp-monitor.sh      # Мониторинг сервисов
├── docs/                   # Отчёты и документация
├── tests/                  # 13 тестов
└── docker-compose.yml      # Docker-развёртывание

📄 License

MIT — use freely.


Related MCP Connectors

Related MCP Servers