Skip to main content
Glama
vivekjais16

MCP Enterprise Server

by vivekjais16
README.md
# MCP Enterprise Server (Model Context Protocol Gateway)

[![CI Pipeline](https://github.com/vivekjais16/mcp-enterprise-server/actions/workflows/ci.yml/badge.svg)](https://github.com/vivekjais16/mcp-enterprise-server/actions)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.115+-009688.svg)](https://fastapi.tiangolo.com)
[![Protocol](https://img.shields.io/badge/MCP-2024--11--05-indigo.svg)](https://modelcontextprotocol.io/)

**Author:** Vivek Jaiswal (<vivekjais16@gmail.com>)  
**Role:** Senior Software Engineer — Python | Django | FastAPI | Generative AI & Agentic AI

---

## 🏛️ Architectural Overview

**MCP Enterprise Server** is a high-performance, security-hardened implementation of Anthropic's **Model Context Protocol (MCP)** specification (JSON-RPC 2.0). It provides stateful AI agents, LLM tool-calling engines, and client interfaces (Claude Desktop, LangGraph supervisors, Cursor) with real-time access to production tools, enterprise databases, knowledge bases, and system observability metrics.

```
+-------------------------------------------------------------+
|               LLM Client / Autonomous Agent                 |
|             (Claude Desktop / LangGraph Router)             |
+------------------------------+------------------------------+
                               |
              JSON-RPC 2.0     |   SSE Stream / Stdio
                               v
+-------------------------------------------------------------+
|              MCP Enterprise Server (FastAPI)                |
|  +---------------------+  +-------------------------------+ |
|  | Bearer Auth & RBAC  |  | Rate Limiter (120 req/min)    | |
|  +---------------------+  +-------------------------------+ |
|  +--------------------------------------------------------+ |
|  |                JSON-RPC 2.0 Engine                     | |
|  |     (initialize, tools/*, resources/*, prompts/*)      | |
|  +--------------------------------------------------------+ |
|        |                  |                 |               |
|        v                  v                 v               |
|  +---------------+  +------------+  +-------------------+   |
|  | Database SQL  |  | Knowledge  |  | Sandboxed Python  |   |
|  | Safety Guard  |  | Search RRF |  | AST Inspector     |   |
|  +---------------+  +------------+  +-------------------+   |
+-------------------------------------------------------------+
```

---

## ⚡ Core Capabilities

### 1. Enterprise Tools
- **`query_database`**: Parameterized SQL query execution with AST validation that blocks mutations (`DROP`, `DELETE`, `UPDATE`, `ALTER`) in read-only agent contexts.
- **`search_knowledge_base`**: Hybrid semantic retrieval across indexed technical documentation with vector scoring.
- **`system_metrics`**: Live host CPU, RAM, disk, and process telemetry inspection for automated SRE agents.
- **`execute_code_sandbox`**: Isolated Python execution with AST import inspection, blocking unsafe primitives (`os`, `sys`, `eval`, `__import__`).

### 2. Contextual Resources
- `system://status` — Live operational health and worker telemetry.
- `database://schema` — Relational schema reflection and column definitions.
- `architecture://overview` — Enterprise microservices topology.

### 3. Prompt Templates
- `audit_sql_query` — Pre-built prompt structure for SQL index optimization and injection audits.
- `incident_investigation` — Automated incident response runbook generation.

### 4. Transports
- **Server-Sent Events (SSE)** (`/sse`): High-throughput streaming transport for distributed microservices and web agents.
- **Stdio Transport** (`src/transports/stdio.py`): Standard I/O interface compatible with Claude Desktop and command-line LLM runners.

---

## 🚀 Quick Start

### 1. Clone & Setup
```bash
git clone https://github.com/vivekjais16/mcp-enterprise-server.git
cd mcp-enterprise-server

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```

### 2. Run Test Suite
```bash
pytest tests/ -v
```

### 3. Launch Server
```bash
uvicorn src.main:app --host 0.0.0.0 --port 8080 --reload
```

---

## 🔒 Security & Authorization

All requests to direct JSON-RPC (`/mcp/rpc`) and SSE (`/sse`) require Bearer token or API key authentication:
```bash
curl -X POST http://localhost:8080/mcp/rpc \
  -H "Authorization: Bearer mcp_live_secret_key_prod_8920171244" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list"
  }'
```

---

## 🐳 Docker Deployment

```bash
docker-compose up -d --build
```