excel_to_txt
Convert Excel spreadsheets (XLS, XLSX) to plain text. Optionally specify a worksheet index to extract specific data.
Instructions
Convert Excel(XLS, XLSX) to TXT.
Ref: https://developer.pdf.co/api-reference/convert-from-excel/text.mdInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | 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 | No | HTTP auth user name if required to access source url. (Optional) | |
| httppassword | No | HTTP auth password if required to access source url. (Optional) | |
| name | No | File name for the generated output. (Optional) | |
| worksheetIndex | No | Index of the worksheet to convert. (Optional) | |
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) |
Implementation Reference
- The main handler for the 'excel_to_txt' tool. Decorated with @mcp.tool(), it accepts parameters (url, httpusername, httppassword, name, worksheetIndex, api_key) and delegates to convert_to('xls', 'txt', ...) to perform the conversion.
@mcp.tool() async def excel_to_txt( 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 TXT. Ref: https://developer.pdf.co/api-reference/convert-from-excel/text.md """ return await convert_to( "xls", "txt", ConversionParams( url=url, httpusername=httpusername, httppassword=httppassword, name=name, worksheetIndex=worksheetIndex, api_key=api_key, ), ) - pdfco/mcp/tools/apis/conversion.py:1044-1044 (registration)The tool is registered using the @mcp.tool() decorator on the excel_to_txt function, which is imported from pdfco/mcp/server.py.
@mcp.tool() - Input parameters are defined inline using Pydantic's Field() with descriptions and defaults. The response type is BaseResponse, defined in models.py.
@mcp.tool() async def excel_to_txt( 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 TXT. Ref: https://developer.pdf.co/api-reference/convert-from-excel/text.md """ return await convert_to( "xls", "txt", ConversionParams( url=url, httpusername=httpusername, httppassword=httppassword, name=name, worksheetIndex=worksheetIndex, api_key=api_key, ), ) - pdfco/mcp/services/pdf.py:6-10 (helper)The convert_to helper function which excel_to_txt calls. It constructs the API endpoint as "xls/convert/to/txt" and delegates to the 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) - pdfco/mcp/models.py:13-40 (helper)The ConversionParams data model used to pass parameters (url, httpusername, httppassword, name, worksheetIndex, etc.) to the convert_to service.
class ConversionParams(BaseModel): url: str = Field( description="URL to the source file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files.", default="", ) 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="", ) pages: str = Field( description="Comma-separated page indices (e.g., '0, 1, 2-' or '1, 3-7'). Use '!' for inverted page numbers (e.g., '!0' for last page). Processes all pages if None. (Optional)", default="", ) unwrap: bool = Field( description="Unwrap lines into a single line within table cells when lineGrouping is enabled. Must be true or false. (Optional)", default=False, ) rect: str = Field( description="Defines coordinates for extraction (e.g., '51.8,114.8,235.5,204.0'). (Optional)", default="", ) lang: str = Field( description="Language for OCR for scanned documents. Default is 'eng'. See PDF.co docs for supported languages. (Optional, Default: 'eng')", default="eng",