php-sdk/tests/Inspector/Http/HttpMcpAppsTest.php
Christopher Hertel 0751a83658
[Examples][Tests] Make the MCP Apps example work over HTTP, and pin it (#439)
* [Examples][Tests] Make the MCP Apps example work over HTTP, and pin it

It was the only example without a session store, so every request under
`php -S` or php-fpm - each its own process - was answered "Session not found
or has expired". It now uses a FileSessionStore like the others.

Inspector snapshots pin what the extension actually puts on the wire: the
ui:// resource's `text/html;profile=mcp-app` MIME type and `ui` marker, and
the `_meta.ui` on the tool that links the two.

* Apply suggestion from @chr-hertel

* Apply suggestion from @chr-hertel
2026-08-18 14:51:34 +02:00

50 lines
1.6 KiB
PHP

<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Tests\Inspector\Http;
/**
* Snapshots the MCP Apps example as the Inspector sees it.
*
* What the snapshots are actually pinning is the extension's metadata surviving
* registration: the `ui://` resource carrying `text/html;profile=mcp-app` and
* the `ui` marker in its `_meta`, and the tool carrying the `UiToolMeta` that
* links it to that resource. Those are the two halves a host needs to render an
* app, and both travel in `_meta`, where a silent drop would otherwise go
* unnoticed until a host failed to render anything.
*/
final class HttpMcpAppsTest extends HttpInspectorSnapshotTestCase
{
public static function provideMethods(): array
{
return [
...parent::provideMethods(),
'Read the UI resource' => [
'method' => 'resources/read',
'options' => ['uri' => 'ui://weather-app'],
'testName' => 'weather_app',
],
'Call the linked tool' => [
'method' => 'tools/call',
'options' => [
'toolName' => 'get_weather',
'toolArgs' => ['city' => 'london'],
],
'testName' => 'get_weather',
],
];
}
protected function getServerScript(): string
{
return \dirname(__DIR__, 3).'/examples/server/mcp-apps/server.php';
}
}