| 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: | |
| 28: | |
| 29: | final readonly class ServerCapabilities implements \JsonSerializable, Arrayable |
| 30: | { |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | public function __construct( |
| 44: | public ?array $experimental = null, |
| 45: | public bool $logging = false, |
| 46: | public bool $completions = false, |
| 47: | public bool $prompts = false, |
| 48: | private ?bool $promptsListChanged = null, |
| 49: | public bool $resources = false, |
| 50: | private ?bool $resourcesSubscribe = null, |
| 51: | private ?bool $resourcesListChanged = null, |
| 52: | public bool $tools = false, |
| 53: | private ?bool $toolsListChanged = null, |
| 54: | ) {} |
| 55: | |
| 56: | #[\Override] |
| 57: | public function toArray(): array |
| 58: | { |
| 59: | $capabilities = []; |
| 60: | |
| 61: | if (null !== $this->experimental && [] !== $this->experimental) { |
| 62: | $capabilities['experimental'] = $this->experimental; |
| 63: | } |
| 64: | |
| 65: | if ($this->logging) { |
| 66: | $capabilities['logging'] = new \stdClass(); |
| 67: | } |
| 68: | |
| 69: | if ($this->completions) { |
| 70: | $capabilities['completions'] = new \stdClass(); |
| 71: | } |
| 72: | |
| 73: | if ($this->prompts || null !== $this->promptsListChanged) { |
| 74: | $capabilities['prompts'] = []; |
| 75: | |
| 76: | if (null !== $this->promptsListChanged) { |
| 77: | $capabilities['prompts']['listChanged'] = $this->promptsListChanged; |
| 78: | } |
| 79: | |
| 80: | $capabilities['prompts'] = (object) $capabilities['prompts']; |
| 81: | } |
| 82: | |
| 83: | if ($this->resources || null !== $this->resourcesSubscribe || null !== $this->resourcesListChanged) { |
| 84: | $capabilities['resources'] = []; |
| 85: | |
| 86: | if (null !== $this->resourcesSubscribe) { |
| 87: | $capabilities['resources']['subscribe'] = $this->resourcesSubscribe; |
| 88: | } |
| 89: | |
| 90: | if (null !== $this->resourcesListChanged) { |
| 91: | $capabilities['resources']['listChanged'] = $this->resourcesListChanged; |
| 92: | } |
| 93: | |
| 94: | $capabilities['resources'] = (object) $capabilities['resources']; |
| 95: | } |
| 96: | |
| 97: | if ($this->tools || null !== $this->toolsListChanged) { |
| 98: | $capabilities['tools'] = []; |
| 99: | |
| 100: | if (null !== $this->toolsListChanged) { |
| 101: | $capabilities['tools']['listChanged'] = $this->toolsListChanged; |
| 102: | } |
| 103: | |
| 104: | $capabilities['tools'] = (object) $capabilities['tools']; |
| 105: | } |
| 106: | |
| 107: | return $capabilities; |
| 108: | } |
| 109: | |
| 110: | |
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: | |
| 119: | |
| 120: | #[\Override] |
| 121: | public function jsonSerialize(): object |
| 122: | { |
| 123: | return (object) $this->toArray(); |
| 124: | } |
| 125: | } |
| 126: | |