Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

upload_file

Upload a file to PDF.co to initiate PDF processing, including conversion, editing, 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 upload_file MCP tool handler. It uploads a file to PDF.co API by posting to /v1/file/upload with the file content, and returns a BaseResponse with the uploaded file URL.
    @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 BaseResponse model used as the return type for the upload_file tool.
    class BaseResponse(BaseModel):
        status: str
        content: Any
        credits_used: int | None = None
        credits_remaining: int | None = None
        tips: str | None = None
  • Registration of the file module (containing upload_file) in the MCP server via import in __init__.py.
    from pdfco.mcp.tools.apis import (
        conversion,
        job,
        file,
        modification,
        form,
        search,
        searchable,
        security,
        document,
        extraction,
        editing,
    )
  • The FastMCP server instance ('mcp') used as the decorator to register the upload_file tool.
    from fastmcp import FastMCP
    
    mcp = FastMCP("pdfco")
  • The PDFCoClient async context manager used by upload_file to authenticate and make HTTP requests to PDF.co API.
    @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()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It fails to disclose any behavioral traits such as authentication requirements, success/failure responses, rate limits, or side effects. The description is too brief to guide safe invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no wasted words, which is efficient. However, it could be slightly expanded to include essential context without becoming verbose. It is appropriately sized but lacks structure for additional guidance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there is no output schema and no annotations, the description should explain what the tool returns (e.g., a URL or job ID). It does not, leaving the agent without critical information for using the result. The description is incomplete for the tool's role as an upload step.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already documents both parameters (file_path and api_key). The description adds no extra meaning beyond the schema, but it is not necessary. A score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (upload) and the target (file to PDF.co API), providing a specific verb and resource. However, it lacks mention of what the upload accomplishes or returns, which could help differentiate it further from sibling tools that also involve file input.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given on when to use this tool versus alternatives, such as prerequisites (e.g., must be used before processing tools like pdf_merge) or context like file size limits. The description does not help an agent decide to select this tool over others.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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