Skip to main content

Local knowledge base CLI with vector + keyword hybrid search and MCP support

Project description

ai-rag

A local knowledge base CLI tool with hybrid vector + keyword search and MCP server support.

Automatically indexes .docx files from a watch directory, stores embeddings in ChromaDB, and exposes retrieval as both a CLI and an MCP server for LLM clients like Claude Desktop and Cursor.

Features

  • 📄 Auto-indexing — watches a directory and indexes .docx files automatically
  • 🔍 Hybrid search — combines semantic vector search with exact keyword matching (RRF fusion)
  • 🤖 MCP server — expose your knowledge base as tools callable by Claude / Cursor / any MCP client
  • ⚙️ Configurable — chunk size, overlap, embedding model, watch directory via YAML config

Installation

pip install ai-rag

Requirements: Python 3.9+, macOS / Linux
First run will download the embedding model (~120 MB).

Quick Start

# 1. Index documents in ~/Downloads
ai-rag sync

# 2. Search
ai-rag search "your query"

# 3. Check status
ai-rag status

Search Modes

# Hybrid (default, recommended)
ai-rag search "direct broadcast architecture" --mode hybrid

# Semantic vector search
ai-rag search "broadcast architecture" --mode vector

# Exact keyword match
ai-rag search "SPU" --mode keyword

# Control number of results
ai-rag search "query" -n 10

File Watcher

# Foreground — auto-re-index when files change
ai-rag watch

# Background daemon
ai-rag watch --daemon
ai-rag stop

MCP Server (for Claude Desktop / Cursor)

Start the MCP server (stdio transport):

ai-rag-mcp

Claude Desktop config

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

{
  "mcpServers": {
    "ai-rag": {
      "command": "ai-rag-mcp"
    }
  }
}

Cursor config (~/.cursor/mcp.json)

{
  "mcpServers": {
    "ai-rag": {
      "command": "ai-rag-mcp"
    }
  }
}

After restarting the client, you can ask: "Search my knowledge base for broadcast backend architecture" and the LLM will call the retrieval tools automatically.

Available MCP Tools

Tool Description
search Hybrid vector + keyword search (recommended)
vector_search Semantic similarity search only
keyword_search Exact keyword / phrase match
get_status Index statistics

Configuration

Default config file: ~/.config/ai-rag/config.yaml

watch_dir: ~/Downloads        # directory to watch and index
file_patterns:
  - "*.docx"
chunk_size: 500               # characters per chunk
chunk_overlap: 100            # overlap between chunks
model_name: paraphrase-multilingual-MiniLM-L12-v2

Architecture

docx files
    │
    ▼
DocxParser → TextChunker (500 chars, 100 overlap)
    │
    ▼
sentence-transformers (paraphrase-multilingual-MiniLM-L12-v2)
    │
    ▼
ChromaDB (local persistent vector store)
    │
    ├── vector_search  (cosine similarity)
    ├── keyword_search (substring match via where_document)
    └── hybrid_search  (RRF fusion, vector×0.7 + keyword×0.3)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_rag-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_rag-0.1.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file ai_rag-0.1.0.tar.gz.

File metadata

  • Download URL: ai_rag-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for ai_rag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2880603ac6191eb278e37f1b95aed9400f2eaea7256d861a93ee12c47cca9faa
MD5 422fa5b31b870978b5851f6d8aef954d
BLAKE2b-256 0be2f5c4318496ef14415d64185afca077dd5ae5c7b2811d449241d255089dfc

See more details on using hashes here.

File details

Details for the file ai_rag-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ai_rag-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for ai_rag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f71fd38670aaf5885be82605b4b1283772a9956559c77ed056270cf7e30c708f
MD5 7e7ade32a35853074e92bb7b1eed59dd
BLAKE2b-256 e1180c89e9c623e7549d58e387c6c81e6d06601ff52bced44c0e4125f06886d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page