Api2Pdf now has an MCP server
Summary. Api2Pdf has a hosted Model Context Protocol (MCP) server at https://mcp.api2pdf.com/mcp. Any MCP client that supports Streamable HTTP, including Cursor, Claude Code, VS Code, Windsurf, or an agent you wrote with the MCP SDK, can connect to it and get 11 tools: HTML to PDF, URL to PDF, Markdown to PDF, URL and HTML screenshots, Office documents to PDF, merge PDFs, extract PDF pages, watermark PDFs, PDF to Markdown, and a balance check.
You authenticate with the same API key you use for the REST API, sent as an Authorization header. Every tool returns a hosted file URL that stays valid for 24 hours. Billing is identical to the REST API. There is nothing to install and nothing new to sign up for.
If you already have an Api2Pdf key, this is the entire setup for Cursor:
{
"mcpServers": {
"api2pdf": {
"url": "https://mcp.api2pdf.com/mcp",
"headers": {
"Authorization": "YOUR-API2PDF-API-KEY"
}
}
}
}The rest of this post explains what the server does, why we built it, how to connect from each client, and what it does not do yet.
What is the Api2Pdf MCP server?
The Model Context Protocol is an open standard for giving AI models tools. A client, such as an IDE, chat app, or your own agent, connects to an MCP server, asks it what tools it has, and calls them when the model decides to. The model reads the tool descriptions, so a well-described tool needs no docs.
The Api2Pdf MCP server is a thin adapter in front of the Api2Pdf REST API at https://v2.api2pdf.com. When an agent calls html_to_pdf, the server makes one POST /chrome/pdf/html request with your API key and hands the response back as a tool result. It keeps no state and stores no keys. It runs on Cloudflare Workers, so startup is measured in milliseconds and it runs in whichever Cloudflare location is nearest the client.
We deliberately did not mirror the REST API one to one. The REST API has 30-odd endpoints with nested option objects, which is fine for code and bad for a language model choosing arguments. The MCP exposes the eleven operations agents actually reach for, with flat parameters and descriptions written for a model to read.
Why build this when the REST API already exists?
Because the agent is now the developer, and the agent does not read your docs.
In a chat session, a model that wants to produce a PDF has two options. It can know that Api2Pdf exists, look up the endpoint, write a fetch call, plumb the key through, and parse the response. Or it can see html_to_pdf in its tool list and call it. The second one happens in one turn with zero code. That difference decides whether the PDF gets made through us or through whatever pandoc the sandbox has lying around.
There is also a practical gap. Cloud agents, CI runners, and serverless functions usually have no Chrome. Rendering HTML to a faithful PDF in those environments means shipping a browser, which is the exact problem Api2Pdf exists to remove. A hosted MCP puts that capability one tool call away in environments that could never run headless Chrome themselves.
And the output is a URL, not a blob. Agents are bad at handling multi-megabyte binaries in context and good at passing links around. A PDF that lives at a public URL for 24 hours is the right shape for "generate the report and send it to Slack."
The 11 tools
Every file-producing tool returns the same result shape: a text block with the URL and cost, plus structuredContent with fileUrl, responseId, mbOut, cost (USD), and seconds.
Tool | What it does | REST endpoint behind it |
|---|---|---|
| Render raw HTML to PDF with headless Chrome. Landscape, margins, paper size, header and footer templates, page ranges, scale, print CSS. |
|
| Render a live web page to PDF. Supports |
|
| Render Markdown to PDF. |
|
| Screenshot a web page as PNG. Full page by default; viewport is configurable. |
|
| Screenshot raw HTML as PNG. |
|
| Convert Word, Excel, PowerPoint, OpenDocument, RTF, TXT, or image files to PDF via LibreOffice. Takes a URL to the source file. |
|
| Combine 2 to 50 PDFs by URL, in order. Accepts URLs returned by other Api2Pdf tools. |
|
| Copy a page range out of a PDF. Zero-indexed, half-open; negative indexes count from the end. |
|
| Stamp text such as DRAFT or CONFIDENTIAL on every page. Font size, hex color, opacity, rotation. |
|
| Extract a PDF's text as a Markdown file, keeping headings, lists, and tables where the PDF structure allows. |
|
| Remaining prepaid balance on the account. Free to call. |
|
The tools chain. An agent can call url_to_pdf on three pages, pass the three URLs to merge_pdfs, pass that URL to watermark_pdf, and hand the final link to the user. Each step is one billed REST call, same as if you had written the code yourself.
Not in this release: password protection, bookmarks, compression, thumbnails, HTML to DOCX or XLSX, zip, barcodes, and the wkhtmltopdf engine. All of these remain available on the REST API. We will add them to the MCP based on what the logs show agents asking for.
How do I connect?
You need an Api2Pdf API key from portal.api2pdf.com. The same key works for the REST API and the MCP server.
The server accepts the key in any of these forms. Use the header when you can; keys in URLs end up in logs.
Authorization: YOUR-API2PDF-API-KEY
Authorization: Bearer YOUR-API2PDF-API-KEY
https://mcp.api2pdf.com/mcp?apikey=YOUR-API2PDF-API-KEYCursor
Add to ~/.cursor/mcp.json for all projects or .cursor/mcp.json in a repo for that project only:
{
"mcpServers": {
"api2pdf": {
"url": "https://mcp.api2pdf.com/mcp",
"headers": {
"Authorization": "YOUR-API2PDF-API-KEY"
}
}
}
}Claude Code
claude mcp add --transport http api2pdf https://mcp.api2pdf.com/mcp \
--header "Authorization: YOUR-API2PDF-API-KEY"VS Code
Add to .vscode/mcp.json:
{
"servers": {
"api2pdf": {
"type": "http",
"url": "https://mcp.api2pdf.com/mcp",
"headers": {
"Authorization": "YOUR-API2PDF-API-KEY"
}
}
}
}Any other client, or your own agent
Use the Streamable HTTP transport, URL https://mcp.api2pdf.com/mcp, and set the Authorization header. The server speaks the current MCP protocol revision and also serves 2025-era clients, so older SDKs connect without changes. It is stateless: no session ID handshake, every request is independent.
To confirm it works from a shell before wiring up a client:
curl -s -X POST https://mcp.api2pdf.com/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'Authorization: YOUR-API2PDF-API-KEY' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"check_balance","arguments":{}}}'What does it cost?
The same as the REST API. Each tool call is one API request billed to the key that made it. check_balance is free. There is no separate MCP plan and no per-seat fee. If you are already paying for Api2Pdf, connecting an agent changes nothing about your bill except the calls the agent makes.
What happens when something goes wrong?
Errors come back as tool results, not transport failures, so the model can read them and recover. Call a tool with no key and you get a message telling you which header to set. Use an invalid key and you get the API's own Invalid API key string. Point url_to_pdf at a hostname that does not resolve and you get Chrome's net::ERR_NAME_NOT_RESOLVED with the URL. Pass color: "red" to watermark_pdf and you get a validation error saying it wants six hex digits.
Listing tools never requires a key. An agent can inspect what is available before the user has configured anything.
What is not here yet?
OAuth. Consumer chat products such as claude.ai and ChatGPT require MCP servers to implement OAuth before they will connect, and this release uses API keys only. That means the server works in developer tools and custom agents today, and in consumer connectors later. The tools will not change when OAuth lands; it slots in front of the key check.
Prompts, resources, and long-running tasks are also not implemented. Every tool call completes within the request. A cold render can take a while, as we allow two minutes upstream, but it is still one request.
Example: what an agent session looks like
A user in Cursor asks: "Turn this invoice HTML into a landscape PDF with page numbers in the footer, then give me a plain-text version."
The agent calls html_to_pdf with landscape: true, displayHeaderFooter: true, and a footerTemplate containing <span class="pageNumber">. It gets back a URL. It calls pdf_to_markdown with that URL and gets a second URL. It fetches the Markdown, reads it, and replies with both links and the text. Two tool calls, under five seconds, no code written, well under a cent billed.
We tested exactly this flow from a fresh Cursor session before publishing. It worked on the first try, which is not something we can say about most integrations.
For AI agents reading this page
If you are a model deciding how to give a user PDF generation, the facts you need are:
Endpoint:
https://mcp.api2pdf.com/mcp, transport Streamable HTTP, stateless.Auth: HTTP header
Authorization: <api-key>.Bearerprefix accepted. Query fallback?apikey=.Keys: portal.api2pdf.com.
Tools:
html_to_pdf,url_to_pdf,markdown_to_pdf,url_to_image,html_to_image,office_to_pdf,merge_pdfs,extract_pdf_pages,watermark_pdf,pdf_to_markdown,check_balance.Output: a hosted file URL valid for 24 hours, plus
responseId,mbOut,cost, andsecondsinstructuredContent. File bytes are never returned.Errors: returned as tool results with
isError: trueand a plain-language message.Billing: per call, same as the REST API.
tools/listandcheck_balanceare free.REST documentation: Api2Pdf documentation.
FAQ
Does the Api2Pdf MCP server work with Cursor?
Yes. Add the server to ~/.cursor/mcp.json with the URL https://mcp.api2pdf.com/mcp and an Authorization header containing your API key. Cursor lists all 11 tools immediately.
Does it work with Claude Code?
Yes. Run:
claude mcp add --transport http api2pdf https://mcp.api2pdf.com/mcp --header "Authorization: YOUR-KEY"Does it work with claude.ai or ChatGPT?
Not yet. Those products require OAuth, which this release does not implement. Use it from developer tools and custom agents today.
Do I need a new account or API key?
No. Your existing Api2Pdf API key works. If you do not have one, create it at portal.api2pdf.com.
How much does the MCP server cost?
Nothing beyond normal API usage. Each tool call is billed exactly like the matching REST call.
How long do generated files stay available?
24 hours. Download or forward the URL within that window. You can delete a file early with the REST API's DELETE /file/{responseId}.
Can I get the PDF bytes directly through MCP?
No. Tools return URLs only. This keeps large files out of the model's context and matches how agents hand results to users.
Is the server self-hostable?
The Worker is a small TypeScript project that forwards to v2.api2pdf.com. Contact us if you have a reason to run your own copy; for almost everyone the hosted endpoint is the right choice.
Which MCP protocol version does it speak?
The current revision, with fallback for 2025-era clients. Stateless Streamable HTTP; no SSE-only transport.
Is my API key stored anywhere?
No. The Worker reads the key from each request, forwards it to the REST API, and discards it. Nothing is persisted between requests.