Skip to main content
Glama

Extract PDF tables to CSV

extract_pdf_tables
DestructiveIdempotent

Extract rows and columns from local text-based PDFs into CSV text or saved CSV files for spreadsheets, pandas, or databases. Use for bordered or spacing-aligned tables; scanned PDFs are skipped.

Instructions

Pull the tables out of a local text PDF.

Use this when you need the rows and columns of a table from a PDF on this computer, for example to load them into a spreadsheet, pandas or a database. Do not use it for scanned PDFs or photos (there is no OCR), for PDFs on the web (download the file first), or when you want the whole document as text (use a PDF-to-Markdown or text tool instead).

path: full path to a PDF on this computer. pages: optional, like "1,3-5". Empty means all pages. strategy: "auto" (default, tries borders first, then spacing), "lines" (tables with ruled borders) or "text" (tables lined up by spacing). Try "text" if "auto" misses a table that has no border lines. output_dir: optional. If set, each table is saved there as a CSV and the file paths are returned. Files named pageN_tableM.csv that already exist there are replaced. If empty, nothing is written and the CSV text of each table is returned.

Scanned (image-only) pages have no text and are skipped. Returns [] if no tables.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>"
    },
    "name": "extract_pdf_tables"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYes
pagesNo
strategyNoauto
output_dirNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A5/5.0
Behavior5/5

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

The annotations declare destructiveHint=true and readOnlyHint=false, and the description justifies both by stating that files named pageN_tableM.csv in output_dir are replaced, and that nothing is written when output_dir is empty. It adds further behavioral context the annotations do not carry: scanned image-only pages are silently skipped and an empty list is returned when no tables are found.

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 front-loaded with purpose, then exclusions, then a compact per-parameter block. Every sentence carries operational value - even the short closing lines about skipped scanned pages and the empty-list return prevent wrong-path invocation - so the length is earned rather than padded.

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?

For a four-parameter tool with no schema documentation, an output schema, and destructive write potential, the description covers invocation, parameter syntax, side effects, edge cases and failure returns. Nothing an agent needs in order to call it safely and correctly is missing.

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 0%, so the description must carry the full parameter burden and does: path is a full local path, pages uses a "1,3-5" syntax with empty meaning all pages, and strategy's three values are each explained, including a recovery hint to try "text" when "auto" misses a borderless table. The output_dir side effects and default behavior are described in detail the schema cannot convey.

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?

"Pull the tables out of a local text PDF" gives a specific verb (extract), a specific resource (tables), and a scoping qualifier (local, text-based). The agent immediately knows this is tabular extraction, not general text extraction, and the scope constraints further sharpen the distinction.

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?

Explicit when-to-use (load table rows into a spreadsheet, pandas or a database) and explicit when-not-to-use with named alternatives: no OCR for scans or photos, download web PDFs first, and use a PDF-to-Markdown or text tool for whole-document text. Each exclusion routes the agent to a different action rather than leaving it to infer.

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