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")

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description carries the burden of behavioral disclosure. It does state the output behavior ('return it as a string'), but does not mention error handling, permissions, or what happens when the document does not exist. For a simple read operation, this is adequate but not rich.

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, front-loaded sentence with no wasted words. It efficiently conveys both the operation and the return format.

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?

This is a simple tool with one parameter, full schema coverage, and no output schema. The description is largely complete for a read operation, especially since it explicitly states the return type. It could be slightly stronger with error or permission context, but nothing essential is missing for basic invocation.

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 already fully documents the only parameter, doc_id, as 'Id of the document to read', so schema coverage is 100%. The description adds no additional parameter meaning beyond the schema, matching the baseline score.

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 states a specific verb and resource: 'Read the contents of a document' and explicitly notes the return type as a string. This clearly distinguishes it from the sibling 'edit_document', which implies modification rather than reading.

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

Usage Guidelines4/5

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

The verb 'Read' establishes a clear context for when this tool is appropriate, and its contrast with 'edit_document' implies read-only usage. However, it does not explicitly state when not to use it or name the alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.