Skip to main content
Glama

Inspect PDF Digital Signatures

inspect_signatures
Read-onlyIdempotent

Examine digital signature fields in a PDF document. Get total signature count, signed/unsigned breakdown, and details per field including signer name, reason, and signing time.

Instructions

Examine digital signature fields in a PDF document.

Args:

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

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

Returns: Total signature field count, signed/unsigned breakdown, and details for each field (signer name, reason, location, signing time, filter/subFilter).

Note: This tool inspects signature field structure only. Cryptographic signature verification is not performed.

Examples:

  • Check if a PDF has been digitally signed

  • Inspect signer information and signing dates

  • Verify signature field structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesAbsolute path to a local PDF file (e.g., "/path/to/document.pdf")
response_formatNoOutput format: "markdown" for human-readable, "json" for structured datamarkdown

Implementation Reference

  • Registration function for the 'inspect_signatures' tool. Defines the tool metadata, input schema, and the async handler that calls analyzeSignatures and formats the result.
    export function registerInspectSignatures(server: McpServer): void {
      server.registerTool(
        'inspect_signatures',
        {
          title: 'Inspect PDF Digital Signatures',
          description: `Examine digital signature fields in a PDF document.
    
    Args:
      - file_path (string): Absolute path to a local PDF file
      - response_format ('markdown' | 'json'): Output format (default: 'markdown')
    
    Returns:
      Total signature field count, signed/unsigned breakdown, and details for each field (signer name, reason, location, signing time, filter/subFilter).
    
    Note: This tool inspects signature field structure only. Cryptographic signature verification is not performed.
    
    Examples:
      - Check if a PDF has been digitally signed
      - Inspect signer information and signing dates
      - Verify signature field structure`,
          inputSchema: InspectSignaturesSchema,
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
        async (params: InspectSignaturesInput) => {
          try {
            const analysis = await analyzeSignatures(params.file_path);
    
            const raw =
              params.response_format === ResponseFormat.JSON
                ? JSON.stringify(analysis, null, 2)
                : formatSignaturesMarkdown(analysis);
    
            const { text } = truncateIfNeeded(raw);
            return { content: [{ type: 'text' as const, text }] };
          } catch (error) {
            const err = handleStructuredError(error);
            return {
              content: [{ type: 'text' as const, text: JSON.stringify(err, null, 2) }],
              isError: true,
            };
          }
        },
      );
    }
  • Core implementation of signature analysis. Loads the PDF with pdf-lib, iterates AcroForm fields looking for 'Sig' type fields, extracts signature metadata (signer name, reason, location, time, filter, subFilter), and returns a SignaturesAnalysis.
    export async function analyzeSignatures(filePath: string): Promise<SignaturesAnalysis> {
      return withSuppressedPdfLibLogs(() => analyzeSignaturesImpl(filePath));
    }
    
    async function analyzeSignaturesImpl(filePath: string): Promise<SignaturesAnalysis> {
      const doc = await loadWithPdfLib(filePath);
      const fields: SignatureFieldInfo[] = [];
    
      try {
        const acroForm = doc.catalog.getAcroForm();
        if (!acroForm) {
          return {
            totalFields: 0,
            signedCount: 0,
            unsignedCount: 0,
            fields: [],
            note: 'No AcroForm found in the document.',
          };
        }
    
        const allFields = acroForm.getAllFields();
    
        for (const [field, _ref] of allFields) {
          const ftName = field.dict.lookupMaybe(PDFName.of('FT'), PDFName);
          if (!ftName || ftName.decodeText() !== 'Sig') continue;
    
          const fieldName = field.getFullyQualifiedName() ?? field.getPartialName() ?? '(unnamed)';
          const vObj = field.dict.get(PDFName.of('V'));
    
          let isSigned = false;
          let signerName: string | null = null;
          let reason: string | null = null;
          let location: string | null = null;
          let contactInfo: string | null = null;
          let signingTime: string | null = null;
          let filter: string | null = null;
          let subFilter: string | null = null;
    
          // If V exists, the field has been signed
          if (vObj) {
            isSigned = true;
    
            let sigDict: PDFDict | undefined;
            if (vObj instanceof PDFRef) {
              const resolved = doc.context.lookup(vObj);
              if (resolved instanceof PDFDict) sigDict = resolved;
            } else if (vObj instanceof PDFDict) {
              sigDict = vObj;
            }
    
            if (sigDict) {
              signerName = extractStringFromDict(sigDict, 'Name');
              reason = extractStringFromDict(sigDict, 'Reason');
              location = extractStringFromDict(sigDict, 'Location');
              contactInfo = extractStringFromDict(sigDict, 'ContactInfo');
              signingTime = extractStringFromDict(sigDict, 'M');
    
              const filterObj = sigDict.lookupMaybe(PDFName.of('Filter'), PDFName);
              filter = filterObj?.decodeText() ?? null;
    
              const subFilterObj = sigDict.lookupMaybe(PDFName.of('SubFilter'), PDFName);
              subFilter = subFilterObj?.decodeText() ?? null;
            }
          }
    
          fields.push({
            fieldName,
            isSigned,
            signerName,
            reason,
            location,
            contactInfo,
            signingTime,
            filter,
            subFilter,
          });
        }
      } catch {
        // Some PDFs may have malformed AcroForm
      }
    
      const signedCount = fields.filter((f) => f.isSigned).length;
      return {
        totalFields: fields.length,
        signedCount,
        unsignedCount: fields.length - signedCount,
        fields,
        note: 'Cryptographic signature verification is not performed. Only field structure is inspected.',
      };
    }
  • Zod schema for inspect_signatures input: file_path (string) and response_format (markdown|json).
    /** inspect_signatures */
    export const InspectSignaturesSchema = z
      .object({
        file_path: FilePathSchema,
        response_format: ResponseFormatSchema,
      })
      .strict();
  • TypeScript type definitions for SignatureFieldInfo (per-field details) and SignaturesAnalysis (aggregate result including totalFields, signedCount, unsignedCount, fields array, and note).
    /** Signature field information */
    export interface SignatureFieldInfo {
      fieldName: string;
      isSigned: boolean;
      signerName: string | null;
      reason: string | null;
      location: string | null;
      contactInfo: string | null;
      signingTime: string | null;
      filter: string | null;
      subFilter: string | null;
    }
    
    /** inspect_signatures output */
    export interface SignaturesAnalysis {
      totalFields: number;
      signedCount: number;
      unsignedCount: number;
      fields: SignatureFieldInfo[];
      note: string;
    }
  • Import of registerInspectSignatures in the main tool index.
    import { registerInspectSignatures } from './tier2/inspect-signatures.js';
  • Registration call for inspect_signatures in the registerAllTools function.
    registerInspectSignatures(server);
  • Formats the SignaturesAnalysis into a human-readable Markdown string with total fields, signed/unsigned counts, and per-field details.
    export function formatSignaturesMarkdown(analysis: SignaturesAnalysis): string {
      const lines: string[] = ['# Digital Signature Analysis', ''];
    
      lines.push(`- **Total Signature Fields**: ${analysis.totalFields}`);
      lines.push(`- **Signed**: ${analysis.signedCount}`);
      lines.push(`- **Unsigned**: ${analysis.unsignedCount}`);
    
      if (analysis.totalFields === 0) {
        lines.push('', 'No signature fields found in this document.');
        lines.push('', `> ${analysis.note}`);
        return lines.join('\n');
      }
    
      lines.push('', '## Signature Fields', '');
      for (const field of analysis.fields) {
        lines.push(`### ${field.fieldName}`, '');
        lines.push(`- **Signed**: ${field.isSigned ? 'Yes' : 'No'}`);
        if (field.signerName) lines.push(`- **Signer**: ${field.signerName}`);
        if (field.reason) lines.push(`- **Reason**: ${field.reason}`);
        if (field.location) lines.push(`- **Location**: ${field.location}`);
        if (field.signingTime) lines.push(`- **Signing Time**: ${field.signingTime}`);
        if (field.filter) lines.push(`- **Filter**: ${field.filter}`);
        if (field.subFilter) lines.push(`- **SubFilter**: ${field.subFilter}`);
        lines.push('');
      }
    
      lines.push(`> ${analysis.note}`);
    
      return lines.join('\n');
    }
  • Helper function to extract a string value from a PDFDict by key name, used to read signature field metadata.
    function extractStringFromDict(dict: PDFDict, key: string): string | null {
      const obj = dict.get(PDFName.of(key));
      if (obj instanceof PDFString) return obj.decodeText();
      if (obj instanceof PDFHexString) return obj.decodeText();
      if (obj instanceof PDFName) return obj.decodeText();
      return null;
    }
Behavior5/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false, which the description complements by explicitly stating it only inspects structure and does not perform verification. There is no contradiction, and the description adds important behavioral context (no cryptographic verification) beyond what annotations provide.

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 concise and well-structured: a single sentence for purpose, followed by Args, Returns, Note, and Examples sections. Every sentence adds necessary information without redundancy, and the most critical information ('Examine digital signature fields') is front-loaded.

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 simple tool with two parameters and no output schema, the description covers all necessary aspects: purpose, input requirements, output details (including example fields), and limitations. The examples provide concrete usage scenarios, making it contextually complete for agent invocation.

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?

Input schema covers both parameters with descriptions, but the tool description adds value by explaining the file_path as 'absolute path to a local PDF file' and response_format with default and examples. The 'Returns' section and examples further clarify parameter usage, compensating for the schema's 100% coverage baseline.

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's purpose: 'Examine digital signature fields in a PDF document.' It specifies the output (total count, signed/unsigned breakdown, details per field) and distinguishes it from sibling tools like validate_tagged by focusing on structure only. The verb 'examine' and resource 'digital signature fields' are specific and unambiguous.

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 explicit contexts for use ('Check if a PDF has been digitally signed', 'Inspect signer information and signing dates') and a clear limitation ('Cryptographic signature verification is not performed'). It implicitly suggests when not to use (if verification is needed) but does not name alternative tools for that purpose.

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