| 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\Request; |
| 15: | |
| 16: | use Nexus\Mcp\Schema\Message\JsonRpcRequest; |
| 17: | use Nexus\Mcp\Schema\Message\RequestId; |
| 18: | use Nexus\Mcp\Schema\ProgressToken; |
| 19: | |
| 20: | /** |
| 21: | * Sent from the server to request a list of root URIs from the client. Roots allow servers to ask |
| 22: | * for specific directories or files to operate on. A common example for roots is providing a set of |
| 23: | * repositories or directories a server should operate on. |
| 24: | * |
| 25: | * This request is typically used when the server needs to understand the file system structure or |
| 26: | * access specific locations that the client has permission to read from. |
| 27: | * |
| 28: | * @extends JsonRpcRequest<array{ |
| 29: | * jsonrpc: '2.0', |
| 30: | * id: int|non-empty-string, |
| 31: | * method: 'roots/list', |
| 32: | * params?: array{ |
| 33: | * _meta?: array<string, mixed>, |
| 34: | * progressToken?: non-empty-string, |
| 35: | * } |
| 36: | * }> |
| 37: | */ |
| 38: | final readonly class ListRootsRequest extends JsonRpcRequest implements ServerRequest |
| 39: | { |
| 40: | /** |
| 41: | * @param null|ProgressToken $progressToken If specified, the caller is requesting out-of-band progress |
| 42: | * notifications for this request (as represented by |
| 43: | * `notifications/progress`). The value of this parameter is an |
| 44: | * opaque token that will be attached to any subsequent notifications. |
| 45: | * The receiver is not obligated to provide these notifications. |
| 46: | */ |
| 47: | public function __construct(RequestId $id, ?ProgressToken $progressToken = null) |
| 48: | { |
| 49: | $params = isset($progressToken) ? ['_meta' => ['progressToken' => $progressToken->token]] : null; |
| 50: | |
| 51: | parent::__construct(self::JSON_RPC_VERSION, $id, 'roots/list', $params); |
| 52: | } |
| 53: | } |
| 54: |