IntegraChat / README.md
nothingworry's picture
Reasoning traces, smarter tools, deterministic backend tests.
ef83e66
|
raw
history blame
17.7 kB

πŸš€ IntegraChat

Multi-Tenant Autonomous MCP Platform

Enterprise-grade AI with autonomous agents, secure multi-tenant RAG, real-time web search, red-flag governance, and analytics.

Python React FastAPI License MCP


πŸ“‘ Table of Contents


πŸ“Œ Overview

IntegraChat is an enterprise-ready, multi-tenant AI platform built to demonstrate the full capabilities of the Model Context Protocol (MCP) in a real production-style environment.

It combines autonomous tool-using agents, RAG retrieval, live web search, and admin governance under strict tenant isolation, powered by Ollama (local) or Groq (cloud) LLM inference.

IntegraChat is a complete "MCP in Action" ecosystem β€” ideal for enterprise demos, research, production scaffolds, and governance-focused AI deployments.


🎯 Purpose

IntegraChat showcases how MCP can power intelligent, governed, multi-tenant AI systems with real-world requirements:

  • πŸ”’ Isolation & Access Control - Strict tenant separation
  • πŸ›‘οΈ Compliance & Red-Flag Detection - Automated safety monitoring
  • πŸ€– Tool-Aware Autonomous Reasoning - Dynamic tool selection
  • πŸ” RAG + Web Search Hybrid AI - Best of both worlds
  • πŸ“Š Analytics & Observability - Full system insights
  • βš™οΈ Admin Governance Workflows - Enterprise-ready controls

🧩 Key Features

1. πŸ€– Autonomous MCP Agents

Agents can intelligently:

  • βœ… Analyze user intent and context
  • βœ… Detect sensitive or unsafe content
  • βœ… Dynamically select multiple tools in sequence (RAG + Web + LLM, Web + LLM, RAG + LLM, etc.)
  • βœ… Multi-step tool execution - Execute tools sequentially and synthesize results
  • βœ… Retrieve tenant-private knowledge
  • βœ… Pull real-time data from the internet
  • βœ… Trigger admin alerts when needed
  • βœ… Respond using Ollama (local) or Groq (cloud) LLM

2. πŸ“š Enterprise RAG System

  • MiniLM embeddings (384-dim) for semantic search
  • Supabase + pgvector for vector storage
  • Automatic database schema initialization on server startup
  • Strict multi-tenant isolation with tenant_id filtering
  • Intelligent text chunking (~300 words per chunk)
  • Vector similarity search using cosine distance

3. 🌐 Live Web Search Tool

  • Real-time news and information
  • General web search capabilities
  • English language results - Forces English content via region parameters
  • Fact-checking & fresh data retrieval
  • Multiple provider support (DuckDuckGo, SerpAPI, Bing)

4. πŸ”„ Multi-Tool Selection & Execution

The intelligent tool selector can:

  • Pattern-based detection - Recognizes fact queries, freshness keywords, internal docs
  • LLM-enhanced planning - Uses LLM to determine optimal tool combinations
  • Sequential execution - Executes tools in order (RAG β†’ Web β†’ LLM)
  • Result synthesis - Combines all tool outputs into comprehensive responses

Supported combinations:

  • RAG + LLM - Internal knowledge questions
  • Web + LLM - Public fact questions
  • RAG + Web + LLM - Comprehensive queries needing both sources
  • LLM only - Simple conversational queries

5. 🚨 Red-Flag Governance Engine

Admins configure rules to:

  • β›” Block unsafe queries automatically
  • πŸ“ Log violations for audit trails
  • πŸ”” Trigger admin alerts in real-time

Example rules: salary, delete all data, confidential client info

6. πŸ“Š Analytics Dashboard

Comprehensive insights for:

  • πŸ“ˆ Query volume and trends
  • πŸ”§ Tool usage statistics
  • 🎯 RAG performance metrics
  • 🚨 Red-flag violation tracking
  • 🧠 Agent reasoning traces
  • πŸ‘₯ Tenant activity monitoring

7. 🏒 Multi-Tenant Isolation

Each tenant gets:

  • πŸ” Private agents
  • πŸ“¦ Private knowledge base
  • βš™οΈ Private admin rules
  • πŸ“Š Private analytics

Isolation is guaranteed via Supabase Row-Level Security (RLS).


πŸ›  Technology Stack

Backend

Technology Purpose
FastAPI High-performance API framework
MCP Client + Servers Model Context Protocol implementation
Supabase Auth + Storage + pgvector database
PostgreSQL + pgvector Vector database for embeddings
MiniLM Embeddings Semantic search embeddings (384-dim)
Ollama / Groq LLM inference engine (configurable)
DuckDuckGo Search Web search provider
Slack / Email Alerting system

Frontend

Technology Purpose
React 18 Modern UI framework
TailwindCSS Utility-first styling
Zustand State management
WebSocket Real-time streaming
Admin Dashboard Analytics & governance UI

