---
title: MCP server
description: Connect an AI agent to SnapHTML over MCP. Browser OAuth, no API key to paste.
sidebar:
  label: MCP server
  order: 6
---

SnapHTML has an [MCP](https://modelcontextprotocol.io) server, so an AI agent can render HTML, templates, and URLs as a tool call — without you handing it an API key.

```
https://api.snhtml.com/mcp
```

Sign-in happens in the browser over OAuth. The agent never sees a key, and you can revoke its access without rotating anything.

## Connect a client

**Claude.ai** — Settings → Connectors → Add custom connector, and paste the URL above. A browser window opens for sign-in.

**Claude Code** — run `/mcp`, choose to add a server, and paste the URL.

**Any other MCP client** — add `https://api.snhtml.com/mcp` as a remote (HTTP) server. Discovery is standard: an unauthenticated request returns `401` with a `WWW-Authenticate` header pointing at the protected resource metadata, which names the authorization server.

The account you sign in with is the account that gets billed, and renders count against the same monthly quota as the HTTP API.

## Tools

### `render_html`

Render an HTML document. `html` is required; every [render option](/docs/render-options) is accepted alongside it.

```json
{
  "html": "<main><h1>Invoice #1842</h1></main>",
  "format": "pdf",
  "pdfFormat": "A4"
}
```

### `capture_url`

Screenshot a publicly reachable page. `url` is required, plus the same render options. Ad networks and cookie banners are blocked by default; pass `blockAds: false` or `blockCookieBanners: false` to capture the page exactly as served.

### `render_template`

Render a [saved template](/docs/templates), substituting its `{{placeholders}}`.

```json
{
  "templateId": "...",
  "variables": { "customer": "Acme Inc", "total": "12,390.00" },
  "format": "pdf"
}
```

### `render_batch`

Queue many renders as one job. With `templateId` each item is a set of `variables` for a [saved template](/docs/templates); without it each item carries its own `url` or `html`. Options in `defaults` apply to every item and any item may override them.

```json
{
  "name": "October invoices",
  "templateId": "...",
  "defaults": { "format": "pdf", "pdfFormat": "A4" },
  "items": [
    { "variables": { "invoice": "1842" }, "fileName": "invoice-1842" },
    { "variables": { "invoice": "1843" }, "fileName": "invoice-1843" }
  ]
}
```

`name` is optional and is what the batch is called in the dashboard; without it the batch is named after the template, or `URL batch` / `HTML batch`.

Returns a `batchId` straight away — the renders have not run yet. See [batch rendering](/docs/batch) for limits and quota behaviour.

### `get_batch`

Reports a batch's progress and a download URL for every finished item. Poll it with the id from `render_batch` until `status` is no longer `queued` or `running`; `partial` means the batch finished with some items failed, and those items carry an `error`.

### `list_templates`

Lists the account's templates with each one's id and the variable names it expects. Call this before `render_template` — the agent needs the id, and it cannot guess your placeholder names.

### `get_usage`

Returns renders used this month, the plan limit, and how many remain.

## What a render returns

Render tools return a **URL**, not the image bytes:

```json
{
  "url": "https://snaphtml.t3.storage.dev/mcp/…/8f3c1b2a.pdf?X-Amz-Signature=…",
  "fileName": "invoice-1842.pdf",
  "format": "pdf",
  "bytes": 48213,
  "expiresInSeconds": 86400,
  "usage": { "renders": 128, "rendersPerMonth": 2000 }
}
```

`url` is a signed link to object storage, valid for 24 hours. Once it expires the file is
unreachable, and storage deletes it automatically soon after — **download anything you need
to keep.** `fileName` is the name to save it under; it is not part of the URL.

This is deliberate: inlining a full-page capture costs an agent thousands of tokens for an image it usually does not need to look at. When it *does* need to see the result — checking a layout, iterating on a design — pass `includeImage: true` and the image comes back as inline content as well. It has no effect on PDFs.

> **Tip**
>
> If the agent is rendering for a vision model to inspect, drop `deviceScaleFactor` to `1`. The default of `2` produces an image large enough that the model downscales it anyway, which costs tokens and *loses* text legibility rather than adding it.

## Protocol support

The server implements revision `2026-07-28` and remains compatible with the older handshake-based revisions back to `2024-11-05`, so both current and older clients work.

It is stateless: every call is a single `POST`, there are no sessions, and `GET`/`DELETE` return `405`. Authorization is checked before anything else, so an unauthenticated request always gets the challenge it needs to start sign-in.

## Troubleshooting

**"Couldn't determine how this server signs in"** — the client could not complete discovery. Check that you pasted the URL exactly, with no trailing slash: `https://api.snhtml.com/mcp`.

**`402` or "Monthly render limit reached"** — the account is out of renders for the month. [Upgrade or wait for the next period](/docs/limits).

**"No SnapHTML account is linked to this identity yet"** — sign in once at [snhtml.com](https://snhtml.com) to finish account setup, then retry.
