---
name: pagebaton-publish
description: Publish or update a single HTML document on an owned PageBaton project and return its verified live link.
---

## Connect

Run `node /absolute/path/to/pagebaton/scripts/mcp.mjs` as a stdio MCP server from an installed PageBaton checkout with Node 22.15 or later. Pass the console origin in `PAGEBATON_BASE_URL` and a project API key from Settings in `PAGEBATON_API_KEY`. The origin accepts HTTPS or loopback HTTP. Supply secrets through the client's environment.

## Publish a new page

1. Obtain the final HTML and intended link name. The connector accepts up to 256 KiB of UTF-8 HTML.
2. Call `prepare_html` with the HTML. Keep the returned draftId.
3. Call `publication_status` with kind `draft` and the draftId. Poll after 1, 2, then 4 seconds until ready. Report invalid or expired drafts to the author.
4. When the author requests publication, call `publish_html` with draftId, slug and a fresh UUID requestId. Retry an identical submission with the same requestId.
5. Poll `publication_status` with kind `publication` and the operationId. Return shareUrl and version only after succeeded. If it fails, report the error code and reason.

## Update an existing link

Use `list_projects` to find the intended project and its revision. Pass projectId and expectedRevision to both preparation and publication, omitting slug. On a revision conflict, show the current version to the author before submitting another replacement. Failed operations preserve the existing live project.

## Direct HTTP integration

The OpenAPI document at `/openapi.json` describes the project API used by the connector. Each request carries an Authorization Bearer header. Draft processing and publication run asynchronously.
