From 51162bcaca7343e0eb933644e6e1f5ce82a35035 Mon Sep 17 00:00:00 2001 From: Bujar Begisholli Date: Wed, 12 Nov 2025 11:08:14 +0100 Subject: [PATCH] [Server] Fix wrong parameter order when creating the tool from array Previously, the meta parameter was incorrectly passed to the icons position due to missing icons argument. Also adds icons support to Builder::addTool() for consistency with the Tool schema. --- src/Capability/Registry/Loader/ArrayLoader.php | 10 +++++++++- src/Server/Builder.php | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Capability/Registry/Loader/ArrayLoader.php b/src/Capability/Registry/Loader/ArrayLoader.php index a826bf6d..b784fd47 100644 --- a/src/Capability/Registry/Loader/ArrayLoader.php +++ b/src/Capability/Registry/Loader/ArrayLoader.php @@ -45,6 +45,7 @@ final class ArrayLoader implements LoaderInterface * name: ?string, * description: ?string, * annotations: ?ToolAnnotations, + * icons: ?array, * meta: ?array * }[] $tools * @param array{ @@ -106,7 +107,14 @@ public function load(ReferenceRegistryInterface $registry): void $inputSchema = $data['inputSchema'] ?? $schemaGenerator->generate($reflection); - $tool = new Tool($name, $inputSchema, $description, $data['annotations'], $data['meta'] ?? null); + $tool = new Tool( + name: $name, + inputSchema: $inputSchema, + description: $description, + annotations: $data['annotations'] ?? null, + icons: $data['icons'] ?? null, + meta: $data['meta'] ?? null, + ); $registry->registerTool($tool, $data['handler'], true); $handlerDesc = $this->getHandlerDescription($data['handler']); diff --git a/src/Server/Builder.php b/src/Server/Builder.php index 2e9991eb..ac8ec578 100644 --- a/src/Server/Builder.php +++ b/src/Server/Builder.php @@ -83,6 +83,7 @@ final class Builder * name: ?string, * description: ?string, * annotations: ?ToolAnnotations, + * icons: ?array, * meta: ?array * }[] */ @@ -315,6 +316,7 @@ public function setProtocolVersion(ProtocolVersion $protocolVersion): self * * @param Handler $handler * @param array|null $inputSchema + * @param Icon[]|null $icons * @param array|null $meta */ public function addTool( @@ -323,9 +325,10 @@ public function addTool( ?string $description = null, ?ToolAnnotations $annotations = null, ?array $inputSchema = null, + ?array $icons = null, ?array $meta = null, ): self { - $this->tools[] = compact('handler', 'name', 'description', 'annotations', 'inputSchema', 'meta'); + $this->tools[] = compact('handler', 'name', 'description', 'annotations', 'inputSchema', 'icons', 'meta'); return $this; }