Skip to main content
Glama

read_doc_contents

Extract text content from documents stored in the Document MCP Server by providing the document ID, returning the content as a readable string.

Instructions

Read the contents of a document and return it as a string.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYesId of the document to read

Implementation Reference

  • The handler function 'read_document' implements the 'read_doc_contents' tool logic. It takes a doc_id parameter, validates that the document exists in the docs dictionary, and returns the document contents or raises a ValueError if not found.
    def read_document(
        doc_id: str = Field(description="Id of the document to read")
    ):
        if doc_id not in docs:
            raise ValueError(f"Doc with id {doc_id} not found")
        
        return docs[doc_id]
  • mcp_server.py:16-19 (registration)
    The @mcp.tool decorator registers the 'read_doc_contents' tool with the MCP server. It defines the tool name and description that appears in the tool registry.
    @mcp.tool(
        name="read_doc_contents",
        description="Read the contents of a document and return it as a string."
    )
  • The 'docs' dictionary defines the data schema and available documents that the read_doc_contents tool operates on. It maps document IDs to their content strings.
    docs = {
        "deposition.md": "This deposition covers the testimony of Angela Smith, P.E.",
        "report.pdf": "The report details the state of a 20m condenser tower.",
        "financials.docx": "These financials outline the project's budget and expenditures",
        "outlook.pdf": "This document presents the projected future performance of the system",
        "plan.md": "The plan outlines the steps for the project's implementation.",
        "spec.txt": "These specifications define the technical requirements for the equipment"
    }
  • The Field definition for the doc_id parameter specifies the input schema for the tool, describing what the parameter represents.
    doc_id: str = Field(description="Id of the document to read")

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/mparth14/MCP-anthropic'

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