Logo von Production-Grade MCP Server + Agentic System

Production-Grade MCP Server + Agentic System

Community
FareedKhan-dev

Building a Production-Grade MCP Server Architecture with a Multi-Agent System

HerausgeberFareedKhan-dev
Repositoryproduction-grade-mcp-agentic-system
SprachePython
Forks
19
Sterne
65
Verfügbare Tools
0
Transporttypstdio, streamable-http
Kategorien
LizenzMIT
Links
  • Tools mit KI-Workflows verbinden

    Production-Grade MCP Server + Agentic System stellt MCP-Funktionen bereit, die kompatible KI-Clients und Agenten nutzen können.

  • 0 verfügbare Tools

    Sehen Sie sich unten die aufrufbaren Aktionen an, einschließlich Namen und Beschreibungen, sofern der Server diese bereitstellt.

  • Konfiguration zum Kopieren

    Nutzen Sie die Installationsbeispiele, um diesen Server in Ihrem bevorzugten MCP-Client zu konfigurieren.

  • Open-Source-Kennzahlen

    65 Sterne und 19 Forks im verlinkten Repository.

🏛️ Production-Grade MCP Server + Agentic System

A reference implementation of an MCP server designed to actually ship

Multi-tenant · Authenticated · Observable · Rate-limited · Cached · Circuit-broken · Governed

Python 3.11+ MCP 2026 License: MIT Docker


📖 Full Step-by-Step Blog Walkthrough

This repository is the companion codebase for a long-form blog post that walks through every single component end to end, with every line of code explained in context. Start there if you want to understand the "why" behind the architecture before reading the code.

🔗 Building a Production-Grade MCP Server Architecture with Agentic System →


🎯 What This Is

Most MCP tutorials end with a @tool decorator that returns "hello world". That is fine for a demo. It is not what ships.

This repository is a reference implementation of an MCP server designed to run in production: multi-tenant, authenticated, observable, rate-limited, cached, circuit-broken, and governed. It exposes a company's heterogeneous data layer (Postgres, Elasticsearch, S3, vector DB) to AI agents as a single, secure tool surface, and ships with a four-agent support copilot (Planner → Retriever → Synthesizer → Critic) that uses it end to end.

The codebase is deliberately organised around twelve components that keep showing up on the 3 AM pager when teams skip them. Each one lives in its own module and can be read, replaced, or extended independently.


🏗️ Architecture Overview

The complete production-grade system: MCP server dispatch pipeline on the right, four-agent orchestrator on the left, data plane on top, observability on the bottom, identity and governance as crosscutting concerns.


🧩 The 12 Components

#ComponentLives inWhat it gives you
1🚪 Transport & Session Layerserver.pystdio for local, Streamable HTTP for remote, horizontal-scale-friendly sessions
2🔐 Authentication Serverauth/oauth.pyOAuth 2.1 + PKCE, short-lived JWTs, JWKS validation
3⚖️ Authorization & Policy Engineauth/policy.pyTool-level RBAC, tenant-scoped ABAC, deny-by-default
4📚 Tool Registry & Discoverytools/registry.pyDynamic toolsets, .well-known capability metadata
5✅ Input Validation Layervalidation/schemas.pyPydantic schemas, enum constraints, agent-adversarial input as default threat model
6🔧 Tool Execution Enginetools/base.pyThree-level hierarchy (atomic / composed / workflow)
7🔄 Circuit Breaker & Retryreliability/Closed → open → half-open, Adaptive Timeout Budget Allocation
8🚦 Rate Limiting & Quotasratelimit/limiter.pyRedis token-bucket (Lua-atomic), per-tenant and per-tool
9⚡ Caching Layercache/manager.pyTwo-tier (L1 in-process, L2 Redis), stampede prevention
10🧱 Structured Error Frameworkerrors/framework.pyMachine-readable errors with retryable and hint fields
11🔭 Observability Stackobservability/OpenTelemetry traces, Prometheus metrics, audit logs
12🛡️ Governance & Multi-Tenancygovernance/Tenant isolation, approval gates, outbound HTTP allowlisting

