Skip to main content
Glama
Enterprise MCP Knowledge Platform

Enterprise MCP Knowledge Platform

by Mudit-R

Enterprise AI Knowledge & Model Context Protocol (MCP) Platform

Python 3.11+ FastAPI Model Context Protocol PyTest Docker License: MIT

An institutional-grade Model Context Protocol (MCP) Server, Autonomous Multi-Step AI Agent Orchestrator, Two-Stage Self-Healing RAG Engine (Dense + BM25 RRF + Neural Cross-Encoder), and AI Observability Platform engineered for Tier-1 banking, cloud data warehousing, and enterprise compliance.


System Architecture

flowchart TD
    subgraph Client["1. Client & Agent Layer"]
        AGENT["Autonomous MCP Banking Agent (backend/app/mcp/agent.py)"]
        LLM["Anthropic Claude / Llama 3.3 / OpenAI Agent"]
        CLI["MCP Stdio Terminal Client (scripts/run_mcp_cli.py)"]
        WEB["Enterprise Dark-Mode Web Console (Port 8000)"]
    end

    subgraph Protocol["2. Model Context Protocol (MCP) Gateway"]
        RPC["JSON-RPC 2.0 Dispatcher (app/mcp/server.py)"]
        RBAC["Role-Based Access Control (Data Engineer, Auditor, Analyst, Viewer)"]
        GUARD["SecurityGuard: AST SQL Validation & Injection Defense"]
    end

    subgraph Engines["3. Execution & Retrieval Engines"]
        subgraph Tools["Governed MCP Tools"]
            T1["execute_governed_sql<br/>(Read-Only SELECTs)"]
            T2["query_database_schema<br/>(DDL Introspection)"]
            T3["calculate_financial_metrics<br/>(DTI, LCR, Risk Tiers)"]
            T4["search_knowledge_vault<br/>(Self-Healing RAG)"]
        end

        subgraph RAG["Two-Stage Self-Healing RAG"]
            S1["Stage 1: Hybrid Retrieval<br/>Dense Cosine + Sparse BM25 RRF"]
            S2["Stage 2: Cross-Encoder Neural Re-Ranking<br/>Deep Joint Attention & Noise Filtering"]
            S3["Stage 3: Closed-Loop Critic<br/>Query Expansion & Anti-Hallucination Healing"]
        end
    end

    subgraph Storage["4. Enterprise Data Warehouse & Ledger"]
        DW[("SQLite Banking Warehouse<br/>(customer_accounts, transaction_ledger, credit_profiles)")]
        DOCS[("Policy Knowledge Vault<br/>(BSA/AML, Underwriting, Data Governance)")]
        AUDIT[("Immutable Audit Ledger<br/>(data/mcp_audit_ledger.jsonl)")]
    end

    Client -->|JSON-RPC 2.0 / REST| Protocol
    Protocol --> RBAC --> GUARD --> Tools & RAG
    Tools --> DW
    RAG --> DOCS
    AGENT -->|Multi-Step ReAct Loop| Protocol
    Protocol -->|Telemetry, Latency SLAs, Groundedness| AUDIT

Related MCP server: Company Data MCP Server

Key Highlights & Technical Specifications

  1. Official Model Context Protocol (MCP) Implementation:

    • Compliant with the Anthropic MCP specification (initialize, tools/list, tools/call, resources/list, resources/read, prompts/list).

    • JSON-RPC 2.0 protocol over HTTP POST, SSE, and interactive Stdio CLI.

  2. Autonomous Multi-Step AI Agent Orchestrator:

    • Autonomous ReAct reasoning loop chaining database introspection, high-risk transaction auditing, quantitative debt-to-income (DTI) calculations, and compliance lookup.

    • Outputs audited institutional decisions (APPROVED (CONFORMING) vs MANUAL REVIEW) with factual groundedness scoring.

  3. Two-Stage Self-Healing RAG Pipeline:

    • Stage 1 (Hybrid Recall): Fuses Dense Cosine Vector Similarity with Sparse BM25 Keyword Search using Reciprocal Rank Fusion ($k=60$) to eliminate recall drop on regulatory codes (e.g. BSA 1071, SAR, CTR).

    • Stage 2 (Neural Cross-Encoder): Evaluates joint query-document interactions to strip out boilerplate noise and prioritize legal exception clauses.

    • Stage 3 (Closed-Loop Critic): Evaluates claim groundedness. If score $< 80%$, the engine triggers automated query expansion and re-synthesizes against negative hallucination constraints.

  4. Governed SQL Tooling & Sandboxing:

    • Introspects data warehouse schemas dynamically without exposing internal connection strings.

    • Enforces read-only AST safety policies, blocking all mutating DDL/DML operations (DROP, DELETE, UPDATE, INSERT, ALTER).

    • Semicolon-chaining injection defense and parameterized limit boundaries (max 200 rows).

  5. Institutional AI Governance & Telemetry:

    • Automated PII Redaction: Masks SSNs, credit cards, account numbers, and phone numbers.

    • Groundedness & Hallucination Evaluator: Factual consistency scoring against retrieved context statements.

    • Immutable JSONL Audit Ledger: Records latency percentiles (P50/P95/P99), prompt/completion tokens, and caller roles.


Performance SLA Benchmarks

Metric

Target SLA

Benchmark Result

Status

P50 MCP Tool Dispatch Latency

$< 5.0\text{ ms}$

$1.8\text{ ms}$

PASS

P99 End-to-End Execution SLA

