chroma-mcp
by: chroma-core
A Model Context Protocol (MCP) server implementation that provides database capabilities for Chroma
πOverview
Purpose: Chroma serves as an open-source embedding database designed to facilitate seamless memory management for developing LLM applications in Python and JavaScript.
Overview: This framework enables developers to connect AI models with external data sources and manage data collections through efficient search capabilities. The Model Context Protocol (MCP) offers a standardized method for LLM applications to retrieve the context they require, empowering users to build intelligent applications with memory features.
Key Features:
-
Flexible Client Types: Supports various client configurations including ephemeral (in-memory) for testing, persistent (file-based) for storage, and cloud integration for automatic connection to Chroma Cloud.
-
Collection Management: Allows users to create, modify, and delete data collections, along with pagination support for collection listing and configuration options for optimized vector search.
-
Document Operations: Facilitates the addition and querying of documents, including metadata filtering, semantic search capabilities, and full text search, enabling complex data retrieval operations.
Chroma MCP Server
Chroma is an open-source embedding database and the fastest way to build Python or JavaScript LLM apps with memory.
The Model Context Protocol (MCP) is an open protocol designed for effortless integration between LLM applications and external data sources or tools, offering a standardized framework to seamlessly provide LLMs with the context they require.
This server provides data retrieval capabilities powered by Chroma, enabling AI models to create collections over generated data and user inputs, and retrieve that data using vector search, full text search, metadata filtering, and more.
Features
-
Flexible Client Types
- Ephemeral (in-memory) for testing and development
- Persistent for file-based storage
- HTTP client for self-hosted Chroma instances
- Cloud client for Chroma Cloud integration (automatically connects to api.trychroma.com)
-
Collection Management
- Create, modify, and delete collections
- List all collections with pagination support
- Get collection information and statistics
- Configure HNSW parameters for optimized vector search
- Select embedding functions when creating collections
-
Document Operations
- Add documents with optional metadata and custom IDs
- Query documents using semantic search
- Advanced filtering using metadata and document content
- Retrieve documents by IDs or filters
- Full text search capabilities
Supported Tools
- chroma_list_collections β List all collections with pagination support
- chroma_create_collection β Create a new collection with optional HNSW configuration
- chroma_peek_collection β View a sample of documents in a collection
- chroma_get_collection_info β Get detailed information about a collection
- chroma_get_collection_count β Get the number of documents in a collection
- chroma_modify_collection β Update a collection's name or metadata
- chroma_delete_collection β Delete a collection
- chroma_add_documents β Add documents with optional metadata and custom IDs
- chroma_query_documents β Query documents using semantic search with advanced filtering
- chroma_get_documents β Retrieve documents by IDs or filters with pagination
- chroma_update_documents β Update existing documents' content, metadata, or embeddings
- chroma_delete_documents β Delete specific documents from a collection
Embedding Functions
Chroma MCP supports several embedding functions: default
, cohere
, openai
, jina
, voyageai
, and roboflow
.
The embedding functions utilize Chroma's collection configuration, which persists the selected embedding function of a collection for retrieval. Once a collection is created using the collection configuration, on retrieval for future queries and inserts, the same embedding function will be used, with no need to specify it again. Embedding function persistence was added in v1.0.0 of Chroma; collections created with version β€0.6.3 do not support this feature.
When accessing embedding functions that utilize external APIs, be sure to add the environment variable for the API key as described in Embedding Function Environment Variables below.
Usage with Claude Desktop
- Add an ephemeral client by adding the following to your
claude_desktop_config.json
file:
"chroma": {
"command": "uvx",
"args": [
"chroma-mcp"
]
}
- Add a persistent client by adding the following:
"chroma": {
"command": "uvx",
"args": [
"chroma-mcp",
"--client-type",
"persistent",
"--data-dir",
"/full/path/to/your/data/directory"
]
}
This will use the specified data directory for persistent storage.
- Connect to Chroma Cloud by adding:
"chroma": {
"command": "uvx",
"args": [
"chroma-mcp",
"--client-type",
"cloud",
"--tenant",
"your-tenant-id",
"--database",
"your-database-name",
"--api-key",
"your-api-key"
]
}
This creates a cloud client that connects to api.trychroma.com using SSL.
Note: For safety, instead of passing API keys as arguments, you can specify a custom path for your environment configuration file using the
--dotenv-path
argument within theargs
list, for example:"args": ["chroma-mcp", "--dotenv-path", "/custom/path/.env"]
.
- Connect to a self-hosted Chroma instance on your own cloud provider by adding:
"chroma": {
"command": "uvx",
"args": [
"chroma-mcp",
"--client-type",
"http",
"--host",
"your-host",
"--port",
"your-port",
"--custom-auth-credentials",
"your-custom-auth-credentials",
"--ssl",
"true"
]
}
This creates an HTTP client that connects to your self-hosted Chroma instance.
Demos
Find reference usages such as shared knowledge bases and adding memory to context windows in the Chroma MCP Docs.
Using Environment Variables
You can configure the client using environment variables. The server automatically loads variables from a .env
file located at the path specified by --dotenv-path
(defaults to .chroma_env
in the working directory) or from system environment variables. Command-line arguments take precedence over environment variables.
# Common variables
export CHROMA_CLIENT_TYPE="http" # or "cloud", "persistent", "ephemeral"
# For persistent client
export CHROMA_DATA_DIR="/full/path/to/your/data/directory"
# For cloud client (Chroma Cloud)
export CHROMA_TENANT="your-tenant-id"
export CHROMA_DATABASE="your-database-name"
export CHROMA_API_KEY="your-api-key"
# For HTTP client (self-hosted)
export CHROMA_HOST="your-host"
export CHROMA_PORT="your-port"
export CHROMA_CUSTOM_AUTH_CREDENTIALS="your-custom-auth-credentials"
export CHROMA_SSL="true"
# Optional: Specify path to .env file (defaults to .chroma_env)
export CHROMA_DOTENV_PATH="/path/to/your/.env"
Embedding Function Environment Variables
When using external embedding functions that require an API key, set environment variables following the naming convention:
CHROMA_<EMBEDDING_FUNCTION_NAME>_API_KEY="<key>"
For example, to set a Cohere API key:
export CHROMA_COHERE_API_KEY="<your-cohere-api-key>"
It is recommended to add these to a .env
file and specify its location via the CHROMA_DOTENV_PATH
environment variable or the --dotenv-path
flag for security and safekeeping.