Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

excel_to_json

Convert Excel files (XLS, XLSX) to JSON format for data processing and integration. Supports public URLs and cloud storage links.

Instructions

Convert Excel(XLS, XLSX) to JSON.
Ref: https://developer.pdf.co/api-reference/convert-from-excel/json.md

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to the source file (XLS, XLSX). Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files.
httpusernameNoHTTP auth user name if required to access source url. (Optional)
httppasswordNoHTTP auth password if required to access source url. (Optional)
nameNoFile name for the generated output. (Optional)
worksheetIndexNoIndex of the worksheet to convert. (Optional)
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)

Implementation Reference

  • The main handler function for the 'excel_to_json' MCP tool. Decorated with @mcp.tool() for automatic registration and schema definition via Pydantic Field descriptions. It wraps the convert_to service to perform Excel to JSON conversion via PDF.co API.
    @mcp.tool()
    async def excel_to_json(
        url: str = Field(
            description="URL to the source file (XLS, XLSX). Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
        ),
        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="",
        ),
        name: str = Field(
            description="File name for the generated output. (Optional)", default=""
        ),
        worksheetIndex: str = Field(
            description="Index of the worksheet to convert. (Optional)", default=""
        ),
        api_key: str = Field(
            description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
            default="",
        ),
    ) -> BaseResponse:
        """
        Convert Excel(XLS, XLSX) to JSON.
        Ref: https://developer.pdf.co/api-reference/convert-from-excel/json.md
        """
        return await convert_to(
            "xls",
            "json",
            ConversionParams(
                url=url,
                httpusername=httpusername,
                httppassword=httppassword,
                name=name,
                worksheetIndex=worksheetIndex,
                api_key=api_key,
            ),
        )
  • Helper function convert_to that constructs the PDF.co API endpoint for conversion from one format to another and calls the generic request function.
    async def convert_to(
        _from: str, _to: str, params: ConversionParams, api_key: str | None = None
    ) -> BaseResponse:
        return await request(f"{_from}/convert/to/{_to}", params, api_key=api_key)
  • Core request helper that makes async POST requests to PDF.co API endpoints, parses responses into BaseResponse, and handles job IDs with tips for completion.
    async def request(
        endpoint: str,
        params: ConversionParams,
        custom_payload: dict | None = None,
        api_key: str | None = None,
    ) -> BaseResponse:
        payload = params.parse_payload(async_mode=True)
        if custom_payload:
            payload.update(custom_payload)
    
        try:
            async with PDFCoClient(api_key=api_key) as client:
                url = f"/v1/{endpoint}"
                print(f"Requesting {url} with payload {payload}", file=sys.stderr)
                response = await client.post(url, json=payload)
                print(f"response: {response}", file=sys.stderr)
                json_data = response.json()
                return BaseResponse(
                    status="working",
                    content=json_data,
                    credits_used=json_data.get("credits"),
                    credits_remaining=json_data.get("remainingCredits"),
                    tips=f"You **should** use the 'wait_job_completion' tool to wait for the job [{json_data.get('jobId')}] to complete if a jobId is present.",
                )
        except Exception as e:
            return BaseResponse(
                status="error",
                content=f"{type(e)}: {[arg for arg in e.args if arg]}",
            )
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. It states the conversion function but doesn't describe important behavioral aspects: whether this is a read-only operation, what happens with large files, error handling, rate limits, or authentication requirements beyond the API key parameter. The reference link might contain details, but the description itself lacks this critical context for an AI agent.

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 extremely concise - just two sentences that directly state the tool's function and provide a reference link. There's no wasted language or unnecessary elaboration. However, the reference link inclusion might suggest the description itself is incomplete, slightly reducing the score from perfect.

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 conversion tool with 6 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the JSON output looks like (structure, formatting), error conditions, performance characteristics, or how it differs from similar conversion tools. The reference link indicates missing information that should be in the description itself for proper agent understanding.

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 description adds no parameter semantics beyond what's already in the schema, which has 100% coverage. All 6 parameters (url, httpusername, httppassword, name, worksheetIndex, api_key) are well-documented in the schema with descriptions, defaults, and required status. The description doesn't provide additional context about parameter relationships, validation rules, or usage examples.

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 tool's purpose: converting Excel files (XLS, XLSX) to JSON format. It specifies the input file types and output format, making the verb+resource relationship explicit. However, it doesn't differentiate from sibling tools like 'excel_to_csv' or 'pdf_to_json', which would require more specific context about when to choose this particular conversion.

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 minimal usage guidance. It mentions a reference link but doesn't explain when to use this tool versus alternatives like 'excel_to_csv' or 'pdf_to_json' from the sibling list. There's no context about typical use cases, prerequisites, or comparisons with other conversion tools available on the server.

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