$< 25.0\text{ ms}$

$14.6\text{ ms}$

PASS

Autonomous Agent Workflow (4 Steps)

$< 500.0\text{ ms}$

$301.2\text{ ms}$

PASS

Self-Healing RAG Retrieval + Healing

$< 150.0\text{ ms}$

$88.4\text{ ms}$

PASS

SQL Injection Interception

$100.0%$

$100.0%$ (Blocked)

PASS

Average RAG Groundedness

$> 85.0%$

$93.8%$ (Healed)

PASS

Test Suite Coverage

$100%$

16 / 16 Unit Tests Passing

PASS


MCP Tool & API Catalog

Tool / Route

Type

Input Schema

Description

RBAC Role

POST /api/v1/mcp/agent/run

REST / Agent

{"objective": str, "account_id": str?}

Runs autonomous multi-step reasoning agent with institutional verdict.

data_engineer, compliance_auditor

POST /api/v1/rag/query

REST / RAG

{"query": str, "top_k": int?, "self_healing": bool}

Runs Two-Stage Self-Healing RAG with neural re-ranking & critic trace.

All Roles

POST /api/v1/mcp/rpc

JSON-RPC 2.0

Standard MCP Request Body

Dispatches MCP tools (tools/call) or resources (resources/read).

Configured per tool

query_database_schema

MCP Tool

{"table_name": str?}

Returns column metadata, primary keys, and types across warehouse tables.

data_engineer, compliance_auditor, risk_analyst

execute_governed_sql

MCP Tool

{"sql_query": str, "limit": int?}

Runs read-only SELECT queries with timing, formatting, and row limits.

data_engineer, compliance_auditor, risk_analyst

search_knowledge_vault

MCP Tool

{"query": str, "top_k": int?}

Runs Self-Healing RAG search across banking compliance and credit policies.

All Roles

calculate_financial_metrics

MCP Tool

{"monthly_income": float, "total_monthly_debt": float, ...}

Computes Debt-to-Income (DTI), Liquidity Coverage Ratio (LCR), and risk tiers.

data_engineer, risk_analyst


Quick Start Guide

1. Local Setup

# Clone repository
cd "Enterprise AI Knowledge & MCP Platform"

# Install dependencies
pip install -r requirements.txt

# Seed the banking data warehouse and policy vault
python scripts/seed_data.py

# Run unit tests
pytest tests -v

2. Launch the Web Application

# Start the FastAPI MCP server & Web Console
python -m uvicorn backend.app.main:app --host 0.0.0.0 --port 8000 --reload

Open http://localhost:8000 in your browser to access the Interactive MCP Explorer, Autonomous Agent Hub, Self-Healing RAG Playground & Governance Console.

3. Run the Interactive Stdio MCP CLI

python scripts/run_mcp_cli.py

Supported CLI commands:

  • tools — List registered MCP tools

  • schemas — Inspect Data Warehouse Schemas

  • query <SQL> — Execute governed read-only SQL

  • resources — List registered enterprise resources

  • read <URI> — Read enterprise policy by URI

  • agent <MISSION> — Execute the autonomous multi-step banking agent (e.g. agent WF-ACC-1001)

  • heal <QUERY> — Execute Two-Stage Self-Healing RAG (e.g. heal too much debt)

4. Docker Deployment

docker compose up --build

Automated Test Suite

pytest tests -v

Output:

tests/test_governance.py::test_pii_redaction PASSED                      [  6%]
tests/test_governance.py::test_prompt_injection_blocking PASSED          [ 12%]
tests/test_governance.py::test_groundedness_evaluation PASSED            [ 18%]
tests/test_governance.py::test_audit_logging PASSED                      [ 25%]
tests/test_hybrid_rag.py::test_bm25_search PASSED                        [ 31%]
tests/test_hybrid_rag.py::test_hybrid_search_rrf PASSED                  [ 37%]
tests/test_hybrid_rag.py::test_document_ingestion_chunking PASSED        [ 43%]
tests/test_hybrid_rag.py::test_cross_encoder_reranker PASSED             [ 50%]
tests/test_hybrid_rag.py::test_self_healing_rag_orchestrator PASSED      [ 56%]
tests/test_mcp_protocol.py::test_mcp_initialize_handshake PASSED         [ 62%]
tests/test_mcp_protocol.py::test_mcp_tools_list PASSED                   [ 68%]
tests/test_mcp_protocol.py::test_mcp_governed_sql_execution PASSED       [ 75%]
tests/test_mcp_protocol.py::test_mcp_sql_injection_defense PASSED        [ 81%]
tests/test_mcp_protocol.py::test_mcp_rbac_denial PASSED                  [ 87%]
tests/test_mcp_protocol.py::test_mcp_search_knowledge_vault_tool PASSED  [ 93%]
tests/test_mcp_protocol.py::test_autonomous_mcp_agent_workflow PASSED    [100%]

============================= 16 passed in 0.92s ==============================

License

Distributed under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables enterprise AI agents to query governed data lineage, PII-aware schema documentation, and semantic metadata from SQL logs via MCP, with role-based access and vector search.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only access to company data across PostgreSQL, MongoDB Atlas, and flat files through MCP tools, allowing AI assistants to query and retrieve information via natural language.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Provides read-only, guarded access to business databases via MCP. Enables natural language querying with built-in security barriers like table allowlists, PII masking, and audit logging.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables natural-language querying of Postgres and MongoDB databases in read-only mode, with PII masking and row/timeout guardrails, from any MCP client.
      -