Multi-Agent RAG MCP Server

Multi-Agent RAG MCP Server

A legal-tech focused system that coordinates specialized agents for document classification, deadline extraction from Spanish legal texts, and strategic business intelligence. It integrates with Claude via MCP to provide semantic document search and automated deadline tracking using a Supabase vector database.

Category
Visit Server

README

Multi-Agent RAG MCP Server

A comprehensive multi-agent Retrieval-Augmented Generation (RAG) system built on the Model Context Protocol (MCP), featuring specialized AI microagents for legal document processing, deadline extraction, and strategic analytics.

๐ŸŽฏ Overview

This project implements an interconnected agentic ecosystem using MCP servers as the foundation for coordinating specialized AI agents. The system is designed for legal tech applications, particularly document intelligence and deadline management.

โœจ Features

  • Multi-Agent Architecture: Three specialized agents working in coordination
  • Vector Storage: Supabase with pgvector for semantic search
  • MCP Integration: Seamless integration with Claude Desktop
  • Legal Document Processing: Specialized for Spanish legal notifications
  • Strategic Analytics: Business intelligence and context analysis
  • Zero-Input Strategy: 75% automation, 25% strategic oversight

๐Ÿค– Agents

1. Deadline Agent

Extracts and manages deadlines from Spanish legal documents with high accuracy.

Capabilities:

  • Spanish legal text processing
  • Deadline extraction and categorization
  • Automated deadline tracking
  • Legal notification parsing

2. Document Classification Agent

Automatically categorizes and classifies legal documents.

Capabilities:

  • Multi-class document classification
  • Metadata extraction
  • Automated tagging
  • Document type recognition

3. SmartContext Analytics Agent

Provides strategic business intelligence and contextual analysis.

Capabilities:

  • Strategic analytics
  • Business context extraction
  • Cross-document insights
  • Trend analysis

๐Ÿ—๏ธ Architecture

rag-mcp-server/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ server.py              # Main MCP server
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ deadline_agent.py
โ”‚   โ”‚   โ”œโ”€โ”€ document_agent.py
โ”‚   โ”‚   โ””โ”€โ”€ smartcontext_agent.py
โ”‚   โ””โ”€โ”€ data_sources/
โ”œโ”€โ”€ database/
โ”‚   โ””โ”€โ”€ schema.sql             # Database schema
โ”œโ”€โ”€ docs/                      # Documentation
โ”œโ”€โ”€ config/                    # Configuration files
โ”œโ”€โ”€ data/                      # Data storage
โ””โ”€โ”€ tests/                     # Test files

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10+
  • Supabase account
  • Claude Desktop (for MCP integration)
  • PostgreSQL with pgvector extension

Installation

  1. Clone the repository
git clone https://github.com/yourusername/rag-mcp-server.git
cd rag-mcp-server
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure environment
cp .env.example .env
# Edit .env with your credentials
  1. Initialize database
# Run the database schema (see docs for details)
psql -h your-supabase-host -U postgres -d your-database -f database/schema.sql
  1. Configure Claude Desktop Edit your Claude Desktop config file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
  "mcpServers": {
    "rag-server": {
      "command": "python",
      "args": ["/Users/yourusername/rag-mcp-server/src/server.py"],
      "env": {
        "SUPABASE_URL": "your_supabase_url",
        "SUPABASE_KEY": "your_supabase_key"
      }
    }
  }
}
  1. Restart Claude Desktop

๐Ÿ› ๏ธ Usage

The system can be used in two ways:

1. MCP Server (Claude Desktop Integration)

Once configured, the agents are available through Claude Desktop with the following tools:

Deadline Agent Tools

  • extract_deadlines - Extract deadlines from legal documents
  • list_deadlines - List all tracked deadlines
  • search_deadlines - Search deadlines by criteria

Document Agent Tools

  • classify_document - Classify document type
  • index_document - Add document to vector store
  • search_documents - Semantic document search

SmartContext Agent Tools

  • analyze_context - Strategic context analysis
  • extract_insights - Business intelligence extraction
  • trend_analysis - Cross-document trend analysis

2. REST API Server (Frontend Integration)

The system also provides a FastAPI REST API for frontend applications:

# Run REST API server (for frontend)
python src/api_server.py

The API server runs on http://localhost:8000 with interactive documentation at http://localhost:8000/docs.

Key Features:

  • Client Management - Create and manage client records
  • Document Upload - Upload documents with automatic processing
  • Data Retrieval - Query documents, deadlines, and analyses per client
  • CORS Enabled - Ready for frontend integration

API Endpoints:

Client Management:

  • POST /api/clients - Create new client
  • GET /api/clients - List all clients
  • GET /api/clients/{client_id} - Get client details
  • PUT /api/clients/{client_id} - Update client
  • DELETE /api/clients/{client_id} - Delete client (soft delete)

Document Operations:

  • POST /api/clients/{client_id}/documents - Upload and process document
  • GET /api/clients/{client_id}/documents - List client's documents
  • GET /api/clients/{client_id}/documents/stats - Document statistics

Deadline Management:

  • GET /api/clients/{client_id}/deadlines - Get client's deadlines
  • GET /api/clients/{client_id}/deadlines/stats - Deadline statistics

Strategic Analysis:

  • GET /api/clients/{client_id}/analysis - Get strategic analyses

Running Both Servers:

# Run MCP server for Claude Desktop (existing functionality)
python src/server.py

# Run REST API server for frontend (new functionality)
python src/api_server.py

Both servers can run independently and use the same database.

๐Ÿ“Š Database Schema

The system uses the following main tables:

  • clients - Client information and management
  • documents - Document metadata and classification
  • deadline_extractions - Deadline extraction operations
  • deadlines - Extracted deadline tracking
  • analyses - Strategic insights and analytics

Client Isolation: All documents, deadlines, and analyses are associated with specific clients via client_id, enabling proper data isolation and multi-tenant support.

See database/schema.sql for complete schema details.

๐Ÿ“š Documentation

Comprehensive documentation is available in the docs/ folder:

  • Quick Start Guide - 30-minute setup from scratch
  • Architecture Guide - Complete system design and patterns
  • Troubleshooting Guide - Common issues and solutions
  • API Reference - Tool definitions and usage

๐Ÿ”’ Security

This system implements three-layered security:

  1. Authentication - User identity verification
  2. Authorization - Access control and permissions
  3. Encryption - Zero-knowledge encryption for sensitive data

Never commit your .env file - it contains sensitive credentials.

๐Ÿงช Testing

Run the test suite:

pytest tests/

Test individual agents:

python test_deadline_extraction.py

๐Ÿค Contributing

This is a personal project, but suggestions and feedback are welcome! Please open an issue to discuss proposed changes.

๐Ÿ“ License

[Add your license here]

๐Ÿ™ Acknowledgments

Built with:

๐Ÿ“ž Contact

[Add your contact information]


Status: Production-Ready
Version: 1.0
Last Updated: November 2024

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured