Skip to main content
Glama

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

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