1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 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\Core\Schema\RequestParams;
15:
16: use Nexus\Assert\Assert;
17: use Nexus\Mcp\Core\Schema\MetaObject\RequestMetaObject;
18: use Nexus\Mcp\Core\Schema\RequestParams;
19: use Nexus\Mcp\Core\Validation\Rfc3986UriValidator;
20:
21: /**
22: * Common params for resource-related requests.
23: *
24: * @template-covariant T of array<string, mixed>
25: *
26: * @extends RequestParams<T>
27: *
28: * @see https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2026-07-28/schema.ts
29: */
30: abstract readonly class ResourceRequestParams extends RequestParams
31: {
32: private const int MAX_URI_BYTES = 8_192;
33:
34: /**
35: * @param non-empty-string $uri
36: */
37: public function __construct(
38: public string $uri,
39: RequestMetaObject $meta,
40: ) {
41: Rfc3986UriValidator::validate($uri, '"params.uri"');
42: Assert::that($uri)->hasMaxLength(
43: self::MAX_URI_BYTES,
44: \sprintf('"params.uri" must not exceed %d bytes.', self::MAX_URI_BYTES),
45: );
46:
47: parent::__construct(meta: $meta);
48: }
49: }
50: