extract_attachments
Extract embedded files and attachments from a PDF, including support for password-protected or remote documents. Simplify retrieval of associated data or resources stored within PDF files.
Instructions
Extracts attachments from a source PDF file.
Ref: https://developer.pdf.co/api-reference/pdf-extract-attachments.md
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) | |
| httppassword | No | HTTP auth password if required to access source url. (Optional) | |
| httpusername | No | HTTP auth user name if required to access source url. (Optional) | |
| password | No | Password of PDF file. (Optional) | |
| url | Yes | URL to the source PDF file. |
Implementation Reference
- pdfco/mcp/tools/apis/extraction.py:31-59 (handler)MCP tool handler for 'extract_attachments': registers the tool via @mcp.tool(), defines input schema with Pydantic Fields, and delegates to service function.@mcp.tool() async def extract_attachments( url: str = Field(description="URL to the source PDF file."), httpusername: str = Field( description="HTTP auth user name if required to access source url. (Optional)", default="", ), httppassword: str = Field( description="HTTP auth password if required to access source url. (Optional)", default="", ), password: str = Field(description="Password of PDF file. (Optional)", default=""), api_key: str = Field( description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default="", ), ) -> BaseResponse: """ Extracts attachments from a source PDF file. Ref: https://developer.pdf.co/api-reference/pdf-extract-attachments.md """ params = ConversionParams( url=url, httpusername=httpusername if httpusername else None, httppassword=httppassword if httppassword else None, password=password if password else None, ) return await extract_pdf_attachments(params, api_key=api_key)
- pdfco/mcp/services/pdf.py:119-123 (helper)Helper service function that sends the API request to PDF.co's extract attachments endpoint.async def extract_pdf_attachments( params: ConversionParams, api_key: str | None = None ) -> BaseResponse: return await request("pdf/attachments/extract", params, api_key=api_key)
- pdfco/mcp/models.py:5-11 (schema)Output schema model used by the tool's BaseResponse return type.class BaseResponse(BaseModel): status: str content: Any credits_used: int | None = None credits_remaining: int | None = None tips: str | None = None
- pdfco/mcp/models.py:13-52 (schema)Input parameters are mapped to this shared ConversionParams Pydantic model for payload construction.class ConversionParams(BaseModel): url: str = Field( description="URL to the source file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files.", default="", ) httpusername: str = Field( description="HTTP auth user name if required to access source url. (Optional)", default="", ) httppassword: str = Field( description="HTTP auth password if required to access source url. (Optional)", default="", ) pages: str = Field( description="Comma-separated page indices (e.g., '0, 1, 2-' or '1, 3-7'). Use '!' for inverted page numbers (e.g., '!0' for last page). Processes all pages if None. (Optional)", default="", ) unwrap: bool = Field( description="Unwrap lines into a single line within table cells when lineGrouping is enabled. Must be true or false. (Optional)", default=False, ) rect: str = Field( description="Defines coordinates for extraction (e.g., '51.8,114.8,235.5,204.0'). (Optional)", default="", ) lang: str = Field( description="Language for OCR for scanned documents. Default is 'eng'. See PDF.co docs for supported languages. (Optional, Default: 'eng')", default="eng", ) line_grouping: str = Field( description="Enables line grouping within table cells when set to '1'. (Optional)", default="0", ) password: str = Field( description="Password of the PDF file. (Optional)", default="" ) name: str = Field( description="File name for the generated output. (Optional)", default="" ) autosize: bool = Field(