🧱 System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Frontend (React)                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Chat UI  β”‚  β”‚  Admin   β”‚  β”‚Analytics β”‚  β”‚WebSocket β”‚  β”‚
β”‚  β”‚          β”‚  β”‚  Panel   β”‚  β”‚ Dashboardβ”‚  β”‚Streaming β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↕ HTTP/WebSocket
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              MCP Client (FastAPI)                           β”‚
β”‚  β€’ Intent handling                                          β”‚
β”‚  β€’ Red-flag scanning                                        β”‚
β”‚  β€’ Multi-tool selection logic                               β”‚
β”‚  β€’ Sequential tool execution                                β”‚
β”‚  β€’ Groq Llama-3.1 integration                              β”‚
β”‚  β€’ Event logging                                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↕ MCP Protocol
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MCP Servers                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚ RAG Server   β”‚  β”‚ Web Search   β”‚  β”‚ Admin Server β”‚     β”‚
β”‚  β”‚ (Knowledge)  β”‚  β”‚ (Live/EN)    β”‚  β”‚ (Governance) β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↕
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Supabase Database                              β”‚
β”‚  β€’ Authentication                                           β”‚
β”‚  β€’ pgvector (embeddings)                                    β”‚
β”‚  β€’ Row-Level Security (RLS)                                 β”‚
β”‚  β€’ Storage                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

IntegraChat/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ agent.py
β”‚   β”‚   β”‚   β”œβ”€β”€ rag.py
β”‚   β”‚   β”‚   β”œβ”€β”€ web.py
β”‚   β”‚   β”‚   β”œβ”€β”€ admin.py
β”‚   β”‚   β”‚   └── analytics.py
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ agent_orchestrator.py
β”‚   β”‚   β”‚   β”œβ”€β”€ intent_classifier.py
β”‚   β”‚   β”‚   β”œβ”€β”€ redflag_detector.py
β”‚   β”‚   β”‚   β”œβ”€β”€ tool_selector.py
β”‚   β”‚   β”‚   β”œβ”€β”€ prompt_builder.py
β”‚   β”‚   β”‚   └── llm_client.py
β”‚   β”‚   β”œβ”€β”€ mcp_clients/
β”‚   β”‚   β”‚   β”œβ”€β”€ rag_client.py
β”‚   β”‚   β”‚   β”œβ”€β”€ web_client.py
β”‚   β”‚   β”‚   └── admin_client.py
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ requests.py
β”‚   β”‚   β”‚   β”œβ”€β”€ responses.py
β”‚   β”‚   β”‚   β”œβ”€β”€ agent_decision.py
β”‚   β”‚   β”‚   └── embeddings.py
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   β”œβ”€β”€ logging.py
β”‚   β”‚   β”‚   β”œβ”€β”€ supabase_client.py
β”‚   β”‚   β”‚   β”œβ”€β”€ tenant_context.py
β”‚   β”‚   β”‚   β”œβ”€β”€ security.py
β”‚   β”‚   β”‚   └── text_extractor.py   
β”‚   β”‚   └── config.py
β”‚   β”‚
β”‚   β”œβ”€β”€ mcp_servers/
β”‚   β”‚   β”œβ”€β”€ main.py              # RAG MCP Server (FastAPI)
β”‚   β”‚   β”œβ”€β”€ database.py          # Supabase/PostgreSQL connection
β”‚   β”‚   └── embeddings.py        # Sentence transformers embeddings
β”‚   β”‚
β”‚   β”œβ”€β”€ workers/
β”‚   β”‚   β”œβ”€β”€ ingestion_worker.py
β”‚   β”‚   β”œβ”€β”€ analytics_worker.py
β”‚   β”‚   β”œβ”€β”€ scheduler.py
β”‚   β”‚   └── celeryconfig.py
β”‚   β”‚
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   β”œβ”€β”€ test_agent.py
β”‚   β”‚   β”œβ”€β”€ test_rag.py
β”‚   β”‚   β”œβ”€β”€ test_admin.py
β”‚   β”‚   β”œβ”€β”€ test_web.py
β”‚   β”‚   └── test_end_to_end.py
β”‚   β”‚
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ chat/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ChatWindow.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ MessageBubble.jsx
β”‚   β”‚   β”‚   β”‚   └── ToolTraces.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ RedFlagEditor.jsx
β”‚   β”‚   β”‚   β”‚   └── TenantManager.jsx
β”‚   β”‚   β”‚   └── analytics/
β”‚   β”‚   β”‚       β”œβ”€β”€ QueryStats.jsx
β”‚   β”‚   β”‚       β”œβ”€β”€ ToolUsageChart.jsx
β”‚   β”‚   β”‚       └── RagEffectiveness.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminPage.jsx
β”‚   β”‚   β”‚   └── AnalyticsPage.jsx
β”‚   β”‚   β”œβ”€β”€ store/
β”‚   β”‚   β”‚   β”œβ”€β”€ chatStore.js
β”‚   β”‚   β”‚   β”œβ”€β”€ adminStore.js
β”‚   β”‚   β”‚   └── analyticsStore.js
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   β”œβ”€β”€ websocket.js
β”‚   β”‚   β”‚   β”œβ”€β”€ api.js
β”‚   β”‚   β”‚   └── formatters.js
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ public/
β”‚   └── package.json
β”‚
β”œβ”€β”€ supabase/
β”‚   β”œβ”€β”€ migrations/
β”‚   β”‚   β”œβ”€β”€ 001_init.sql
β”‚   β”‚   β”œβ”€β”€ 002_embeddings.sql
β”‚   β”‚   β”œβ”€β”€ 003_redflag_rules.sql
β”‚   β”‚   └── 004_analytics_tables.sql
β”‚   β”œβ”€β”€ seed/
β”‚   β”‚   β”œβ”€β”€ default_redflags.sql
β”‚   β”‚   └── demo_tenants.sql
β”‚   β”œβ”€β”€ policies/
β”‚   β”‚   β”œβ”€β”€ rls_tenant_documents.sql
β”‚   β”‚   β”œβ”€β”€ rls_tenant_embeddings.sql
β”‚   β”‚   └── rls_admin_rules.sql
β”‚   β”œβ”€β”€ functions/
β”‚   β”‚   └── vector_search.sql
β”‚   └── README.md
β”‚
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ architecture-diagram.png
β”‚   β”œβ”€β”€ sequence-mcp-agent.png
β”‚   β”œβ”€β”€ api-spec.md
β”‚   β”œβ”€β”€ mcp-server-protocol.md
β”‚   └── rag-pipeline.md
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ run_dev.sh
β”‚   β”œβ”€β”€ build_all.sh
β”‚   β”œβ”€β”€ reset_db.sh
β”‚   └── run_workers.sh
β”‚
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ README.md
└── LICENSE

