[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:
parent
8daca8129e
commit
63ffeed0cc
2 changed files with 13 additions and 2 deletions
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ final class Builder
|
|||
* name: ?string,
|
||||
* description: ?string,
|
||||
* annotations: ?ToolAnnotations,
|
||||
* icons: ?array<int, Icon>,
|
||||
* meta: ?array<string, mixed>
|
||||
* }[]
|
||||
*/
|
||||
|
|
@ -315,6 +316,7 @@ final class Builder
|
|||
*
|
||||
* @param Handler $handler
|
||||
* @param array<string, mixed>|null $inputSchema
|
||||
* @param Icon[]|null $icons
|
||||
* @param array<string, mixed>|null $meta
|
||||
*/
|
||||
public function addTool(
|
||||
|
|
@ -323,9 +325,10 @@ final class Builder
|
|||
?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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue