Labsco
cornelcroi logo

Context Lens

β˜… 24

from cornelcroi

Semantic search knowledge base for MCP-enabled AI assistants

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

Context Lens

Give your AI the ability to understand meaning, not just match keywords.

PyPI version Python 3.11+ License: MIT

What is Context Lens?

Context Lens transforms any content into a searchable knowledge base for your AI assistant. This self-contained Model Context Protocol (MCP) server with built-in serverless vector storage (LanceDB) brings semantic search to your conversations. Point it at any content - codebases, documentation, contracts, or text files - and your AI can instantly understand and answer questions about the content.

Traditional keyword search finds files containing specific words. Miss the exact term? Miss the content.

Context Lens understands meaning. Ask about "authentication" and find code about login, credentials, tokens, OAuth, and access control - even if those files never use the word "authentication."

See It In Action

Want to understand how Context-Lens works? Here's the fun part: you can use Context-Lens to learn about Context-Lens.

Context-Lens Demo

Demo: Using Claude Desktop with Context-Lens to index and query this repository itself. No git clone, no scrolling through code - just questions and answers.

Why LanceDB?

Context Lens uses LanceDB - a modern, serverless vector database:

  • πŸ†“ Completely Free & Local - No cloud services, API keys, or subscriptions
  • ⚑ Zero Infrastructure - Embedded database, just a file on disk
  • πŸš€ Fast & Efficient - Built on Apache Arrow, optimized for vector search
  • πŸ’Ύ Simple Storage - Single file database, easy to backup or move

Think of it as "SQLite for AI embeddings" - all the power of vector search without the complexity.

Features

  • πŸ” Semantic Search - Understand meaning, not just keywords
  • πŸš€ Zero Setup - No installation, no configuration, no API keys
  • πŸ’Ύ Serverless Storage - Built-in LanceDB, no external database
  • πŸ”’ 100% Local & Private - All data stays on your machine
  • πŸ“ Local & GitHub - Index local files or public GitHub repositories
  • 🎯 Smart Parsing - Language-aware chunking for better results

Architecture

Context Lens Architecture

How It Works

When you add content to Context Lens, it doesn't just dump text into a database. Here's what actually happens:

Smart Reading: Context Lens detects your file type and uses specialized parsers. Python files are analyzed with AST parsing, JSON is parsed structurally, Markdown is split by headers. This preserves the natural structure of your content.

Meaningful Chunks: Instead of arbitrary character limits, content is chunked intelligently - complete functions, logical paragraphs, full sections. Your code never gets split mid-function.

Semantic Vectors: Each chunk is converted to a 384-dimensional vector using a local embedding model. These vectors capture meaning, not just words. "authentication" and "login system" become similar vectors even though they share no words.

Local Storage: Everything goes into LanceDB - a serverless vector database that's just a file on your disk. No cloud services, no API calls, completely private.

Conceptual Search: When you ask a question, it becomes a vector too. Context Lens finds chunks with similar vectors (similar meaning) and ranks them by relevance. You get answers based on concepts, not keyword matching.

Technical Specifications

ComponentDetails
Embedding Modelsentence-transformers/all-MiniLM-L6-v2
Vector Dimensions384 dimensions
Model Size~90MB (downloads on first use)
Chunk Size1000 characters (default, configurable)
Chunk Overlap200 characters (default, configurable)
Vector DatabaseLanceDB (serverless, file-based)
Storage FormatApache Arrow columnar format
Search MethodCosine similarity
Processing100% local, no external API calls

πŸ“– Want to customize? See SETUP.md for configuration options and TECHNICAL.md for performance benchmarks.

MCP Registry

Context Lens is published to the official Model Context Protocol Registry as io.github.cornelcroi/context-lens.

πŸ“– Registry details and verification: See REGISTRY.md for installation verification and registry information.

<!-- mcp-name: io.github.cornelcroi/context-lens -->

Smart Parsing & Chunking

Context Lens doesn't just split text blindly - it understands code structure and creates intelligent chunks that respect language boundaries.

The difference: Generic chunking splits code arbitrarily by character count, often breaking functions mid-way. Smart parsing understands your code's structure and creates complete, meaningful chunks.

Supported File Types

  • 🐍 Python (.py, .pyw) - Functions, classes, imports
  • ⚑ JavaScript/TypeScript (.js, .jsx, .ts, .tsx, .mjs, .cjs) - Functions, classes, imports
  • πŸ“¦ JSON (.json, .jsonc) - Top-level keys, nested objects
  • πŸ“‹ YAML (.yaml, .yml) - Top-level keys, lists, mappings
  • πŸ“ Markdown (.md, .markdown, .mdx) - Header hierarchy, code blocks
  • πŸ¦€ Rust (.rs) - Structs, traits, impl blocks, functions
  • πŸ“„ Other Files (.txt, .log, .cpp, .java, etc.) - Intelligent paragraph/sentence splitting

Benefits

βœ… Complete Code Units - Never splits functions or classes mid-way
βœ… Preserved Context - Docstrings, comments, and structure stay intact
βœ… Better Search - Find complete, understandable code snippets
βœ… Automatic - No configuration needed, works based on file extension

πŸ“– Want to see how it works? Check out PARSING_EXAMPLES.md for detailed examples.

What You Can Add

Context Lens works with text-based files from multiple sources:

  • πŸ“ Local files & folders - Your projects, documentation, any text files
  • 🌐 GitHub repositories - Public repos, specific branches, directories, or files
  • πŸ”— Direct file URLs - Any HTTP/HTTPS accessible file
  • πŸ“„ Documents - Contracts, policies, research papers, technical docs

Supported file types: .py, .js, .ts, .java, .cpp, .go, .rs, .rb, .php, .json, .yaml, .md, .txt, .sh, and more (25+ extensions)

Maximum file size: 10 MB (configurable via MAX_FILE_SIZE_MB environment variable)

Examples:

  • ./src/ - Local directory
  • /path/to/file.py - Single local file
  • https://github.com/fastapi/fastapi - Entire repository
  • https://github.com/django/django/tree/main/django/contrib/auth - Specific directory
  • https://example.com/config.yaml - Direct file URL
  • /path/to/contracts/ - Legal documents

πŸ“– See more examples: USAGE_GUIDE.md

Available Tools

  • πŸ“₯ add_document - Add files, folders, or GitHub URLs
  • πŸ” search_documents - Semantic search across all content
  • πŸ“‹ list_documents - Browse indexed documents
  • ℹ️ get_document_info - Get metadata about a document
  • πŸ—‘οΈ remove_document - Remove specific documents
  • 🧹 clear_knowledge_base - Remove all documents

πŸ“– See detailed examples: USAGE_GUIDE.md

Documentation

Contributing

Contributions are welcome! Please:

  1. Open an issue first to discuss your idea
  2. Get approval before starting work
  3. Submit a PR referencing the issue

See CONTRIBUTING.md for details.

License

MIT License - see LICENSE for details.


Star the repo if you find it useful! ⭐