Chroma MCP Server

0.2.6 · active · verified Fri Apr 17

Chroma MCP (Multi-Modal Controller for Persistance) Server acts as a vector database integration layer for LLM applications. It provides a set of tools that allow LLM agents to interact with ChromaDB, handling complex operations like document creation, updates, and deletions. The current version is 0.2.6, and it sees somewhat frequent updates, often tied to new releases of the underlying `chromadb` library.

Common errors

Warnings

Install

Quickstart

The Chroma MCP Server is a FastAPI application. This quickstart demonstrates how to run it locally using `uvicorn`, configuring the ChromaDB backend via environment variables to use a temporary directory for data storage. The server will start and be accessible at `http://127.0.0.1:8000` (or configured host/port).

import os
import uvicorn
import tempfile
import shutil

# This library is a server application designed to be run, not typically imported
# for client-side functionality. The quickstart demonstrates how to run the server locally.

# Create a temporary directory for ChromaDB to store its data
temp_dir = tempfile.mkdtemp()
print(f"ChromaDB data will be stored in: {temp_dir}")

# Configure the Chroma MCP server via environment variables.
# These are crucial for the server to operate correctly.
os.environ["CHROMA_DB_PATH"] = temp_dir # Use a local persistent ChromaDB path
os.environ["CHROMA_SERVER_HOST"] = os.environ.get('CHROMA_SERVER_HOST', '127.0.0.1')
os.environ["CHROMA_SERVER_PORT"] = os.environ.get('CHROMA_SERVER_PORT', '8000')
os.environ["CHROMA_SERVER_ROOT_PATH"] = os.environ.get('CHROMA_SERVER_ROOT_PATH', '')
os.environ["LOG_LEVEL"] = os.environ.get('LOG_LEVEL', 'info') # Optional: set log level

print(f"Starting Chroma MCP Server on http://{os.environ['CHROMA_SERVER_HOST']}:{os.environ['CHROMA_SERVER_PORT']}")
print("Press Ctrl+C to stop the server.")

try:
    # Run the Chroma MCP FastAPI application using uvicorn.
    # The application instance is found at 'chroma_mcp.app:app'.
    uvicorn.run(
        "chroma_mcp.app:app",
        host=os.environ["CHROMA_SERVER_HOST"],
        port=int(os.environ["CHROMA_SERVER_PORT"]),
        log_level=os.environ["LOG_LEVEL"],
        reload=False # Set to True for development, False for production
    )
except KeyboardInterrupt:
    print("\nServer stopped.")
finally:
    # Clean up the temporary directory used by ChromaDB
    print(f"Cleaning up temporary ChromaDB data directory: {temp_dir}")
    shutil.rmtree(temp_dir)

view raw JSON →