📖 Diving Deeper, Section by Section

Each diagram below links back to the corresponding section in the blog, where every line of code is walked through in detail.

📦 Data Persistence Layer

Postgres + Row-Level Security · Tenant isolation at the DB layer

🚪 Transport & Session Layer

Dual transport · Stateless session · Middleware chain

🔐 Authentication, Policy & Governance

OAuth 2.1 · YAML policies · Human-in-the-loop approvals

🔧 Tool Execution Engine

Three-level hierarchy · Atomic · Composed · Workflow

🔄 Reliability Layer

Circuit breakers · Retry with jitter · ATBA budget allocator

⚡ Rate Limiting & Caching

Redis token bucket · Two-tier cache · Stampede lock

🔭 Observability Stack

OpenTelemetry · Prometheus · Audit logs · One trace ID

🤖 Multi-Agentic Architecture

Four-agent design · Planner · Retriever · Synthesizer · Critic

🎼 The Orchestrator Flow

End-to-end agent orchestration with one bounded revise loop


🚀 Quick Start

Prerequisites

  • Docker & Docker Compose
  • Python 3.11+ (only for running the CLI locally)
  • An Anthropic API key (for the agent layer)

1. Clone and Configure

bash
git clone https://github.com/FareedKhan-dev/production-grade-mcp-agentic-system.git
cd production-grade-mcp-agentic-system
cp .env.example .env

Edit .env and set at minimum:

  • ANTHROPIC_API_KEY — for the agent layer
  • ATLAS_AUTH_JWKS_URL — your OAuth 2.1 provider's JWKS endpoint (or leave default for dev)

2. Bring Up the Stack

bash
docker compose up -d

That brings up the full local environment:

ServiceURLWhat it is
🏛️ MCP Serverhttp://localhost:8080/mcpStreamable HTTP endpoint
🔍 Discoveryhttp://localhost:8080/.well-known/mcp-serverUnauthenticated capability metadata
📊 Metricshttp://localhost:8080/metricsPrometheus scrape target
❤️ Healthhttp://localhost:8080/healthzLiveness probe
🔭 Jaegerhttp://localhost:16686Distributed tracing UI
📈 Grafanahttp://localhost:3000Metrics dashboards (admin / admin)
🗄️ MinIO Consolehttp://localhost:9001S3-compatible storage UI

3. Run the Support Copilot CLI

bash
pip install -e .

export ATLAS_MCP_URL=http://localhost:8080
export ATLAS_MCP_TOKEN=dev-token
export ATLAS_TENANT=acme
export ANTHROPIC_API_KEY=sk-ant-...

atlas-copilot "Why was the refund on order o_9002 for CUST-1001 delayed?"

You will see the four agents run end-to-end, the final draft printed with [S1][S2] citations, and a full trace summary including token counts, tool calls, and the run_id that ties back to Jaeger.

4. Connect from Claude Desktop / Cursor

Add this to your MCP host config:

json
{
  "mcpServers": {
    "production-mcp": {
      "type": "http",
      "url": "http://localhost:8080/mcp",
      "headers": {
        "Authorization": "Bearer ${ATLAS_MCP_TOKEN}",
        "X-Tenant-Id": "acme"
      }
    }
  }
}

📂 Repository Structure

.
├── 📄 README.md
├── 🐳 docker-compose.yml          # Full local stack: app + data + observability
├── 🐳 Dockerfile                  # Two-stage build, non-root runtime
├── 📜 LICENSE
├── 📦 pyproject.toml              # Dependencies, dev tools, CLI entry points
├── ⚙️  .env.example                # Every setting documented by component
│
├── 🔧 config/                     # Runtime configuration (hot-reloadable)
│   ├── http_allowlist.yaml       # Per-tenant outbound HTTP allowlist
│   └── policy.yaml               # YAML-driven authorization policies
│
├── 🚢 deploy/                     # Deployment sidecar configs
│   ├── otel/config.yaml          # OpenTelemetry Collector pipeline
│   ├── prometheus/prometheus.yml # Prometheus scrape targets
│   └── sql/init.sql              # Schema + RLS policies + seed data
│
├── 📚 docs/                       # Deep-dive documentation
│   ├── AGENT_SYSTEM.md           # Multi-agent orchestrator internals
│   ├── ARCHITECTURE.md           # The 12 components in detail
│   └── DEPLOYMENT.md             # K8s, Cloudflare Workers, bare-metal
│
├── 🧠 src/atlas_mcp/              # Main application source
│   ├── config.py                 # Centralized typed settings
│   ├── server.py                 # ⚡ Component 1: Transport & dispatch
│   │
│   ├── 🤖 agents/                 # Four-agent support copilot
│   │   ├── planner.py            # Emits retrieval plan JSON
│   │   ├── retriever.py          # Bounded tool-calling loop
│   │   ├── synthesizer.py        # Drafts reply with citations
│   │   ├── critic.py             # Approves or sends one revise
│   │   ├── orchestrator.py       # Wires the four agents together
│   │   ├── mcp_client.py         # Thin JSON-RPC MCP client
│   │   ├── memory.py             # STM (Redis) + LTM (vector)
│   │   └── cli.py                # atlas-copilot CLI entry point
│   │
│   ├── 🔐 auth/                   # Components 2 + 3
│   │   ├── oauth.py              # JWT + JWKS validation
│   │   ├── middleware.py         # Bearer token extraction
│   │   └── policy.py             # YAML-driven policy engine
│   │
│   ├── 🛡️  governance/             # Component 12
│   │   ├── tenant.py             # Tenant pinning middleware
│   │   └── approval.py           # Human-in-the-loop gate
│   │
│   ├── 🔧 tools/                  # Components 4 + 6
│   │   ├── registry.py           # In-memory tool index + discovery
│   │   ├── base.py               # Tool abstract base + metadata
│   │   ├── atomic/               # Level 1: one backend each
│   │   ├── composed/             # Level 2: deterministic chains
│   │   └── workflow/             # Level 3: multi-step procedures
│   │
│   ├── 🔄 reliability/            # Component 7
│   │   ├── circuit_breaker.py    # 3-state machine per tool
│   │   ├── retry.py              # Exponential backoff + jitter
│   │   └── atba.py               # Adaptive Timeout Budget Allocation
│   │
│   ├── 🚦 ratelimit/              # Component 8
│   │   └── limiter.py            # Redis token bucket (Lua-atomic)
│   │
│   ├── ⚡ cache/                   # Component 9
│   │   └── manager.py            # L1 + L2 cache with stampede lock
│   │
│   ├── 🧱 errors/                 # Component 10
│   │   └── framework.py          # Structured Error Recovery (SERF)
│   │
│   ├── 🔭 observability/          # Component 11
│   │   ├── tracing.py            # OpenTelemetry spans
│   │   ├── metrics.py            # Prometheus instruments
│   │   └── audit.py              # Structured JSONL audit log
│   │
│   └── ✅ validation/             # Component 5
│       └── schemas.py            # Tool call envelope
│
└── 🧪 tests/                      # Narrow tests, load-bearing properties
    ├── test_circuit_breaker.py   # State machine transitions
    ├── test_errors.py            # SERF wire format + retry semantics
    └── test_policy.py            # Deny-beats-allow + default-deny

🎨 Tech Stack

LayerTechnology
LanguagePython 3.11+
Web frameworkStarlette + Uvicorn
MCP SDKmcp>=1.2.0
AuthPyJWT + Authlib (OAuth 2.1 resource server)
ValidationPydantic v2 + Pydantic Settings
Databaseasyncpg (PostgreSQL 16 with RLS)
SearchElasticsearch 8 (async client)
Vector DBQdrant
Object storageaioboto3 (MinIO / S3)
Cache + queuesRedis 7 (redis[hiredis])
Reliabilitytenacity (retries) + custom breaker + custom ATBA
TracingOpenTelemetry SDK + OTLP exporter
Metricsprometheus_client
Loggingstructlog (JSON)
LLMAnthropic Messages API (Claude)

🧪 Testing

The test suite is deliberately narrow, covering the three load-bearing safety properties:

