Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
40 changes: 40 additions & 0 deletions tests/phpunit/ServerInfoTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace App\Tests\Phpunit;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class ServerInfoTest extends WebTestCase
{
/**
* The serverInfo sent back on initialize is what a client names the server
* after (VS Code prefixes every tool with it), so it must come from the
* configuration (mcp.app, mcp.version), not from the SDK's 'app'/'dev'
* defaults.
*/
public function testInitializeReportsTheConfiguredServerInfo(): void
{
$client = static::createClient();
$container = static::getContainer();

$client->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']);
}
}
Loading