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

  1. Change data_type: 'list'data_type: 'any' in input definitions
  2. Add JSON decoding in executeLegacy() since MCP passes complex types as JSON strings
  3. 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_terms works by chance because terms can be simple strings
  • The same issue likely affects mcp_batch_update_content and 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

Command icon 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:

Comments

guillaumeg created an issue. See original summary.

  • mowens committed c5d22418 on master
    Fix list schema rejecting complex objects in batch tools
    
    The default...
mowens’s picture

Thanks 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.

mowens’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.