Uses Ollama for local LLM inference to power multi-agent orchestration, query analysis, and result synthesis. Enables the MCP server to analyze user queries, split them into agent-specific tasks, and synthesize responses from multiple agents using locally-run language models.
Contract Comparisons - MCP Server with Multi-Agent Orchestration
Using WIPO to give recommendations
A Model Context Protocol (MCP) server with multi-agent orchestration capabilities, featuring a simple web interface for querying agents. This system supports multiple LLM providers (Ollama, OpenAI, Anthropic, Google) and orchestrates multiple agents to process complex queries with document management.
Features
MCP-Compliant: Implements Model Context Protocol standards
FastAPI Server: Modern async Python web framework
Multi-Agent Orchestration: Intelligent query splitting and result synthesis
PDF Document Upload: Upload and manage PDF documents with automatic text extraction
Document Selection: Manual selection via UI or automatic detection from query text
Smart Document Matching: Orchestrator automatically matches document names from queries
Flexible LLM Provider Support: Switch between Ollama (local), OpenAI, Anthropic, or Google via UI or environment variables
Model Selection: Choose from available models for your selected provider
Web Interface: Modern Next.js frontend with document management sidebar and provider/model selection
Automatic Agent Discovery: Agents are automatically discovered and registered
RESTful API: Standard HTTP endpoints for agent and document management
Quick Start
For detailed setup instructions, see
Prerequisites
Python 3.11+
Node.js 18+
LLM Provider (choose one or more):
Ollama (local, free): Install from ollama.ai and pull a model:
ollama pull llama3:latestOpenAI (cloud, paid): Get API key from platform.openai.com
Anthropic (cloud, paid): Get API key from console.anthropic.com
Google (cloud, paid): Get API key from ai.google.dev
Quick Installation
Access the frontend at http://localhost:3000
Using the System
Select LLM Provider & Model:
Use the dropdowns at the top of the chat to select your provider (Ollama, OpenAI, etc.)
Choose a model from the available models for that provider
The system will use your selection for all LLM calls in that query
Upload Documents: Click "Upload PDF" in the sidebar to upload text-based PDF files
Select Documents:
Manual: Check the box next to documents you want to query
Automatic: Just mention the document in your query (e.g., "tell me about my italy document")
Ask Questions: Type your query in the chat
The system will use your selected provider/model
Automatically uses selected documents
Internal agent searches through actual document text
External agent queries external databases (WIPO, etc.)
Architecture
Components
MCP Server (Python/FastAPI)
Orchestrates multi-agent workflows
LLM-agnostic architecture - supports Ollama, OpenAI, Anthropic, Google
Provider can be switched per-request via UI or defaults to
LLM_PROVIDERenv varRuns on port 8000
Frontend (Next.js/React)
Simple chat interface
Connects to MCP server
Runs on port 3000
Agents
Internal Agent: Searches through uploaded PDF documents using extracted text
External Agent: Queries external databases (e.g., WIPO for compliance information)
Orchestrator
Analyzes user queries using LLM
Automatically detects and matches documents from query text
Splits queries into agent-specific tasks
Synthesizes results from multiple agents
Has access to all uploaded documents for intelligent routing
Workflow
Document Management
The system supports two ways to select documents for queries:
Manual Selection: Users can select documents via checkboxes in the sidebar
Automatic Detection: Orchestrator automatically detects documents mentioned in queries
Example: "tell me about my italy document" → automatically finds "Italy-111.pdf"
Works with variations: "italian document", "japan-111", etc.
Both methods can work together (manual + auto-detected)
API Endpoints
MCP Server (Port 8000)
GET /health- Health checkGET /api/providers- Get list of configured LLM providersGET /api/models?provider=ollama- Get available models for a providerPOST /orchestrate- Process user query{ "query": "your query here", "selected_documents": ["document1.pdf", "document2.pdf"], // Optional "provider": "openai", // Optional: override default provider "model": "gpt-4" // Optional: override default model }POST /api/upload- Upload a PDF documentContent-Type:
multipart/form-dataBody:
file(PDF file)
GET /api/documents- List all uploaded documentsDELETE /api/documents/{filename}- Delete a documentGET /mcp/agents- List all registered agentsGET /mcp/resources- List all MCP resourcesPOST /discover- Trigger agent discovery
Frontend (Port 3000)
GET /- Main chat interfacePOST /api/chat- Chat endpoint (forwards to MCP server)
Project Structure
Configuration
Create a .env file from env.example:
Basic Configuration
LLM Provider Configuration
Option 1: Ollama (Local, Free)
Option 2: OpenAI (Cloud, Paid)
Option 3: Anthropic (Cloud, Paid)
Option 4: Google (Cloud, Paid)
Note: You can configure multiple providers in .env. The UI will show all configured providers in the dropdown, and you can switch between them per-request. The LLM_PROVIDER variable sets the default provider.
Documentation
SETUP.md - Comprehensive setup guide with step-by-step instructions
WORKFLOW.md - Detailed workflow explanation including document upload, processing, and LLM provider architecture
QUICKSTART.md - Quick start guide for getting up and running in 5 minutes
FUTURE_GOALS.md - Planned improvements and next steps (LangGraph, WIPO integration, agent enhancements)
Key Features Explained
Document Upload & Management
Upload PDFs: Use the sidebar "Upload PDF" button to upload text-based PDF files
Text Extraction: pdfplumber automatically extracts text from all pages
Storage: Documents saved to
backend/uploads/(persists) + text cached in memory (fast access)Document Selection:
Manual: Check boxes in sidebar
Automatic: Mention document in query (e.g., "italy document" → finds "Italy-111.pdf")
How Documents Are Used
Upload: PDF → Text extraction → Storage
Query: User asks question (with or without mentioning document)
Detection: Orchestrator matches documents from query or uses manual selection
Processing: Internal agent retrieves document text and includes it in LLM prompt
Response: LLM searches through actual document content to answer
Example Use Cases
"What does my italy contract say?" → Auto-detects Italy-111.pdf, searches through it
"Compare my italy and japan documents" → Finds both, searches through both
"What do I need to change in my italy contract for australia?" → Uses internal agent (Italy document) + external agent (Australian compliance)
Development
Running Tests
Viewing Logs
MCP server logs are written to /tmp/mcp_server.log:
Or use the helper script:
Helper Scripts
./start_server.sh- Start MCP server with log viewing./view_logs.sh- View MCP server logs
Troubleshooting
See SETUP.md for detailed troubleshooting guide.
Common issues:
Ollama not running: Start Ollama and verify with
curl http://localhost:11434/api/tagsOpenAI/Anthropic/Google errors: Check API key is set correctly in
.envProvider not showing in UI: Ensure API key is set in
.envfor that providerPort conflicts: Kill processes on ports 8000 or 3000
Module not found: Ensure virtual environment is activated and dependencies installed
License
[Add your license information here]
Contributing
Create a feature branch
Make your changes
Add tests
Submit a pull request