bash
pip install -e ".[dev]"
pytest -v
  • test_circuit_breaker.py — state machine transitions, retryable vs deterministic error classification
  • test_errors.py — SERF wire format, retry semantics, MCP-level error data
  • test_policy.py — default-deny, deny-beats-allow, glob matching, PII condition blocking

🛣️ Production Deployment

For running this in an actual production environment (managed Postgres, real OAuth provider, SIEM integration, Kubernetes), see docs/DEPLOYMENT.md.

Key swaps between local dev and production:

Local (docker-compose)Production
Dev JWT issuerWorkOS AuthKit / Auth0 / Keycloak
MinIOAWS S3 / GCS / Azure Blob
Local PostgresAWS RDS / Cloud SQL / Supabase
Redis containerUpstash / ElastiCache / MemoryDB
Local OTel collectorDatadog / Honeycomb / Grafana Cloud
File-based audit logSplunk / Chronicle / SIEM of choice

📚 Documentation


📜 License

MIT. See LICENSE.


⭐ If this helped you, please consider starring the repo

Built with ☕ and a lot of 3 AM debugging

📖 Read the full blog walkthrough · 🐛 Report an issue · 💬 Start a discussion

Installation

TypingMind
{
  "mcpServers": {
    "production-grade-mcp-agentic-system": {
      "command": "atlas-copilot",
      "args": [
        "{{config.QUERY}}"
      ],
      "env": {
        "QUERY": "<QUERY>"
      }
    }
  }
}

Production-Grade MCP Server + Agentic System MCP mit mehreren KI-Modellen nutzen

TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. Sobald Production-Grade MCP Server + Agentic System verbunden ist, können Sie die Integration mit verschiedenen KI-Modellen in TypingMind verwenden, statt sie für jedes Modell separat einzurichten. Sie können MCP lokal auf Ihrem Gerät ausführen oder über eine URL eine Verbindung zu einem Remote-MCP-Server herstellen.

Option 1: Lokalen Konnektor verwenden

Nutzen Sie diese Option, wenn der MCP-Server Zugriff auf lokale Dateien, Apps oder private Ressourcen auf Ihrem Computer benötigt.

1

MCP-Einstellungen öffnen

Gehen Sie in TypingMind zu „Einstellungen“, „Erweiterte Einstellungen“ und dann „Model Context Protocol“ und wählen Sie „Konnektor-Setup“.

  1. Öffnen Sie TypingMind in Ihrem Browser.
  2. Klicken Sie auf das Symbol „Optionen“.
  3. Gehen Sie zu „Erweiterte Einstellungen“.
  4. Öffnen Sie den Abschnitt „Model Context Protocol“.
  5. Klicken Sie auf „Konnektor-Setup“ und wählen Sie „Dieses Gerät“.
Einrichtungsbildschirm des TypingMind-MCP-Konnektors mit ausgewählter Option „Dieses Gerät“
2

Konnektor-Befehl ausführen

Wählen Sie „Dieses Gerät“, kopieren Sie den Befehl aus TypingMind und führen Sie ihn im Terminal aus. Lassen Sie den Prozess laufen, solange Sie MCP verwenden.

  1. Kopieren Sie den in TypingMind angezeigten Einrichtungsbefehl.
  2. Öffnen Sie unter macOS Terminal bzw. unter Windows Windows Terminal.
  3. Fügen Sie den Befehl ein und führen Sie ihn aus.
  4. Bestätigen Sie die Paketinstallation, wenn Sie im Terminal zum Fortfahren aufgefordert werden.
  5. Lassen Sie das Terminalfenster geöffnet und den Prozess darin laufen, solange Sie MCP-Tools verwenden.
3

Production-Grade MCP Server + Agentic System als Server hinzufügen

Wenn der Konnektorstatus „Bereit“ anzeigt, klicken Sie auf „Server ändern“ und fügen Sie die MCP-Server-Konfiguration ein.

  1. Warten Sie, bis der Konnektorstatus „Bereit“ anzeigt.
  2. Klicken Sie auf „Server ändern“.
  3. Fügen Sie die MCP-Server-Konfiguration für Production-Grade MCP Server + Agentic System ein.
  4. Speichern Sie die Serverliste.
  5. Aktualisieren Sie die Ansicht, um bei Bedarf zu prüfen, ob der Konnektor weiterhin bereit ist.
