Problem/Motivation
When attempting to use the search-content tool through the MCP server, the following error occurs:
Request Failed: 400 {
"error": {
"message": "Invalid schema for function 'mcp_mcp-server-dr_content_search_content':
In context=('properties', 'filters', 'items', 'properties', 'value', 'type', '2'),
array schema missing items.",
"code": "invalid_function_parameters"
}
}
The error indicates that the JSON Schema for the value property in the filters configuration is invalid. Specifically, when 'array' is specified as a type in the type array, JSON Schema requires an items property to define what the array contains.
Steps to reproduce
- Enable the MCP module with the Content plugin
- Configure the Content plugin to expose article content type
- Attempt to call the
search-contenttool via MCP - Observe the 400 error with invalid schema message
Proposed resolution
Replace the type array notation with oneOf to properly define each type variant, including the required items property for arrays.
Current code (incorrect) in src/Plugin/Mcp/Content.php (line 347-350):
'value' => [
'type' => ['string', 'number', 'array'],
'description' => 'Value to filter by',
],
Proposed fix:
'value' => [
'description' => 'Value to filter by',
'oneOf' => [
['type' => 'string'],
['type' => 'number'],
[
'type' => 'array',
'items' => [
'oneOf' => [
['type' => 'string'],
['type' => 'number'],
],
],
],
],
],
Why This Fix Works
According to JSON Schema specification:
- When using
"type": "array", the schema must include anitemsproperty to define the structure of array elements - Using
oneOfallows defining multiple type alternatives where each can have its own complete schema definition - This approach properly validates that array values contain either strings or numbers
Additional context
This issue affects all MCP clients (Claude Desktop, custom implementations, etc.) trying to use the Content plugin's search functionality. The schema validation happens at the MCP client level before the request is even sent to the Drupal server.
Related Resources
Issue fork mcp-3555455
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
Comment #3
robertoperuzzoComment #4
gagosha commented