- Issue created by @roromedia
- 🇬🇪Georgia gagosha
Summary
The MCP Content plugin's
search-content
tool consistently fails with an "Unknown field: status" error when attempting to search for any content, even with empty filters. This affects all content searches through the MCP interface.Steps to Reproduce
- Install MCP module (tested with latest dev version)
- Enable the Content plugin in MCP Extra
- Attempt to search for any content using the MCP content search tool:
{ "contentType": "YOUR_CONTENT_TYPE", "filters": [], "limit": 10 }
- Error occurs: "Unknown field: status"
Expected Behavior
Content search should work without errors and return matching nodes.
Actual Behavior
All content searches fail with "Unknown field: status" error, making the MCP content search functionality unusable.
Root Cause Analysis
The issue is in
web/modules/contrib/mcp/modules/mcp_extra/src/Plugin/Mcp/Content.php
in thesearchContent()
method around line 430:$query = $this->entityTypeManager->getStorage('node')->getQuery() ->accessCheck(TRUE) ->condition('type', $contentType) ->condition('status', 1) // <-- This line adds a status condition ->range($offset, $limit) ->sort('created', 'DESC'); // <-- This line sorts by created field
The method automatically adds conditions for
status
(to show only published content) and sorts bycreated
, but theisSupportedField()
method only recognizestitle
,body
, and custom fields starting withfield_
. Core Drupal fields likestatus
,created
,nid
, etc. are not included in the supported fields list.Later in the code, when processing user filters, it validates all fields (including the automatically added ones) against
isSupportedField()
, causing the error.Proposed Solution
Modify the
isSupportedField()
method to include core Drupal node fields that are used by the system:private function isSupportedField( FieldDefinitionInterface $fieldDefinition, ): bool { $supportedTypes = [ 'string', 'string_long', 'list_string', 'datetime', 'boolean', 'text_long', ]; $fieldName = $fieldDefinition->getName(); // Core fields that are used by the system automatically if (in_array($fieldName, ['title', 'body', 'status', 'created', 'changed', 'nid', 'uid', 'type'])) { return TRUE; } if (str_starts_with($fieldName, 'field_') && in_array( $fieldDefinition->getType(), $supportedTypes ) ) { return TRUE; } return FALSE; }
Additional Notes
- This affects the latest dev version as of the time of this report
- The issue makes the entire MCP content search functionality unusable
- The fix is minimal and only adds recognition for core Drupal fields that the system already uses
- Core fields added:
status
,created
,changed
,nid
,uid
,type
Environment
- Drupal version: 10.4.3
- MCP module: Latest dev version
- PHP version: 8.3
Patch
The fix involves changing line ~560 in
Content.php
from:if (in_array($fieldName, ['title', 'body'])) {
to:
if (in_array($fieldName, ['title', 'body', 'status', 'created', 'changed', 'nid', 'uid', 'type'])) {
This ensures that core Drupal fields used by the search system are recognized as supported fields.