From 6d3ea0194f6fc666d7bb323d1226d7657910fdf7 Mon Sep 17 00:00:00 2001 From: Sergey Shevchenko Date: Wed, 15 Apr 2026 14:33:26 +1200 Subject: [PATCH] Add optional instructions to Implementation class --- src/Implementation.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Implementation.php b/src/Implementation.php index 591bf23..ff33384 100644 --- a/src/Implementation.php +++ b/src/Implementation.php @@ -7,27 +7,32 @@ use JsonSerializable; /** - * Describes the name and version of an MCP implementation. + * Describes the name, version and optional usage instructions of an MCP implementation. */ class Implementation implements JsonSerializable { public function __construct( public readonly string $name, - public readonly string $version + public readonly string $version, + public readonly ?string $instructions = null, ) { } - public static function make(string $name, string $version): static + public static function make(string $name, string $version, ?string $instructions = null): static { - return new static($name, $version); + return new static($name, $version, $instructions); } public function toArray(): array { - return [ + $result = [ 'name' => $this->name, 'version' => $this->version, ]; + if ($this->instructions !== null) { + $result['instructions'] = $this->instructions; + } + return $result; } public static function fromArray(array $data): static @@ -38,7 +43,7 @@ public static function fromArray(array $data): static if (empty($data['version']) || !is_string($data['version'])) { throw new \InvalidArgumentException("Invalid or missing 'version' in Implementation data."); } - return new static($data['name'], $data['version']); + return new static($data['name'], $data['version'], $data['instructions'] ?? null); } public function jsonSerialize(): array