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;
15:
16: /**
17: * Describes the MCP implementation.
18: *
19: * @extends BaseMetadata<array{
20: * name: non-empty-string,
21: * version: non-empty-string,
22: * title?: non-empty-string,
23: * icons?: list<template-type<Icon, Arrayable, 'T'>>,
24: * websiteUrl?: non-empty-string,
25: * }>
26: */
27: final readonly class Implementation extends BaseMetadata
28: {
29: /**
30: * @param non-empty-string $version
31: * @param null|list<Icon> $icons Optional set of sized icons that the client can display in a user interface.
32: * @param null|non-empty-string $websiteUrl An optional URL of the website for this implementation.
33: */
34: public function __construct(
35: string $name,
36: public string $version,
37: ?string $title = null,
38: public ?array $icons = null,
39: public ?string $websiteUrl = null,
40: ) {
41: parent::__construct($name, $title);
42: }
43:
44: #[\Override]
45: public function toArray(): array
46: {
47: return array_filter([
48: 'name' => $this->name,
49: 'version' => $this->version,
50: 'title' => $this->title,
51: 'icons' => null === $this->icons ? null : array_map(
52: static fn(Icon $icon): array => $icon->toArray(),
53: $this->icons,
54: ),
55: 'websiteUrl' => $this->websiteUrl,
56: ], static fn(mixed $value): bool => null !== $value);
57: }
58: }
59: