Skip to main content
Glama
Chroma MCP Server

Chroma MCP Server

by privetin

Chroma MCP 服务器

模型上下文协议 (MCP) 服务器实现,通过 Chroma 提供矢量数据库功能。该服务器支持语义文档搜索、元数据过滤以及具有持久存储的文档管理。

要求

  • Python 3.8+

  • Chroma 0.4.0+

  • MCP SDK 0.1.0+

Related MCP server: Chroma MCP Server

成分

资源

服务器通过Chroma的矢量数据库提供文档存储和检索:

  • 存储包含内容和元数据的文档

  • 将数据保存在src/chroma/data目录中

  • 支持语义相似性搜索

工具

服务器实现 CRUD 操作和搜索功能:

文档管理

  • create_document :创建新文档

    • 必需: document_id 、 content

    • 可选: metadata (键值对)

    • 返回:成功确认

    • 错误:已存在,输入无效

  • read_document :通过 ID 检索文档

    • 必填: document_id

    • 返回:文档内容和元数据

    • 错误:未找到

  • update_document :更新现有文档

    • 必需: document_id 、 content

    • 可选: metadata

    • 返回:成功确认

    • 错误:未找到,输入无效

  • delete_document :删除文档

    • 必填: document_id

    • 返回:成功确认

    • 错误:未找到

  • list_documents :列出所有文档

    • 可选: limit 、 offset

    • 返回:包含内容和元数据的文档列表

搜索行动

  • search_similar :查找语义相似的文档

    • 必填: query

    • 可选: num_results 、 metadata_filter 、 content_filter

    • 返回:具有距离分数的相似文档的排序列表

    • 错误:过滤器无效

特征

  • 语义搜索:使用 Chroma 的嵌入查找基于含义的文档

  • 元数据过滤:按元数据字段过滤搜索结果

  • 内容过滤:基于文档内容的附加过滤

  • 持久存储:服务器重启后数据仍保留在本地目录中

  • 错误处理:全面的错误处理,清晰的消息

  • 重试逻辑:瞬时故障自动重试

安装

  1. 安装依赖项:

uv venv
uv sync --dev --all-extras

配置

克劳德桌面

将服务器配置添加到您的 Claude Desktop 配置中:

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

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

{
  "mcpServers": {
    "chroma": {
      "command": "uv",
      "args": [
        "--directory",
        "C:/MCP/server/community/chroma",
        "run",
        "chroma"
      ]
    }
  }
}

数据存储

服务器将数据存储在:

  • Windows: src/chroma/data

  • MacOS/Linux: src/chroma/data

用法

  1. 启动服务器:

uv run chroma
  1. 使用 MCP 工具与服务器交互:

# Create a document
create_document({
    "document_id": "ml_paper1",
    "content": "Convolutional neural networks improve image recognition accuracy.",
    "metadata": {
        "year": 2020,
        "field": "computer vision",
        "complexity": "advanced"
    }
})

# Search similar documents
search_similar({
    "query": "machine learning models",
    "num_results": 2,
    "metadata_filter": {
        "year": 2020,
        "field": "computer vision"
    }
})

错误处理

服务器针对常见场景提供了清晰的错误消息:

  • Document already exists [id=X]

  • Document not found [id=X]

  • Invalid input: Missing document_id or content

  • Invalid filter

  • Operation failed: [details]

发展

测试

  1. 运行 MCP Inspector 进行交互式测试:

npx @modelcontextprotocol/inspector uv --directory C:/MCP/server/community/chroma run chroma
  1. 使用检查器的 Web 界面可以执行以下操作:

    • 测试 CRUD 操作

    • 验证搜索功能

    • 检查错误处理

    • 监控服务器日志

建筑

  1. 更新依赖项:

uv compile pyproject.toml
  1. 构建包:

uv build

贡献

欢迎贡献!请阅读我们的贡献指南,了解详情:

  • 代码风格

  • 测试要求

  • 拉取请求流程

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

Available Tools

6 tools
create_documentC

Create a new document in the Chroma vector database

Inputs: content (required), document_id (required), metadata.

delete_documentB

Delete a document from the Chroma vector database by its ID

Inputs: document_id (required).

list_documentsB

List all documents stored in the Chroma vector database with pagination

Inputs: limit, offset.

read_documentC

Retrieve a document from the Chroma vector database by its ID

Inputs: document_id (required).

search_similarC

Search for semantically similar documents in the Chroma vector database

Inputs: query (required), num_results, content_filter, metadata_filter.

update_documentC

Update an existing document in the Chroma vector database

Inputs: content (required), document_id (required), metadata.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: create, delete, list, read, search, and update documents. The actions and targets are well-defined, making it easy for an agent to select the correct tool without confusion.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern (e.g., create_document, delete_document) using snake_case throughout. The naming is predictable and readable, with no deviations in style or convention.

    Tool Count5/5

    With 6 tools, this server is well-scoped for managing documents in a vector database. Each tool earns its place by covering essential CRUD operations and semantic search, avoiding bloat or thinness for the domain.

    Completeness5/5

    The toolset provides complete CRUD/lifecycle coverage for documents (create, read, update, delete, list) and includes a semantic search function. There are no obvious gaps, enabling agents to handle all core workflows without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers