IntegraChat / README.md
nothingworry's picture
first commit
9a99098
|
raw
history blame
15.8 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 Groq's Llama-3.1-8B.

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 tools (RAG, Web, Admin, etc.)
  • βœ… Retrieve tenant-private knowledge
  • βœ… Pull real-time data from the internet
  • βœ… Trigger admin alerts when needed
  • βœ… Respond using Groq's Llama-3.1-8B

2. πŸ“š Enterprise RAG System

  • MiniLM embeddings for semantic search
  • Supabase + pgvector for vector storage
  • Strict multi-tenant RLS enforcement for security
  • Multiple format support: PDF / DOCX / TXT / URL ingestion
  • Intelligent chunking + semantic search

3. 🌐 Live Web Search Tool

  • Real-time news and information
  • General web search capabilities
  • Fact-checking & fresh data retrieval
  • Multiple provider support (DuckDuckGo, SerpAPI, Bing)

4. 🚨 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

5. πŸ“Š 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

6. 🏒 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
MiniLM Embeddings Semantic search embeddings
Groq Llama-3.1-8B LLM inference engine
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                                        β”‚
β”‚  β€’ Tool selection logic                                     β”‚
β”‚  β€’ Groq Llama-3.1 integration                              β”‚
β”‚  β€’ Event logging                                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↕ MCP Protocol
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MCP Servers                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚ RAG Server   β”‚  β”‚ Web Search   β”‚  β”‚ Admin Server β”‚     β”‚
β”‚  β”‚ (Knowledge)  β”‚  β”‚   (Live)     β”‚  β”‚ (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
β”‚   β”‚   └── config.py
β”‚   β”‚
β”‚   β”œβ”€β”€ mcp_servers/
β”‚   β”‚   β”œβ”€β”€ rag_server/
β”‚   β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”‚   β”œβ”€β”€ chunker.py
β”‚   β”‚   β”‚   β”œβ”€β”€ search.py
β”‚   β”‚   β”‚   β”œβ”€β”€ embeddings.py
β”‚   β”‚   β”‚   β”œβ”€β”€ ingestion/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ingest_pdf.py
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ingest_docx.py
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ingest_txt.py
β”‚   β”‚   β”‚   β”‚   └── ingest_url.py
β”‚   β”‚   β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ documents_repo.py
β”‚   β”‚   β”‚   β”‚   └── embeddings_repo.py
β”‚   β”‚   β”‚   └── config.py
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ web_server/
β”‚   β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”‚   β”œβ”€β”€ providers/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ddg.py
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ serpapi.py (optional)
β”‚   β”‚   β”‚   β”‚   └── bing.py (optional)
β”‚   β”‚   β”‚   └── utils.py
β”‚   β”‚   β”‚
β”‚   β”‚   └── admin_server/
β”‚   β”‚       β”œβ”€β”€ main.py
β”‚   β”‚       β”œβ”€β”€ redflag_rules.py
β”‚   β”‚       β”œβ”€β”€ alerts/
β”‚   β”‚       β”‚   β”œβ”€β”€ slack.py
β”‚   β”‚       β”‚   β”œβ”€β”€ email.py
β”‚   β”‚       β”‚   └── webhook.py
β”‚   β”‚       └── audit_logs.py
β”‚   β”‚
β”‚   β”œβ”€β”€ 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+
  • βœ… Supabase project (with pgvector extension)
  • βœ… Groq API key
  • βœ… 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

    cp .env.example .env
    # Edit .env and fill in your Supabase + Groq keys
    
  4. Run the development server

    uvicorn api.main:app --reload
    

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 RAG + web search reasoning
🏒 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 retrieve private knowledge using RAG, access live web information, and enforce admin-defined safety rules via a red-flag compliance system. It includes an analytics dashboard, 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