MCP Server: Entity Seeder uses wrong type for content
**Project:** AI Agents (`ai_agents`) **Version:** 1.3.0 **Component:** Code — `Drupal\ai_agents\Plugin\AiFunctionCall\ContentEntitySeeder` (`ai_agent:content_entity_seeder`) I was using the mcp server on a brand new install. I tried getting Claude to make an article with some example text but it didn't work out. ContentEntitySeeder stores multi-property field values as literal "Array" (one nesting level dropped) **Problem** When the `content_entity_seeder` tool writes a field whose value goes through the `field_values` → `values` structure, it unwraps only **one** level of the nesting the tool schema defines, so the field receives an array where a scalar is expected. Drupal then string-casts it and stores the literal text `Array`. **Where** `ContentEntitySeeder::execute()`: `foreach ($lists['field_values'] as $field_value) { $values[$field_value['value_name']] = $field_value['values'][0]; } ` The `values` context (defined via `ContentEntityFieldValue`) is **doubly nested** — `[["the text"]]`. So `$field_value['values'][0]` is still `["the text"]` (an array), not `"the text"`. It should be `$field_value['values'][0][0]`. **Reproduce** Call the tool to set a node `body` (a `text_with_summary` field): `entity_type: node entity_id: 3 entity_array: - field_name: body field_values: - { value_name: value, values: [["<p>Hello</p>"]] } - { value_name: format, values: [["full_html"]] } ` The tool reports success, but the stored `body.value` and `body.format` are both the string `Array`. Verified via `drush`: `$node->get('body')->first()->value // => "Array" $node->get('body')->first()->format // => "Array" ` **Impact** Any agent using this tool to create/edit content silently corrupts every multi-property/scalar field value (body, text fields, etc.). The node `title`/`label` is unaffected because it's set through a separate path (the `label` context), which is why content gets created with a correct title but an empty/garbage body. **Suggested fix** `$field_value['values'][0]` → `$field_value['values'][0][0]` (or flatten one level). So Claude helped me tr ack this down and write the above report on what went down. I even uninstalled a bunch of modules to keep it minimal and I still had this issue. So I'm pretty sure this is a real bug and I am simply unable to get the mcp server to save actual text content. The content always just has: `Array` as the only thing I see. So in the meantime I had Claude patch it up and it seems to work now. Here is what it gave me to pop in my Dockerfile. ```diff Fix ContentEntitySeeder storing multi-property field values as the literal string "Array". The `values` context (ContentEntityFieldValue) is doubly nested — e.g. [["<p>html</p>"]] — but execute() unwrapped only one level with `[0]`, leaving an array where Drupal expects a scalar. Drupal then string-casts it, storing the literal text "Array" for body/text fields (title is unaffected because it is set via the separate `label` context path). Reported upstream: https://www.drupal.org/project/ai_agents/issues/<fill-in> --- a/src/Plugin/AiFunctionCall/ContentEntitySeeder.php +++ b/src/Plugin/AiFunctionCall/ContentEntitySeeder.php @@ -158,7 +158,7 @@ class ContentEntitySeeder extends FunctionCallBase implements ExecutableFunction $field_name = $lists['field_name']; $values = []; foreach ($lists['field_values'] as $field_value) { - $values[$field_value['value_name']] = $field_value['values'][0]; + $values[$field_value['value_name']] = $field_value['values'][0][0]; } $data[$field_name][] = $values; } ```
issue