chroma_delete_documents
Remove specific documents from a Chroma collection by specifying their IDs and collection name. Confirms the number of documents deleted and handles errors for invalid inputs or non-existent collections.
Instructions
Delete documents from a Chroma collection.
Args:
collection_name: Name of the collection to delete documents from
ids: List of document IDs to delete
Returns:
A confirmation message indicating the number of documents deleted.
Raises:
ValueError: If 'ids' is empty
Exception: If the collection does not exist or if the delete operation fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_name | Yes | ||
| ids | Yes |
Implementation Reference
- src/chroma_mcp/server.py:567-606 (handler)The main handler function for the 'chroma_delete_documents' tool. It deletes specified documents by IDs from a Chroma collection using the ChromaDB client. Decorated with @mcp.tool() which also serves as the registration in FastMCP.@mcp.tool() async def chroma_delete_documents( collection_name: str, ids: List[str] ) -> str: """Delete documents from a Chroma collection. Args: collection_name: Name of the collection to delete documents from ids: List of document IDs to delete Returns: A confirmation message indicating the number of documents deleted. Raises: ValueError: If 'ids' is empty Exception: If the collection does not exist or if the delete operation fails. """ if not ids: raise ValueError("The 'ids' list cannot be empty.") client = get_chroma_client() try: collection = client.get_collection(collection_name) except Exception as e: raise Exception( f"Failed to get collection '{collection_name}': {str(e)}" ) from e try: collection.delete(ids=ids) return ( f"Successfully deleted {len(ids)} documents from " f"collection '{collection_name}'. Note: Non-existent IDs are ignored by ChromaDB." ) except Exception as e: raise Exception( f"Failed to delete documents from collection '{collection_name}': {str(e)}" ) from e