[5.x] MCP: `configuration.update` fails for Matrix fields with TypeError on `$propagationMethod`

クローズ
#20,406 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

@brandonkelly がすでに取り組んでいます。

2026年11月6日 から。

  • #20428 @brandonkelly による — マージ済み

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php

調査の方向性

Start in craft\mcp\capabilities\Fields::update() and trace how field settings reach Craft::configure(), comparing that path with Matrix field construction and its propagationMethod normalization. Reproduce with the craft shell commands in the report, then check the MCP update and error handling paths. Done when Matrix settings updates save successfully and failures return useful error details; the separate stdio config lock observation may need follow-up.

索引モデルが issue の本文から書いたものです。

説明

bug repo:cms
What happened?
Description

Updating the settings of a Matrix field via the MCP tool configuration.update (type fields) always fails. The MCP client only receives the generic error Error while executing tool. The console log only contains [mcp] Unhandled error during tool execution, without the exception.

Running the same steps as craft\mcp\capabilities\Fields::update() in craft shell shows the underlying exception:

TypeError: Cannot assign string to property craft\fields\Matrix::$propagationMethod of type craft\enums\PropagationMethod

Cause: Fields::update() builds the new attributes from the current settings:

$attributes = [...array_replace($field->getSettings(), $this->sensitiveValues->restore($settings, $field->getSettings())), ...$attributes];
Craft::configure($field, $attributes);

$field->getSettings() returns propagationMethod as the string 'all'. Craft::configure() then assigns that string directly to the typed property Matrix::$propagationMethod (PropagationMethod enum). This bypasses the normalization the Matrix constructor normally does. So any settings update on any Matrix
field fails, whatever settings are supplied. Creating a Matrix field via configuration.create works fine.

Steps to reproduce
  1. Have a Matrix field, e.g. handle components, with allowAdminChanges enabled.
  2. Start the MCP server: php craft mcp/serve --user=admin.
  3. Call configuration.update:
    {
      "type": "fields",
      "identifier": { "handle": "components" },
      "attributes": {
        "settings": {
          "entryTypes": [
            { "uid": "<existing entry type uid>" },
            { "uid": "<new entry type uid>" }
          ]
        }
      }
    }
    
  4. The tool returns Error while executing tool. Supplying no entryTypes and only another setting (e.g. maxEntries) fails the same way.

To see the exception directly, run in php craft shell:

$field = Craft::$app->getFields()->getFieldByHandle('components');
get_debug_type($field->getSettings()['propagationMethod']); // "string"
Craft::configure($field, $field->getSettings());            // TypeError
Expected behavior

The supplied settings are merged into the Matrix field and the field is saved, e.g. the new entry type is added. If something fails, the MCP response includes the actual error message.

Actual behavior
  • The update fails with a TypeError on Matrix::$propagationMethod before anything is saved.
  • The MCP client only gets Error while executing tool, and the log entry has no exception details. This makes the cause very hard to find.
Additional observation (stdio server)

Possibly related: with mcp/serve (stdio), after the first successful project config change (e.g. configuration.create), the long-running process seems to keep the project config lock. The project config is also not flushed to the projectconfig table, because the request never ends. Afterwards:

  • other craft CLI commands fail with craft\errors\BusyResourceException: A lock could not be acquired to modify the project config.
  • YAML is only written after calling project-config.write, and the stored config stays out of sync until the MCP process is restarted and project-config/apply runs.

Happy to open a separate issue for this if preferred.

Craft CMS version

5.12.0.1

PHP version

8.4.27

Operating system and version

macOS 27.0.1

Database type and version

MySQL 8.0.33

Image driver and version

No response

Installed plugins and versions

No response

主要言語
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 を短くまとめたダイジェスト。