| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Schema; |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | final readonly class ClientCapabilities implements \JsonSerializable, Arrayable |
| 28: | { |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | public function __construct( |
| 37: | public ?array $experimental = null, |
| 38: | public bool $roots = false, |
| 39: | private ?bool $rootsListChanged = null, |
| 40: | public bool $sampling = false, |
| 41: | public bool $elicitation = false, |
| 42: | ) {} |
| 43: | |
| 44: | #[\Override] |
| 45: | public function toArray(): array |
| 46: | { |
| 47: | $capabilities = []; |
| 48: | |
| 49: | if (null !== $this->experimental && [] !== $this->experimental) { |
| 50: | $capabilities['experimental'] = $this->experimental; |
| 51: | } |
| 52: | |
| 53: | if ($this->roots || null !== $this->rootsListChanged) { |
| 54: | $capabilities['roots'] = []; |
| 55: | |
| 56: | if (null !== $this->rootsListChanged) { |
| 57: | $capabilities['roots']['listChanged'] = $this->rootsListChanged; |
| 58: | } |
| 59: | |
| 60: | $capabilities['roots'] = (object) $capabilities['roots']; |
| 61: | } |
| 62: | |
| 63: | if ($this->sampling) { |
| 64: | $capabilities['sampling'] = new \stdClass(); |
| 65: | } |
| 66: | |
| 67: | if ($this->elicitation) { |
| 68: | $capabilities['elicitation'] = new \stdClass(); |
| 69: | } |
| 70: | |
| 71: | return $capabilities; |
| 72: | } |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | #[\Override] |
| 83: | public function jsonSerialize(): object |
| 84: | { |
| 85: | return (object) $this->toArray(); |
| 86: | } |
| 87: | } |
| 88: | |