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);
        }
      }
    );

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