[Server] Fix wrong parameter order when creating the tool from array (#147)

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.
This commit is contained in:
Bujar Begisholli - C24 2025-11-12 11:34:17 +01:00 • committed by GitHub
commit 63ffeed0cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -45,6 +45,7 @@ final class ArrayLoader implements LoaderInterface
* name: ?string,
* description: ?string,
* annotations: ?ToolAnnotations,
* icons: ?array<int, \Mcp\Schema\Icon>,
* meta: ?array<string, mixed>
* }[] $tools
* @param array{
@ -106,7 +107,14 @@ final class ArrayLoader implements LoaderInterface
$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']);