Invalid JSON Schema in Content plugin's search-content tool causes 400 error
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3555455. --> Reported by: [robertoperuzzo](https://www.drupal.org/user/2661375) Related to !40 >>> <h2>Problem/Motivation</h2> <p>When attempting to use the <code>search-content</code> tool through the MCP server, the following error occurs:</p> <pre> 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" } } </pre><p>The error indicates that the JSON Schema for the <code>value</code> property in the filters configuration is invalid. Specifically, when <code>'array'</code> is specified as a type in the <code>type</code> array, JSON Schema requires an <code>items</code> property to define what the array contains.</p> <h2>Steps to reproduce</h2> <ol> <li>Enable the MCP module with the Content plugin</li> <li>Configure the Content plugin to expose article content type</li> <li>Attempt to call the <code>search-content</code> tool via MCP</li> <li>Observe the 400 error with invalid schema message</li> </ol> <h2>Proposed resolution</h2> <p>Replace the <code>type</code> array notation with <code>oneOf</code> to properly define each type variant, including the required <code>items</code> property for arrays.</p> <p><strong>Current code (incorrect)</strong> in <code>src/Plugin/Mcp/Content.php</code> (line 347-350):</p> <pre><div class="codeblock"><code class="language-php">'value'&nbsp;&nbsp;&nbsp; =&gt; [<br>&nbsp; 'type'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; ['string', 'number', 'array'],<br>&nbsp; 'description' =&gt; 'Value to filter by',<br>],<p><strong>Proposed fix:</strong></p> <pre><div class="codeblock"><code class="language-php">'value'&nbsp;&nbsp;&nbsp; =&gt; [<br>&nbsp; 'description' =&gt; 'Value to filter by',<br>&nbsp; 'oneOf'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; [<br>&nbsp;&nbsp;&nbsp; ['type' =&gt; 'string'],<br>&nbsp;&nbsp;&nbsp; ['type' =&gt; 'number'],<br>&nbsp;&nbsp;&nbsp; [<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'type'&nbsp; =&gt; 'array',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'items' =&gt; [<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'oneOf' =&gt; [<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ['type' =&gt; 'string'],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ['type' =&gt; 'number'],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ],<br>&nbsp;&nbsp;&nbsp; ],<br>&nbsp; ],<br>],<h3>Why This Fix Works</h3> <p>According to JSON Schema specification:</p> <ul> <li>When using <code>"type": "array"</code>, the schema <strong>must</strong> include an <code>items</code> property to define the structure of array elements</li> <li>Using <code>oneOf</code> allows defining multiple type alternatives where each can have its own complete schema definition</li> <li>This approach properly validates that array values contain either strings or numbers</li> </ul> <h2>Additional context</h2> <p>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.</p> <h3>Related Resources</h3> <ul> <li><a href="https://json-schema.org/understanding-json-schema/reference/array.html">JSON Schema Specification</a></li> <li><a href="https://modelcontextprotocol.io/docs/concepts/tools">MCP Tools Documentation</a></li> </ul> </code></div></pre></code></div></pre>
issue