Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

pdf_make_searchable

Convert scanned PDFs or images into searchable PDFs by adding an invisible text layer through OCR, enabling text search within documents.

Instructions

Convert scanned PDF documents or image files into a text-searchable PDF. Runs OCR and adds an invisible text layer that can be used for text search. Ref: https://developer.pdf.co/api-reference/pdf-change-text-searchable/searchable.md

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL 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.
httpusernameNoHTTP auth user name if required to access source url. (Optional)
httppasswordNoHTTP auth password if required to access source url. (Optional)
langNoLanguage for OCR for scanned documents. Default is 'eng'. See PDF.co docs for supported languages. (Optional, Default: 'eng')eng
pagesNoComma-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)
passwordNoPassword of the PDF file. (Optional)
nameNoFile name for the generated output. (Optional)
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)

Implementation Reference

  • The core handler function for the 'pdf_make_searchable' tool. It is registered as an MCP tool via the @mcp.tool() decorator, defines the input schema using Pydantic Field descriptions, and implements the logic by constructing ConversionParams and delegating to the service layer.
    @mcp.tool() async def pdf_make_searchable( 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." ), 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="", ), 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", ), 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="", ), password: str = Field( description="Password of the PDF file. (Optional)", default="" ), name: str = Field( description="File name for the generated output. (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 scanned PDF documents or image files into a text-searchable PDF. Runs OCR and adds an invisible text layer that can be used for text search. Ref: https://developer.pdf.co/api-reference/pdf-change-text-searchable/searchable.md """ params = ConversionParams( url=url, httpusername=httpusername, httppassword=httppassword, lang=lang, pages=pages, password=password, name=name, ) return await make_pdf_searchable(params, api_key=api_key)
  • Supporting helper function that performs the actual API call to PDF.co's 'pdf/makesearchable' endpoint via the generic request function.
    async def make_pdf_searchable( params: ConversionParams, api_key: str | None = None ) -> BaseResponse: return await request("pdf/makesearchable", params, api_key=api_key)
  • Pydantic model for the tool's output response.
    class BaseResponse(BaseModel): status: str content: Any credits_used: int | None = None credits_remaining: int | None = None tips: str | None = None
  • Pydantic model defining input parameters for PDF conversion tools, including those used by pdf_make_searchable. Note: excerpt truncated for brevity; full class includes more fields and parse_payload method.
    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", ) line_grouping: str = Field( description="Enables line grouping within table cells when set to '1'. (Optional)", default="0", ) password: str = Field( description="Password of the PDF file. (Optional)", default="" ) name: str = Field( description="File name for the generated output. (Optional)", default="" ) autosize: bool = Field( description="Controls automatic page sizing. If true, page dimensions adjust to content. If false, uses worksheet’s page setup. (Optional)", default=False, ) html: str = Field( description="Input HTML code to be converted. To convert the link to a PDF use the /pdf/convert/from/url endpoint instead.", default="", ) templateId: str = Field( description="Set to the ID of your HTML template. You can find and copy the ID from HTML to PDF Templates.", default="", ) templateData: str = Field( description="Set it to a string with input JSON data (recommended) or CSV data.", default="", ) margins: str = Field( description="Set to CSS style margins like 10px, 5mm, 5in for all sides or 5px 5px 5px 5px (the order of margins is top, right, bottom, left). (Optional)", default="", ) paperSize: str = Field( description="A4 is set by default. Can be Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6 or a custom size. Custom size can be set in px (pixels), mm or in (inches) with width and height separated by space like this: 200 300, 200px 300px, 200mm 300mm, 20cm 30cm or 6in 8in. (Optional)", default="", ) orientation: str = Field( description="Set to Portrait or Landscape. Portrait is set by default. (Optional)", default="", ) printBackground: bool = Field( description="true by default. Set to false to disable printing of background. (Optional)", default=True, ) mediaType: str = Field( description="Uses print by default. Set to screen to convert HTML as it appears in a browser or print to convert as it appears for printing or none to set none as mediaType for CSS styles. (Optional)", default="", ) DoNotWaitFullLoad: bool = Field( description="false by default. Set to true to skip waiting for full load (like full video load etc. that may affect the total conversion time). (Optional)", default=False, ) header: str = Field( description="User definable HTML for the header to be applied on every page header. (Optional)", default="", ) footer: str = Field( description="User definable HTML for the footer to be applied on every page footer. (Optional)", default="", ) worksheetIndex: str = Field( description="Index of the worksheet to convert. (Optional)", default="" )
  • Core helper function that handles HTTP requests to the PDF.co API, used by make_pdf_searchable.
    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