Skip to main content
Glama

Read PDF Text

read_text
Read-onlyIdempotent

Extract text from PDFs with Y-coordinate reading order. Handle multi-column layouts and compact whitespace for Japanese forms to reduce token consumption.

Instructions

Extract text content from a PDF document with Y-coordinate-based reading order preservation.

Text is extracted page by page, sorted by vertical position (top to bottom) then horizontal position (left to right), providing natural reading order.

For untagged multi-column PDFs (e.g. older 新旧対照表 PDFs that lack a structure tree), pass split_columns: 2 or 3 to bucket items by X-coordinate left-to-right. Tagged PDFs with proper <Table> markup should use the extract_tables tool instead.

For Japanese form-style PDFs (帳票・様式) where U+3000 fullwidth spaces are used as visual indentation, pass compact_whitespace: true to collapse runs of whitespace to a single ASCII space. Cuts 20–40% of token consumption without losing content.

Args:

  • file_path (string): Absolute path to a local PDF file

  • pages (string, optional): Page range to extract. Format: "1-5", "3", or "1,3,5-7". Omit for all pages.

  • response_format ('markdown' | 'json'): Output format (default: 'markdown')

  • split_columns (1 | 2 | 3, optional): Column-aware reordering for untagged multi-column PDFs. Default 1 = existing Y-sort.

  • compact_whitespace (boolean, optional): Collapse whitespace runs (incl. U+3000) to one ASCII space and trim each line. Default false.

Returns: Extracted text organized by page number. With split_columns >= 2, columns are separated by a blank line so a downstream LLM can tell them apart.

Examples:

  • Extract all text: { file_path: "/path/to/doc.pdf" }

  • Untagged 新旧対照表: { file_path: "/path/to/older-shinkyu.pdf", split_columns: 2 }

  • Japanese form template: { file_path: "/path/to/form.pdf", compact_whitespace: true }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesAbsolute path to a local PDF file (e.g., "/path/to/document.pdf")
pagesNoPage range to process. Format: "1-5", "3", or "1,3,5-7". Omit for all pages.
response_formatNoOutput format: "markdown" for human-readable, "json" for structured datamarkdown
split_columnsNoNumber of columns to use when reordering text. 1 (default) = existing Y-sort. 2 or 3 = bucket by X-coordinate left-to-right. Use for untagged 新旧対照表 / two-column PDFs where Y-sort would interleave columns. Tagged PDFs with proper <Table> markup should use extract_tables instead.
compact_whitespaceNoWhen true, collapse runs of whitespace (incl. fullwidth space U+3000) to a single ASCII space and trim each line. Reduces token consumption on Japanese form-style PDFs. Default: false (no whitespace normalization).
Behavior5/5

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

Annotations already indicate readOnly, non-destructive, idempotent behavior. The description adds reading order details, page-by-page extraction, and column separation behavior, providing full transparency beyond annotations.

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 well-structured with clear sections, bullet points, and examples. Every sentence adds value, making it informative without unnecessary repetition.

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

Completeness5/5

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

Despite lacking an output schema, the description explains return format (organized by page, column separation). All parameters are fully documented, and the tool's functionality is comprehensively covered.

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

Parameters5/5

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

Schema coverage is 100%, and the description expands on each parameter with use cases, formats, and effects (e.g., compact_whitespace reduces tokens). Examples clarify complex parameters like split_columns.

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 'Extract text content from a PDF document' with specific reading order preservation. It differentiates from sibling tools like extract_tables (for tagged PDFs) and others, making the tool's unique role evident.

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 provides explicit guidance: when to use split_columns (untagged multi-column PDFs) and compact_whitespace (Japanese form PDFs). It also directs users to extract_tables for tagged PDFs, offering clear alternatives.

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/shuji-bonji/pdf-reader-mcp'

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