Skip to main content
Glama

read_document

Retrieve and examine the contents of a markdown document from the docs directory, including frontmatter, for detailed analysis or reference using the MCP Documentation Service.

Instructions

Read a markdown document from the docs directory. Returns the document content including frontmatter. Use this tool when you need to examine the contents of a single document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Core implementation of the read_document tool. Validates path, reads file content, parses frontmatter metadata, and returns structured ToolResponse.
    async readDocument(docPath: string): Promise<ToolResponse> { try { const validPath = await this.validatePath(docPath); const content = await fs.readFile(validPath, "utf-8"); return { content: [{ type: "text", text: content }], metadata: { path: docPath, ...parseFrontmatter(content).frontmatter, }, }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error reading document: ${errorMessage}` }, ], isError: true, }; } }
  • Zod schema for validating input to read_document tool, extending base schema to require 'path' parameter.
    export const ReadDocumentSchema = ToolInputSchema.extend({ path: z.string(), });
  • src/index.ts:198-205 (registration)
    Tool registration in MCP server's listToolsRequestHandler. Defines name, description, and converts Zod schema to JSON schema for MCP protocol.
    { name: "read_document", description: "Read a markdown document from the docs directory. Returns the document content " + "including frontmatter. Use this tool when you need to examine the contents of a " + "single document.", inputSchema: zodToJsonSchema(ReadDocumentSchema) as any, },
  • src/index.ts:311-319 (registration)
    Dispatch handler in MCP server's CallToolRequestHandler that parses input with schema and calls the DocumentHandler.readDocument method.
    case "read_document": { const parsed = ReadDocumentSchema.safeParse(args); if (!parsed.success) { throw new Error( `Invalid arguments for read_document: ${parsed.error}` ); } return await documentHandler.readDocument(parsed.data.path); }

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/alekspetrov/mcp-docs-service'

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