[5.x]: MCP returns `[]` for CKEditor field values

Abierto
#20,404 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@i-just ya está trabajando en esto.

Desde el 6/11/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

repo:cms
What happened?

MCP can write CKEditor fields but can't read them back. The HTML saves to the database, but every read returns [] or leaves the field out. This happens in elements_get, elements_list, revisions, and the public craft_query tool. So an agent can't proofread or summarize rich text, and it can't check its own writes.

I think the cause is in src/mcp/serializers/ElementSerializer.php. The CKEditor field implements ElementContainerFieldInterface because it can hold Nested Entries, and the serializer treats every field with that interface as a list of nested elements:

  • Line 75: with fields: null, the field is skipped as a nested field.
  • Line 79: with fields: ["body"], it goes to nestedValue(). The value is a craft\ckeditor\data\FieldData object, not an element, query, or collection, so it falls through to default => [].

Should CKEditor fields go through $field->serializeValue() here, with Nested Entries added separately? The 6.x serializer has the same check.

Steps to reproduce
  1. Install CKEditor 5.9.0 and add a CKEditor field body to an Entry Type. No Nested Entry Types.
  2. Create an Entry with body set to <p>Hello</p>.
  3. Call elements_get with {"type": "entry", "id": <id>, "fields": ["body"]}.
  4. Call elements_get with {"type": "entry", "id": <id>, "fields": null}.
  5. Call elements_update with {"type": "entry", "id": <id>, "fields": {"body": "<p>Changed</p>"}}, then repeat step 3.
Expected behavior

body returns the HTML ("<p>Hello</p>") for both fields: ["body"] and fields: null.

Actual behavior
  • Step 3 returns "body": [].
  • Step 4 has no body key.
  • Step 5 saves <p>Changed</p> to elements_sites.content, but the read still returns [].

It's the same when body is inside a Matrix Block. The blocks come back with only a title. On the public server, that means a chatbot can't read article text even when the Section is approved.

Craft CMS version

5.12.0.1, and 5.x-dev (3419773)

PHP version

8.4.20

Operating system and version

DDEV 1.25.2 on macOS

Database type and version

MySQL 8.0.40

Installed plugins and versions
  • CKEditor 5.9.0
Lenguaje dominante
PHP
Estrellas
3.6k
Forks
712
Merge medio
13 h 13 min
PR fusionados (30 d)
372

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de craftcms/cms

Todos los issues de craftcms/cms

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.