Skip to main content
Glama

pilot_pdf

Save the current webpage as a downloadable A4 PDF document. Use to export receipts, archive pages, or create offline copies.

Instructions

Save the current page as a PDF document in A4 format. Use when the user wants to export the page as a downloadable PDF, save a receipt, or archive a page for offline reading.

Parameters:

  • output_path: File path to save the PDF (default: /tmp/pilot-page.pdf). Must be within the allowed output directory

Returns: Confirmation with the file path where the PDF was saved.

Errors:

  • "Output path must be within ...": The path is outside the allowed directory. Set PILOT_OUTPUT_DIR or use /tmp.

  • "Page is not HTML": The current page is a non-HTML resource (e.g., a binary download) and cannot be exported as PDF.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
output_pathNoOutput file path

Implementation Reference

  • The pilot_pdf tool handler registered via server.tool(). It takes an optional output_path, validates it, saves the page as A4 PDF using Playwright's page.pdf(), and returns confirmation.
      server.tool(
        'pilot_pdf',
        `Save the current page as a PDF document in A4 format.
    Use when the user wants to export the page as a downloadable PDF, save a receipt, or archive a page for offline reading.
    
    Parameters:
    - output_path: File path to save the PDF (default: /tmp/pilot-page.pdf). Must be within the allowed output directory
    
    Returns: Confirmation with the file path where the PDF was saved.
    
    Errors:
    - "Output path must be within ...": The path is outside the allowed directory. Set PILOT_OUTPUT_DIR or use /tmp.
    - "Page is not HTML": The current page is a non-HTML resource (e.g., a binary download) and cannot be exported as PDF.`,
          { output_path: z.string().optional().describe('Output file path') },
        async ({ output_path }) => {
          await bm.ensureBrowser();
          try {
            const pdfPath = output_path ? validateOutputPath(output_path) : path.join(TEMP_DIR, 'pilot-page.pdf');
            await bm.getPage().pdf({ path: pdfPath, format: 'A4' });
            return { content: [{ type: 'text' as const, text: `PDF saved: ${pdfPath}` }] };
          } catch (err) {
            return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
          }
        }
      );
  • Zod schema for pilot_pdf: optional string parameter 'output_path' with description 'Output file path'.
    { output_path: z.string().optional().describe('Output file path') },
  • Registration of all visual tools (including pilot_pdf) via registerVisualTools() in the registerAllTools function.
    registerVisualTools(effectiveServer, bm);
  • Helper function validateOutputPath used by pilot_pdf to ensure the output path is within the allowed directory (PILOT_OUTPUT_DIR or /tmp).
    export function validateOutputPath(outputPath: string): string {
      const allowed = process.env.PILOT_OUTPUT_DIR || os.tmpdir();
      let normalizedAllowed: string;
      try {
        normalizedAllowed = fs.realpathSync(path.resolve(allowed));
      } catch {
        normalizedAllowed = path.resolve(allowed);
      }
      try {
        const parentDir = path.dirname(outputPath);
        const realParent = fs.realpathSync(parentDir);
        const resolved = path.resolve(realParent, path.basename(outputPath));
        if (!resolved.startsWith(normalizedAllowed + path.sep) && resolved !== normalizedAllowed) {
          throw new Error(`Output path must be within ${normalizedAllowed}: ${outputPath}`);
        }
        return resolved;
      } catch (err) {
        if (err instanceof Error && err.message.includes('Output path must be within')) {
          throw err;
        }
        const resolved = path.resolve(outputPath);
        if (!resolved.startsWith(normalizedAllowed + path.sep) && resolved !== normalizedAllowed) {
          throw new Error(`Output path must be within ${normalizedAllowed}: ${outputPath}`);
        }
        return resolved;
      }
    }
Behavior4/5

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

No annotations are present, so the description carries full burden. It discloses default behavior (A4 format, default output path), return value (confirmation with file path), and error conditions ('Output path must be within ...', 'Page is not HTML'). It does not explicitly state that the tool does not modify browser state, but the mutation is limited to file system write, which is implied.

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 concise, front-loading the main purpose, then providing clear sections for parameters and errors. It is appropriately sized for the tool's simplicity, though the error list could be slightly trimmed without losing value.

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?

Given no output schema and one parameter, the description adequately covers usage, return value, and errors. It could mention that the PDF uses default print settings and that the page must be HTML, but those are already implied by the error list. Overall, it provides sufficient context for correct invocation.

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 input schema provides minimal description for 'output_path' ('Output file path'). The description adds significant value: default value (/tmp/pilot-page.pdf), directory constraint, and implied usage. With 100% schema coverage, the description elevates understanding beyond the schema's minimal description.

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 'Save the current page as a PDF document in A4 format' which specifies the action, resource (current page), and format. This distinguishes it from other pilot tools like pilot_screenshot (image) or pilot_page_text (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 explicitly provides use cases: 'Use when the user wants to export the page as a downloadable PDF, save a receipt, or archive a page for offline reading.' It does not, however, mention when not to use or alternative tools, but given the sibling context, the differentiation is clear.

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/TacosyHorchata/Pilot'

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