[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
This commit is contained in:
parent
7407661260
commit
0751a83658
1 changed files with 130 additions and 0 deletions
50
tests/Inspector/Http/HttpMcpAppsTest.php
Normal file
50
tests/Inspector/Http/HttpMcpAppsTest.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?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';
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue