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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# **IntegraChat β Multi-Tenant Autonomous MCP Platform**
|
| 2 |
+
|
| 3 |
+
### **Enterprise-grade AI with autonomous agents, secure multi-tenant RAG, real-time web search, red-flag governance, and analytics.**
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## **π Overview**
|
| 8 |
+
|
| 9 |
+
**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.
|
| 10 |
+
|
| 11 |
+
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**.
|
| 12 |
+
|
| 13 |
+
IntegraChat is a complete "**MCP in Action**" ecosystem β ideal for enterprise demos, research, production scaffolds, and governance-focused AI deployments.
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# **π― Purpose**
|
| 18 |
+
|
| 19 |
+
IntegraChat showcases how MCP can power **intelligent, governed, multi-tenant AI systems** with real-world requirements:
|
| 20 |
+
|
| 21 |
+
* Isolation & access control
|
| 22 |
+
* Compliance & red-flag detection
|
| 23 |
+
* Tool-aware autonomous reasoning
|
| 24 |
+
* RAG + web search hybrid AI
|
| 25 |
+
* Analytics & observability
|
| 26 |
+
* Admin governance workflows
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
# **π§© Key Features**
|
| 31 |
+
|
| 32 |
+
## **1. Autonomous MCP Agents**
|
| 33 |
+
|
| 34 |
+
Agents can:
|
| 35 |
+
|
| 36 |
+
* Analyze user intent
|
| 37 |
+
* Detect sensitive or unsafe content
|
| 38 |
+
* Dynamically select tools (RAG, Web, Admin, etc.)
|
| 39 |
+
* Retrieve tenant-private knowledge
|
| 40 |
+
* Pull real-time data from the internet
|
| 41 |
+
* Trigger admin alerts
|
| 42 |
+
* Respond using Groq's **Llama-3.1-8B**
|
| 43 |
+
|
| 44 |
+
## **2. Enterprise RAG System**
|
| 45 |
+
|
| 46 |
+
* MiniLM embeddings
|
| 47 |
+
* Supabase + pgvector
|
| 48 |
+
* Strict multi-tenant RLS enforcement
|
| 49 |
+
* PDF / DOCX / TXT / URL ingestion
|
| 50 |
+
* Chunking + semantic search
|
| 51 |
+
|
| 52 |
+
## **3. Live Web Search Tool**
|
| 53 |
+
|
| 54 |
+
* Real-time news
|
| 55 |
+
* General web search
|
| 56 |
+
* Fact-checking & fresh data retrieval
|
| 57 |
+
|
| 58 |
+
## **4. Red-Flag Governance Engine**
|
| 59 |
+
|
| 60 |
+
Admins configure rules to:
|
| 61 |
+
|
| 62 |
+
* Block unsafe queries
|
| 63 |
+
* Log violations
|
| 64 |
+
* Trigger admin alerts
|
| 65 |
+
|
| 66 |
+
Examples: `salary`, `delete all data`, `confidential client info`.
|
| 67 |
+
|
| 68 |
+
## **5. Analytics Dashboard**
|
| 69 |
+
|
| 70 |
+
Includes insights for:
|
| 71 |
+
|
| 72 |
+
* Query volume
|
| 73 |
+
* Tool usage
|
| 74 |
+
* RAG performance
|
| 75 |
+
* Red-flag violations
|
| 76 |
+
* Agent reasoning traces
|
| 77 |
+
* Tenant activity
|
| 78 |
+
|
| 79 |
+
## **6. Multi-Tenant Isolation**
|
| 80 |
+
|
| 81 |
+
Each tenant gets:
|
| 82 |
+
|
| 83 |
+
* Private agents
|
| 84 |
+
* Private knowledge base
|
| 85 |
+
* Private admin rules
|
| 86 |
+
* Private analytics
|
| 87 |
+
|
| 88 |
+
Isolation is guaranteed via **Supabase RLS**.
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
# **π Technology Stack**
|
| 93 |
+
|
| 94 |
+
## **Backend**
|
| 95 |
+
|
| 96 |
+
* FastAPI
|
| 97 |
+
* MCP Client + MCP Servers
|
| 98 |
+
* Supabase (Auth + Storage + pgvector)
|
| 99 |
+
* MiniLM Embeddings
|
| 100 |
+
* Groq Llama-3.1-8B
|
| 101 |
+
* DuckDuckGo Search
|
| 102 |
+
* Slack / Email alerting
|
| 103 |
+
|
| 104 |
+
## **Frontend**
|
| 105 |
+
|
| 106 |
+
* React 18
|
| 107 |
+
* TailwindCSS
|
| 108 |
+
* Zustand
|
| 109 |
+
* WebSocket streaming
|
| 110 |
+
* Admin dashboard + analytics
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
+
|
| 114 |
+
# **π§± System Architecture**
|
| 115 |
+
|
| 116 |
+
```
|
| 117 |
+
Frontend (React)
|
| 118 |
+
|
| 119 |
+
- Chat UI
|
| 120 |
+
|
| 121 |
+
- Admin Panel
|
| 122 |
+
|
| 123 |
+
- Analytics / Insights
|
| 124 |
+
|
| 125 |
+
- WebSocket streaming
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
MCP Client (FastAPI)
|
| 130 |
+
|
| 131 |
+
- Intent handling
|
| 132 |
+
|
| 133 |
+
- Red-flag scanning
|
| 134 |
+
|
| 135 |
+
- Tool selection logic
|
| 136 |
+
|
| 137 |
+
- Calls Groq Llama-3.1
|
| 138 |
+
|
| 139 |
+
- Event logging
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
MCP Servers:
|
| 144 |
+
|
| 145 |
+
- RAG Server (private knowledge)
|
| 146 |
+
|
| 147 |
+
- Web Search Server (live data)
|
| 148 |
+
|
| 149 |
+
- Admin Server (alerts / governance)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
Database:
|
| 154 |
+
|
| 155 |
+
- Supabase (Auth + Storage + pgvector + RLS)
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
---
|
| 159 |
+
|
| 160 |
+
# **π Project Structure**
|
| 161 |
+
|
| 162 |
+
```
|
| 163 |
+
IntegraChat/
|
| 164 |
+
βββ backend/
|
| 165 |
+
β βββ api/
|
| 166 |
+
β β βββ main.py
|
| 167 |
+
β β βββ routes/
|
| 168 |
+
β β β βββ agent.py
|
| 169 |
+
β β β βββ rag.py
|
| 170 |
+
β β β βββ web.py
|
| 171 |
+
β β β βββ admin.py
|
| 172 |
+
β β β βββ analytics.py
|
| 173 |
+
β β βββ services/
|
| 174 |
+
β β β βββ agent_orchestrator.py
|
| 175 |
+
β β β βββ intent_classifier.py
|
| 176 |
+
β β β βββ redflag_detector.py
|
| 177 |
+
β β β βββ tool_selector.py
|
| 178 |
+
β β β βββ prompt_builder.py
|
| 179 |
+
β β β βββ llm_client.py
|
| 180 |
+
β β βββ mcp_clients/
|
| 181 |
+
β β β βββ rag_client.py
|
| 182 |
+
β β β βββ web_client.py
|
| 183 |
+
β β β βββ admin_client.py
|
| 184 |
+
β β βββ models/
|
| 185 |
+
β β β βββ requests.py
|
| 186 |
+
β β β βββ responses.py
|
| 187 |
+
β β β βββ agent_decision.py
|
| 188 |
+
β β β βββ embeddings.py
|
| 189 |
+
β β βββ utils/
|
| 190 |
+
β β β βββ logging.py
|
| 191 |
+
β β β βββ supabase_client.py
|
| 192 |
+
β β β βββ tenant_context.py
|
| 193 |
+
β β β βββ security.py
|
| 194 |
+
β β βββ config.py
|
| 195 |
+
β β
|
| 196 |
+
β βββ mcp_servers/
|
| 197 |
+
β β βββ rag_server/
|
| 198 |
+
β β β βββ main.py
|
| 199 |
+
β β β βββ chunker.py
|
| 200 |
+
β β β βββ search.py
|
| 201 |
+
β β β βββ embeddings.py
|
| 202 |
+
β β β βββ ingestion/
|
| 203 |
+
β β β β βββ ingest_pdf.py
|
| 204 |
+
β β β β βββ ingest_docx.py
|
| 205 |
+
β β β β βββ ingest_txt.py
|
| 206 |
+
β β β β βββ ingest_url.py
|
| 207 |
+
β β β βββ db/
|
| 208 |
+
β β β β βββ documents_repo.py
|
| 209 |
+
β β β β βββ embeddings_repo.py
|
| 210 |
+
β β β ββοΏ½οΏ½ config.py
|
| 211 |
+
β β β
|
| 212 |
+
β β βββ web_server/
|
| 213 |
+
β β β βββ main.py
|
| 214 |
+
β β β βββ providers/
|
| 215 |
+
β β β β βββ ddg.py
|
| 216 |
+
β β β β βββ serpapi.py (optional)
|
| 217 |
+
β β β β βββ bing.py (optional)
|
| 218 |
+
β β β βββ utils.py
|
| 219 |
+
β β β
|
| 220 |
+
β β βββ admin_server/
|
| 221 |
+
β β βββ main.py
|
| 222 |
+
β β βββ redflag_rules.py
|
| 223 |
+
β β βββ alerts/
|
| 224 |
+
β β β βββ slack.py
|
| 225 |
+
β β β βββ email.py
|
| 226 |
+
β β β βββ webhook.py
|
| 227 |
+
β β βββ audit_logs.py
|
| 228 |
+
β β
|
| 229 |
+
β βββ workers/
|
| 230 |
+
β β βββ ingestion_worker.py
|
| 231 |
+
β β βββ analytics_worker.py
|
| 232 |
+
β β βββ scheduler.py
|
| 233 |
+
β β βββ celeryconfig.py
|
| 234 |
+
β β
|
| 235 |
+
β βββ tests/
|
| 236 |
+
β β βββ test_agent.py
|
| 237 |
+
β β βββ test_rag.py
|
| 238 |
+
β β βββ test_admin.py
|
| 239 |
+
β β βββ test_web.py
|
| 240 |
+
β β βββ test_end_to_end.py
|
| 241 |
+
β β
|
| 242 |
+
β βββ Dockerfile
|
| 243 |
+
β
|
| 244 |
+
βββ frontend/
|
| 245 |
+
β βββ src/
|
| 246 |
+
β β βββ components/
|
| 247 |
+
β β β βββ chat/ChatWindow.jsx
|
| 248 |
+
β β β βββ chat/MessageBubble.jsx
|
| 249 |
+
β β β βββ chat/ToolTraces.jsx
|
| 250 |
+
β β β βββ admin/RedFlagEditor.jsx
|
| 251 |
+
β β β βββ admin/TenantManager.jsx
|
| 252 |
+
β β β βββ analytics/QueryStats.jsx
|
| 253 |
+
β β β βββ analytics/ToolUsageChart.jsx
|
| 254 |
+
β β β βββ analytics/RagEffectiveness.jsx
|
| 255 |
+
β β βββ pages/
|
| 256 |
+
β β β βββ ChatPage.jsx
|
| 257 |
+
β β β βββ AdminPage.jsx
|
| 258 |
+
β β β βββ AnalyticsPage.jsx
|
| 259 |
+
β β βββ store/
|
| 260 |
+
β β β βββ chatStore.js
|
| 261 |
+
β β β βββ adminStore.js
|
| 262 |
+
β β β βββ analyticsStore.js
|
| 263 |
+
β β βββ utils/
|
| 264 |
+
β β β βββ websocket.js
|
| 265 |
+
β β β βββ api.js
|
| 266 |
+
β β β βββ formatters.js
|
| 267 |
+
β β βββ App.jsx
|
| 268 |
+
β β βββ main.jsx
|
| 269 |
+
β βββ public/
|
| 270 |
+
β βββ package.json
|
| 271 |
+
β
|
| 272 |
+
βββ supabase/
|
| 273 |
+
β βββ migrations/
|
| 274 |
+
β β βββ 001_init.sql
|
| 275 |
+
β β βββ 002_embeddings.sql
|
| 276 |
+
β β βββ 003_redflag_rules.sql
|
| 277 |
+
β β βββ 004_analytics_tables.sql
|
| 278 |
+
β βββ seed/
|
| 279 |
+
β β βββ default_redflags.sql
|
| 280 |
+
β β βββ demo_tenants.sql
|
| 281 |
+
β βββ policies/
|
| 282 |
+
β β βββ rls_tenant_documents.sql
|
| 283 |
+
β β βββ rls_tenant_embeddings.sql
|
| 284 |
+
β β βββ rls_admin_rules.sql
|
| 285 |
+
β βββ functions/
|
| 286 |
+
β β βββ vector_search.sql
|
| 287 |
+
β βββ README.md
|
| 288 |
+
β
|
| 289 |
+
βββ docs/
|
| 290 |
+
β βββ architecture-diagram.png
|
| 291 |
+
β βββ sequence-mcp-agent.png
|
| 292 |
+
β βββ api-spec.md
|
| 293 |
+
β βββ mcp-server-protocol.md
|
| 294 |
+
β βββ rag-pipeline.md
|
| 295 |
+
β
|
| 296 |
+
βββ scripts/
|
| 297 |
+
β βββ run_dev.sh
|
| 298 |
+
β βββ build_all.sh
|
| 299 |
+
β βββ reset_db.sh
|
| 300 |
+
β βββ run_workers.sh
|
| 301 |
+
β
|
| 302 |
+
βββ docker-compose.yml
|
| 303 |
+
βββ README.md
|
| 304 |
+
βββ LICENSE
|
| 305 |
+
```
|
| 306 |
+
|
| 307 |
+
---
|
| 308 |
+
|
| 309 |
+
# **π Getting Started**
|
| 310 |
+
|
| 311 |
+
## **Prerequisites**
|
| 312 |
+
|
| 313 |
+
* Python 3.10+
|
| 314 |
+
* Node.js 18+
|
| 315 |
+
* Supabase project
|
| 316 |
+
* Groq API key
|
| 317 |
+
* DuckDuckGo Search key (if configured)
|
| 318 |
+
* Slack/Email webhook for alerts (optional)
|
| 319 |
+
|
| 320 |
+
---
|
| 321 |
+
|
| 322 |
+
## **Backend Setup**
|
| 323 |
+
|
| 324 |
+
```sh
|
| 325 |
+
cd backend
|
| 326 |
+
pip install -r requirements.txt
|
| 327 |
+
cp .env.example .env # Fill in Supabase + Groq keys
|
| 328 |
+
uvicorn app:app --reload
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
## **Frontend Setup**
|
| 332 |
+
|
| 333 |
+
```sh
|
| 334 |
+
cd frontend
|
| 335 |
+
npm install
|
| 336 |
+
npm run dev
|
| 337 |
+
```
|
| 338 |
+
|
| 339 |
+
---
|
| 340 |
+
|
| 341 |
+
# **β¨ Why IntegraChat Stands Out**
|
| 342 |
+
|
| 343 |
+
* **True MCP-native autonomous agents** (not static prompts)
|
| 344 |
+
* **Enterprise governance system** with regex-based red-flag rules
|
| 345 |
+
* **Hybrid RAG + web search** reasoning
|
| 346 |
+
* **Production-grade multi-tenant design** with strict Supabase RLS
|
| 347 |
+
* **Full observability**: logs, analytics, tool events, violations
|
| 348 |
+
* **Demo-ready**: perfect for enterprise presentations
|
| 349 |
+
|
| 350 |
+
---
|
| 351 |
+
|
| 352 |
+
# **π· Submission Metadata**
|
| 353 |
+
|
| 354 |
+
**Track:** MCP in Action
|
| 355 |
+
|
| 356 |
+
**Category:** Enterprise
|
| 357 |
+
|
| 358 |
+
**Tag:** `mcp-in-action-track-enterprise`
|
| 359 |
+
|
| 360 |
+
**Project Name:** **IntegraChat**
|
| 361 |
+
|
| 362 |
+
### **Short Summary**
|
| 363 |
+
|
| 364 |
+
> 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.
|
| 365 |
+
|
| 366 |
+
---
|
| 367 |
+
|
| 368 |
+
# **π License**
|
| 369 |
+
|
| 370 |
+
Add your license here (MIT recommended).
|
| 371 |
+
|
| 372 |
+
---
|
| 373 |
+
|
| 374 |
+
# **π¬ Contact**
|
| 375 |
+
|
| 376 |
+
If you'd like, I can generate:
|
| 377 |
+
|
| 378 |
+
* β Pitch deck
|
| 379 |
+
* β Notion documentation
|
| 380 |
+
* β Demo video script
|
| 381 |
+
* β Architecture diagram SVG
|
| 382 |
+
* β Full API reference
|
| 383 |
+
|
| 384 |
+
---
|
| 385 |
+
|