Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 2a2f7fb

Browse files
committed
fix(discovery): fix empty schema in tool discovery
1 parent 68447f5 commit 2a2f7fb

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/Service/ResponseFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Ecourty\McpServerBundle\HttpFoundation\JsonRpcResponse;
1010
use Symfony\Component\HttpFoundation\JsonResponse;
1111
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
12+
use Symfony\Component\Serializer\Serializer;
1213
use Symfony\Component\Serializer\SerializerInterface;
1314

1415
/**
@@ -46,6 +47,8 @@ private function createResponse(JsonRpcResponse $response): JsonResponse
4647
{
4748
$json = $this->serializer->serialize($response, 'json', [
4849
AbstractObjectNormalizer::SKIP_NULL_VALUES => true,
50+
AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true,
51+
Serializer::EMPTY_ARRAY_AS_OBJECT => true,
4952
]);
5053

5154
return JsonResponse::fromJsonString($json, JsonResponse::HTTP_OK);

tests/Controller/EntrypointControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function testToolList(): void
152152
], $tools[0]['annotations']);
153153

154154
$this->assertArrayHasKey('inputSchema', $tools[1]);
155-
$this->assertSame([], $tools[1]['inputSchema']);
155+
$this->assertEmpty($tools[1]['inputSchema']);
156156

157157
$this->assertArrayHasKey('inputSchema', $tools[2]);
158158
$this->assertSame([

0 commit comments

Comments
 (0)