Integrations

MCP

Vizy fields work with Craft’s Model Context Protocol (MCP) server, so an AI client can read and edit their content. For example, you can ask a connected client to summarise an article’s body, rewrite its introduction, or add a Callout block after the second paragraph.

This integration requires Craft 5.12.1 or later. Vizy still works on earlier supported Craft versions, but the MCP server isn’t available there, and on Craft 5.12.0 clients read a Vizy field’s stored JSON instead of the format described below.

Connecting a Client

Follow Craft’s MCP setup instructions (opens new window) to connect a client through the authenticated HTTP server or the local mcp/serve command. Vizy doesn’t add tools of its own. A Vizy field is read and saved through Craft’s elements_* tools along with the other fields of the entry, or any other element, that it belongs to.

The client acts as the signed-in user and follows the same permissions as the control panel. An HTTP connection authorised for read-only access can read Vizy fields, and editing them also requires write access.

Reading a Vizy Field

elements_get returns a Vizy field along with the rest of an element’s fields. Name the field in fields to read only that field, which also includes the nested entries of any Matrix fields inside its blocks. For example, if your entry has a Vizy field with the handle bodyContent, these arguments read it from entry 42:

{
  "type": "entries",
  "id": 42,
  "fields": ["bodyContent"]
}

The field’s value is its document. Text, headings, lists, tables and layouts appear as nodes, each with a type, its attrs and its child nodes in content. A text node holds its text and any marks, such as bold or a link. Links also include their href, and links to an entry, asset or category include the linked element’s elementId. Each block appears with its Block Type’s handle in blockType and the values of its fields in fields, keyed by field handle.

For example, a paragraph linking to a guide, followed by a Callout block, reads like this:

{
  "type": "doc",
  "attrs": { "schemaVersion": 2 },
  "content": [
    {
      "type": "paragraph",
      "content": [
        { "type": "text", "text": "Read our " },
        {
          "type": "text",
          "text": "guide",
          "marks": [
            {
              "type": "link",
              "attrs": { "type": "url", "value": "https://example.com/guide", "newWindow": false },
              "href": "https://example.com/guide"
            }
          ]
        }
      ]
    },
    {
      "type": "vizyBlock",
      "attrs": {
        "blockUid": "8f2c6a3e-5d1b-4c2a-9e7f-1a2b3c4d5e6f",
        "blockTypeUid": "0b7d9e21-4a6f-4f53-8c1e-6d2f0a9b8c7d",
        "enabled": true
      },
      "blockType": "callout",
      "fields": {
        "heading": "Before you start",
        "featured": true,
        "relatedArticles": [17, 23]
      }
    }
  ]
}

Field values inside blocks are returned the same way Craft returns the entry’s own fields, and only the fields the user can see are included. A link to an element the user can’t view keeps its stored destination but has no href or elementId. Disabled blocks are included with enabled set to false, and Craft’s public MCP server leaves them out, as the front end does.

Editing a Vizy Field

Saving a Vizy field replaces its whole document, so read the field first, change what you need, and send the complete document back with elements_update. The document can go back in the same shape elements_get returned it. Call elements_field_schema for the entry to see exactly what the field accepts, including the fields of each Block Type.

For example, these arguments to elements_update change the introduction and the Callout block’s heading, and keep everything else as it was read:

{
  "type": "entries",
  "id": 42,
  "fields": {
    "bodyContent": {
      "type": "doc",
      "attrs": { "schemaVersion": 2 },
      "content": [
        {
          "type": "paragraph",
          "content": [
            { "type": "text", "text": "Start with our " },
            {
              "type": "text",
              "text": "guide",
              "marks": [
                {
                  "type": "link",
                  "attrs": { "type": "url", "value": "https://example.com/guide", "newWindow": false },
                  "href": "https://example.com/guide"
                }
              ]
            }
          ]
        },
        {
          "type": "vizyBlock",
          "attrs": {
            "blockUid": "8f2c6a3e-5d1b-4c2a-9e7f-1a2b3c4d5e6f",
            "blockTypeUid": "0b7d9e21-4a6f-4f53-8c1e-6d2f0a9b8c7d",
            "enabled": true
          },
          "blockType": "callout",
          "fields": {
            "heading": "Read this first",
            "featured": true,
            "relatedArticles": [17, 23]
          }
        }
      ]
    }
  }
}

The href and elementId on links and a block’s blockType are only there to read, so Vizy ignores them. To change where a link points, change its attrs, and to change a block’s type, change its attrs.blockTypeUid.

To add a block, give it a new UUID as its blockUid, the blockTypeUid of the Block Type you want, and its values in fields. Keep each existing block’s blockUid. Include every field you want to keep, because a field left out of fields is saved empty. A handle the Block Type doesn’t have is rejected with a message listing the fields it does have. Matrix fields inside blocks can’t be changed through a Vizy field, so their values in fields are ignored and their nested entries stay as they are.

Vizy stores block values keyed by the UID of each field’s placement in the Block Type’s field layout. A block can also be sent with its values in attrs.fieldSlots keyed by those placement UIDs, which the field schema lists, in place of fields. That’s also how to set a field whose handle more than one field in the layout uses.

Vizy validates the document as it does when an editor saves the entry. The field’s Editor Config limits which formatting and nodes can be added, and its block settings limit which Block Types can be added. Block fields the user can’t see or edit keep their stored values, whatever the client sends. Sending null clears the field.