Skip to main content
Glama
shuji-bonji
by shuji-bonji

Extract Tables (Tagged PDF)

extract_tables
Read-onlyIdempotent

Extract tables from tagged PDFs: walks structure tree to pull cell text, outputting as Markdown or JSON for structured data.

Instructions

Extract every <Table> subtree from a Tagged PDF as a structured row/cell list, optionally rendered as Markdown tables.

How it works: walks the StructTree and pulls cell text for each <TR><TH>/<TD>, then collapses kerning whitespace (e.g. "消 費 税 法" → "消費税法"). This sidesteps reading-order extraction's failure mode on multi-column tables (typical of 新旧対照表 PDFs).

Args:

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

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

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

Returns: Markdown — # Extracted Tables summary block followed by one ## Page N — Table M section per table with a GFM table.

JSON — { isTagged, tables: [{ page, index, headerRows, bodyRows, footerRows }], totalTables, pagesScanned, note? }.

Limitations:

  • Untagged PDFs return an empty result and a note.

  • colspan/rowspan are not honoured (cells are listed in source order).

  • Nested tables are skipped to keep page indices stable.

Examples:

  • Pull 新旧対照表 from a kaisei tsutatsu PDF for diffing

  • Convert 帳票 (form template) tables into structured data

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
Behavior5/5

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

The description discloses key behavioral traits: how it walks the StructTree, collapses kerning whitespace, and handles unsupported features (colspan, nested tables). These details go beyond the annotations (readOnlyHint, idempotentHint), which already indicate safe, non-destructive usage, providing agents with full context.

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: main purpose, how it works, args, returns, limitations, examples. Every sentence adds value, and the most critical information (what the tool does) is front-loaded, making it easy for an agent to quickly understand and act.

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?

Given the complexity of table extraction from tagged PDFs, the description covers all necessary aspects: purpose, mechanics, parameter details, return formats (including examples), and limitations. No output schema is provided, but the description compensates by detailing the JSON structure. The examples further clarify use cases.

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 input schema covers all three parameters with descriptions (100% coverage). The description adds value by explaining the page range format, enum options for response_format, and return structure details, going beyond the schema to clarify usage.

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 tool extracts `<Table>` subtrees from tagged PDFs and provides structured output. It distinguishes itself from sibling tools like `read_text` by explicitly mentioning it handles multi-column tables where reading-order extraction fails, making its purpose highly specific.

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

Usage Guidelines4/5

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

The description explains when to use (tagged PDFs with tables, especially multi-column) and notes limitations (untagged PDFs return empty, no colspan/rowspan support, nested tables skipped). It implies an alternative for non-table text extraction but does not explicitly name sibling tools for comparison, leaving room for slight ambiguity.

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