| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Schema\Result; |
| 15: | |
| 16: | use Nexus\Mcp\Schema\BaseMetadata; |
| 17: | use Nexus\Mcp\Schema\Tool\Tool; |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | final readonly class ListToolsResult extends PaginatedResult implements ServerResult |
| 29: | { |
| 30: | |
| 31: | |
| 32: | |
| 33: | public function __construct( |
| 34: | public array $tools, |
| 35: | ?string $nextCursor = null, |
| 36: | ?array $meta = null, |
| 37: | ) { |
| 38: | parent::__construct($nextCursor, $meta); |
| 39: | } |
| 40: | |
| 41: | #[\Override] |
| 42: | public function toArray(): array |
| 43: | { |
| 44: | return array_filter([ |
| 45: | '_meta' => $this->meta, |
| 46: | 'tools' => array_map( |
| 47: | static fn(Tool $tool): array => $tool->toArray(), |
| 48: | $this->tools, |
| 49: | ), |
| 50: | 'nextCursor' => $this->nextCursor, |
| 51: | ], static fn(mixed $value): bool => null !== $value); |
| 52: | } |
| 53: | } |
| 54: | |