ai-due-diligence-copilot
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ai-due-diligence-copilotWhat was Apple's operating margin for the last fiscal year?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AI Due Diligence Copilot
AI Due Diligence Copilot is an end-to-end financial document analysis system that ingests corporate filings (10-K / 10-Q), extracts structured financial information, retrieves supporting evidence, and answers analyst questions using the most reliable source available.
Unlike many AI applications that rely entirely on an LLM, this system intelligently routes each question to either:
Structured financial data stored in PostgreSQL
Retrieved filing evidence through a Retrieval-Augmented Generation (RAG) pipeline
A combination of both
To improve trustworthiness, generated answers can be evaluated using a PyTorch-based groundedness classifier that checks whether claims are supported by retrieved evidence.
Why This Project?
Financial analysts frequently need answers that are:
Factually accurate
Explainable
Traceable to source documents
Traditional LLM-based assistants can hallucinate numbers or provide unsupported claims.
This project addresses that problem by:
Using SQL for quantitative reasoning
Using RAG for qualitative document understanding
Using groundedness evaluation to assess evidence support
Supporting optional Claude-based answer synthesis while remaining fully functional without any paid API
For deeper implementation details and design decisions, see:
ARCHITECTURE.mdRelated MCP server: SEC-MCP
Features
Document Ingestion
Upload financial filings (
.txt,.pdf,.md)Automatic document cleaning and chunking
Filing metadata tracking
Persistent PostgreSQL storage
Structured Financial Metric Extraction
Currently extracts and stores:
Revenue
Operating Margin
Net Income
R&D Expense
Cash & Cash Equivalents
These metrics are stored in PostgreSQL and can be queried directly for quantitative analysis.
Intelligent Query Routing
The system automatically determines whether a question should be answered through:
Structured SQL retrieval
Document retrieval (RAG)
SQL + RAG
Examples:
Question | Route |
What was the change in operating margin? | SQL |
What supplier risks does the company face? | RAG |
How did margins change and why? | SQL + RAG |
MCP Tool Integration
Implements Model Context Protocol (MCP) tools:
Company Lookup
Financial Ratio Calculator
Document Search
Groundedness Evaluation
A lightweight PyTorch classifier evaluates whether generated claims are supported by retrieved evidence.
Outputs include:
Groundedness scores
Claim-level support classification
Confidence indicators
Evaluation Harness
Built-in evaluation framework measuring:
Routing accuracy
Retrieval relevance
Groundedness
Latency
Interactive Dashboard
Web interface for:
Filing uploads
Question answering
Viewing routing decisions
Viewing tool usage
Viewing groundedness scores
System Architecture
Financial Filing
│
▼
Document Ingestion
│
▼
Chunking
│
▼
Metric Extraction + Vectorization
(TF-IDF + SVD)
│ │
▼ ▼
PostgreSQL Vector Store
▲ ▲
│ │
User Query ───► Query Router ───┘
│
┌──────────┴──────────┐
▼ ▼
SQL Financial Route RAG Retrieval
▼ ▼
Financial Metrics Evidence Search
└──────────┬──────────┘
▼
Answer Generation
▼
Groundedness Evaluation
▼
Final ResponseAnswer Generation Modes
1. Offline / Local Mode (Default)
No API keys required.
The system answers questions using:
PostgreSQL financial data
RAG retrieval
Extractive answer generation
PyTorch groundedness evaluation
This mode was used during development and testing.
2. Claude-Assisted Mode (Optional)
If an Anthropic API key is provided:
ANTHROPIC_API_KEY=your_api_key_hereretrieved evidence can be passed to Claude for natural-language answer generation.
Pipeline:
User Query
↓
Retrieval / SQL
↓
Claude
↓
Groundedness Evaluation
↓
Final ResponseClaude is only used for answer synthesis.
The system does not depend on Claude for:
Retrieval
Query routing
Financial calculations
Groundedness scoring
If no API key is present, the application automatically falls back to the local extractive pipeline.
Tech Stack
Backend
Technology | Purpose |
FastAPI | API Framework |
Uvicorn | ASGI Server |
Pydantic | Data Validation |
Database
Technology | Purpose |
PostgreSQL | Primary Database |
SQLAlchemy | ORM |
Machine Learning
Technology | Purpose |
PyTorch | Groundedness Classifier |
Scikit-Learn | Retrieval Pipeline |
NumPy | Numerical Operations |
Retrieval
Component | Purpose |
TF-IDF | Document Vectorization |
Truncated SVD | Dense Semantic Representation |
Cosine Similarity | Retrieval Ranking |
AI Tooling
Component | Purpose |
MCP Tools | Structured Tool Access |
Query Router | Route Selection |
Groundedness Evaluator | Evidence Validation |
Project Structure
diligence-copilot/
│
├── app/
│ ├── db/
│ ├── ingestion/
│ ├── ml/
│ ├── rag/
│ ├── mcp_tools/
│ └── main.py
│
├── data/
│
├── scripts/
│ └── setup_postgres.sql
│
├── tests/
│
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
├── ARCHITECTURE.md
└── README.mdInstallation
Prerequisites
Python 3.11+
PostgreSQL 16+ (tested on PostgreSQL 17.11)
Git
1. Clone Repository
git clone <repository-url>
cd diligence-copilot2. Create Virtual Environment
Windows
python -m venv venv
.\venv\Scripts\Activate.ps1Linux / macOS
python -m venv venv
source venv/bin/activate3. Install Dependencies
Install CPU-only PyTorch:
pip install torch --index-url https://download.pytorch.org/whl/cpuInstall project requirements:
pip install -r requirements.txt4. Configure PostgreSQL
Run:
psql -U postgres -f scripts/setup_postgres.sqlThis creates:
diligence_copilotdatabasediligence_appuserRequired permissions
5. Build Groundedness Dataset
python -m app.ml.build_dataset6. Train Groundedness Classifier
python -m app.ml.groundedness7. Start Application
uvicorn app.main:app --reloadApplication:
http://localhost:8000API Documentation:
http://localhost:8000/docsDocker
docker-compose up --buildVerification Walkthrough
Create Test Filing
Total revenue for fiscal year 2024 was $500 million.
Operating margin for fiscal year 2024 was 12.5%, compared to 10.1% in fiscal year 2023.
The company faces significant risk from a single supplier located in Vietnam.Upload Filing
Use:
Ticker: TEST
Company: Test Company
Fiscal Period: FY2024
Example output:
Done: 1 chunks, 3 financial metrics extracted.Test Financial Reasoning
Question:
What was the change in operating margin?Example output:
operating_margin moved from 10.1 (FY2023)
to 12.5 (FY2024), a change of 23.76%.Route:
SQLTool:
financial_ratio_calculatorTest Retrieval
Question:
What supplier risks does the company face?Example output:
The company faces significant risk from a single supplier located in Vietnam.Note: For very small filings that fit into a single chunk, retrieval may return the entire chunk rather than a single sentence.
Route:
RAGRun Evaluation
python -m app.eval.run_evalResults
Validated end-to-end on:
Document ingestion
Financial metric extraction
PostgreSQL persistence
Query routing
SQL-based financial reasoning
Retrieval-based risk analysis
Groundedness evaluation
FastAPI deployment
Sample Evaluation Results
Metric | Value |
Route Accuracy | 1.00 |
Average Retrieval Relevance | 0.67 |
Average Latency | ~30ms |
Groundedness Classifier
Metric | Value |
Accuracy | 0.70 – 0.90 |
Recall | 0.75 – 1.00 |
Results vary slightly because the evaluation dataset is intentionally small.
Limitations
Groundedness classifier trained on 38 labeled examples
Financial metric extraction currently uses rule-based patterns
Retrieval uses TF-IDF + SVD instead of transformer embeddings
Vector index is in-memory and optimized for demonstration-scale workloads
Claude integration is optional and not required for core functionality
Future Improvements
Transformer-based embeddings
Hybrid search (keyword + vector)
Larger groundedness datasets
LLM-based extraction fallback
Multi-step agent workflows
pgvector integration
Multi-document comparison
Automated analyst report generation
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for SEC EDGAR that provides real-time access to filings, financial statements, and full-text search across all EDGAR documents.Apache 2.0
- AlicenseNot gradedqualityBmaintenanceMCP server for analyzing SEC filings (10-K, 10-Q, 8-K) with industry-aware financial extraction and BERT-based NLP.1MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that provides deterministic finance tools for SEC filing analysis, enabling LLMs to compute financial ratios, fetch filings, and perform equity research without hallucinated numbers.MIT
- AlicenseAqualityBmaintenanceAn MCP server that wraps SEC EDGAR APIs to provide company financial data, screening metrics, and disclosure signals for investment diligence, with every figure traced to its source filing.8MIT
Related MCP Connectors
Query SEC EDGAR filings, XBRL financials, and company data through MCP. STDIO & Streamable HTTP.
MCP server for nonprofit financials via ProPublica — IRS Form 990 data for 1.8M+ nonprofits.
Remote MCP server to enrich company profiles with structured B2B data and confidence scores.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jaskarn09/ai-due-diligence-copilot'
If you have feedback or need assistance with the MCP directory API, please join our Discord server