Skip to main content
Glama
qdrant-financial-docs

qdrant-financial-docs

README.md
# Claude Financial Intelligence System

Equip Claude Desktop with custom tools to search **both text and images** in financial PDFs using multimodal embeddings, vector search, and the Model Context Protocol (MCP).

> ๐Ÿ’ฌ **ยฟHablas espaรฑol?** Join our [Spanish-speaking Telegram community](https://t.me/IA_CienciaDeDatos_ES) to discuss AI, ML, and data science projects!

**The Problem:** Traditional search systems only index text, missing 50%+ of information locked in charts, graphs, and visualizations.

**The Solution:** This system embeds both text chunks AND images into the same 3072-dimensional vector space using Google Gemini's multimodal embeddings, then exposes search tools to Claude Desktop via MCP.

![Sample](images/sample.png)

---

## ๐ŸŽฏ Key Features

- **Multimodal Search**: Query charts, graphs, and text using multimodal embeddings
- **Hybrid Search**: Combine semantic similarity with metadata filtering
- **Custom Tools**: 4 custom MCP tools for semantic search, filtering, comparisons, and discovery
- **Local Development**: Runs entirely on your laptop via Dockerโ€”no cloud required
- **Production Ready**: Seamless migration to Qdrant Cloud when you need scale

---
 
## ๐Ÿ—๏ธ Architecture

### Ingestion Pipeline

Extract text AND images from PDFs, embed both modalities using Gemini API, and store in Qdrant with rich metadata (ticker, quarter, year, document type).
![Ingestion Pipeline](images/ingestion_pipeline.png)

### Query Flow

Hybrid search combines metadata filtering with semantic similarity to return multimodal results (text + charts).
![Query Result](images/flow.png)

---

## ๐Ÿ› ๏ธ Tech Stack

| Component | Technology | Purpose |
|-----------|-----------|---------|
| **LLM Interface** | Claude Desktop | Natural language queries via MCP |
| **Bridge** | Model Context Protocol (MCP) | Exposes custom tools to Claude |
| **Tools** | LangChain Community | Semantic search, filtering, comparisons |
| **Vector DB** | Qdrant  | Local/[cloud vector storage](https://cloud.qdrant.io/signup?utm_medium=referral&utm_source=stars&utm_campaign=devrel&utm_content=eduardo-vasquez) |
| **Embeddings** | Google Gemini Embeddings 2 | Multimodal embeddings (3072-dim, text + images) |
| **PDF Parsing** | LangChain + PyPDF | Extract text + images from PDFs |
| **Package Manager** | uv | Fast Python dependency management |

---

## ๐Ÿš€ Quick Start

### Prerequisites

- Docker (for Qdrant)
- Python 3.10+
- Claude Desktop
- Google Gemini API key (free tier available)

### 1. Clone & Install

```bash
git clone <your-repo-url>
cd agent-tools-claude
```

### 2. Set Up Environment

Copy the example environment file and fill in your API key:

```bash
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY
```

### 3. Start Qdrant

```bash
docker compose up -d
```

Qdrant will be available at `http://localhost:6333` (Web UI at `/dashboard`)

### 4. Ingest Documents

```bash
# Install dependencies (using uv)
uv sync

# Ingest PDFs using Justfile
just ingest data/nvidia/

# Or ingest a single PDF
just ingest data/nvidia/NVDA-Q3-2025.pdf
```

Alternatively, run the ingestion script directly:
```bash
uv python scripts/ingest_pdf.py data/nvidia/
```

### 5. Configure Claude Desktop

Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "qdrant-financial-docs": {
      "command": "/path/to/uv",
      "args": [
        "--directory",
        "/path/to/agent-tools-claude",
        "run",
        "servers/mcp_server.py"
      ]
    }
  }
}
```

### 6. Restart Claude Desktop

Quit Claude Desktop completely (โŒ˜+Q) and reopen. You should see the ๐Ÿ”Œ icon indicating MCP tools are connected.

### 7. Start Querying!

Try these queries in Claude Desktop:

- "What was NVIDIA's Q3 2025 data center revenue?"
- "Compare Q2 and Q3 gaming revenue"
- "Show me all Q4 documents"
- "What risks were mentioned in the earnings call?"

---

## ๐Ÿ“ Project Structure

```
agent-tools-claude/
โ”œโ”€โ”€ servers/
โ”‚   โ”œโ”€โ”€ mcp_server.py              # MCP server implementation
โ”‚   โ””โ”€โ”€ tool_definitions.yaml       # Declarative tool descriptions
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ config.py                   # Configuration (loads .env)
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ””โ”€โ”€ embedder.py            # Gemini embedder wrapper
โ”‚   โ”œโ”€โ”€ helpers/
โ”‚   โ”‚   โ”œโ”€โ”€ logs.py                # Logging utilities
โ”‚   โ”‚   โ””โ”€โ”€ qdrant_utils.py        # Qdrant operations
โ”‚   โ”œโ”€โ”€ tools/
โ”‚   โ”‚   โ””โ”€โ”€ qdrant_tools.py        # LangChain tool definitions
โ”‚   โ””โ”€โ”€ scripts/
โ”‚       โ””โ”€โ”€ pdf_ingestion.py       # Multimodal ingestion pipeline
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ ingest_pdf.py              # CLI for PDF ingestion
โ”‚   โ””โ”€โ”€ delete_collection.py       # Utility to reset database
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ list_qdrant_tools.py       # List all MCP tools
โ”‚   โ””โ”€โ”€ test_qdrant_tools.py       # Test tools directly
โ”œโ”€โ”€ data/                          # Your PDF documents (gitignored)
โ”œโ”€โ”€ docker-compose.yml             # Qdrant local setup
โ”œโ”€โ”€ pyproject.toml                 # Python dependencies
โ”œโ”€โ”€ .env.example                   # Environment variable template
โ””โ”€โ”€ README.md                      # This file
```

---

## ๐Ÿ”ง Configuration

### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `GEMINI_API_KEY` | Google Gemini API key | Required |
| `QDRANT_URL` | Qdrant instance URL | `http://localhost:6333` |
| `QDRANT_API_KEY` | Qdrant Cloud API key (optional) | None |
| `QDRANT_COLLECTION_NAME` | Collection name in Qdrant | `stock-market` |
| `EMBEDDING_MODEL` | Gemini embedding model | `gemini-embedding-2-preview` |
| `EMBEDDING_DIMENSIONS` | Vector dimensions | `3072` |

