Skip to main content
Glama
cablate

Simple Document Processing MCP Server

document_reader

Extract text content from PDF, DOCX, TXT, HTML, and CSV files by specifying the file path, enabling document analysis and processing.

Instructions

Read content from non-image document-files at specified paths, supporting various file formats: .pdf, .docx, .txt, .html, .csv

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file to be read

Implementation Reference

  • Core handler function that executes the document reading logic by determining file type and calling appropriate reader, returning success/data or error.
    export async function readFile(filePath: string) {
      try {
        const ext = path.extname(filePath).toLowerCase();
        let content: string;
    
        switch (ext) {
          case ".pdf":
            content = await readPDFFile(filePath);
            break;
          case ".docx":
            content = await readDocxFile(filePath);
            break;
          case ".txt":
            content = await readTextFile(filePath);
            break;
          case ".html":
            content = await readHTMLFile(filePath);
            break;
          case ".csv":
            content = await readCSVFile(filePath);
            break;
          default:
            throw new Error(`Unsupported file format: ${ext}`);
        }
    
        return {
          success: true,
          data: content,
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : "Unknown error",
        };
      }
    } 
  • MCP server request handler dispatch for 'document_reader' tool: validates input, calls readFile, formats response.
    if (name === "document_reader") {
      if (!isFileReaderArgs(args)) {
        throw new Error("Invalid arguments for document_reader");
      }
    
      const result = await readFile(args.filePath);
      if (!result.success) {
        return {
          content: [{ type: "text", text: `Error: ${result.error}` }],
          isError: true,
        };
      }
      return {
        content: [{ type: "text", text: result.data }],
        isError: false,
      };
    }
  • Tool definition with name, description, and input schema requiring 'filePath'.
    export const DOCUMENT_READER_TOOL: Tool = {
      name: "document_reader",
      description:
        "Read content from non-image document-files at specified paths, supporting various file formats: .pdf, .docx, .txt, .html, .csv",
      inputSchema: {
        type: "object",
        properties: {
          filePath: {
            type: "string",
            description: "Path to the file to be read",
          },
        },
        required: ["filePath"],
      },
    };
  • Exports array of all tools including DOCUMENT_READER_TOOL for server registration.
    export const tools = [DOCUMENT_READER_TOOL, PDF_MERGE_TOOL, PDF_SPLIT_TOOL, DOCX_TO_PDF_TOOL, DOCX_TO_HTML_TOOL, HTML_CLEAN_TOOL, HTML_TO_TEXT_TOOL, HTML_TO_MARKDOWN_TOOL, HTML_EXTRACT_RESOURCES_TOOL, HTML_FORMAT_TOOL, TEXT_DIFF_TOOL, TEXT_SPLIT_TOOL, TEXT_FORMAT_TOOL, TEXT_ENCODING_CONVERT_TOOL, EXCEL_READ_TOOL, FORMAT_CONVERTER_TOOL];
  • Type guard/validator for document_reader input arguments.
    export function isFileReaderArgs(args: unknown): args is FileReaderArgs {
      return (
        typeof args === "object" &&
        args !== null &&
        "filePath" in args &&
        typeof (args as FileReaderArgs).filePath === "string"
      );
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers limited behavioral insight. It specifies supported file formats and excludes image files, but doesn't disclose error handling, file size limits, encoding details, or output structure, which are critical for a read operation with varied formats.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded and concise, using a single sentence to state the purpose and supported formats. There's no wasted text, though it could be slightly more structured by separating core functionality from format details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of reading multiple file formats and no output schema, the description is incomplete. It lacks details on return values (e.g., text content, metadata), error cases, or performance considerations, making it inadequate for full agent understanding without additional context.

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 input schema has 100% description coverage, so the baseline is 3. The description adds no additional parameter semantics beyond what the schema provides (e.g., it doesn't clarify path formats or constraints), relying entirely on the schema's documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Read content') and resource ('from non-image document-files at specified paths'), making the purpose evident. It distinguishes itself from siblings by specifying file formats (.pdf, .docx, .txt, .html, .csv), though it doesn't explicitly contrast with tools like 'excel_read' or 'text_splitter'.

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

Usage Guidelines2/5

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

No explicit guidance on when to use this tool versus alternatives is provided. While it lists supported file formats, it doesn't mention when to choose this over siblings like 'excel_read' for Excel files or 'html_to_text' for HTML, leaving usage context implied rather than stated.

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/cablate/mcp-doc-forge'

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