1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2025 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\Schema\Result;
15:
16: use Nexus\Mcp\Schema\Arrayable;
17:
18: /**
19: * The base result object that is passed to a JSON-RPC response.
20: *
21: * @template TArray of array<string, mixed>
22: * @template TJson = TArray
23: *
24: * @implements Arrayable<TArray>
25: */
26: abstract readonly class Result implements \JsonSerializable, Arrayable
27: {
28: /**
29: * @param null|array<string, mixed> $meta Reserved by MCP to allow clients and servers to attach
30: * additional metadata to their interactions.
31: */
32: public function __construct(
33: public ?array $meta = null,
34: ) {}
35:
36: /**
37: * @return TJson
38: */
39: #[\Override]
40: public function jsonSerialize(): mixed
41: {
42: return $this->toArray();
43: }
44: }
45: