Skip to main content
Glama

x402_pdf_extract

Extract text content from PDF documents via URL using PyMuPDF. Handles multi-page PDFs and returns extracted text, page count, and metadata with automatic USDC micropayments.

Instructions

Extract text content from a PDF document via URL. Price: $0.01 USDC per extraction.

Uses PyMuPDF for fast text extraction. Handles multi-page PDFs. Without X402_PRIVATE_KEY, only the free test endpoint is available.

Returns: extracted text, page count, and metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_urlYesURL of the PDF to extract text from

Implementation Reference

  • The implementation of the `x402_pdf_extract` tool handler, which utilizes the `apiPost` helper to communicate with the PDF extraction API.
    // ─── Tool: x402_pdf_extract ─────────────────────────────────────────────────
    
    server.tool(
      "x402_pdf_extract",
      `Extract text content from a PDF document via URL.
    Price: $0.01 USDC per extraction.
    
    Uses PyMuPDF for fast text extraction. Handles multi-page PDFs.
    Without X402_PRIVATE_KEY, only the free test endpoint is available.
    
    Returns: extracted text, page count, and metadata.`,
      {
        pdf_url: z.string().url().describe("URL of the PDF to extract text from"),
      },
      async (params) => {
        const base = APIS.pdf.baseUrl;
    
        try {
          const usePaid = !!PRIVATE_KEY;
          const endpoint = usePaid ? "/extract" : "/test/extract";
    
          const data = await apiPost(
            base,
            endpoint,
            { url: params.pdf_url },
            usePaid
          );
    
          return textResult({
            mode: usePaid ? "paid" : "free_test",
            cost: usePaid ? "$0.01" : "free",
            ...data,
          });
        } catch (err: any) {
          return errorResult(err.message);
        }
      }
    );
Behavior4/5

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

Excellent disclosure given zero annotations: explicitly states cost per call, authentication prerequisites (private key requirement), implementation method (PyMuPDF), and return structure (text, page count, metadata). Does not mention rate limits or error behaviors, preventing a 5.

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?

Six sentences, each earning its place: purpose, pricing, implementation, capabilities, auth requirements, and return values. Front-loaded with the core action and no redundant phrases.

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 single-parameter extraction tool without annotations or output schema, the description compensates comprehensively by documenting costs, authentication, processing capabilities (multi-page), and return values—everything an agent needs to invoke the tool correctly.

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?

With 100% schema description coverage for pdf_url ('URL of the PDF to extract text from'), the schema carries the parameter semantics. The description mentions 'via URL' but does not add additional parameter constraints (e.g., public accessibility, size limits) beyond the schema 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 opens with 'Extract text content from a PDF document via URL'—a specific verb (extract), resource (PDF text), and method (URL) that clearly distinguishes it from siblings like x402_scrape_url (general web) and x402_transcribe_audio (audio).

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?

Provides clear usage context through pricing ($0.01 USDC) and authentication requirements (X402_PRIVATE_KEY vs free test endpoint), which are critical decision factors. Lacks explicit comparison to x402_scrape_url for HTML content, but PDF specificity provides implicit differentiation.

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/jameswilliamwisdom/x402-mcp-server'

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