πŸš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • βœ… Python 3.10+
  • βœ… Node.js 18+ (for frontend)
  • βœ… Supabase project (with pgvector extension enabled)
  • βœ… PostgreSQL connection string (from Supabase)
  • βœ… Ollama (for local LLM) or Groq API key (for cloud LLM)
  • βœ… DuckDuckGo Search key (optional, if configured)
  • βœ… Slack/Email webhook for alerts (optional)

Backend Setup

  1. Navigate to backend directory

    cd backend
    
  2. Install dependencies

    pip install -r requirements.txt
    
  3. Configure environment variables

    Create a .env file in the project root with the following:

    # Database Configurationa
    POSTGRESQL_URL=postgresql://user:password@host:port/database
    SUPABASE_URL=https://your-project.supabase.co
    SUPABASE_SERVICE_KEY=your_service_role_key
    
    # MCP Server URLs
    RAG_MCP_URL=http://localhost:8001
    WEB_MCP_URL=http://localhost:8002
    ADMIN_MCP_URL=http://localhost:8003
    
    # LLM Configuration
    OLLAMA_URL=http://localhost:11434
    OLLAMA_MODEL=llama3
    # Or use Groq instead:
    # GROQ_API_KEY=your_groq_api_key
    
  4. Start the RAG MCP Server

    cd backend/mcp_servers
    python main.py
    

    The server will automatically initialize the database schema on startup.

    • Server runs on http://localhost:8001
    • API docs available at http://localhost:8001/docs
  5. Run the main API server

    cd backend
    uvicorn api.main:app --reload
    

RAG MCP Server API

The RAG MCP Server provides two main endpoints:

Ingest Documents:

curl -X POST http://localhost:8001/ingest \
  -H "Content-Type: application/json" \
  -d '{
    "tenant_id": "tenant123",
    "content": "Your document text here..."
  }'

Semantic Search:

curl -X POST http://localhost:8001/search \
  -H "Content-Type: application/json" \
  -d '{
    "tenant_id": "tenant123",
    "query": "What are the HR policies?"
  }'

Frontend Setup

  1. Navigate to frontend directory

    cd frontend
    
  2. Install dependencies

    npm install
    
  3. Start the development server

    npm run dev
    

Quick Start with Docker

docker-compose up -d

✨ Why IntegraChat Stands Out

Feature Description
πŸ€– True MCP-Native Autonomous agents (not static prompts)
πŸ›‘οΈ Enterprise Governance Regex-based red-flag rules system
πŸ” Hybrid Intelligence Multi-tool selection (RAG + Web + LLM combinations)
πŸ”„ Sequential Execution Execute multiple tools in sequence and synthesize results
🌐 English Web Search Forces English language results for better accuracy
🏒 Production-Grade Multi-tenant design with strict Supabase RLS
πŸ“Š Full Observability Logs, analytics, tool events, violations
🎯 Demo-Ready Perfect for enterprise presentations

🏷 Submission Metadata

Field Value
Track MCP in Action
Category Enterprise
Tag mcp-in-action-track-enterprise
Project Name IntegraChat

Short Summary

IntegraChat is a multi-tenant AI platform where autonomous MCP-powered agents intelligently select and execute multiple tools in sequence (RAG + Web + LLM combinations), retrieve private knowledge using RAG, access live web information in English, and enforce admin-defined safety rules via a red-flag compliance system. It includes an analytics dashboard, advanced multi-tool selection engine, and strict tenant isolation.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ“¬ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


πŸ™ Acknowledgments


Made with ❀️ for the MCP community

⬆ Back to Top