Persistence model
The MCP server is a stateless connector. The live editor owns design state, and your host application is responsible for storing and retrieving the authoritative design JSON — the MCP server never writes template content to a database on your behalf.
How it works​
MCP sessions connect an AI client or backend to a live editor. AI mutations flow through MCP to the editor over the live bridge, and the editor returns each tool result to MCP.
Nothing is written to persistent storage by the MCP server itself.
Where designs live​
| Layer | What it holds | Lifetime |
|---|---|---|
| Editor (browser) | Full design state in Redux | Active editor session |
| MCP server | Session metadata, pairing state, and routing state | Active MCP session / TTL |
mcp_sessions PG row | Session metadata only — id, project, auth, TTL | Session TTL (default 2 h) |
| Your host application's database | Authoritative design JSON | Whatever you decide |
The mcp_sessions row survives a Cloud Run revision swap or server restart. When the editor reconnects, it re-pairs using the same session id and resumes routing tool calls to the editor. No design data is lost as long as your host app has persisted the latest snapshot.
Recommended host app pattern​
Wire up onChange in your SDK config to persist the design whenever the editor changes, and call loadDesign on mount to restore it.
import { DragbleEditor, type DesignData, type DesignJson } from '@dragble/editor-sdk';
const templateId = 'tpl_abc123';
// Initialise the editor and register the change handler
const editor = new DragbleEditor({
// ...your other config...
onChange: async (data: DesignData) => {
await fetch(`/api/templates/${templateId}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ design: data.design }),
});
},
});
// On mount, load the saved design from your database
async function initEditor() {
const res = await fetch(`/api/templates/${templateId}`);
const { design }: { design: DesignJson } = await res.json();
editor.loadDesign(design);
}
initEditor();
onChange fires after every user or live AI-driven mutation. Debounce or batch writes if your API has rate limits.
FAQ​
How do I support cross-device editing?​
Store the design JSON in your own database, keyed by template id. When a user opens the editor on a second device, fetch the latest JSON from your database and call editor.loadDesign(design). The MCP server has no role in that lookup.
What happens during a Cloud Run revision swap?​
The mcp_sessions row in Postgres survives the swap because it lives outside the container. Once the new revision is up, the editor reconnects and re-pairs with the same session id. No design data is lost as long as your host app has persisted the latest snapshot.
Can AI clients edit while the editor is closed?​
No. MCP design tools require a connected editor because the editor owns the design state. If the editor is closed or disconnected, tool calls return EDITOR_NOT_CONNECTED.
Where do design exports and backups live?​
In your host application. For durable backups, save the JSON returned by the editor SDK (exportJson, getDesign, or your onChange payload, depending on your integration). MCP export tools operate through the live editor session and do not replace your persistence layer.