Skip to main content
Glama
privetin

Chroma MCP Server

by privetin

list_documents

Retrieve a paginated list of all documents stored in the Chroma vector database, specifying limit and offset for efficient navigation and management.

Instructions

List all documents stored in the Chroma vector database with pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
offsetNo

Implementation Reference

  • The core handler function for executing the 'list_documents' tool. It extracts limit and offset from arguments, queries the Chroma collection using collection.get(), formats the results (IDs, content, metadata) into a structured text response, and handles errors with DocumentOperationError. Includes retry decorator for reliability.
    @retry_operation("list_documents")
    async def handle_list_documents(arguments: dict) -> list[types.TextContent]:
        """Handle document listing with retry logic"""
        limit = arguments.get("limit", 10)
        offset = arguments.get("offset", 0)
    
        try:
            # Get all documents
            results = collection.get(
                limit=limit,
                offset=offset,
                include=['documents', 'metadatas']
            )
    
            if not results or not results.get('ids'):
                return [
                    types.TextContent(
                        type="text",
                        text="No documents found in collection"
                    )
                ]
    
            # Format results
            response = [f"Documents (showing {len(results['ids'])} results):"]
            for i, (doc_id, content, metadata) in enumerate(
                zip(results['ids'], results['documents'], results['metadatas'])
            ):
                response.append(f"\nID: {doc_id}")
                response.append(f"Content: {content}")
                if metadata:
                    response.append(f"Metadata: {metadata}")
    
            return [
                types.TextContent(
                    type="text",
                    text="\n".join(response)
                )
            ]
        except Exception as e:
            raise DocumentOperationError(str(e))
  • Registration of the 'list_documents' tool in the @server.list_tools() handler. Defines the tool's name, description, and input schema supporting optional pagination parameters (limit, offset).
    types.Tool(
        name="list_documents",
        description="List all documents stored in the Chroma vector database with pagination",
        inputSchema={
            "type": "object",
            "properties": {
                "limit": {"type": "integer", "minimum": 1, "default": 10},
                "offset": {"type": "integer", "minimum": 0, "default": 0}
            }
        }
    ),
  • Dispatch logic in the main @server.call_tool() handler that routes 'list_documents' calls to the specific handle_list_documents function.
    elif name == "list_documents":
        return await handle_list_documents(arguments)
  • Input schema for the 'list_documents' tool defined in server.command_options, specifying pagination parameters with types, constraints, and defaults.
    "list_documents": {
        "type": "object",
        "properties": {
            "limit": {"type": "integer", "minimum": 1, "default": 10},
            "offset": {"type": "integer", "minimum": 0, "default": 0}
        }
    },
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 mentions 'pagination' which is useful context, but fails to describe critical behaviors: whether this is a read-only operation (implied but not stated), what the return format looks like (e.g., list of document objects), or any limitations (e.g., performance with large datasets). For a tool with zero annotation coverage, this leaves significant gaps.

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 core purpose ('List all documents') and adds essential context ('stored in the Chroma vector database with pagination'). Every word earns its place with zero redundancy or wasted verbiage.

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

Completeness3/5

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

Given the tool's moderate complexity (list operation with pagination), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose and pagination behavior but lacks details on return values, error conditions, or interaction with sibling tools. For a read operation in a database context, this leaves the agent with incomplete information.

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

Parameters4/5

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

The description adds meaningful context beyond the input schema. While the schema documents 'limit' and 'offset' parameters with technical details (type, defaults, constraints), the description explains their purpose ('pagination'), which the schema doesn't cover (0% description coverage). This compensates well for the schema's lack of semantic information.

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 verb ('List') and resource ('documents stored in the Chroma vector database'), making the purpose unambiguous. It distinguishes from siblings like 'read_document' (single document) and 'search_similar' (semantic search), but doesn't explicitly contrast with 'create_document' or 'update_document' which are write operations.

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 for retrieving all documents with pagination, but provides no explicit guidance on when to use this tool versus alternatives like 'search_similar' for filtered results or 'read_document' for a specific document. The mention of 'pagination' suggests it's for bulk retrieval, but this is only implied rather than stated as a guideline.

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