---
title: "MCP Server"
description: "Manage Cmssy workspace content from AI agents using @cmssy/mcp-server. Setup, available tools, and the patch_block_content deep dive."
url: https://www.cmssy.com/docs/api/mcp
last_updated: 2026-10-09
---

# MCP Server

Manage cmssy content from AI agents over MCP - connect Claude to the hosted server by signing in, or run `@cmssy/mcp-server` over stdio with an API token.

## Overview

`@cmssy/mcp-server` is a Model Context Protocol server that bridges AI agents (Claude Code, Claude Desktop, any MCP-aware tool) to a Cmssy workspace. Once configured, the agent can list and edit pages, add or remove blocks, publish drafts, manage forms, and more - without ever leaving its editor.

It runs three ways: Claude connects to the hosted server at `https://api.cmssy.io/mcp` by signing in to cmssy, any client that takes an API key sends a `cs_` token to the same URL, and any MCP client can launch the npm package over stdio with an API token. None of them needs a long-lived server of your own.

### What makes it different from the HTTP API

- **Workspace-scoped** - a single token + workspace ID pair, everything enforced server-side
- **High-level tools** - `add_block_to_page`, `publish_page`, `patch_block_content`, not raw GraphQL
- **Tenant isolation built in** - every query is filtered by your workspace; you can't accidentally touch another tenant

## Connect Claude (no token)

Claude on the web, Claude Desktop and Claude Code connect to the hosted server at `https://api.cmssy.io/mcp`. You sign in to cmssy and pick the workspaces Claude may use - there is no token to copy and nothing to install.

### Claude on the web or desktop

1. Open **Settings → Connectors** and choose **Add custom connector**.
2. Paste `https://api.cmssy.io/mcp` and add it.
3. Click **Connect**, sign in to cmssy, tick the workspaces Claude may use and choose **Read only** or **Read and write**.

A connector added on claude.ai is available in Claude Desktop too.

### Claude Code

```bash
claude mcp add --transport http cmssy https://api.cmssy.io/mcp
```

Then run `/mcp` in Claude Code and authenticate: the same sign-in and workspace choice open in your browser.

In the admin, **Account → Connected apps → Connect an AI app** shows the same URL and commands with copy buttons.

### Codex

```bash
codex mcp add cmssy --url https://api.cmssy.io/mcp
codex mcp login cmssy
```

The login opens the same sign-in and workspace choice in your browser. After that, Codex can call the cmssy tools in any session.

### What Claude can do

- **Your role, per workspace** - Claude acts as you, with the role you hold in each workspace you ticked. Read only keeps it to reading even where your role could write.
- **Several workspaces at once** - every tool takes a `workspace` argument (`org-slug/workspace-slug`), and `list_workspaces` lists the ones you granted. A workspace you join later can be added under **Account → Connected apps → Edit workspaces**, no reconnect needed - it works on the app's next call.
- **Destructive tools ask first** - Claude asks you before a tool that deletes or publishes, and that approval is the check - the server adds no confirmation of its own (below).
- **Audited as you** - a change Claude makes is recorded in the workspace's audit log under your name, like a change you make in the admin.

### Disconnecting

**Account → Connected apps → Disconnect** cuts Claude off from every workspace at once. **Edit workspaces** adds or removes single workspaces without disconnecting. A workspace admin can remove one workspace from a member's app in **Settings → Connected apps**; the member's other workspaces keep working. Losing access to a workspace takes it out of your connections.

### What reaches Claude

Only the content of the workspaces you ticked, and only what a tool call returns. cmssy stores the connection itself (which app, which workspaces, read or write) and hashed tokens - never a copy of the conversation.

## Connect with an API token (hosted)

Tools that ask for a server URL and an API key - v0, Lovable, Bolt or your own MCP client - can use the hosted server with a `cs_` token instead of signing in. Create one under **API Tokens** in the dashboard sidebar, then give the client:

```
URL:    https://api.cmssy.io/mcp
Header: Authorization: Bearer cs_your_token_here
```

- **Workspaces** - a token scoped to one workspace reaches only that workspace; an unscoped token reaches every workspace you belong to, including ones you join later. `list_workspaces` names them, and every tool takes a `workspace` argument.
- **Permissions** - read and write, limited by your role in each workspace, the same as a GraphQL call with that token. There is no read-only option here - use the sign-in connection above for that.
- **Audit and limits** - a change is logged under your name with the token's id, and the call limit counts per token.
- **Revoking** - delete the token under API Tokens and the next call gets 401. Changing your password does not revoke API tokens, and Disconnect under Connected apps does not reach them.

## Set up with an API token (stdio)

For CI, scripts or an agent without a browser, run the npm package with an API token instead.

### 1. Create an API token

**API Tokens** in the dashboard sidebar → **Create Token**, then pick one workspace to scope it to, or keep every workspace you belong to. Copy the `cs_…` value immediately - tokens are shown once. Scope is authentication only; what the token can do is determined by your role and `isSuperAdmin` flag.

