Drupal is a registered trademark of Dries Buytaert
drupal 10.6.12 Update released for Drupal core (10.6.12)! drupal 11.3.13 Update released for Drupal core (11.3.13)! drupal 10.6.11 Update released for Drupal core (10.6.11)! drupal 11.3.12 Update released for Drupal core (11.3.12)! drupal 11.2.14 Update released for Drupal core (11.2.14)! drupal 10.5.12 Update released for Drupal core (10.5.12)! cms 2.1.3 Update released for Drupal core (2.1.3)! drupal 10.5.11 Update released for Drupal core (10.5.11)! drupal 11.3.11 Update released for Drupal core (11.3.11)! drupal 11.2.13 Update released for Drupal core (11.2.13)! drupal 10.6.10 Update released for Drupal core (10.6.10)! cms 2.1.2 Update released for Drupal core (2.1.2)! drupal 11.1.10 Update released for Drupal core (11.1.10)! drupal 10.5.10 Update released for Drupal core (10.5.10)! drupal 10.4.10 Update released for Drupal core (10.4.10)! drupal 11.2.12 Update released for Drupal core (11.2.12)! drupal 11.3.10 Update released for Drupal core (11.3.10)! drupal 10.6.9 Update released for Drupal core (10.6.9)! drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)!

views_mcp

No security coverage
View on drupal.org

Expose any Views display as a read-only MCP tool by flicking a setting on the display - no code. A companion to MCP Server: where MCP Server provides the Model Context Protocol runtime and the tool plugin system, Views MCP turns your existing, curated views into AI-callable tools.

What it does

A Views display extender adds an Expose as MCP tool setting to every display. Enable it on a display and Views MCP registers one MCP tool for that display. When an AI client calls the tool, the view is executed with the supplied exposed-filter values and pager, and the result rows are returned as structured data.

So a new AI-callable query is just a new (or newly-flagged) view display - no plugin code, no routes.

Requirements

  • Drupal 10.3+ or 11; PHP 8.3+.
  • drupal/mcp_server ^2.0@alpha - the MCP runtime and tool plugin system.
  • drupal/views (Drupal core).

Installation

Install with Composer and enable the module:

composer require drupal/views_mcp
drush en views_mcp

Note: MCP Server is currently an alpha release, so a site on the default stable minimum-stability cannot resolve it without opting in. Either require the dependency explicitly first (composer require drupal/mcp_server:^2.0@alpha), or set "minimum-stability": "alpha" with "prefer-stable": true in your root composer.json before requiring Views MCP.

Installation enables the Views MCP display extender in views.settings, which is what makes the Expose as MCP tool setting appear on displays. (Uninstall removes it again.)

Exposing a view

  1. Edit a view and select the display you want to expose - an existing page display, or a lean display you build just for the AI.
  2. In the display settings, open the Other section and click Expose as MCP tool.
  3. Enable Expose this display as a read-only MCP tool and save the view.

Per-display overrides on the same form:

Setting Effect Tool description override Optional. Shown to the AI client to explain what the tool does. Leave empty for a generated description. Tool ID override Optional machine name (lowercase letters, numbers and underscores) used as the tool ID - e.g. recent_content yields views_mcp.recent_content. Must be unique across all exposed displays. Leave empty to derive it from the view and display IDs (see below).

After flagging (or unflagging) a display, rebuild the cache so the tool list is regenerated (drush cr), then reload the MCP server in your AI client.

How the derived tool works

One tool is registered per flagged display. Its machine name is the Tool ID override when set, otherwise it is derived from the view and display IDs joined by a double underscore - for example, flagging the Page display of the content view yields views_mcp.content__page_1.

Inputs. The tool's input schema is built from the display:

  • Each exposed filter becomes a parameter, keyed by the filter's exposed identifier.
  • limit - page size, 1-100 (default 25).
  • offset - pagination offset (default 0).

Output. A successful call returns a {success, message, data} envelope. The data payload carries the view/display IDs, the rendered rows, the total row count, and paging metadata (returned, has_more, next_offset). To page through a large result set, pass the next_offset from one call as the offset of the next.

Execution. Field values are rendered to plain text and length-capped. The view runs in the current request context and its own access controls fully apply (see Security).

Security

  • Runs with the caller's access, never elevated. The view executes in the current request context (over STDIO, the anonymous account) and its own access controls fully apply, so a display only ever returns rows that account is permitted to see. The tool does not switch accounts or run as user 1. To expose a display whose data requires access, configure that access on the view (and grant it to the account the MCP transport runs as) rather than relying on the module to elevate. Flag only displays whose data is appropriate for your MCP client.
  • Read-only. The derived tools are declared read-only, non-destructive, and idempotent; they execute the view and read rows, and never write.
  • Always paginated. Results are capped (a limit of at most 100) and paged, so a flagged display cannot return an unbounded result set in a single call. Prefer flagging displays that are aggregated or have a sensible pager.
  • Exposure surface. A display is only reachable once it is explicitly flagged; nothing is exposed by default. MCP Server governs who can reach the tools over its transports.

Design notes

  • A setting, not a display type. Views Data Export / REST Export are display types because they render an HTTP response at a path. An MCP tool is invoked programmatically and returns structured data, so "AI-callable" is metadata on a display - a setting - not a new render pipeline.
  • Rendering inside a Fiber. The MCP SDK runs tool calls inside a PHP Fiber, and Drupal's renderer suspends the current fiber whenever it renders - which the SDK would otherwise drop. Field values are therefore rendered inside a self-driven fiber (renderSafe() in ViewsMcpTool).

Roadmap

Proof-of-concept. Before a stable contrib release: richer exposed-filter to JSON Schema typing (numbers, multi-value, operators), and optional rendered-vs-raw value modes.

Activity

Total releases
1
First release
Jun 2026
Latest release
6 hours ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.0.x-dev Dev Jun 26, 2026