A Model Context Protocol (MCP) server that enables LLMs to interact directly with documents through conceptual search powered by LanceDB. Features corpus-driven concept extraction, WordNet semantic enrichment, and multi-signal hybrid ranking for superior search accuracy.
- π§ Conceptual Search: Corpus concepts + WordNet + hybrid signals for intelligent retrieval
- π Multi-Signal Ranking: Vector similarity, BM25, title matching, concept matching, synonym expansion
- π€ LLM-Powered: Claude Sonnet 4.5 for concept extraction, Grok-4-fast for summaries
- π WordNet Integration: Synonym expansion and hierarchical concept navigation (161K+ words)
- β‘ Lightning Fast: Cloud AI + local embeddings, no timeout issues
- π‘οΈ Robust PDF Handling: Gracefully handles corrupted files with OCR fallback
- π Comprehensive Indexing: Extracts 100+ concepts per document
- π Security First: Local storage with secure API key management
Requirements:
- Node.js 18+
- OpenRouter API key (sign up here)
- Python 3.9+ with NLTK (for WordNet)
- MCP Client (Claude Desktop or Cursor)
# Clone and install
git clone https://github.com/m2ux/lance-mcp.git
cd lance-mcp
npm install
npm run build
# Install WordNet
pip3 install nltk
python3 -c "import nltk; nltk.download('wordnet'); nltk.download('omw-1.4')"
# Configure API key
cp .env.example .env
# Edit .env and add your OpenRouter API keyCursor (~/.cursor/mcp.json):
{
"mcpServers": {
"lancedb": {
"command": "node",
"args": [
"/path/to/lance-mcp/dist/conceptual_index.js",
"/home/username/.lance_mcp"
]
}
}
}Claude Desktop
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"lancedb": {
"command": "node",
"args": [
"/path/to/lance-mcp/dist/conceptual_index.js",
"/home/username/.lance_mcp"
]
}
}
}Complete setup from PDFs to working conceptual search in 15 minutes!
# Clone and build
git clone https://github.com/m2ux/lance-mcp.git
cd lance-mcp
npm install
npm run build# Install Python NLTK
pip3 install nltk
# Download WordNet data
python3 -c "import nltk; nltk.download('wordnet'); nltk.download('omw-1.4')"
# Verify installation
python3 -c "from nltk.corpus import wordnet as wn; print(f'β
WordNet ready: {len(list(wn.all_synsets()))} synsets')"# Copy example environment file
cp .env.example .env
# Edit .env and add your OpenRouter API key
# Get one at: https://openrouter.ai/keys
nano .env # or use your preferred editor# Set environment
source .env
# Initial seeding (create database from scratch)
npx tsx hybrid_fast_seed.ts \
--dbpath ~/.lance_mcp \
--filesdir ~/Documents/my-pdfs \
--overwrite
# OR: Incremental seeding (add new/changed documents only - much faster!)
npx tsx hybrid_fast_seed.ts \
--dbpath ~/.lance_mcp \
--filesdir ~/Documents/my-pdfs
# Note: Omit --overwrite to skip already-processed filesWhat happens during seeding:
- π Loads PDF files (with OCR fallback for scanned documents)
- π Smart detection: Skips files already in database (unless
--overwriteused) - π§ Extracts 100+ concepts per document (Claude Sonnet 4.5)
- π Generates summaries (Grok-4-fast)
- π Enriches with WordNet synonyms and hierarchies
- β‘ Creates fast local embeddings (384-dimensional)
- πΎ Stores in 3 LanceDB tables: catalog, chunks, concepts
-
Open Cursor settings and navigate to MCP configuration
-
Edit your MCP config file:
Linux/macOS:
~/.cursor/mcp.jsonWindows:%APPDATA%/Cursor/User/mcp.json -
Add the configuration:
{ "mcpServers": { "lancedb": { "command": "node", "args": [ "/path/to/your/lance-mcp/dist/simple_index.js", "/home/your-username/.lance_mcp" ] } } }Replace the paths with your actual paths:
# Find your full paths pwd # In lance-mcp directory echo ~/.lance_mcp # Database location
# Reload window in Cursor: Cmd/Ctrl + Shift + P β "Reload Window"
# The conceptual search tools should now be availableTry these example queries:
1. "What documents do we have?"
β Uses: catalog_search with concept expansion
2. "Find information about strategic thinking"
β Expands to: strategy, tactics, planning, decision making, etc.
β Returns: Relevant documents with concept matches
3. "Search for leadership principles"
β Finds: Documents about leadership, management, command, etc.
β Shows matched concepts and expanded terms
Seed your documents with concept extraction:
# Set up environment
export OPENROUTER_API_KEY=your_key_here
# Run seeding with conceptual indexing
npx tsx hybrid_fast_seed.ts \
--dbpath ~/.lance_mcp \
--filesdir ~/Documents/your-pdfs \
--overwriteWhat's created:
- Catalog table: Document summaries with embedded concepts
- Chunks table: Detailed text segments for deep search
- Concepts table: Extracted concepts with co-occurrence relationships
Features:
- π§ Comprehensive: Extracts 100+ concepts per document (Claude Sonnet 4.5)
- π Fast summaries: Grok-4-fast for quick overviews
- π WordNet enriched: Automatic synonym and hierarchy expansion
- π‘οΈ Robust: Auto-skips corrupted PDFs, OCR fallback for scanned docs
- π° Seeding cost: ~$4.80 per 100 documents (one-time)
Required:
--dbpath: Directory to store the LanceDB database--filesdir: Directory containing PDF files to process
Optional:
--overwrite: Recreate database from scratch (deletes existing data)- Without this flag: Only processes new or changed files (incremental mode)
- With this flag: Reprocesses everything (useful for testing or upgrades)
Incremental vs Full Seeding:
# Incremental (recommended for updates) - Only new/changed files
npx tsx hybrid_fast_seed.ts --dbpath ~/.lance_mcp --filesdir ~/Documents/pdfs
# Full (initial setup or rebuild) - Process everything
npx tsx hybrid_fast_seed.ts --dbpath ~/.lance_mcp --filesdir ~/Documents/pdfs --overwriteTime savings with incremental:
- Initial 100 docs: ~25 minutes + ~$4.80
- Add 10 new docs: ~3 minutes + ~$0.48 β¨
- Add 1 new doc: ~15 seconds + ~$0.05 β¨
Conceptual search finds documents by meaning, not just keywords:
"What documents do we have?"
β Lists catalog with AI summaries and extracted concepts
"Find information about strategic thinking"
β Expands: strategy, tactics, planning, decision making
β Finds: All documents with related concepts
"Search for leadership principles"
β Expands: leadership, management, command, authority
β Returns: Chunks from ANY document about leadership
"How do threads synchronize?"
β Expands: concurrency, mutex, semaphore, locks
β Finds: Technical docs even without exact wording
The server provides 3 conceptual search tools:
Search document summaries to find relevant sources
- Query expansion with corpus concepts + WordNet
- Returns: Documents with concept matches and scores
Find specific information within a chosen document
- Requires
sourceparameter (document path) - Concept-aware search within single document
Search across ALL documents for detailed information
- Returns: Top 10 most relevant chunks from entire corpus
- Full conceptual expansion and multi-signal ranking
Documents
β
PDF Processing (with OCR fallback)
β
βββββββββββββββββββ¬ββββββββββββββββββββ
β β β
Concept Summary Chunks
Extraction Generation Creation
(Sonnet 4.5) (Grok-4-fast) (Local)
β β β
Concepts Catalog Chunks
Table Table Table
βββββββββββββββββββ΄ββββββββββββββββ
β
Conceptual Search Engine
(5 signals)
β
βββββββββββββββΌββββββββββββββ
β β β
Corpus WordNet Hybrid
Concepts Synonyms Scoring
hybrid_fast_seed.ts # Seeding with concept extraction
src/
βββ conceptual_index.ts # MCP server entry point
βββ concepts/ # Concept extraction & indexing
β βββ concept_extractor.ts # LLM-based extraction
β βββ concept_index.ts # Index builder
β βββ query_expander.ts # Query expansion
β βββ types.ts # Shared types
βββ wordnet/ # WordNet integration
β βββ wordnet_service.ts # Python NLTK bridge
βββ lancedb/ # Database clients
β βββ conceptual_search_client.ts # Search engine
βββ tools/ # MCP tools
βββ conceptual_registry.ts # Tool registry
# Build project
npm run build
# Test with MCP Inspector
npx @modelcontextprotocol/inspector dist/conceptual_index.js ~/.lance_mcp
# Run concept extraction tests
npx tsx test/conceptual_search_test.ts- Fork the repository
- Create a feature branch
- Make your changes (ensure no API keys in code!)
- Run tests:
npm run buildand verify no errors - Submit a pull request
Seeding costs (OpenRouter):
- Concept extraction: ~$0.041/doc (Claude Sonnet 4.5)
- Summarization: ~$0.007/doc (Grok-4-fast)
- Total: ~$0.048 per document
For 100 documents: ~$4.80
For 1,000 documents: ~$48
Runtime search: No additional API calls to OpenRouter (vector search is local)
Note: When used with AI agents (Cursor, Claude Desktop), the agent incurs costs for processing search results
This project is licensed under the MIT License - see the LICENSE file for details.