### PDF Metadata Extraction

The ingestion pipeline automatically extracts metadata from filenames:

**Pattern:** `{TICKER}-{Quarter}-{Year}-{Type}.pdf`

**Examples:**
- `NVDA-Q3-2025-Transcript.pdf` โ†’ ticker: NVDA, quarter: Q3, year: 2025
- `AMD-Q4-2024-Presentation.pdf` โ†’ ticker: AMD, quarter: Q4, year: 2024

Metadata enables fast filtering: "Get all Q3 2025 documents" (20ms vs 500ms semantic search)

---

## ๐Ÿ’ก Usage Examples

### CLI: Ingest Documents

```bash
# Single file
just ingest data/nvidia/NVDA-Q3-2025.pdf

# Entire folder (recursive)
just ingest data/nvidia/
```
 
---

## ๐ŸŽจ MCP Tools

The system exposes 4 custom tools to Claude Desktop:

![Custom tools](images/custom_tools.png)

### 1. `search_documents`
- **Purpose:** Semantic search by meaning (not exact keywords)
- **Use Case:** "What did Jensen say about AI chips?"

### 2. `filter_by_metadata`
- **Purpose:** Fast retrieval of all documents matching filters
- **Use Case:** "Get all Q3 2025 documents"

### 3. `compare_quarters`
- **Purpose:** Cross-period trend analysis
- **Use Case:** "Compare Q2 vs Q3 revenue"