No browser? An agent can create the account, organization, workspace and token through the API - see [Creating a token without a browser](https://www.cmssy.com/docs/auth/api-tokens.md).

### 2. Find your workspace ID

**Settings → Workspace** has a copy button next to the ID, in the Workspace Information section. It's the same workspace tied to your [API token](https://www.cmssy.com/docs/auth/api-tokens.md).

### 3. Add it to your editor's MCP config

For Claude Code, edit `.mcp.json` in your project root (or register it for every project with `claude mcp add --scope user`):

```json
{
  "mcpServers": {
    "cmssy": {
      "command": "npx",
      "args": [
        "-y",
        "@cmssy/mcp-server@latest",
        "--token", "cs_your_token_here",
        "--workspace-id", "507f1f77bcf86cd799439011"
      ]
    }
  }
}
```

Environment-variable equivalents are also supported: `CMSSY_API_TOKEN`, `CMSSY_WORKSPACE_ID`, `CMSSY_API_URL`. Useful if you don't want the token in a committed config file.

`--api-url` (or `CMSSY_API_URL`) is the API origin and defaults to `https://api.cmssy.io`; the server appends `/graphql` itself, so leave it out. This differs from the SDK and CLI, where the same variable holds the full `/graphql` endpoint, so don't share one value between your app and the MCP server.

### 4. Restart the editor

Claude Code picks up the server on the next session start. You should see a `cmssy` MCP entry with the available tools listed.

## Available tools

The complete list, with the permission each tool needs, is [MCP tools](https://www.cmssy.com/docs/api/mcp-tools.md) - the server generates it on every release, so it always matches what your version exposes. The tools share one naming shape - `list_*` and `get_*` to read, `create_*` / `update_*` / `delete_*` to write, plus verbs for state transitions - and fall into these groups:

- **Pages and blocks** - the page tree, blocks, layout regions, page types and publishing: `get_page`, `add_block_to_page`, `patch_block_content`, `publish_page`. Call `list_block_types` before adding a block: it returns the block types your site actually registers.
- **Models and records** - schemas and their entries, including bulk `import_records`. `delete_record` refuses while a block still uses the record and names the pages that do; pass `force: true` to delete anyway.
- **Media** - uploads and folders.
- **Forms** - forms and their submissions.
- **Commerce** - products, orders (manual orders, payments, invoices, refunds, fulfillment, the order pipeline), carts, discounts and customers.
- **Webhooks** - subscriptions, deliveries and signing secrets. `list_webhook_event_types` is the allowlist of subscribable events; a signing secret is returned once, on create and on rotate.
- **Workspace** - `get_workspace_info` (plan, limits, usage), `get_site_config`, the team and roles.

Full-text `search_content` is not bound by the MCP server; it is reachable from the [in-admin assistant](https://www.cmssy.com/docs/editor/assistant.md). Nothing in the set touches your code: no tool writes a file, edits a component or opens a pull request - AI edits content, and block schemas stay in your repository under review.

## Guardrails on destructive actions

The MCP server has no confirmation step of its own: a tool whose effect is hard to undo - for example `delete_page`, `publish_page`, `refund_order`, `bulk_delete_products`, `start_bulk_delete_products` - runs on its first call. The check is your MCP client's tool approval - Claude Code, for example, asks before any tool that is not on your allowlist.

- Every tool carries MCP annotations: `readOnlyHint` on tools that only read, `destructiveHint` on tools that change or remove data, so a client can tell from `tools/list` which ones to hold for approval.
- A hosted connection granted read-only access refuses every write on the server, whatever the client approves.
- The admin's AI assistant still holds a destructive tool until you approve it with a button in the chat.

## Dev drafts: a block that is not deployed yet

Every write tool takes an optional `target`. `"draft"` (the default) edits the shared page draft; `"devDraft"` edits your own per-user overlay, which starts from the current page and changes nobody else's preview.

That is what makes it safe to compose a page around a block type that so far exists only on your machine. When the block ships, `promote_dev_draft` moves your overlay onto the shared draft. `get_page` with `target: "devDraft"` returns the overlay next to the shared draft, or `null` when you have none. It refuses with `DEV_DRAFT_PROMOTE_REFUSED` when the overlay would add `blockWarnings` the shared draft does not have, or would empty or remove a shared-draft block that holds content; the error lists the `blockWarnings` and `emptiedBlocks`. Fix the dev draft and promote again - `force: true` overrides the check, for when fixing is ruled out.

## patch_block_content - surgical edits

For targeted edits on multi-KB content (docs articles, long blog posts), `patch_block_content` sends only the diff - not the full string. Backed by MongoDB `findOneAndUpdate` with `$set` + `arrayFilters`, tenant-scoped, atomic. Typically \~10× cheaper in tokens than re-sending the whole HTML via `update_block_content`.

### Three operation types

#### `insert_before` / `insert_after`

Insert HTML directly before/after a unique marker. The marker MUST match exactly one location - zero or multiple occurrences reject the op with `BAD_USER_INPUT`.

```json
{
  "op": "insert_after",
  "marker": "<h2>Pricing</h2>",
  "html": "<p>Plans start at $0/month.</p>"
}
```

#### `replace_section`

Replace everything from `startMarker` (inclusive) to `endMarker` (exclusive). Both markers must resolve uniquely.

```json
{
  "op": "replace_section",
  "startMarker": "<h2>Pricing</h2>",
  "endMarker": "<h2>FAQ</h2>",
  "html": "<h2>Pricing</h2><p>New plans here.</p>"
}
```

### Multiple ops in one call

Operations apply in order on the running result. Any failure (missing marker, ambiguous, etc.) aborts the whole patch - no half-applied state.

```json
{
  "pageId": "...",
  "blockId": "...",
  "locale": "en",
  "operations": [
    {
      "op": "insert_before",
      "marker": "<h2>Appendix</h2>",
      "html": "<h2>New Section</h2><p>…</p>"
    },
    {
      "op": "replace_section",
      "startMarker": "<h2>Pricing</h2>",
      "endMarker": "<h2>FAQ</h2>",
      "html": "<h2>Pricing</h2><p>Updated.</p>"
    }
  ]
}
```

### When an operation fails

- **0 matches** - marker not found. Check for an exact character-level match; whitespace and attribute order matter.
- **2+ matches** - marker isn't unique. Add surrounding HTML to disambiguate. Overlapping matches count (`"aa"` in `"aaa"` counts as 2), so avoid ultra-short markers.
- **Field not a string** - the targeted `fieldPath` resolves to an array or object. Use `update_block_content` for structured fields.
- **Layout blocks not supported** - header/footer and other layout blocks go through `update_block_content`.

## patch_block_content vs update_block_content

|   | `patch_block_content` | `update_block_content` |
| - | - | - |
| When to use | Targeted edits on an HTML string | Full content rewrite, any shape |
| Token cost | Proportional to the diff | Proportional to the full content |
| Typical savings | \~10× on multi-KB content | – |
| Field types | String only (via `fieldPath`) | Any (strings, arrays, nested objects) |
| Partial failure | Whole patch aborts - no half-applied state | Whole write applies or fails |
| Layout blocks | Not supported | Supported |

**Rule of thumb:** if you'd previously re-send the entire HTML to change one paragraph, use `patch_block_content`. Otherwise stick with `update_block_content`.

## Troubleshooting

- **Every call fails with 404** - `--api-url` ends in `/graphql`. Pass the origin only (`https://api.cmssy.io`, the default) - the server appends the path itself.
- **“Workspace not found”** - the user behind the token is not a member of the given `--workspace-id`, or the id is wrong. A token authenticates a person; what it may do comes from that person's role in that workspace. Check the pair in Workspace Settings.
- **“Not authenticated”** - token expired or revoked. Create a new one from API Tokens in the dashboard sidebar.
- **MCP server not visible in the editor** - restart the editor after config changes. In Claude Code, check *Settings → MCP → cmssy* for startup logs.
- **Rate limits / plan limits** - writes count against your organization's plan limits (see [Plans, limits and usage](https://www.cmssy.com/docs/editor/limits.md)) and the [rate limits](https://www.cmssy.com/docs/api/rate-limits.md); a `429` carries `Retry-After`, so wait that long and retry. `get_workspace_info` shows current usage vs limits.

## Response mode

Every write tool accepts an optional `response: "minimal" | "full"` param (default `"minimal"`). Minimal returns a small compact-JSON ack (\~100-200 bytes) with just the IDs and state you need to chain the next call - not the full mutated resource.

### Minimal ack shapes

- Page tools (`create_page`, `update_page_blocks`, `update_page_settings`, `publish_page`, `unpublish_page`, `revert_to_published`, `update_page_layout`) - `{id, slug, hasUnpublishedChanges, updatedAt}` (+`published` on publish/unpublish)
- Block-on-page tools (`add_block_to_page`, `update_block_content`, `remove_block_from_page`) - `{pageId, blockId, hasUnpublishedChanges, updatedAt}`
- Form tools (`create_form`, `update_form`) - `{id, slug, status, updatedAt}`
- Model tools (`create_model`, `update_model`) - `{id, slug, updatedAt}`
- Record tools (`create_record`, `update_record`) - `{id, status, updatedAt}`

### When to opt into `full`

Pass `response: "full"` when you actually need the full mutated resource in the same call - e.g. to verify a complete transformation, read a server-generated field, or debug. Otherwise chain a follow-up read tool (`get_page` / `get_form` / `get_model` / `get_record`).

### Tools that don't take `response`

Already return a compact ack and are unchanged: `patch_block_content`, all `delete_*`, `update_form_submission_status`, `import_records`.

## Version

Use `@cmssy/mcp-server@latest` in `.mcp.json` to pick up new tools as they ship; `npx @cmssy/mcp-server --version` prints the version you run. Every release republishes [MCP tools](https://www.cmssy.com/docs/api/mcp-tools.md) from the server itself, so that page always matches the newest version.
