diff --git a/config/services.yaml b/config/services.yaml index 3f7bca4..a5ce6e8 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -50,6 +50,7 @@ services: # you CAN still use autowiring: we just want to show what it looks like without autowire: true calls: + - setServerInfo: ['%mcp.app%', '%mcp.version%', '%mcp.description%', '%mcp.icons%', '%mcp.website_url%'] - setPaginationLimit: ['%mcp.pagination_limit%'] - setInstructions: ['%mcp.instructions%'] - setEventDispatcher: ['@event_dispatcher'] diff --git a/tests/phpunit/ServerInfoTest.php b/tests/phpunit/ServerInfoTest.php new file mode 100644 index 0000000..e044db0 --- /dev/null +++ b/tests/phpunit/ServerInfoTest.php @@ -0,0 +1,40 @@ +request('POST', '/_mcp', [], [], [ + 'CONTENT_TYPE' => 'application/json', + 'HTTP_ACCEPT' => 'application/json, text/event-stream', + ], json_encode([ + 'jsonrpc' => '2.0', + 'id' => 1, + 'method' => 'initialize', + 'params' => [ + 'protocolVersion' => '2025-06-18', + 'capabilities' => new \stdClass(), + 'clientInfo' => ['name' => 'phpunit', 'version' => '1.0'], + ], + ])); + + $this->assertResponseIsSuccessful(); + $response = json_decode($client->getResponse()->getContent(), true); + + $this->assertSame($container->getParameter('mcp.app'), $response['result']['serverInfo']['name']); + $this->assertSame($container->getParameter('mcp.version'), $response['result']['serverInfo']['version']); + $this->assertNotSame('app', $response['result']['serverInfo']['name']); + } +}