ChromaDB-MCP ๐
March 27, 2025 ยท View on GitHub
A powerful document similarity search service that uses ChromaDB vector database with Model Context Protocol (MCP) integration. This project enables semantic search capabilities through a lightweight MCP server.
๐ Description
ChromaDB-MCP processes documents, splits them into semantic chunks, embeds them using Google's text embedding models, and stores them in a ChromaDB vector database. It then exposes an MCP tool that allows you to query for similar chunks to any input text.
๐๏ธ Repository Structure
.
โโโ chroma_db/ # Persistent storage for vector database
โโโ files/ # Directory for input documents
โโโ scripts/ # Utility scripts
โ โโโ files_ingestion/ # Document processing and ingestion scripts
โโโ src/ # Source code
โ โโโ configs/ # Configuration settings
โ โโโ infra/ # Infrastructure implementations
โ โโโ ports/ # Interface definitions
โ โโโ tools/ # MCP tool implementations
โ โโโ dependency_manager.py # Dependency injection container
โ โโโ server.py # MCP server implementation
โโโ .env # Environment variables
โโโ Justfile # Command runner for common operations
โโโ main.py # Application entry point
โโโ pyproject.toml # Project dependencies and metadata
โ๏ธ Environment Variables
The following environment variables must be set (in a .env file or directly in your environment):
INPUT_DIR๐ - Directory containing documents to process (e.g., "/path/to/files")CHROMA_PERSIST_DIRECTORY๐พ - Directory to store the ChromaDB database (e.g., "/path/to/chroma_db")GOOGLE_API_KEY๐ - Your Google API key for text embeddings
Example .env file:
INPUT_DIR="/path/to/files"
CHROMA_PERSIST_DIRECTORY="/path/to/chroma_db"
GOOGLE_API_KEY="your-google-api-key"
๐ Getting Started
Prerequisites
Setup
-
Clone the repository:
git clone https://github.com/yourusername/chromadb-mcp.git cd chromadb-mcp -
Create a
.envfile with required environment variables. -
Set up the environment and ingest documents:
just setup
Running the Server
Run the MCP server:
just run
For development with MCP Inspector:
just dev
๐ฌ Demo
Using with Claude Desktop
You can seamlessly integrate ChromaDB-MCP with Claude desktop for enhanced document retrieval capabilities. Follow these steps:
-
Weโll need to configure Claude for Desktop for whichever MCP servers you want to use. To do this, open your Claude for Desktop App configuration at
~/Library/Application Support/Claude/claude_desktop_config.jsonin a text editor. -
Add a new tool with the following configuration:
{ "mcpServers": { "chromadb": { "command": "/path/to/bin/uv", "args": [ "--directory", "/path/to/chromadb-mcp", "run", "main.py" ], "env": { "INPUT_DIR": "/path/to/files", "CHROMA_PERSIST_DIRECTORY": "/path/to/chroma_db", "GOOGLE_API_KEY": "YOUR-REAL-API-KEY-HERE" } } } }Obs: You can either set the environment variables in the
.envfile or directly in the MCP server configuration. -
Now you can ask Claude questions about your documents! For example:
- "Find information about project architecture in my documents"
- "What are the key components of the system design?"
- "Summarize what the documents say about implementation details"
If you have any issues, please refer to official documentation here.
Demo Video
https://github.com/user-attachments/assets/c954a6e0-cded-4f95-b63d-a50ba930bada
๐ Features
- ๐ Document ingestion and chunking
- ๐ง Semantic embeddings using Google's text-embedding-004 model
- ๐ Vector similarity search through ChromaDB
- ๐ MCP server interface for easy integration with other applications
๐ ๏ธ API
The MCP server exposes the following tool:
get_similar_chunks(query: str, k: int = 2)- Retrieves k chunks similar to the input query