Skip to main content
Glama
privetin

Chroma MCP Server

by privetin

read_document

Retrieve a specific document from the Chroma vector database using its unique ID, enabling efficient document access and management for semantic search and metadata filtering.

Instructions

Retrieve a document from the Chroma vector database by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYes

Implementation Reference

  • Main execution logic for the read_document tool: extracts document_id, fetches from Chroma collection using collection.get(), handles not found errors, formats content and metadata into TextContent response.
    @retry_operation("read_document")
    async def handle_read_document(arguments: dict) -> list[types.TextContent]:
        """Handle document reading with retry logic"""
        doc_id = arguments.get("document_id")
    
        if not doc_id:
            raise DocumentOperationError("Missing document_id")
    
        logger.info(f"Reading document with ID: {doc_id}")
    
        try:
            result = collection.get(ids=[doc_id])
            
            if not result or not result.get('ids') or len(result['ids']) == 0:
                raise DocumentOperationError(f"Document not found [id={doc_id}]")
    
            logger.info(f"Successfully retrieved document: {doc_id}")
            
            # Format the response
            doc_content = result['documents'][0]
            doc_metadata = result['metadatas'][0] if result.get('metadatas') else {}
            
            response = [
                f"Document ID: {doc_id}",
                f"Content: {doc_content}",
                f"Metadata: {doc_metadata}"
            ]
    
            return [
                types.TextContent(
                    type="text",
                    text="\n".join(response)
                )
            ]
    
        except Exception as e:
            raise DocumentOperationError(str(e))
  • Input schema definition for read_document tool, exposed via the list_tools() handler. Requires 'document_id' string.
    types.Tool(
        name="read_document",
        description="Retrieve a document from the Chroma vector database by its ID",
        inputSchema={
            "type": "object",
            "properties": {
                "document_id": {"type": "string"}
            },
            "required": ["document_id"]
        }
    ),
  • Dispatch logic in the @server.call_tool() handler that routes 'read_document' calls to the handle_read_document function.
    elif name == "read_document":
        return await handle_read_document(arguments)
  • Internal command_options schema for read_document tool validation, identical to the exposed schema.
    "read_document": {
        "type": "object",
        "properties": {
            "document_id": {"type": "string"}
        },
        "required": ["document_id"]
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool retrieves a document, implying a read operation, but doesn't disclose behavioral traits such as error handling (e.g., what happens if the ID doesn't exist), performance characteristics, or any rate limits. The description is minimal and lacks context beyond the basic action.

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 front-loads the key action and resource. There is no wasted language, and it directly communicates the tool's purpose without unnecessary elaboration.

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 no annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't explain what is returned (e.g., document content, metadata), error cases, or how it fits into the broader context of sibling tools. For a retrieval tool in a database system, more detail is needed for effective use.

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

Parameters3/5

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

The schema description coverage is 0%, but the description adds meaning by specifying that the parameter 'document_id' is used to retrieve a document. However, it doesn't provide details on the ID format, constraints, or examples. With only one parameter, the baseline is 4, but the lack of additional semantic context reduces it to 3.

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 ('Retrieve') and resource ('a document from the Chroma vector database'), specifying it's done by ID. It distinguishes from siblings like create_document (creation) and delete_document (deletion), but doesn't explicitly differentiate from list_documents or search_similar in terms of retrieval method.

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?

No guidance is provided on when to use this tool versus alternatives like list_documents (for browsing) or search_similar (for similarity-based retrieval). The description implies usage when you have a specific document ID, but lacks explicit context or exclusions.

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