1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Extension\Apps\Client;
15:
16: use Nexus\Mcp\Core\Exception\RuntimeException;
17: use Nexus\Mcp\Core\Schema\Resource\Resource;
18: use Nexus\Mcp\Core\Schema\Resource\ResourceContents;
19: use Nexus\Mcp\Core\Schema\Result\InputRequiredResult;
20: use Nexus\Mcp\Core\Schema\Result\InputResponse;
21: use Nexus\Mcp\Core\Schema\Result\ListToolsResult;
22: use Nexus\Mcp\Core\Schema\Result\ReadResourceResult;
23: use Nexus\Mcp\Core\Schema\Tool\Tool;
24: use Nexus\Mcp\Extension\Apps\Schema\UiResourceMeta;
25: use Nexus\Mcp\Extension\Apps\Schema\UiToolMeta;
26:
27: /**
28: * Client-side surface of the MCP Apps extension.
29: */
30: interface AppClientInterface
31: {
32: /**
33: * Reads a tool's `_meta.ui` object, falling back to the deprecated flat
34: * `_meta["ui/resourceUri"]` key when the nested form carries no `resourceUri`.
35: */
36: public function resolveToolMeta(Tool $tool): ?UiToolMeta;
37:
38: public function resolveResourceMeta(Resource|ResourceContents $source): ?UiResourceMeta;
39:
40: /**
41: * The tools whose `_meta.ui` links a UI resource, skipping any whose metadata
42: * cannot be decoded.
43: *
44: * @return list<AppTool>
45: */
46: public function findAppTools(ListToolsResult $result): array;
47:
48: /**
49: * Reads a `ui://` resource, verifying every returned content item carries
50: * one of the accepted UI mime types.
51: *
52: * @param non-empty-string $uri
53: * @param null|array<int|non-empty-string, InputResponse> $inputResponses
54: *
55: * @throws RuntimeException
56: */
57: public function readAppResource(string $uri, ?array $inputResponses = null, ?string $requestState = null): InputRequiredResult|ReadResourceResult;
58: }
59: