Skip to content

[MCP Bundle] Add tests for mcp.page_size parameter #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
46 changes: 46 additions & 0 deletions src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\AI\McpBundle\McpBundle;
use Symfony\AI\McpSdk\Capability\Tool\IdentifierInterface;
use Symfony\AI\McpSdk\Server\NotificationHandlerInterface;
use Symfony\AI\McpSdk\Server\RequestHandler\ToolListHandler;
use Symfony\AI\McpSdk\Server\RequestHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand Down Expand Up @@ -143,6 +144,51 @@ public function testServerAutoconfigurations()
$this->assertArrayHasKey('mcp.server.request_handler', $autoconfiguredInstances[RequestHandlerInterface::class]->getTags());
}

public function testDefaultPageSizeConfiguration()
{
$container = $this->buildContainer([]);

// Test that the default page_size parameter is set to 20
$this->assertSame(20, $container->getParameter('mcp.page_size'));

// Test that ToolListHandler is registered
$this->assertTrue($container->hasDefinition('mcp.server.request_handler.tool_list'));

$definition = $container->getDefinition('mcp.server.request_handler.tool_list');
$this->assertSame(ToolListHandler::class, $definition->getClass());
}

public function testCustomPageSizeConfiguration()
{
$container = $this->buildContainer([
'mcp' => [
'page_size' => 50,
],
]);

// Test that the custom page_size parameter is set
$this->assertSame(50, $container->getParameter('mcp.page_size'));
}

public function testMissingHandlerServices()
{
$container = $this->buildContainer([
'mcp' => [
'client_transports' => [
'stdio' => true,
'sse' => false,
],
],
]);

// Currently, only ToolListHandler is registered
$this->assertTrue($container->hasDefinition('mcp.server.request_handler.tool_list'));

// These services should be registered but are currently missing
$this->assertFalse($container->hasDefinition('mcp.server.request_handler.resource_list'));
$this->assertFalse($container->hasDefinition('mcp.server.request_handler.prompt_list'));
}

private function buildContainer(array $configuration): ContainerBuilder
{
$container = new ContainerBuilder();
Expand Down