Skip to main content
Glama

update_document

Modify and update content or metadata of an existing document in the Chroma vector database using a specified document ID.

Instructions

Update an existing document in the Chroma vector database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
document_idYes
metadataNo

Implementation Reference

  • The main handler function that executes the update_document tool. It validates inputs, checks if the document exists, processes metadata, calls collection.update(), and returns success message. Wrapped with retry decorator.
    async def handle_update_document(arguments: dict) -> list[types.TextContent]: """Handle document update with retry logic""" doc_id = arguments.get("document_id") content = arguments.get("content") metadata = arguments.get("metadata") if not doc_id or not content: raise DocumentOperationError("Missing document_id or content") logger.info(f"Updating document: {doc_id}") try: # Check if document exists existing = collection.get(ids=[doc_id]) if not existing or not existing.get('ids'): raise DocumentOperationError(f"Document not found [id={doc_id}]") # Update document if metadata: # Keep numeric values in metadata processed_metadata = { k: v if isinstance(v, (int, float)) else str(v) for k, v in metadata.items() } collection.update( ids=[doc_id], documents=[content], metadatas=[processed_metadata] ) else: collection.update( ids=[doc_id], documents=[content] ) logger.info(f"Successfully updated document: {doc_id}") return [ types.TextContent( type="text", text=f"Updated document '{doc_id}' successfully" ) ] except Exception as e: raise DocumentOperationError(str(e))
  • Input schema definition for the update_document tool, defining parameters: document_id (required string), content (required string), metadata (optional object). Used in tool registration.
    inputSchema={ "type": "object", "properties": { "document_id": {"type": "string"}, "content": {"type": "string"}, "metadata": { "type": "object", "additionalProperties": True } }, "required": ["document_id", "content"] }
  • Tool dispatch registration in the @server.call_tool() handler, routing 'update_document' calls to handle_update_document.
    elif name == "update_document": return await handle_update_document(arguments)
  • Tool registration in @server.list_tools(), defining name, description, and inputSchema for update_document.
    types.Tool( name="update_document", description="Update an existing document in the Chroma vector database", inputSchema={ "type": "object", "properties": { "document_id": {"type": "string"}, "content": {"type": "string"}, "metadata": { "type": "object", "additionalProperties": True } }, "required": ["document_id", "content"] }
  • Additional schema in server.command_options for update_document input validation.
    "update_document": { "type": "object", "properties": { "document_id": {"type": "string"}, "content": {"type": "string"}, "metadata": {"type": "object", "additionalProperties": True} }, "required": ["document_id", "content"] },

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/privetin/chroma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server