feat: #3585942 Support MCP Apps through native plugins

Closes #3585942

Native MCP Server plugins currently cannot advertise an MCP App's UI resource or retain its content metadata throughout registration and reading. Modules have to bridge SDK registration themselves.

This MR enables the SDK's McpApps extension in the shared server factory and forwards generic metadata from native tools, resources, and resource templates. Tool derivatives inherit metadata unless explicitly replaced or cleared. Resource handlers return SDK content objects so text and blob _meta survives fresh and cached reads, including UI CSP metadata. Resource providers continue returning CacheableResourceContent.

MCP Apps is advertised unconditionally from the shared server factory. Reviewers should assess this proposed behavior, including whether advertisement should instead depend on configured app resources. Host rendering and the coordinated Tool API/Tool Bridge changes remain outside this MR.

Testing

Existing registration and functional tests cover extension advertisement and tool/resource metadata. Focused unit coverage checks derivative overrides and both resource handlers with fresh and cached text/blob content.

Current commit (3d2a374)

Pipeline #999112 passes with allowed failures. Default, previous-major (PHPUnit 9), and lowest-SDK PHPUnit jobs pass. Default, lowest-SDK, and next-SDK PHPStan jobs pass, as do PHPCS, cspell, and composer-lint.

The new resource handler test now exercises all four text/blob and resource/template combinations through a shared helper, removing its dependency on data provider attribute discovery. This fixes the blocking PHPUnit 9 failure from the first post-rebase pipeline.

Two allowed failures remain: previous-major PHPStan (also failing on the unchanged target branch) and next-SDK PHPUnit (the elicitation test receives JSON where it expects an event stream; the cause remains unconfirmed).

Local PHP syntax validation and git diff --check pass. The full local suite could not run because Docker was unavailable; validation above comes from CI.

Earlier validation, before the rebase

  • PHP MCP SDK 0.8.1: full suite passed (66 tests, 528 assertions).
  • PHP MCP SDK 0.7.1: relevant tests passed (9 tests, 174 assertions). At that time, the full suite had a ProtocolVersionTest::testUnsupportedVersionHeaderIsRejected failure also reproduced on unchanged 2.x. This is historical context, not a claim about the current rebased commit.
  • PHPCS (Drupal and DrupalPractice), PHPStan, and git diff --check passed.

AI disclosure

AI-Generated: Yes. OpenAI Codex generated portions of the implementation and tests and drafted this MR description under human guidance.

Edited by Ronald te Brake

Merge request reports

Loading
Loading