Skip to main content
Glama

Annotate PDF (markup / drawing)

annotate_pdf
Idempotent

Add markup annotations such as highlights, sticky notes, and shapes to an existing PDF non-destructively, preserving original content for review and collaboration.

Instructions

Append markup annotations (ISO 32000-1 §12.5) to an existing PDF as a non-destructive incremental update (original bytes preserved). Types: text (sticky note), highlight | underline | strikeout | squiggly, square | circle, line (needs start/end), freetext. Each needs a 0-based page and rect [x1,y1,x2,y2]; optional contents, color, opacity, title and type-specific fields. VISUAL OVERLAY ONLY — nothing is removed or redacted (covered text stays extractable). Encrypted sources → ENCRYPTED_SOURCE (decrypt_pdf first).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdfBase64YesBase64-encoded source PDF to annotate.
outputModeNo'base64' (default) returns the PDF inline; 'file' writes it inside the PDFNATIVE_MCP_OUTPUT_DIR sandbox (SECURITY_VIOLATION when the sandbox is not configured).base64
outputPathNoRequired when outputMode='file'. Relative path inside the sandbox; must end with .pdf (no absolute paths, no '..').
annotationsYesMarkup / drawing annotations to add. Each is attached to a 0-based page index.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeYes
summaryNoTool-specific summary, when produced.
filePathNoSandboxed absolute path (file mode).
sizeBytesYes
diagnosticsNoEngine diagnostics (when includeDiagnostics=true).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.6.2
    • changedInput schema / properties / annotations / items / properties / color / oneOf
      Previous value: -[
      -  {
      -    "description": "Hex (e.g. \"#ffcc00\") or PDF operator string (\"R G B\").",
      -    "type": "string"
      -  },
      -  {
      -    "description": "RGB tuple, 0.0–1.0.",
      -    "items": {
      -      "type": "number"
      -    },
      -    "maxItems": 3,
      -    "minItems": 3,
      -    "type": "array"
      -  }
      -]New value: +[
      +  {
      +    "description": "Hex (e.g. \"#ffcc00\") or PDF operator string (\"R G B\", or \"C M Y K\" for DeviceCMYK), each operand 0.0–1.0.",
      +    "type": "string"
      +  },
      +  {
      +    "description": "RGB tuple, 0.0–1.0.",
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 3,
      +    "minItems": 3,
      +    "type": "array"
      +  },
      +  {
      +    "description": "DeviceCMYK ink percentages [c, m, y, k], each 0–100.",
      +    "items": {
      +      "maximum": 100,
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "maxItems": 4,
      +    "minItems": 4,
      +    "type": "array"
      +  }
      +]
    • changedInput schema / properties / annotations / items / properties / interiorColor / oneOf
      Previous value: -[
      -  {
      -    "description": "Hex (e.g. \"#ffcc00\") or PDF operator string (\"R G B\").",
      -    "type": "string"
      -  },
      -  {
      -    "description": "RGB tuple, 0.0–1.0.",
      -    "items": {
      -      "type": "number"
      -    },
      -    "maxItems": 3,
      -    "minItems": 3,
      -    "type": "array"
      -  }
      -]New value: +[
      +  {
      +    "description": "Hex (e.g. \"#ffcc00\") or PDF operator string (\"R G B\", or \"C M Y K\" for DeviceCMYK), each operand 0.0–1.0.",
      +    "type": "string"
      +  },
      +  {
      +    "description": "RGB tuple, 0.0–1.0.",
      +    "items": {
      +      "type": "number"
      +    },
      +    "maxItems": 3,
      +    "minItems": 3,
      +    "type": "array"
      +  },
      +  {
      +    "description": "DeviceCMYK ink percentages [c, m, y, k], each 0–100.",
      +    "items": {
      +      "maximum": 100,
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "maxItems": 4,
      +    "minItems": 4,
      +    "type": "array"
      +  }
      +]
    • changedOutput schema / properties / diagnostics / description
      Previous value: -"PDF/A diagnostics (when includeDiagnostics=true)."New value: +"Engine diagnostics (when includeDiagnostics=true)."
  2. Changed6 schema fields changed
    • addedInput schema / properties / outputMode / description
      Added value: +"'base64' (default) returns the PDF inline; 'file' writes it inside the PDFNATIVE_MCP_OUTPUT_DIR sandbox (SECURITY_VIOLATION when the sandbox is not configured)."
    • addedInput schema / properties / outputPath / description
      Added value: +"Required when outputMode='file'. Relative path inside the sandbox; must end with .pdf (no absolute paths, no '..')."
    • changedOutput schema / description
      Previous value: -"Structured result of a PDF-producing tool. In base64 mode the PDF bytes are delivered out-of-band as an embedded `resource` content block (data: URI), NOT duplicated here, to keep responses token-frugal. In file mode `filePath` is the sandboxed absolute path."New value: +"Result of a PDF-producing tool. base64 mode: the PDF arrives as an embedded `resource` content block (not duplicated here); file mode: `filePath`."
    • addedOutput schema / properties / diagnostics
      Added value: +{
      +  "description": "PDF/A diagnostics (when includeDiagnostics=true).",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "code": {
      +        "type": "string"
      +      },
      +      "message": {
      +        "type": "string"
      +      },
      +      "severity": {
      +        "enum": [
      +          "warning"
      +        ],
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "code",
      +      "message",
      +      "severity"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • changedOutput schema / properties / filePath / description
      Previous value: -"Absolute sandboxed file path (when mode='file')."New value: +"Sandboxed absolute path (file mode)."
    • addedOutput schema / properties / summary
      Added value: +{
      +  "additionalProperties": true,
      +  "description": "Tool-specific summary, when produced.",
      +  "type": "object"
      +}
  3. Addedv1.4.0

TDQS

A4.6/5.0
Behavior5/5

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

Discloses behavior well beyond annotations: non-destructive incremental update preserving original bytes, VISUAL OVERLAY ONLY semantics (covered text remains extractable — critical for anyone who might assume redaction), and the encrypted-source error code with remediation. Annotations declare idempotent=true and destructive=false, consistent with the description.

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?

Dense but front-loaded: purpose, non-destructive guarantee, type list, coordinates, then the critical visual-only caveat and error handling. A bit packed but every clause carries information; no filler.

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 output schema exists, return values need not be explained. The description covers mutation semantics, coordinates, type-specific fields, error handling for encrypted sources, and the crucial non-redaction caveat — everything an agent needs to invoke correctly.

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?

Schema coverage is 100%, so baseline is 3. Description adds derivative value by summarizing type-specific requirements (line needs start/end, each needs page+rect) and the page-0-based convention, though the schema itself documents these in detail.

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?

States a specific verb (append) and resource (markup annotations), enumerates the annotation types supported, and distinguishes the tool from siblings like generate_basic_pdf or inspect_pdf by naming the ISO spec section.

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?

Explicitly handles the encrypted-source case by pointing to decrypt_pdf first via the ENCRYPTED_SOURCE error. The 'non-destructive' framing clarifies that this is for overlay markup, but it doesn't contrast against sibling tools like fill_form or add_table for agent routing.

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