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]}", )

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