Skip to content

Conversation

@tomingtoming
Copy link
Contributor

@tomingtoming tomingtoming commented Apr 2, 2025

Description

This pull request introduces the chroma_update_documents tool to the Chroma MCP server. This tool allows users to update existing documents within a specified Chroma collection by providing their IDs.

Key Features:

  • Update Documents: Modifies the content (documents), metadata (metadatas), or embeddings (embeddings) of existing documents identified by their unique IDs.
  • Partial Updates: Supports updating only specific fields (e.g., only updating metadata while keeping the document content the same).
  • Error Handling: Includes checks for invalid arguments (e.g., empty ID list, no update fields provided) and handles cases where the specified collection does not exist.

Implementation Details:

  • Added the chroma_update_documents function to src/chroma_mcp/server.py, which interacts with the ChromaDB client's update method.
  • Registered the new tool within the MCP server instance.

Testing:

Added comprehensive tests in tests/test_server.py to cover various scenarios:

  • test_update_documents_success: Verifies successful updates of document content and metadata.
  • test_update_documents_invalid_args: Ensures appropriate errors are raised for invalid input (empty IDs, no update fields).
  • test_update_documents_collection_not_found: Checks error handling when the target collection doesn't exist.
  • test_update_documents_id_not_found: Confirms that attempting to update non-existent IDs does not raise an error but completes the request (as per ChromaDB behavior).

This new tool enhances the capabilities of the Chroma MCP server, providing users with more granular control over their collection data.

Related PRs

Following the merge of this PR, I plan to merge the pull request for adding the document deletion feature (chroma_delete_documents):

@jairad26
Copy link
Collaborator

jairad26 commented Apr 2, 2025

thanks for the PR!

@jairad26 jairad26 merged commit 8863b47 into chroma-core:main Apr 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants