MCP Now
Chroma

Chroma

by privetin
GitHub

Vector database server for semantic document search and metadata filtering, built on Chroma

document
server
error
metadata
content

Chroma MCP Server

A Model Context Protocol (MCP) server implementation that provides vector database capabilities through Chroma. This server enables semantic document search, metadata filtering, and document management with persistent storage.

Requirements

  • Python 3.8+
  • Chroma 0.4.0+
  • MCP SDK 0.1.0+

Components

Resources

The server provides document storage and retrieval through Chroma's vector database:

  • Stores documents with content and metadata
  • Persists data in src/chroma/data directory
  • Supports semantic similarity search

Tools

The server implements CRUD operations and search functionality:

Document Management

  • create_document: Create a new document

    • Required: document_id, content
    • Optional: metadata (key-value pairs)
    • Returns: Success confirmation
    • Error: Already exists, Invalid input
  • read_document: Retrieve a document by ID

    • Required: document_id
    • Returns: Document content and metadata
    • Error: Not found
  • update_document: Update an existing document

    • Required: document_id, content
    • Optional: metadata
    • Returns: Success confirmation
    • Error: Not found, Invalid input
  • delete_document: Remove a document

    • Required: document_id
    • Returns: Success confirmation
    • Error: Not found
  • list_documents: List all documents

    • Optional: limit, offset
    • Returns: List of documents with content and metadata

Search Operations

  • search_similar: Find semantically similar documents
    • Required: query
    • Optional: num_results, metadata_filter, content_filter
    • Returns: Ranked list of similar documents with distance scores
    • Error: Invalid filter

Features

  • Semantic Search: Find documents based on meaning using Chroma's embeddings
  • Metadata Filtering: Filter search results by metadata fields
  • Content Filtering: Additional filtering based on document content
  • Persistent Storage: Data persists in local directory between server restarts
  • Error Handling: Comprehensive error handling with clear messages
  • Retry Logic: Automatic retries for transient failures

Installation

  1. Install dependencies:
1uv venv 2uv sync --dev --all-extras

Configuration

Claude Desktop

Add the server configuration to your Claude Desktop config:

Windows: C:\Users\<username>\AppData\Roaming\Claude\claude_desktop_config.json

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

1{ 2 "mcpServers": { 3 "chroma": { 4 "command": "uv", 5 "args": [ 6 "--directory", 7 "C:/MCP/server/community/chroma", 8 "run", 9 "chroma" 10 ] 11 } 12 } 13}

Data Storage

The server stores data in:

  • Windows: src/chroma/data
  • MacOS/Linux: src/chroma/data

Usage

  1. Start the server:
1uv run chroma
  1. Use MCP tools to interact with the server:
1# Create a document 2create_document({ 3 "document_id": "ml_paper1", 4 "content": "Convolutional neural networks improve image recognition accuracy.", 5 "metadata": { 6 "year": 2020, 7 "field": "computer vision", 8 "complexity": "advanced" 9 } 10}) 11 12# Search similar documents 13search_similar({ 14 "query": "machine learning models", 15 "num_results": 2, 16 "metadata_filter": { 17 "year": 2020, 18 "field": "computer vision" 19 } 20})

Error Handling

The server provides clear error messages for common scenarios:

  • Document already exists [id=X]
  • Document not found [id=X]
  • Invalid input: Missing document_id or content
  • Invalid filter
  • Operation failed: [details]

Development

Testing

  1. Run the MCP Inspector for interactive testing:
1npx @modelcontextprotocol/inspector uv --directory C:/MCP/server/community/chroma run chroma
  1. Use the inspector's web interface to:
    • Test CRUD operations
    • Verify search functionality
    • Check error handling
    • Monitor server logs

Building

  1. Update dependencies:
1uv compile pyproject.toml
  1. Build package:
1uv build

Contributing

Contributions are welcome! Please read our Contributing Guidelines for details on:

  • Code style
  • Testing requirements
  • Pull request process

License

This project is licensed under the MIT License - see the LICENSE file for details.