Skip to main content
Glama

chroma_get_documents

Retrieve documents from a Chroma collection with optional filtering by IDs, metadata, or content. Supports logical operators, regex, and custom includes for precise querying and response customization.

Instructions

Get documents from a Chroma collection with optional filtering.

Args:
    collection_name: Name of the collection to get documents from
    ids: Optional list of document IDs to retrieve
    where: Optional metadata filters using Chroma's query operators
           Examples:
           - Simple equality: {"metadata_field": "value"}
           - Comparison: {"metadata_field": {"$gt": 5}}
           - Logical AND: {"$and": [{"field1": {"$eq": "value1"}}, {"field2": {"$gt": 5}}]}
           - Logical OR: {"$or": [{"field1": {"$eq": "value1"}}, {"field1": {"$eq": "value2"}}]}
    where_document: Optional document content filters
           Examples:
           - Contains: {"$contains": "value"}
           - Not contains: {"$not_contains": "value"}
           - Regex: {"$regex": "[a-z]+"}
           - Not regex: {"$not_regex": "[a-z]+"}
           - Logical AND: {"$and": [{"$contains": "value1"}, {"$not_regex": "[a-z]+"}]}
           - Logical OR: {"$or": [{"$regex": "[a-z]+"}, {"$not_contains": "value2"}]}
    include: List of what to include in response. By default, this will include documents, and metadatas.
    limit: Optional maximum number of documents to return
    offset: Optional number of documents to skip before returning results

Returns:
    Dictionary containing the matching documents, their IDs, and requested includes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYes
idsNo
includeNo
limitNo
offsetNo
whereNo
where_documentNo

Implementation Reference

  • The handler function for the 'chroma_get_documents' tool. It is decorated with @mcp.tool() for registration and implements the core logic: retrieves a Chroma collection and calls its .get() method with provided parameters (ids, where, where_document, include, limit, offset), returning the results or raising an exception on failure.
    @mcp.tool()
    async def chroma_get_documents(
        collection_name: str,
        ids: List[str] | None = None,
        where: Dict | None = None,
        where_document: Dict | None = None,
        include: List[str] = ["documents", "metadatas"],
        limit: int | None = None,
        offset: int | None = None
    ) -> Dict:
        """Get documents from a Chroma collection with optional filtering.
        
        Args:
            collection_name: Name of the collection to get documents from
            ids: Optional list of document IDs to retrieve
            where: Optional metadata filters using Chroma's query operators
                   Examples:
                   - Simple equality: {"metadata_field": "value"}
                   - Comparison: {"metadata_field": {"$gt": 5}}
                   - Logical AND: {"$and": [{"field1": {"$eq": "value1"}}, {"field2": {"$gt": 5}}]}
                   - Logical OR: {"$or": [{"field1": {"$eq": "value1"}}, {"field1": {"$eq": "value2"}}]}
            where_document: Optional document content filters
                   Examples:
                   - Contains: {"$contains": "value"}
                   - Not contains: {"$not_contains": "value"}
                   - Regex: {"$regex": "[a-z]+"}
                   - Not regex: {"$not_regex": "[a-z]+"}
                   - Logical AND: {"$and": [{"$contains": "value1"}, {"$not_regex": "[a-z]+"}]}
                   - Logical OR: {"$or": [{"$regex": "[a-z]+"}, {"$not_contains": "value2"}]}
            include: List of what to include in response. By default, this will include documents, and metadatas.
            limit: Optional maximum number of documents to return
            offset: Optional number of documents to skip before returning results
        
        Returns:
            Dictionary containing the matching documents, their IDs, and requested includes
        """
        client = get_chroma_client()
        try:
            collection = client.get_collection(collection_name)
            return collection.get(
                ids=ids,
                where=where,
                where_document=where_document,
                include=include,
                limit=limit,
                offset=offset
            )
        except Exception as e:
            raise Exception(f"Failed to get documents from collection '{collection_name}': {str(e)}") from e
Behavior3/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 effectively describes the tool's read-only nature through the verb 'Get' and details filtering capabilities, but it doesn't cover aspects like error handling, performance implications of complex filters, or pagination behavior beyond limit/offset parameters. The return format is mentioned but not elaborated.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement, organized parameter explanations, and a returns section. While comprehensive, it's slightly verbose due to extensive examples for 'where' and 'where_document', but every sentence earns its place by clarifying complex filtering syntax that isn't obvious from parameter names alone.

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

Completeness4/5

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

For a tool with 7 parameters, 0% schema coverage, no annotations, and no output schema, the description does an excellent job of explaining parameter semantics and the return format. It covers the core functionality thoroughly, though it could be more complete by addressing behavioral aspects like error cases or performance limits, which are important given the complexity of filtering options.

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

Parameters5/5

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

Given 0% schema description coverage, the description compensates fully by providing detailed semantics for all 7 parameters. It explains each parameter's purpose (e.g., 'where: Optional metadata filters'), includes syntax examples for complex parameters like 'where' and 'where_document', and clarifies defaults (e.g., 'include' defaults to documents and metadatas). This adds significant value beyond the bare schema.

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

Purpose5/5

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

The description clearly states the tool's purpose with a specific verb ('Get documents') and resource ('from a Chroma collection'), distinguishing it from siblings like chroma_query_documents (which likely searches semantically) and chroma_peek_collection (which might preview without filtering). The phrase 'with optional filtering' further clarifies its retrieval nature.

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

Usage Guidelines3/5

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

The description implies usage through the mention of 'optional filtering' and the detailed parameter examples, suggesting it's for retrieving documents with specific criteria. However, it lacks explicit guidance on when to use this tool versus alternatives like chroma_query_documents or chroma_peek_collection, leaving the agent to infer based on parameter names.

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/chroma-core/chroma-mcp'

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