# MCP server

The address of a project's MCP server, how it authenticates, how to add it to Claude Code and Cursor, and every tool with its arguments.

Every Mojimoto project has an MCP server. An agent connected to it reads the content model and creates, edits and publishes content as tool calls, limited to what its token allows.

Use it when you want Claude Code, Cursor or another MCP client to write content or change the content model. A site that only reads published content does not need it: that is what the [Content Delivery API](/docs/api/delivery) is for.

## Server address

```text
https://mojimoto.com/mcp/{project}
```

`{project}` is your project's id. The server speaks MCP over HTTP: the client sends each JSON-RPC message as a `POST` to that address.

It offers thirteen tools and one resource, and no prompts. It introduces itself as `Mojimoto Server`.

## Authenticate with a project token

Send one of the project's API tokens as a bearer token on every request:

```text
Authorization: Bearer mjmt_your_write_token
```

Create the token on the project's **API keys** page. The token decides which project the server works on and which tools it offers:

| Token | What it gets |
| --- | --- |
| A token with `write` and no limits | Every tool. |
| A token with `write`, limited to some operations | The two read tools, plus the tools for those operations. See [What a token can use](#what-a-token-can-use). |
| A token limited to some content types | Its tools only work on those types, and the lists only show them. |
| A token without `write` | The two read tools. It sees published content only, or drafts too if it has `preview`. |
| The project's public read token | No tools. Create a token for MCP instead. |

A request with no token or an unknown one is answered with HTTP `401`. A project whose subscription has ended, past its 30-day grace period, is answered with `402`. How tokens, abilities and limits work is on the [Authentication](/docs/api/authentication) page.

Requests are limited per token, per minute: 40 on the Free plan, 120 on Starter, 300 on Pro and 1,000 on Enterprise. Over the limit, the answer is `429`.

Every write is recorded against the token's name, so give each agent a token of its own.

## Add it to Claude Code

```bash
claude mcp add --transport http mojimoto https://mojimoto.com/mcp/acme \
  --header "Authorization: Bearer mjmt_your_write_token"
```

To keep the token out of your repository, put the server in the project's `.mcp.json` and let it read the token from the environment:

```json .mcp.json
{
  "mcpServers": {
    "mojimoto": {
      "type": "http",
      "url": "https://mojimoto.com/mcp/acme",
      "headers": {
        "Authorization": "Bearer ${MOJIMOTO_WRITE_TOKEN}"
      }
    }
  }
}
```

```bash
export MOJIMOTO_WRITE_TOKEN=mjmt_your_write_token
claude
```

`npx @mojimoto/cli init` writes that file for you. See [Claude Code](/docs/ai/claude-code).

## Add it to Cursor and other clients

Cursor reads `.cursor/mcp.json`:

```json .cursor/mcp.json
{
  "mcpServers": {
    "mojimoto": {
      "url": "https://mojimoto.com/mcp/acme",
      "headers": {
        "Authorization": "Bearer ${env:MOJIMOTO_WRITE_TOKEN}"
      }
    }
  }
}
```

Any other client works the same way, as long as it supports MCP servers over HTTP and lets you set a request header. Give it the server address and the `Authorization` header.

## Check the connection

The server answers plain HTTP, so `curl` can list the tools a token gets:

```bash
curl -X POST https://mojimoto.com/mcp/acme \
  -H "Authorization: Bearer mjmt_your_read_token" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

With a token that can only read, the answer lists the two read tools:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {
        "name": "list-content-types-tool",
        "title": "List Content Types Tool",
        "description": "List the content types (models) and their field schemas for the current project.",
        "inputSchema": {
          "type": "object",
          "properties": []
        },
        "annotations": []
      },
      {
        "name": "list-documents-tool",
        "title": "List Documents Tool",
        "description": "List documents in the current project, optionally filtered by content type, returning their current draft content.",
        "inputSchema": {
          "properties": {
            "type": {
              "description": "Filter by content type api_id, e.g. \"marketing_page\".",
              "type": "string"
            },
            "lang": {
              "description": "Locale code, e.g. \"en-gb\".",
              "type": "string"
            }
          },
          "type": "object"
        },
        "annotations": []
      }
    ]
  }
}
```

## What a token can use

A token with `write` can be limited to some operations when it is created. Each operation unlocks its own tools:

| Operation | Tools |
| --- | --- |
| None needed | `list-content-types-tool`, `list-documents-tool` |
| `draft` (create and edit drafts) | `create-document-tool`, `update-document-tool` |
| `publish` (publish and unpublish) | `publish-document-tool`, `unpublish-document-tool` |
| `delete` (delete entries) | `delete-document-tool` |
| `upload` (upload media) | `upload-asset-tool` |
| `model` (change content models) | `create-content-type-tool`, `update-content-type-tool`, `add-field-tool`, `update-field-tool`, `remove-field-tool` |

A tool the token cannot use is left out of its tool list. A token made for drafting, with `draft` and `upload`, sees five tools: the two read tools, `create-document-tool`, `update-document-tool` and `upload-asset-tool`.

## The content model resource

The server has one resource, `mojimoto://content-model`, served as `application/typescript`.

It is the project's content model as generated TypeScript types: every content type, its fields and the shape of their values, including block types. It is the same file the [types endpoint](/docs/tools/generated-types) returns. An agent should read it before writing content or changing the model.

## How results and errors come back

A tool that worked returns one text item holding JSON:

```json
{
  "jsonrpc": "2.0",
  "id": 5,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\n    \"id\": 7,\n    \"uid\": \"ada\",\n    \"version_id\": 7\n}"
      }
    ],
    "isError": false
  }
}
```

A tool that refused returns `isError: true` and a sentence saying why:

```json
{
  "jsonrpc": "2.0",
  "id": 6,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Cannot publish - Site name is required."
      }
    ],
    "isError": true
  }
}
```

Calling a tool that is not in the token's list is a protocol error instead: code `-32602`, `Tool [delete-document-tool] not found.`

The rest of this page shows each tool's arguments and the JSON inside that text item.

## Read tools

### list-content-types-tool

Lists the content types and their fields. It takes no arguments.

```json
{
  "content_types": [
    {
      "api_id": "author",
      "label": "Author",
      "repeatable": true,
      "fields": ["name", "slug", "role"],
      "schema": {
        "Main": {
          "name": { "type": "symbol", "config": { "label": "Name", "required": true } },
          "slug": { "type": "slug", "config": { "label": "Slug" } },
          "role": { "type": "symbol", "config": { "label": "Role" } }
        }
      }
    }
  ]
}
```

`schema` is the type's tabs, each a map of field id to `{"type", "config"}`. `fields` is the same field ids as a flat list. The result does not include the type's `format`, and `repeatable` is a legacy flag that does not tell you. To see a format, read `GET /api/v1/{project}/content-types`.

### list-documents-tool

Lists the entries in the project. All of them come back in one result.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | No | Only entries of this content type. |
| `lang` | string | No | The locale to read. Defaults to the project's default locale. |

```json
{
  "documents": [
    {
      "id": 2,
      "uid": "sam-baker",
      "type": "author",
      "has_published": true,
      "data": {
        "name": "Sam Baker",
        "slug": "sam-baker",
        "role": "Head baker"
      }
    }
  ]
}
```

`data` is the content as it is stored, not as the delivery API serves it: a reference is an entry id and a media field is `{"asset_id", "fit"}`. A token with `write` or `preview` gets each entry's working draft. Any other token gets published content, and entries with nothing published are left out.

## Content tools

### create-document-tool

Creates an entry. Needs the `draft` operation.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | The content type's api id. |
| `uid` | string | For `page` types | The entry's URL slug. Leave it out for `single` and `component` types. |
| `lang` | string | No | The locale of the first draft. Has to be one of the project's locales. Defaults to the default locale. |
| `data` | object | No | Field values, saved as the first draft. |

```json
{
  "id": 7,
  "uid": "ada",
  "version_id": 7
}
```

`version_id` is only there when you sent `data`. The entry is not published: call `publish-document-tool` for that. An entry created without `data` has no versions, so it cannot be delivered or resolved from a reference until it has content.

### update-document-tool

Saves a draft of an entry. Needs the `draft` operation.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `document_id` | integer | Yes | The entry's id. |
| `lang` | string | No | The locale to write. Has to be one of the project's locales. |
| `data` | object | Yes | Field values, keyed by field id. |

```json
{
  "version_id": 12,
  "status": "draft"
}
```

Each call saves a new version that holds exactly the `data` you send. Fields you leave out are not carried over from the last draft, so send them all. Field rules such as `required` are not checked on a draft.

### publish-document-tool

Publishes an entry in one locale. Needs the `publish` operation.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `document_id` | integer | Yes | The entry's id. |
| `lang` | string | No | The locale to publish. Has to be one of the project's locales. |
| `data` | object | No | Field values to publish in place of the latest draft. |

```json
{
  "published": true,
  "version_id": 11,
  "uid": "home"
}
```

Without `data`, the latest draft is published. This is where field rules are checked. If any fail, nothing is published and the error lists them: `Cannot publish - Site name is required.`

### unpublish-document-tool

Takes an entry's locale off the delivery API without deleting anything. Needs the `publish` operation.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `document_id` | integer | Yes | The entry's id. |
| `lang` | string | No | The locale to unpublish. Has to be one of the project's locales. |

```json
{
  "unpublished": true,
  "id": 1,
  "lang": "en-gb"
}
```

The published content is kept as the working draft. The entry becomes a `404` on the delivery API and references to it collapse to stubs. Publish it again to bring it back. Unpublishing a locale that is not published is an error.

### delete-document-tool

Permanently deletes an entry and its version history. Needs the `delete` operation.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `document_id` | integer | Yes | The entry's id. |

```json
{
  "deleted": 6
}
```

A `reference` that pointed at the entry resolves to `null`, and the entry drops out of any `references` list. Use `unpublish-document-tool` when the content might come back.

### upload-asset-tool

Uploads an image or a file to the project's media library. Needs the `upload` operation.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | One of these two | A public `http` or `https` address to download the file from. |
| `content_base64` | string | One of these two | The file itself, base64-encoded. |
| `filename` | string | With `content_base64` | The filename with its extension, such as `hero.jpg`. With `url` it defaults to the last part of the address. |
| `alt` | string | No | Alt text, stored on the asset and delivered with every field that uses it. |

```json
{
  "id": 7,
  "url": "https://…/hero.jpg",
  "filename": "hero.jpg",
  "mime_type": "image/jpeg",
  "width": 2400,
  "height": 1200,
  "alt": "A loaf on a wooden board",
  "media_field_value": {
    "asset_id": 7,
    "fit": "cover"
  }
}
```

Write `media_field_value` into a `media` field as it is. Change `fit` to `contain` if the image should not be cropped.

- Send `url` or `content_base64`, never both.
- The file can be up to 20MB.
- Redirects are not followed. Give the final address.
- An address that resolves to a private network is refused.
- `width` and `height` are `null` for files that are not images.

## Model tools

All five need the `model` operation. They change one thing at a time, so they never overwrite a field a person set up by hand.

### create-content-type-tool

Creates a content type with an empty `Main` tab. Add its fields with `add-field-tool`.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `api_id` | string | Yes | A snake_case id, such as `blog_post`. |
| `label` | string | No | The name editors see. Defaults to the api id made readable. |
| `format` | string | No | `page` (a collection, the default), `single` or `component`. |
| `repeatable` | boolean | No | A legacy flag. It does not make a single. Use `format`. |

```json
{
  "api_id": "hero_section",
  "schema": {
    "Main": []
  }
}
```

It fails if the api id is taken: `A content type "hero_section" already exists.` Which format to choose is in the [Content modelling guide for agents](/docs/ai/modelling-guide).

### update-content-type-tool

Changes a content type's label, format or icon. Its fields are not touched.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | The content type's api id. |
| `label` | string | One of these three | The new label. |
| `format` | string | One of these three | `page`, `single` or `component`. |
| `icon` | string | One of these three | The name of the type's sidebar icon. |

```json
{
  "api_id": "author",
  "label": "Writer",
  "format": "page"
}
```

A type can become `single` only while it has at most one entry, and `page` only when every entry has a `uid`.

### add-field-tool

Adds one field to a content type.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | The content type's api id. |
| `field` | string | Yes | A snake_case id for the new field. |
| `definition` | object | Yes | The field, as `{"type": "symbol", "config": {"label": "Heading"}}`. |
| `tab` | string | No | The tab to put it in. Defaults to the type's first tab. |

It returns the type's `api_id` and its whole `schema` with the new field in it. It fails if the field exists: `Field "title" already exists on "page". Use update to change it.`

The field types and their `config` keys are on the [Field types](/docs/concepts/field-types) page.

### update-field-tool

Replaces the definition of one field. Every other field is left as it is.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | The content type's api id. |
| `field` | string | Yes | The id of the field to replace. |
| `definition` | object | Yes | The whole new definition. |

It returns the type's `api_id` and whole `schema`. The definition is replaced, not merged: send every setting the field should keep. For a `blocks` field that means every block type.

### remove-field-tool

Removes one field from a content type.

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | Yes | The content type's api id. |
| `field` | string | Yes | The id of the field to remove. |

It returns the type's `api_id` and whole `schema`. Removing a field changes the model only. Values already stored under that id stay in existing entries, and are still delivered, until those entries are saved without them.

## What the tools do not cover

- **Deleting a content type.** Use `DELETE /content-types/{type}` in the [Content Management API](/docs/api/management).
- **Reading one entry as a site would see it**, with references and media resolved. Use the [Content Delivery API](/docs/api/delivery).
- **Listing the media library.** Use `GET /assets` in the delivery API.

## What the server tells the agent

When a client connects, the server sends it a short set of instructions. In summary:

- The project is decided by the token, and the token may limit the tools and content types.
- Read `mojimoto://content-model` or list the content types before writing.
- The field tools change one field at a time and never overwrite other fields.
- Page sections that belong to one page go in a `blocks` field. A `references` field to `component` entries is for content shared between pages. Page structure does not go in a `json` field.
- Images and files go through `upload-asset-tool` first, and media fields store `{"asset_id", "fit"}`.

Those rules are set out in full in the [Content modelling guide for agents](/docs/ai/modelling-guide).
