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\Core\Schema\ResultResponse;
15:
16: use Nexus\Mcp\Core\Schema\JsonRpc\JsonRpcResultResponse;
17: use Nexus\Mcp\Core\Schema\RequestId;
18: use Nexus\Mcp\Core\Schema\Result;
19: use Nexus\Mcp\Core\Schema\Result\ListResourceTemplatesResult;
20:
21: /**
22: * A successful response from the server for a `resources/templates/list` request.
23: *
24: * @property-read ListResourceTemplatesResult $result
25: *
26: * @extends JsonRpcResultResponse<array{
27: * jsonrpc: '2.0',
28: * id: int|non-empty-string,
29: * result: template-type<ListResourceTemplatesResult, Result, 'T'>,
30: * }>
31: *
32: * @see https://modelcontextprotocol.io/specification/draft/schema#listresourcetemplatesresultresponse
33: */
34: final readonly class ListResourceTemplatesResultResponse extends JsonRpcResultResponse
35: {
36: public function __construct(RequestId $id, ListResourceTemplatesResult $result)
37: {
38: parent::__construct(id: $id, result: $result);
39: }
40:
41: #[\Override]
42: public static function fromArray(array $data): static
43: {
44: $id = self::parseId($data);
45: $payload = self::parseResult($data);
46: self::rejectInputRequired($payload);
47:
48: return new self(id: $id, result: ListResourceTemplatesResult::fromArray($payload));
49: }
50:
51: #[\Override]
52: public function toArray(): array
53: {
54: return [
55: 'jsonrpc' => self::JSONRPC_VERSION,
56: 'id' => $this->id->id,
57: 'result' => $this->result->toArray(),
58: ];
59: }
60: }
61: