Hi!
First, thanks for your great module and the amazing list of tools you're shipping. I've been playing with the batch capabilities and faced an issue when trying to create nodes in batch with Claude Desktop using the STDIO server.
Below is the issue description (with the help of Claude!):
Problem
The mcp_batch_create_content tool cannot create content with fields. It fails with a schema validation error before reaching the PHP code.
Error:
validation_errors: [{ "message": "The data ({type}) must match the type: {expected}", "keyword": "type", "path": "items.0" }]
Root Cause
In ToolApiSchemaConverter::inputDefinitionToSchema() (line 173), when data_type: 'list' is used without a ListInputDefinition, the default schema is:
$schema['items'] = ['type' => 'string'];
This rejects complex objects like {"title": "...", "fields": {...}}.
Solution
- Change
data_type: 'list'→data_type: 'any'in input definitions - Add JSON decoding in
executeLegacy()since MCP passes complex types as JSON strings - Strengthen validation to ensure the decoded value is an array
Testing
✅ Tested with 5 items containing body + entity reference fields
✅ Tested with 50 items (maximum limit)
✅ 0 errors in both cases
Files Changed
modules/mcp_tools_batch/src/Plugin/tool/Tool/CreateMultipleContent.php
Additional Notes
mcp_batch_create_termsworks by chance because terms can be simple strings- The same issue likely affects
mcp_batch_update_contentand other batch tools with complex inputs - Render cache invalidation after batch creation may need separate investigation
A merge request will follow shortly.
Issue fork mcp_tools-3572001
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3572001-batch-create-content-list-to-any
changes, plain diff MR !1
Comments
Comment #4
mowens commentedThanks for the report and the extensive testing on this.
We fixed it in ToolApiSchemaConverter::inputDefinitionToSchema() directly - the default items schema for data_type: 'list' now generates {} instead of {"type": "string"}, so it accepts any type. This fixes all batch tools without needing to change each tool individually.
Won't be merging the MR directly since we went with the schema-level fix, but your diagnosis was spot-on and credited you in the commit.
Really appreciate the feedback. Let me know if you run into future issues.
Comment #6
mowens commented