Problem/Motivation
The MCP Content plugin currently exposes node content as raw field JSON:
- It does not respect site presentation (view modes).
- It’s suboptimal for LLM/AI consumption, which benefits from rendered text/Markdown.
- It bypasses Drupal’s render layer and formatting.
- It only supports a limited set of field types, forcing manual, lossy extraction of values; complex fields (e.g., paragraphs, lists with formatters) are not faithfully represented.
We need to expose rendered content as complete Markdown, configurable by view mode, while preserving cacheability and language context.
Steps to reproduce
- Enable MCP and the mcp_extra submodule.
- Configure MCP to expose at least one content type.
- Request the resource node/{content_type}/{nid}.
- Observe the response is application/json with a subset of raw fields (only supported types), not the fully rendered content as Markdown.
Proposed resolution
- Integrate the markdownify.entity_converter service to convert node entities to Markdown based on Drupal’s render process.
- Add a requirement: ensure markdownify module is enabled.
- Add a global configuration option to select the node view mode for rendering (default: full), using EntityDisplayRepository to populate choices.
- Keep content type metadata endpoints as JSON; only node content responses become Markdown.
- Keep the search tool (search-content) and return resources built from the new Markdown rendering.
- This approach removes the current field-type limitations by returning the complete, formatter-aware Markdown output, including complex fields.
Remaining tasks
Test and review changes.
User interface changes
In the Content plugin configuration form:
- Add a “View mode for content rendering” select with available node view modes.
- Default to full and include help text about Markdown conversion.
API changes
For node resources node/{type}/{id}:
- mimeType changes from application/json to text/plain.
- text now contains the rendered Markdown for the node using the configured view mode, including complex fields via formatters.
Content type metadata endpoints remain JSON.
Data model changes
No data model changes.
Comments