read_pdf_forms_info
Extracts field names, types, and values from fillable PDF forms. Provides structured data for form automation or data extraction.
Instructions
Extracts information about fillable PDF fields from an input PDF file.
Ref: https://developer.pdf.co/api-reference/forms/info-reader.md
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files. | |
| httpusername | No | HTTP auth user name if required to access source url. (Optional) | |
| httppassword | No | HTTP auth password if required to access source url. (Optional) | |
| password | No | Password of PDF file. (Optional) | |
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) |
Implementation Reference
- pdfco/mcp/services/pdf.py:26-29 (helper)The service/helper function 'get_pdf_form_fields_info' that makes the actual API call to 'pdf/info/fields' endpoint. Called by the read_pdf_forms_info handler.
async def get_pdf_form_fields_info( params: ConversionParams, api_key: str | None = None ) -> BaseResponse: return await request("pdf/info/fields", params, api_key=api_key) - pdfco/mcp/services/client.py:1-58 (helper)The HTTP client (PDFCoClient) used to make the API request to PDF.co. Handles API key resolution from parameter or environment variable, and manages the async HTTP session.
from contextlib import asynccontextmanager from httpx import AsyncClient import os import sys from typing import AsyncGenerator import importlib.metadata __BASE_URL = "https://api.pdf.co" X_API_KEY = os.getenv("X_API_KEY") __version__ = importlib.metadata.version("pdfco-mcp") print(f"pdfco-mcp version: {__version__}", file=sys.stderr) @asynccontextmanager async def PDFCoClient(api_key: str | None = None) -> AsyncGenerator[AsyncClient, None]: # Use provided API key, fall back to environment variable x_api_key = api_key or X_API_KEY if not x_api_key: raise ValueError("""API key is required. Please provide an API key as a parameter or set X_API_KEY in the environment variables. To get the API key: 1. Sign up at https://pdf.co 2. Get the API key from the dashboard 3. Either set it as an environment variable or provide it as a parameter Environment variable setup example (.cursor/mcp.json): ```json { "mcpServers": { "pdfco": { "command": "uvx", "args": [ "pdfco-mcp" ], "env": { "X_API_KEY": "YOUR_API_KEY" } } } } ``` Or provide the API key as a parameter when calling the tool. """) client = AsyncClient( base_url=__BASE_URL, headers={ "x-api-key": x_api_key, "User-Agent": f"pdfco-mcp/{__version__}", }, ) try: yield client finally: await client.aclose()