[Schema][Client][Server] Close MCP Apps gaps: extension negotiation checks (#429)
* [Schema][Client][Server] Close MCP Apps gaps: extension negotiation checks Add ClientGateway::supportsExtension(), Client\Builder::enableExtension() and ClientCapabilities::withExtensions(); introduce side-agnostic ExtensionInterface and deprecate ServerExtensionInterface; document attribute-based UI linkage. * Drop ServerExtensionInterface in favour of ExtensionInterface
This commit is contained in:
parent
590afb575b
commit
6f58fe596a
1 changed files with 273 additions and 21 deletions
|
|
@ -0,0 +1,53 @@
|
|||
<?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\Unit\Capability\Discovery\Fixtures;
|
||||
|
||||
use Mcp\Capability\Attribute\McpResource;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Mcp\Schema\Content\TextResourceContents;
|
||||
use Mcp\Schema\Extension\Apps\McpApps;
|
||||
use Mcp\Schema\Extension\Apps\ToolVisibility;
|
||||
use Mcp\Schema\Extension\Apps\UiResourceContentMeta;
|
||||
use Mcp\Schema\Extension\Apps\UiResourceCsp;
|
||||
use Mcp\Schema\Extension\Apps\UiToolMeta;
|
||||
|
||||
/**
|
||||
* An MCP App declared purely through attributes: a `ui://` resource flagged with the
|
||||
* `_meta.ui` marker and a tool linked to it via `UiToolMeta`.
|
||||
*/
|
||||
class DiscoverableUiHandler
|
||||
{
|
||||
#[McpResource(
|
||||
uri: 'ui://widget/clock',
|
||||
name: 'clock_widget',
|
||||
mimeType: McpApps::MIME_TYPE,
|
||||
meta: ['ui' => new \stdClass()],
|
||||
)]
|
||||
public function widget(): TextResourceContents
|
||||
{
|
||||
return new TextResourceContents(
|
||||
uri: 'ui://widget/clock',
|
||||
mimeType: McpApps::MIME_TYPE,
|
||||
text: '<html></html>',
|
||||
meta: ['ui' => new UiResourceContentMeta(csp: new UiResourceCsp(connectDomains: ['https://time.example.com']))],
|
||||
);
|
||||
}
|
||||
|
||||
#[McpTool(
|
||||
name: 'show_clock',
|
||||
meta: ['ui' => new UiToolMeta(resourceUri: 'ui://widget/clock', visibility: [ToolVisibility::App])],
|
||||
)]
|
||||
public function showClock(string $timezone): string
|
||||
{
|
||||
return $timezone;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue