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
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | Id of the document to read |
Implementation Reference
- mcp_server.py:20-26 (handler)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." ) - mcp_server.py:6-13 (schema)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" } - mcp_server.py:21-21 (schema)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")