Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

upload_file

Transfer a file to the PDF.co API for processing, enabling tasks like PDF conversion, editing, and security operations. Requires the file’s absolute path and an optional API key.

Instructions

Upload a file to the PDF.co API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)
file_pathYesThe absolute path to the file to upload

Implementation Reference

  • The main handler function for the 'upload_file' tool. It uploads a local file to PDF.co API using PDFCoClient and returns a BaseResponse.
    @mcp.tool() async def upload_file( file_path: str = Field(description="The absolute path to the file to upload"), api_key: str = Field( description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default="", ), ) -> BaseResponse: """ Upload a file to the PDF.co API """ try: async with PDFCoClient(api_key=api_key) as client: response = await client.post( "/v1/file/upload", files={ "file": open(file_path, "rb"), }, ) res = response.json() return BaseResponse( status="success" if res["status"] == 200 else "error", content=res, tips=f"You can use the url {res['url']} to access the file", ) except Exception as e: return BaseResponse( status="error", content=str(e), )
  • Pydantic model used as the output schema for the upload_file tool (and others).
    class BaseResponse(BaseModel): status: str content: Any credits_used: int | None = None credits_remaining: int | None = None tips: str | None = None
  • Imports the 'file' module (containing upload_file), which triggers registration of the tool via the @mcp.tool() decorator when the module is imported.
    from pdfco.mcp.tools.apis import ( conversion, job, file, modification, form, search, searchable, security, document, extraction, editing, )
  • Imports the mcp decorator and other dependencies used in the upload_file handler.
    from pdfco.mcp.server import mcp from pdfco.mcp.services.client import PDFCoClient

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/pdfdotco/pdfco-mcp'

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