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\BaseMetadata;
17: use Nexus\Mcp\Schema\Prompt\Prompt;
18:
19: /**
20: * The server's response to a `prompts/list` request from the client.
21: *
22: * @extends PaginatedResult<array{
23: * _meta?: array<string, mixed>,
24: * prompts: list<template-type<Prompt, BaseMetadata, 'T'>>,
25: * nextCursor?: non-empty-string,
26: * }>
27: */
28: final readonly class ListPromptsResult extends PaginatedResult implements ServerResult
29: {
30: /**
31: * @param list<Prompt> $prompts
32: */
33: public function __construct(
34: public array $prompts,
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: 'prompts' => array_map(
47: static fn(Prompt $prompt): array => $prompt->toArray(),
48: $this->prompts,
49: ),
50: 'nextCursor' => $this->nextCursor,
51: ], static fn(mixed $value): bool => null !== $value);
52: }
53: }
54: