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

  1. Enable the MCP module with the Content plugin
  2. Configure the Content plugin to expose article content type
  3. Attempt to call the search-content tool via MCP
  4. 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 an items property to define the structure of array elements
  • Using oneOf allows 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

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

robertoperuzzo created an issue. See original summary.

robertoperuzzo’s picture

Assigned: robertoperuzzo » Unassigned
Status: Active » Needs review
gagosha’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.