From 86a6697c434557a91c6ce62e60476a8604c929bb Mon Sep 17 00:00:00 2001 From: Pushpak Chhajed Date: Wed, 29 Oct 2025 16:48:57 +0530 Subject: [PATCH 1/2] Ensure the property field exists in tool input schemas --- src/Server/Tool.php | 9 ++++++--- tests/Unit/Tools/ToolTest.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/Server/Tool.php b/src/Server/Tool.php index 110411a..a9568af 100644 --- a/src/Server/Tool.php +++ b/src/Server/Tool.php @@ -57,14 +57,17 @@ public function toMethodCall(): array public function toArray(): array { $annotations = $this->annotations(); + $schema = JsonSchema::object( + $this->schema(...), + )->toArray(); + + $schema['properties'] ??= (object) []; return [ 'name' => $this->name(), 'title' => $this->title(), 'description' => $this->description(), - 'inputSchema' => JsonSchema::object( - $this->schema(...), - )->toArray(), + 'inputSchema' => $schema, 'annotations' => $annotations === [] ? (object) [] : $annotations, ]; } diff --git a/tests/Unit/Tools/ToolTest.php b/tests/Unit/Tools/ToolTest.php index 11f7a8a..c30c158 100644 --- a/tests/Unit/Tools/ToolTest.php +++ b/tests/Unit/Tools/ToolTest.php @@ -72,6 +72,28 @@ ]); }); +it('includes an empty properties object when the schema has no properties', function (): void { + $tool = new TestTool; + $array = $tool->toArray(); + + expect($array['inputSchema']) + ->toHaveKey('type', 'object') + ->toHaveKey('properties') + ->and($array['inputSchema']['properties'])->toEqual((object) []); +}); + +it('includes schema properties when defined', function (): void { + $tool = new ToolWithSchema; + $array = $tool->toArray(); + + expect($array['inputSchema']['properties']) + ->toHaveKey('message') + ->and($array['inputSchema']['properties']['message']) + ->toHaveKey('type', 'string') + ->toHaveKey('description', 'The message to echo') + ->and($array['inputSchema']['required'])->toEqual(['message']); +}); + class TestTool extends Tool { public function description(): string @@ -123,3 +145,13 @@ class CustomToolName extends TestTool { protected string $name = 'my_custom_tool_name'; } + +class ToolWithSchema extends TestTool +{ + public function schema(\Illuminate\JsonSchema\JsonSchema $schema): array + { + return [ + 'message' => $schema->string()->description('The message to echo')->required(), + ]; + } +} From eccab7019d4e5ce98292afaedf513fd7c403d561 Mon Sep 17 00:00:00 2001 From: Pushpak Chhajed Date: Wed, 29 Oct 2025 16:53:12 +0530 Subject: [PATCH 2/2] Update the minimum code coverage threshold to 91.4% --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d570a1a..be814e5 100644 --- a/composer.json +++ b/composer.json @@ -80,7 +80,7 @@ "pint --test", "rector --dry-run" ], - "test:unit": "pest --ci --coverage --min=91.2", + "test:unit": "pest --ci --coverage --min=91.4", "test:types": "phpstan", "test": [ "@test:lint",