Skip to main content
Glama
pdf4me
by pdf4me

add_page_number_to_pdf

Add page numbers to PDFs by specifying a format, position, font, and margins. Customize with placeholders for current page and total count, and skip the first page if needed.

Instructions

Add page numbers to a PDF via PDF4me POST /api/v2/AddPageNumber. When helping a user, explain how to set page_number_format before calling: use the literal character # for the current page (1, 2, 3, …) and the literal substring {1} for the total page count. Those are placeholders, not Python format specifiers—pass them exactly as strings (e.g. '# of {1}' renders as '1 of 10', 'Page #' as 'Page 1', '# / {1}' as '1 / 10', '(#)' as '(1)', '#' alone as '1'). align_x must be left, center, or right; align_y must be top, middle, or bottom. Optional: margin_x_in_mm and margin_y_in_mm (integers 0–100 mm from the chosen edge), font_size (8–72), is_bold, is_italic, skip_first_page. Requires a local pdf_file_path; output defaults next to the source file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
align_xNoHorizontal position of the page number text.right
align_yNoVertical position of the page number text.bottom
is_boldNoIf true, render page numbers in bold.
font_sizeNoFont size for the page number (allowed range 8–72 when set).
is_italicNoIf true, render page numbers in italic.
output_dirNoDirectory for the saved PDF; defaults to the input file's directory.
pdf_file_pathYesAbsolute or relative path to the input PDF file.
margin_x_in_mmNoHorizontal margin from the aligned edge, in millimeters (0–100).
margin_y_in_mmNoVertical margin from the aligned edge, in millimeters (0–100).
skip_first_pageNoIf true, do not print a page number on the first page.
output_file_nameNoFile name for the saved PDF (e.g. numbered_report.pdf).
request_doc_nameNoOutput document name sent to the API (should end with .pdf). Defaults to the input file basename.
page_number_formatYesText pattern for each footer/header line. Use # for current page number and {1} for total pages (both are literal characters in the string). Examples: '# of {1}', 'Page #', '# / {1}', '(#)', '#'.
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool calls a POST endpoint, requires a local pdf_file_path, and writes output next to the source file. However, it does not state whether the original file is preserved, what the return value is, or any error/rate-limit behavior, leaving some gaps.

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 the purpose and then provides a necessary deep-dive into page_number_format, which justifies its length. Each sentence adds value, though the API endpoint detail is somewhat redundant given the tool's name and could be trimmed.

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

Completeness4/5

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

For a 13-parameter tool with no annotations or output schema, the description covers the key aspects: purpose, format syntax, parameter constraints, and output location. The main gaps are explicit return-value documentation and error handling, but the guidance provided is substantial and sufficient for most use cases.

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?

The schema describes all 13 parameters, but the description adds crucial non-obvious semantics: the literal meaning of '#' and '{1}' in page_number_format, with concrete rendering examples ('# of {1}' -> '1 of 10'). It also gives explicit ranges for margin and font size, going well beyond the schema's brief descriptions.

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 opens with a specific verb and resource: 'Add page numbers to a PDF via PDF4me POST /api/v2/AddPageNumber.' It clearly distinguishes this tool from siblings like add_text_stamp_to_pdf or add_html_header_footer_to_pdf by focusing on page numbering and naming the exact API endpoint.

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 frames the context ('Add page numbers to a PDF') and provides direct guidance on how to prepare the page_number_format parameter, which is essential for correct use. It does not explicitly name alternative tools or exclusion conditions, but the operational guidance is clear and actionable.

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