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:
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Upload a file' implies a write/mutation operation, but there's no information about authentication requirements (beyond what's in the schema), rate limits, file size restrictions, supported formats, or what happens after upload. The description adds minimal behavioral context beyond the basic action.

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

Conciseness5/5

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

The description is extremely concise - a single sentence that directly states the tool's purpose. There's zero wasted language, and it's perfectly front-loaded with the essential information. This is an example of efficient communication.

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?

For a file upload tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the upload accomplishes in the PDF.co ecosystem, what happens to the uploaded file, what formats are supported, or what the response contains. Given the complexity of file operations and the lack of structured metadata, more context is needed.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description doesn't add any parameter semantics beyond what's in the schema - it doesn't explain the upload process, file requirements, or API integration details. This meets the baseline for high schema coverage.

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 target resource ('a file to the PDF.co API'), making the purpose immediately understandable. It doesn't differentiate from sibling tools, but since siblings are all PDF processing tools with different functions (conversion, parsing, etc.), this tool's purpose is distinct enough without explicit differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives. While the tool name 'upload_file' suggests a generic file upload function, there's no mention of prerequisites, typical use cases, or how it relates to other tools in the server (like whether uploaded files are processed by other tools).

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