Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Implementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down