ContentBuilder.js · ContentBox.js · Guide
Claude works on the user's whole site through your CMS, with no editor open, and every change can be taken back.
In this series
Claude
↓ MCP
Your connector
↓ your code
Your database
In live editing, the editor and its Undo stand between Claude and the database. Here nothing does: Claude's tool calls change your stored pages directly. Whatever your tools allow, Claude can do, and a chat cannot press Undo.
So the safety must be built into the tools, and into your CMS itself. The next sections show how.
Use the same code for versions and the Trash in your dashboard, your editor's save and the connector. Then a page deleted from the dashboard is as safe as one Claude deleted, and you write the rules once.
✓ Do
✕ Don't
Your connector sees single tool calls, one by one. Nothing in a call says which request or chat it belongs to, so the connector cannot keep "one version per request". Keeping the page before every change is simpler, and never misses a state.
Give every change tool a required request field: the user's request, in their words. All changes for one request then carry the same label, and later the user can say "go back to before I asked for the pricing table". Claude finds the first version with that label.
// Work out the new page first, keep the old one, then save.
async function changeContent(db, user, address, request, change) {
const page = await findPage(db, user, address);
const after = change(page.html); // an error here changes nothing
await saveVersion(db, page, 'ai', request);
await db.pages.updateOne(
{ _id: page._id, rev: page.rev }, // not changed meanwhile
{ $set: { html: after }, $inc: { rev: 1 } });
}
async function saveVersion(db, page, kind, label) {
await db.page_versions.insertOne({
pageId: page._id, user: page.user,
kind, // published, ai, settings, restore, editor
label, createdAt: new Date(),
page: { ...page }, // a full copy
});
}"Go back to before I asked for the pricing table": Claude finds the version by its label.
Every published version. Of the others, the newest 100 per page is plenty.
1. Give each page a Versions item in its menu, next to View Draft.
2. In the list, show the kind of each version, the request it belongs to, and when it was kept. View opens it read-only; Restore puts it back into the draft.
3. Add an All / Published switch. Claude's versions are many, and the user often wants only the publishing history.
Give Claude a tool that reads one section of an old version. Then "bring back the old header" restores that section alone, and keeps everything else the user changed since.
Keep two copies of each page: the draft, which Claude and the editor change, and the live page, which visitors see.
Settings such as the title, description, address and social image often change on the live page at once, as in a dashboard's Settings dialog. If yours do, keep a version before they change too.
Refuse an address that another page already uses, both when Claude changes it and when a version or a page from the Trash is restored.
Deleting a page moves it to the Trash, together with its live copy. Its versions stay.
Restore brings the page back with its history, and live again if it was live. If its address is taken by then, the user restores it under another one.
Only a person empties the Trash, in your dashboard, with a confirm step. Your connector has no tool for it.
async function trashPage(db, user, slug) {
const page = await db.pages.findOne({ user, slug });
const live = await db.live.findOne({ user, slug });
await db.trash.insertOne({
user, slug, page, live, deletedAt: new Date() });
await db.pages.deleteOne({ _id: page._id });
if(live) await db.live.deleteOne({ _id: live._id });
}
Delete forever asks first, and only in the dashboard.
Each tool is a door into your CMS. Offer the ones a user would ask for, and nothing that cannot be taken back. The list shows the page tools; add your other CMS tasks, such as products or blog posts, the same way and with the same rules.
list_pages add_page delete_page (to the Trash) list_trash restore_pageget_page_settings update_page_settingsget_outline get_section edit_section replace_section insert_section delete_section get_page_styles get_framework_docspublish_page unpublish_pagelist_versions get_version_outline get_version_section restore_versionlist_images get_upload_link check_upload import_imagecheck_site: titles, descriptions, headings, alt text, large images and broken links, checked on your server, only the problems sent back. On a large site: one line per kind of problem, with a few example pages, and the pages with the most problems. screenshot_page: a picture of the draft (first screen or one section, desktop or phone).Mark tools that only read with readOnlyHint. claude.ai then lists them as read-only tools, which users can allow as a group, and asks only about the tools that change something.
server.registerTool('get_outline', {
description: 'The sections of a page.',
inputSchema: { page: z.string() },
annotations: { readOnlyHint: true },
}, run);Delete forever, empty the Trash, delete files, write to the live page, change another user's pages, run code on your server.
Claude calls screenshot_page at phone width, shows the picture in the chat and describes what it sees. Users check a change without opening the site.
On the Allow page, let the user choose: Read only (Claude can look at the site, answer questions and suggest changes) or Full access (Claude can also make changes).
Store the choice with the key. A read-only key gets only the reading tools. This is a rule in your connector, not a request to Claude.
The choice on the Allow page.
In the user's settings, let them switch groups of tools on or off, for example Pages, Content, Page settings, Publishing, Images. Someone may want Claude to write but never publish.
Check the switches on every call, so a group switched off stops working at once. Claude apps keep the tool list they received when connecting, so the list itself changes only after the user reconnects.
A panel in the dashboard: the address to add, the switches, and things to ask.
If several people work on one site, follow each person's role. Claude gets no more than the person who connected it: if an editor may not publish or change settings, neither may Claude through that editor's key.
Check the role inside each tool, the same way your dashboard checks it.
A page is a list of sections. Find a section's exact position in the stored page and replace only those characters. Every other section stays byte for byte the same, so a small request never rewrites the whole page.
For a text, a link or a class, let Claude send "find this exact piece, replace it with that" inside one section:
edit_section({
page: '/about',
section: 2,
edits: [
{ find: 'Six people', replace: 'Seven people' },
],
request: 'we are seven now',
})The editor normally adds the font stylesheet for each typography class it uses. When the connector saves a section, do the same, so a section Claude writes shows its fonts even though no editor opened it.
claude.ai cannot pass a file the user attached in the chat to a connector. So give Claude a tool that makes a short-lived link to a small upload page on your site. The user opens it, adds files, and tells Claude; Claude then reads what arrived.
The upload page Claude links to (valid for 30 minutes).
A tool that lists the user's newest files lets Claude use what is there.
If you let Claude copy an image from the web, refuse addresses inside your own network, follow only a few redirects, accept images only, and limit the size.
Removing files stays manual, in your asset manager.
Use your site's own login. When a user adds the connector, Claude opens your login page if needed, then an Allow page that says what Claude will be able to do.
The MCP libraries include the standard login handlers (OAuth with PKCE and client registration); you add your login and the Allow page.
Editors save on their own every few seconds. If Claude changes a page that is open in the editor, the editor's next save would overwrite Claude's change.
Give each page a rev number that goes up on every write. The editor sends the rev it opened. If the page has changed since:
The editor's notice after Claude changed the open page.
A connector can give Claude short instructions, sent with the tool list. Use them to explain how your site works and how to work safely. The rules themselves still belong in the tools.
Start with the site's own address. A user with several sites connected then gets changes on the right one.
This connector is for the website https://www.example.com.
DRAFT AND LIVE
- Every page has a draft and a live copy. All content changes go
to the draft. Visitors see the live copy only after publish_page.
- Publish only when the user asks for it.
SAFETY
- Before every change the page is saved as a version, labelled
with "request": the user's request, in their words.
- To undo: list_versions, then restore_version for the whole page,
or get_version_section to put back only part of it.
- delete_page moves the page to the Trash. Files are never deleted.
HOW TO WORK
- list_pages first. Read a section with get_section before
changing it.
- Small changes: edit_section with the exact text from get_section.
- New content matches what is already there: read an existing
section first.Claude writes markup following the framework guides that come with the editor: the classes for layout and typography, and the attributes for animation and light and dark modes. Give them to Claude through a tool, so they are read only when needed.
Record which editor version the guides describe.
The rule
The editor your site runs, and its runtime and asset files, must be that version or newer.
Otherwise Claude writes markup for features your site does not have yet: a page with scroll animation or light and dark modes then looks broken in the editor and on the site. When you update the guides, update the editor too.
Every tool call costs the user's chat some tokens: what Claude sends to the tool, and what the tool sends back. The tool list and instructions are sent on every turn.
A statistics page for developers shows which tools are worth making cheaper: by tool, by request, and every call.