Skip to main content
Glama
pdf4me
by pdf4me

extract_text_by_expression

Extract matching text from a PDF using a regular expression, with optional page range. Saves results as JSON, text, and CSV.

Instructions

Extract text from a PDF matching a regex via PDF4me ExtractTextByExpression (/api/v2/ExtractTextByExpression). pdf_file_path, expression, page_sequence (e.g. '1-' all pages, '1-3', '1,2,3'); optional output_dir. Saves JSON, a matches text file, and CSV.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYes
output_dirNo
page_sequenceNo1-
pdf_file_pathYes
request_doc_nameNo
Behavior3/5

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

With no annotations, the description must carry the burden. It discloses output behavior (saves JSON, text, CSV) and explains page_sequence options. However, it doesn’t state whether the original PDF is modified or mention any prerequisites, limits, or error handling.

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 with purpose and includes the API endpoint and key parameters without fluff. It’s concise, though the first sentence is a bit dense with parameter names.

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

Completeness3/5

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

Given 5 parameters and no output schema, the description covers the core invocation and outputs but leaves gaps: request_doc_name is unexplained, and the format/content of the generated JSON/CSV files is not detailed. It’s adequate but not fully complete.

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?

Schema descriptions are 0%, so the description is the only source. It explains page_sequence with examples, identifies expression as a regex, and marks output_dir optional, but it omits any explanation of request_doc_name, leaving a parameter undocumented.

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 text from a PDF based on a regex, naming the specific API endpoint. It distinguishes itself from siblings like extract_pages_from_pdf and extract_text_from_image by focusing on regex-based text extraction.

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 provides clear context for when the tool is appropriate (extracting text matching a regex from a PDF) and includes practical parameter examples for page_sequence. It doesn’t explicitly name alternatives, but the purpose is clear enough.

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/pdf4me/pdf4me-mcp'

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