Labsco
lhstorm logo

QuantConnect Docs

β˜… 2

from lhstorm

An MCP server for intelligent search and retrieval of QuantConnect PDF documentation.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

QuantConnect PDF MCP Server

An advanced Model Context Protocol (MCP) server that provides intelligent search and retrieval capabilities for QuantConnect PDF documentation. This server converts PDFs to searchable markdown format and provides fast, context-aware search using TF-IDF scoring and proximity matching.

Features

  • Intelligent PDF Processing: Automatically converts PDFs to structured markdown with proper formatting
  • Fast Search Index: Uses inverted index with TF-IDF scoring for relevant results
  • Context-Aware Results: Returns relevant excerpts with highlighted matches
  • Caching System: Avoids reprocessing unchanged PDFs for better performance
  • Proximity Matching: Boosts results where query terms appear close together
  • Three MCP Tools: Search, list documents, and retrieve full content

Project Structure

QuantConnectServer/
β”œβ”€β”€ server.py           # Main MCP server with enhanced search
β”œβ”€β”€ convert_pdfs.py     # Standalone PDF conversion utility
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ README.md          # This documentation
β”œβ”€β”€ env/               # Python virtual environment
└── quantconnect-docs/ # PDF documents and converted markdown
    β”œβ”€β”€ Quantconnect-Local-Platform-Python-2.pdf
    β”œβ”€β”€ Quantconnect-Writing-Algorithms-Python-2.pdf
    └── markdown/      # Auto-generated markdown files
        β”œβ”€β”€ .pdf_cache.json      # Processing cache
        β”œβ”€β”€ .search_index.pkl    # Search index cache
        └── *.md files           # Converted documents

Available MCP Tools

The server provides three powerful tools accessible through Claude:

1. search_quantconnect_docs

Purpose: Intelligent search through all QuantConnect documentation Parameters:

  • query (required): Search terms or topic to find
  • max_results (optional): Number of results to return (default: 5)

Features:

  • TF-IDF scoring for relevance ranking
  • Proximity matching for multi-word queries
  • Context extraction with highlighted matches
  • Returns document excerpts with page numbers

2. list_quantconnect_docs

Purpose: List all available PDF documents in the collection Parameters: None

Returns: Complete catalog of processed documents with metadata

3. get_document_content

Purpose: Retrieve full content from specific documents Parameters:

  • filename (required): Document name (with or without .md extension)
  • page_number (optional): Specific page to retrieve

Use cases: Reading complete sections, accessing specific pages, extracting code examples

Technical Architecture

Search Engine

  • Inverted Index: Maps words to document locations for fast lookup
  • TF-IDF Scoring: Balances term frequency with document rarity
  • Proximity Boosting: Enhances results where query terms appear together
  • Context Extraction: Provides relevant snippets around matches

Caching System

  • PDF Processing Cache: Avoids reprocessing unchanged files using MD5 hashes
  • Search Index Cache: Persists search index for faster startup
  • Incremental Updates: Only processes new or modified PDFs

Performance Features

  • Asynchronous Processing: Non-blocking PDF conversion and indexing
  • Background Initialization: Server starts immediately while processing continues
  • Efficient Storage: Markdown conversion reduces memory usage vs. raw PDF text

Version History

  • v0.3.0: Enhanced search with TF-IDF scoring and proximity matching
  • v0.2.0: Added caching system and background processing
  • v0.1.0: Basic PDF to markdown conversion and simple search