Skip to main content
Glama
privetin

Chroma MCP Server

by privetin

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"]
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool updates a document, implying mutation, but fails to describe critical behaviors such as permission requirements, whether updates are idempotent or reversible, error handling, or what happens to unspecified metadata fields. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks details on parameters, behavioral traits, return values, and usage context, making it inadequate for an agent to reliably invoke the tool without additional assumptions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter details. The description mentions 'update an existing document' but adds no meaning beyond the tool name—it doesn't explain what 'content', 'document_id', or 'metadata' represent, their formats, or how they interact. This fails to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Update') and resource ('an existing document in the Chroma vector database'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'create_document' or 'read_document' beyond the implied distinction of updating versus creating or reading.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create_document' or 'delete_document'. It lacks context about prerequisites (e.g., document must exist), exclusions, or specific scenarios where updating is appropriate over other operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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