Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

upload_file

Upload files to the PDF.co API for processing tasks like conversion, editing, searching, and security operations.

Instructions

Upload a file to the PDF.co API

Input Schema

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

Implementation Reference

  • The main handler function for the 'upload_file' tool. It uploads the specified file to the PDF.co API using the PDFCoClient, handles the response, and returns a BaseResponse with status, content, and tips.
    @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), )
  • The @mcp.tool() decorator registers this function as the 'upload_file' MCP tool.
    @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 Field definitions provide input schema (parameters) and output type (BaseResponse).
    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:

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