Labsco
nonatofabio logo

Local FAISS

β˜… 32

from nonatofabio

About Local FAISS vector store as an MCP server – drop-in local RAG for Claude / Copilot / Agents.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeNeeds API keys

Local FAISS MCP Server

<!-- mcp-name: io.github.nonatofabio/local-faiss-mcp -->

License: MIT Python 3.10+ Tests PyPI version

A Model Context Protocol (MCP) server that provides local vector database functionality using FAISS for Retrieval-Augmented Generation (RAG) applications.

demo

Features

Core Capabilities

  • Local Vector Storage: Uses FAISS for efficient similarity search without external dependencies
  • Document Ingestion: Automatically chunks and embeds documents for storage
  • Semantic Search: Query documents using natural language with sentence embeddings
  • Persistent Storage: Indexes and metadata are saved to disk
  • MCP Compatible: Works with any MCP-compatible AI agent or client

v0.2.0 Highlights

  • CLI Tool: local-faiss command for standalone indexing and search
  • Document Formats: Native PDF/TXT/MD support, DOCX/HTML/EPUB with pandoc
  • Re-ranking: Two-stage retrieve and rerank for better results
  • Custom Embeddings: Choose any Hugging Face embedding model
  • MCP Prompts: Built-in prompts for answer extraction and summarization

Command-Line Interface

The local-faiss CLI provides standalone document indexing and search capabilities.

Index Command

Index documents from the command line:

# Index single file
local-faiss index document.pdf

# Index multiple files
local-faiss index doc1.pdf doc2.txt doc3.md

# Index all files in folder
local-faiss index documents/

# Index recursively
local-faiss index -r documents/

# Index with glob pattern
local-faiss index "docs/**/*.pdf"

Configuration: The CLI automatically uses MCP configuration from:

  1. ./.mcp.json (local/project-specific)
  2. ~/.claude/.mcp.json (Claude Code config)
  3. ~/.mcp.json (fallback)

If no config exists, creates ./.mcp.json with default settings (./.vector_store).

Supported formats:

  • Native: TXT, MD, PDF (always available)
  • With pandoc: DOCX, ODT, HTML, RTF, EPUB, etc.
    • Install: brew install pandoc (macOS) or apt install pandoc (Linux)

Search Command

Search the indexed documents:

# Basic search
local-faiss search "What is FAISS?"

# Get more results
local-faiss search -k 5 "similarity search algorithms"

Results show:

  • Source file path
  • FAISS distance score
  • Re-rank score (if enabled in MCP config)
  • Text preview (first 300 characters)

CLI Features

  • βœ… Incremental indexing: Adds to existing index, doesn't overwrite
  • βœ… Progress output: Shows indexing progress for each file
  • βœ… Shared config: Uses same settings as MCP server
  • βœ… Auto-detection: Supports glob patterns and recursive folders
  • βœ… Format support: Handles PDF, TXT, MD natively; DOCX+ with pandoc

Architecture

  • Embedding Model: Configurable via --embed flag (default: all-MiniLM-L6-v2 with 384 dimensions)
    • Supports any Hugging Face sentence-transformers model
    • Automatically detects embedding dimensions
    • Model choice persisted with the index
  • Index Type: FAISS IndexFlatL2 for exact L2 distance search
  • Chunking: Documents are split into ~500 word chunks with 50 word overlap
  • Storage: Index saved as faiss.index, metadata saved as metadata.json

Choosing an Embedding Model

Different models offer different trade-offs:

ModelDimensionsSpeedQualityUse Case
all-MiniLM-L6-v2384FastGoodDefault, balanced performance
all-mpnet-base-v2768MediumBetterHigher quality embeddings
paraphrase-multilingual-MiniLM-L12-v2384FastGoodMultilingual support
all-MiniLM-L12-v2384MediumBetterBetter quality at same size

Important: Once you create an index with a specific model, you must use the same model for subsequent runs. The server will detect dimension mismatches and warn you.

Development

Standalone Test

Test the FAISS vector store functionality without MCP infrastructure:

source venv/bin/activate
python test_standalone.py

This test:

  • Initializes the vector store
  • Ingests sample documents
  • Performs semantic search queries
  • Tests persistence and reload
  • Cleans up test files

Unit Tests

Run the complete test suite:

pytest tests/ -v

Run specific test files:

# Test embedding model functionality
pytest tests/test_embedding_models.py -v

# Run standalone integration test
python tests/test_standalone.py

The test suite includes:

  • test_embedding_models.py: Comprehensive tests for custom embedding models, dimension detection, and compatibility
  • test_standalone.py: End-to-end integration test without MCP infrastructure