Skip to main content

MCP server with FAISS local vector database for RAG

Project description

Local FAISS MCP Server

License: MIT Python 3.10+ Tests

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

Features

  • 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

Quickstart

pip install local-faiss-mcp

Then configure your MCP client (see Configuration) and try your first query in Claude:

Use the query_rag_store tool to search for: "How does FAISS perform similarity search?"

Claude will retrieve relevant document chunks from your vector store and use them to answer your question.

Installation

From PyPI (Recommended)

pip install local-faiss-mcp

From Source

git clone https://github.com/nonatofabio/local_faiss_mcp.git
cd local_faiss_mcp
pip install -e .

Usage

Running the Server

After installation, you can run the server in three ways:

1. Using the installed command (easiest):

local-faiss-mcp --index-dir /path/to/index/directory

2. As a Python module:

python -m local_faiss_mcp --index-dir /path/to/index/directory

3. For development/testing:

python local_faiss_mcp/server.py --index-dir /path/to/index/directory

Command-line Arguments:

  • --index-dir: Directory to store FAISS index and metadata files (default: current directory)

The server will:

  • Create the index directory if it doesn't exist
  • Load existing FAISS index from {index-dir}/faiss.index (or create a new one)
  • Load document metadata from {index-dir}/metadata.json (or create new)
  • Listen for MCP tool calls via stdin/stdout

Available Tools

1. ingest_document

Ingest a document into the vector store.

Parameters:

  • document (required): The text content to ingest
  • source (optional): Identifier for the document source (default: "unknown")

Example:

{
  "document": "FAISS is a library for efficient similarity search...",
  "source": "faiss_docs.txt"
}

2. query_rag_store

Query the vector store for relevant document chunks.

Parameters:

  • query (required): The search query text
  • top_k (optional): Number of results to return (default: 3)

Example:

{
  "query": "How does FAISS perform similarity search?",
  "top_k": 5
}

Configuration with MCP Clients

Claude Code

Add this server to your Claude Code MCP configuration (.mcp.json):

User-wide configuration (~/.claude/.mcp.json):

{
  "mcpServers": {
    "local-faiss-mcp": {
      "command": "local-faiss-mcp"
    }
  }
}

With custom index directory:

{
  "mcpServers": {
    "local-faiss-mcp": {
      "command": "local-faiss-mcp",
      "args": [
        "--index-dir",
        "/home/user/vector_indexes/my_project"
      ]
    }
  }
}

Project-specific configuration (./.mcp.json in your project):

{
  "mcpServers": {
    "local-faiss-mcp": {
      "command": "local-faiss-mcp",
      "args": [
        "--index-dir",
        "./.vector_store"
      ]
    }
  }
}

Alternative: Using Python module (if the command isn't in PATH):

{
  "mcpServers": {
    "local-faiss-mcp": {
      "command": "python",
      "args": ["-m", "local_faiss_mcp", "--index-dir", "./.vector_store"]
    }
  }
}

Claude Desktop

Add this server to your Claude Desktop configuration:

{
  "mcpServers": {
    "local-faiss-mcp": {
      "command": "local-faiss-mcp",
      "args": ["--index-dir", "/path/to/index/directory"]
    }
  }
}

Architecture

  • Embedding Model: Uses all-MiniLM-L6-v2 from sentence-transformers (384 dimensions)
  • 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

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 unit tests:

pytest

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

local_faiss_mcp-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

local_faiss_mcp-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: local_faiss_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for local_faiss_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea64f4cc6a1c56c9e4ce9dfcf46eda98e56bb72263d55f56c4f1d54d3123de08
MD5 3d6b6767439b6922401c96cb2a8c9a5b
BLAKE2b-256 0a127407c7cebc9b1f8451c0a59050889ae26f03d4e1de26c99354feff862f79

See more details on using hashes here.

Provenance

The following attestation bundles were made for local_faiss_mcp-0.1.0.tar.gz:

Publisher: publish.yml on nonatofabio/local_faiss_mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for local_faiss_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 684ba9a1f1b4f81b039caa604eb635f90e064072624356247f26ba7ed930cdab
MD5 1c4101939a69bd1da0bd7185fce79ca8
BLAKE2b-256 78f104852ce2d2406ac203c26f6a5e4aba0f9e29d9d0b8ba7d8034994da9efa7

See more details on using hashes here.

Provenance

The following attestation bundles were made for local_faiss_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on nonatofabio/local_faiss_mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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