### 4. `get_available_data`
- **Purpose:** Discover available tickers, quarters, years
- **Use Case:** "What data do you have?"

---

## ๐Ÿงช Development

### Run MCP Server Directly

```bash
# Test the MCP server
uv run servers/mcp_server.py
```

### Test Tools Without Claude

```bash
# List available tools
python examples/list_qdrant_tools.py

# Test semantic search
python examples/test_qdrant_tools.py
```

### Reset Database

```bash
# Delete collection and start fresh
just delete-collection
```

### View Qdrant UI

Open `http://localhost:6333/dashboard` to:
- Explore collections
- View vector points
- Test queries manually

---

## ๐Ÿ”ฎ Future Enhancements

- [ ] **Multi-Company Support:** Ingest AMD, Intel, etc. for competitive analysis
- [ ] **REST API:** Webhook endpoint for automatic ingestion
- [ ] **Audio Transcription:** Add earnings call audio via Whisper
- [ ] **Multi-Language:** Leverage Gemini's 100+ language support
- [ ] **Cloud Migration:** Scale to Qdrant Cloud for millions of vectors

---

## ๐Ÿค Contributing

Contributions welcome! This is a learning project showcasing:
- Building custom Claude Desktop tools via MCP
- Multimodal search implementation
- Vector database optimization
- Hybrid search strategies

---

## ๐Ÿ“ License

MIT License - see [LICENSE](LICENSE) file for details

---

## ๐Ÿ”— Resources

- [Qdrant Documentation](https://qdrant.tech/documentation/?utm_medium=referral&utm_source=stars&utm_campaign=devrel&utm_content=eduardo-vasquez)
- [Google Gemini API](https://ai.google.dev/)
- [Anthropic Claude](https://claude.ai/)

---

## ๐Ÿ’ฌ Join the Community

Interested in AI, machine learning, and data science? **Join our community to learn and share:**

- ๐Ÿ’ฌ **[Telegram Community (Spanish)](https://t.me/IA_CienciaDeDatos_ES)** - Discuss AI, ML, data science, and build cool projects together (Spanish-speaking community)
- ๐Ÿ’ผ **[LinkedIn](https://www.linkedin.com/in/eduardo-vasquez-n)** - Let's connect and stay in touch

Found this project helpful? Give it a โญ on GitHub!

 

TDQS

A4/5.0

Scored across 5 tools

Disambiguation3/5

The descriptions work hard to separate search_documents (specific topic) from filter_by_metadata (whole-quarter summaries), but compare_quarters is essentially filter_by_metadata run across multiple quarters, so the boundary is thin. Similarly, get_collection_stats and get_available_data both answer 'how much data do you have?' using document counts, differentiated only by 'technical debugging' vs. 'discovery' framing. The explicit WHEN/NEVER guidance helps, but several tool pairs still tempt misselection.

Naming Consistency5/5

All five tools use snake_case verb-first names (get_collection_stats, search_documents, filter_by_metadata, compare_quarters, get_available_data). The verb choice reflects the action (get/search/filter/compare) and the noun reflects the target resource, making the set highly predictable.

Tool Count4/5

Five tools is a tight, well-scoped set for a read-only financial document QA server, and each one has an identifiable role. However, compare_quarters is arguably an aggregate variant of filter_by_metadata, so one tool is somewhat redundant, leaving the set a touch thin on genuinely distinct operations.

Completeness4/5

The read-only surface covers discovery (get_available_data, get_collection_stats), targeted retrieval (search_documents), full retrieval (filter_by_metadata), and trend analysis (compare_quarters) โ€” a coherent lifecycle for document QA. Minor gaps exist, such as fetching a single document by ID or listing distinct tickers without counts, but agents can work around these.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues