# MCP server

Let your AI agent create PDFs directly. Remote MCP server, Streamable HTTP transport:

```
https://html-pdf.com/mcp
```

Auth: **OAuth 2.1**. Clients like Claude.ai, ChatGPT and Claude Code open an html-pdf.com login when you connect, so there is no key to copy. You can also send the header `Authorization: Bearer hp_live_...`, or use `https://html-pdf.com/mcp?api_key=hp_live_...` in clients that only accept a URL.

No key yet? You don't need one. Add the server URL and your client opens an html-pdf.com login. New accounts get 100 free credits.

## Tools

| tool | what it does |
|---|---|
| `html_to_pdf` | Render HTML to PDF. Returns a download URL (valid 24h), page count and credits left. Same options as the [API](/docs): `html`, `filename`, `format`, `landscape`, `margin`, `css`, `header_html`, `footer_html`, `print_background`, `media`, `wait_delay`, `max_pages`. |
| `url_to_pdf` | Render a public web page (`url`) to PDF. Same options as `html_to_pdf` except `html`/`css`. |
| `get_credits` | Remaining credits, top-up link and auto top-up status. |
| `buy_credits` | Create a Stripe payment link for a credit pack (`usd`: 10, 25, 50, 100, 250) to give to the user. |
| `set_auto_topup` | Turn auto top-up on or off (`enabled`, `threshold`, `usd`) after the first purchase. The owner is emailed about every change. |

## Claude Code

```bash
claude mcp add --transport http html-pdf https://html-pdf.com/mcp \
  --header "Authorization: Bearer $HTML_PDF_KEY"
```

## Claude Desktop / claude.ai

Customize → Connectors → **+** → Add custom connector (Team/Enterprise: an owner adds it under Organization settings → Connectors). Paste this URL, click **Connect** and log in with your email.

```
https://html-pdf.com/mcp
```

## Cursor

`~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "html-pdf": {
      "url": "https://html-pdf.com/mcp",
      "headers": { "Authorization": "Bearer hp_live_..." }
    }
  }
}
```

## VS Code

`.vscode/mcp.json`:

```json
{
  "servers": {
    "html-pdf": {
      "type": "http",
      "url": "https://html-pdf.com/mcp",
      "headers": { "Authorization": "Bearer ${input:html-pdf-key}" }
    }
  },
  "inputs": [{ "id": "html-pdf-key", "type": "promptString", "description": "html-pdf.com API key", "password": true }]
}
```

## Codex

`~/.codex/config.toml`:

```toml
[mcp_servers.html-pdf]
url = "https://html-pdf.com/mcp"
bearer_token_env_var = "HTML_PDF_KEY"
```

## Other clients

Any client supporting remote MCP over Streamable HTTP works. For stdio-only clients use a bridge:

```bash
npx -y mcp-remote https://html-pdf.com/mcp --header "Authorization: Bearer $HTML_PDF_KEY"
```

## Prompt examples

- "Turn this invoice data into a clean A4 PDF with page numbers in the footer."
- "Generate a PDF of the weekly report as a landscape Letter page."
- "How many html-pdf credits do I have left?"
