HTML to PDF in Codex

HTML to PDF in Codex

Add HTML and URL to PDF conversion to OpenAI Codex CLI with the html-pdf.com remote MCP server. It takes three lines of config.toml and no local install.

Quick answer: run codex mcp add html-pdf --url https://html-pdf.com/mcp --bearer-token-env HTML_PDF_KEY with your key in HTML_PDF_KEY, then ask Codex "Make a PDF of https://example.com".

Get an API key

You need a key before you connect. Create one with a single call (or by email at https://html-pdf.com/login):

curl -X POST https://html-pdf.com/v1/signup \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'

The key is shown once. Open the link we email you to confirm your address, which adds 100 free credits (1 credit = 1 PDF page). Then export the key in your shell profile:

export HTML_PDF_KEY=hp_live_...

Connect

This step registers the server with Codex. Add it to ~/.codex/config.toml:

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

Codex reads the key from HTML_PDF_KEY and sends it as Authorization: Bearer .... The key never sits in the config file.

Or add it from the CLI:

codex mcp add html-pdf --url https://html-pdf.com/mcp --bearer-token-env HTML_PDF_KEY

Start Codex and run /mcp to see the html-pdf tools.

Try it

Once connected, you just ask in plain words. You don't write any code. For example:

Tips

These options help you get cleaner PDFs and safer automation.

Troubleshooting

Most issues come from a missing environment variable or a typo in the TOML.

FAQ

How do I add an MCP server to Codex CLI?

Add an [mcp_servers.html-pdf] table to ~/.codex/config.toml with the url and bearer_token_env_var, or run codex mcp add. Then run /mcp to check the tools.

Where should I keep my API key?

Keep it in the HTML_PDF_KEY environment variable. Codex reads it from there, so the key never sits in config.toml.

Is there a free tier?

Yes. A new account gets 100 free credits once you confirm your email, with no card. 1 credit = 1 PDF page, and failed renders cost nothing.

Can I use it in CI without Codex?

Yes. Call POST https://html-pdf.com/v1/pdf directly with Authorization: Bearer $HTML_PDF_KEY and a JSON body with html or url. See the API docs.

Full reference: API docs · MCP server

This page as markdown · text