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

オープン
#20,404 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@i-just がすでに取り組んでいます。

2026年11月6日 から。

評価

この issue はまだ評価されていません。

説明

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
主要言語
PHP
スター
3.6k
フォーク
712
平均マージ
13時間 13分
マージ済み PR(30日)
372

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

craftcms/cms のほかの issue

craftcms/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。