MCP-Einstellungen in TypingMind mit aktivem Server und der Schaltfläche „Server ändern“
{
  "mcpServers": {
    "production-grade-mcp-agentic-system": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Verbindung modellübergreifend nutzen

Speichern Sie die Serverliste, öffnen Sie „Plugins“ und aktivieren Sie die MCP-Tools von Production-Grade MCP Server + Agentic System. Wählen Sie dann ein beliebiges unterstütztes KI-Modell in TypingMind und verwenden Sie die Tools im Chat oder weisen Sie sie einem KI-Agenten zu.

  1. Öffnen Sie die Seite „Plugins“ in TypingMind.
  2. Aktivieren Sie die MCP-Tools von Production-Grade MCP Server + Agentic System.
  3. Starten Sie einen Chat und wählen Sie das KI-Modell, das Sie verwenden möchten.
  4. Nutzen Sie die MCP-Tools im Chat oder weisen Sie sie einem KI-Agenten zu.
  5. Wechseln Sie bei Bedarf zu einem anderen KI-Modell, ohne die MCP-Verbindung erneut herzustellen.
TypingMind-Chat mit aktivierten MCP-Tools und einem ausgewählten KI-Modell
Können Sie mir mit Production-Grade MCP Server + Agentic System bei dieser Aufgabe helfen?
Production-Grade MCP Server + Agentic System
Gerne. Ich habe es gelesen.
Das habe ich mit Production-Grade MCP Server + Agentic System gefunden.

Option 2: Eine MCP-Server-URL hinzufügen

Nutzen Sie diese Option, wenn Production-Grade MCP Server + Agentic System bereits auf einem Remote-Server gehostet wird oder Ihr Team einen gemeinsamen Konnektor für mehrere Benutzer benötigt.

1

MCP-Konnektoren öffnen

Gehen Sie in TypingMind zu „Plugins“, öffnen Sie „MCP-Konnektoren“ und wählen Sie dann „URL hinzufügen“.

  1. Öffnen Sie TypingMind in Ihrem Browser.
  2. Gehen Sie zu „Plugins“.
  3. Öffnen Sie „MCP-Konnektoren“.
  4. Klicken Sie auf „Neue URL“.
TypingMind-Formular zum Hinzufügen einer benutzerdefinierten MCP-Server-URL
2

Server-URL einfügen

Geben Sie die MCP-Server-URL des Anbieters in das Feld „Server-URL“ ein. Fügen Sie einen Verbindungsnamen, eine Beschreibung, ein Symbol, benutzerdefinierte HTTP-Header oder OAuth-Client-Einstellungen hinzu, falls der Server diese erfordert.

  1. Fügen Sie die MCP-Server-URL des Anbieters in das Feld „Server-URL“ ein.
  2. Geben Sie einen Verbindungsnamen für Production-Grade MCP Server + Agentic System ein.
  3. Fügen Sie bei Bedarf eine Beschreibung und ein Symbol hinzu, um die Verbindung leichter zu erkennen.
  4. Fügen Sie benutzerdefinierte HTTP-Header oder OAuth-Client-Daten hinzu, falls der Server eine Authentifizierung erfordert.
3

Verbindung erstellen

Klicken Sie auf „Verbindung erstellen“, kehren Sie dann zur Plugin-Liste zurück und prüfen Sie, ob die neue MCP-Verbindung aktiv ist.

  1. Klicken Sie auf „Verbindung erstellen“.
  2. Kehren Sie zur Liste der MCP-Konnektoren zurück.
  3. Prüfen Sie, ob die Verbindung zu Production-Grade MCP Server + Agentic System als aktiv angezeigt wird.
  4. Aktualisieren Sie die Plugin-Liste, falls die Verbindung nicht sofort angezeigt wird.
4

Modelle ohne erneuten Verbindungsaufbau wechseln

Starten Sie einen Chat mit Ihrem bevorzugten Modell, aktivieren Sie unter „Plugins“ die Tools von Production-Grade MCP Server + Agentic System und wechseln Sie bei Bedarf zu einem anderen Modell. Die MCP-Verbindung bleibt im TypingMind-Arbeitsbereich verfügbar.

  1. Starten Sie einen neuen Chat in TypingMind.
  2. Wählen Sie das KI-Modell, das Sie verwenden möchten.
  3. Aktivieren Sie die Tools von Production-Grade MCP Server + Agentic System unter „Plugins“.
  4. Bitten Sie das Modell, das Tool bei Bedarf zu verwenden.
  5. Wechseln Sie zu einem anderen KI-Modell und verwenden Sie dieselbe MCP-Verbindung weiter.
TypingMind-Chat mit aktivierten MCP-Tools und einem ausgewählten KI-Modell
Können Sie mir mit Production-Grade MCP Server + Agentic System bei dieser Aufgabe helfen?
Production-Grade MCP Server + Agentic System
Gerne. Ich habe es gelesen.
Das habe ich mit Production-Grade MCP Server + Agentic System gefunden.

Häufig gestellte Fragen

Wofür wird der MCP-Server Production-Grade MCP Server + Agentic System verwendet?

Production-Grade MCP Server + Agentic System ist ein MCP-Server, über den kompatible KI-Clients auf externe Tools und Kontext zugreifen können. In TypingMind können Sie diesen MCP-Server einmal hinzufügen und seine Tools in Ihrem KI-Arbeitsbereich verfügbar machen.

Kann ich Production-Grade MCP Server + Agentic System MCP mit mehreren KI-Modellen in TypingMind verwenden?

Ja. TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. So können Sie Production-Grade MCP Server + Agentic System mit verschiedenen KI-Modellen wie Claude, ChatGPT, Gemini oder anderen in TypingMind konfigurierten Modellen verwenden, ohne den MCP-Server für jedes Modell separat einzurichten.

Warum Production-Grade MCP Server + Agentic System MCP mit TypingMind nutzen?

TypingMind ist eine der besten Oberflächen für LLM-Chats, da es mehrere KI-Modelle, Prompts, Plugins, KI-Agenten, API-Schlüssel und MCP-Tools in einem Arbeitsbereich vereint. Sobald Production-Grade MCP Server + Agentic System verbunden ist, können Sie die zugehörigen MCP-Tools mit Ihren bevorzugten Modellen nutzen und Ihre Chat-Abläufe in TypingMind übersichtlich organisieren.

Wie verbinde ich Production-Grade MCP Server + Agentic System MCP mit TypingMind?

Sie können Production-Grade MCP Server + Agentic System in TypingMind über den lokalen MCP-Konnektor oder durch Hinzufügen der URL eines entfernten MCP-Servers verbinden. Verwenden Sie den lokalen Konnektor, wenn der Server auf Dateien, Apps oder private Ressourcen auf Ihrem Gerät zugreifen muss. Nutzen Sie eine Server-URL, wenn der MCP-Server extern gehostet wird.

Welche Tools stellt Production-Grade MCP Server + Agentic System MCP in TypingMind bereit?

Production-Grade MCP Server + Agentic System stellt MCP-Funktionen bereit, die Sie auf der Plugins-Seite in TypingMind aktivieren und im Chat verwenden oder KI-Agenten zuweisen können.

Muss ich meine API-Schlüssel mit TypingMind teilen, um Production-Grade MCP Server + Agentic System MCP zu verwenden?

Nein. TypingMind arbeitet vorrangig lokal, sodass Sie die Kontrolle über Ihre Modellanbieter, API-Schlüssel, Prompts und MCP-Konfiguration behalten. Falls Production-Grade MCP Server + Agentic System eine Authentifizierung erfordert, fügen Sie beim Erstellen der Verbindung die erforderlichen Header, OAuth-Einstellungen oder die lokale Konfiguration für diesen MCP-Server hinzu.

Ähnliche MCP-Server

Alle

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