Skip to main content
Glama

read_document

Retrieve and examine the content of a single markdown document from the documentation directory, including frontmatter metadata.

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

  • The core handler function for the read_document tool. It validates the document path, reads the file content using fs.readFile, extracts frontmatter metadata, and returns a ToolResponse object.
    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 the read_document tool. Requires a 'path' parameter specifying the document to read.
    export const ReadDocumentSchema = ToolInputSchema.extend({
      path: z.string(),
    });
  • src/index.ts:199-205 (registration)
    Tool registration in the listToolsRequestSchema handler, defining the tool's name, description, and input 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 logic in the callToolRequestSchema handler that validates arguments using the 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);
    }
Behavior3/5

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

No annotations are provided, so the description carries full burden. It discloses that the tool reads (not modifies) and returns content with frontmatter, which is useful behavioral context. However, it doesn't mention error conditions (e.g., what happens if the path doesn't exist), performance characteristics, or authentication requirements. For a read operation with no annotations, this is adequate but not comprehensive.

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?

Two sentences, zero waste. The first sentence states purpose and output, the second provides usage guidance. Every word earns its place, and information is front-loaded appropriately.

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?

Given 1 parameter, no annotations, and no output schema, the description is reasonably complete for a simple read operation. It covers purpose, usage, and output format. However, it lacks details on error handling or path format, which could be useful for a tool interacting with a filesystem. Overall, it's sufficient but not exhaustive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 1 parameter with 0% description coverage, so the description must compensate. It implies 'path' refers to a document in the 'docs directory' but doesn't specify format (e.g., relative vs. absolute path) or constraints. The description adds meaningful context about the parameter's purpose, though more detail would be helpful. With 0% schema coverage, this is above baseline.

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 clearly states the specific action ('Read a markdown document'), resource ('from the docs directory'), and output ('Returns the document content including frontmatter'). It distinguishes this tool from siblings like 'list_documents' (which lists rather than reads content) and 'edit_document' (which modifies rather than reads).

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'Use this tool when you need to examine the contents of a single document.' This provides clear guidance that distinguishes it from alternatives like 'list_documents' (for browsing) or 'search_documents' (for finding documents).

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

Install Server

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

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