Skip to content

Commit 3e8a0b8

Browse files
committed
minor #232 [MCP Bundle] Add tests for mcp.page_size parameter (OskarStark)
This PR was merged into the main branch. Discussion ---------- [MCP Bundle] Add tests for `mcp.page_size` parameter | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | -- | License | MIT This adds tests for the pagination functionality that was introduced in PR #227. Commits ------- b584484 Test existing pagination configuration in McpBundleTest
2 parents f924bed + b584484 commit 3e8a0b8

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\AI\McpBundle\McpBundle;
1818
use Symfony\AI\McpSdk\Capability\Tool\IdentifierInterface;
1919
use Symfony\AI\McpSdk\Server\NotificationHandlerInterface;
20+
use Symfony\AI\McpSdk\Server\RequestHandler\ToolListHandler;
2021
use Symfony\AI\McpSdk\Server\RequestHandlerInterface;
2122
use Symfony\Component\DependencyInjection\ContainerBuilder;
2223

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

147+
public function testDefaultPageSizeConfiguration()
148+
{
149+
$container = $this->buildContainer([]);
150+
151+
// Test that the default page_size parameter is set to 20
152+
$this->assertSame(20, $container->getParameter('mcp.page_size'));
153+
154+
// Test that ToolListHandler is registered
155+
$this->assertTrue($container->hasDefinition('mcp.server.request_handler.tool_list'));
156+
157+
$definition = $container->getDefinition('mcp.server.request_handler.tool_list');
158+
$this->assertSame(ToolListHandler::class, $definition->getClass());
159+
}
160+
161+
public function testCustomPageSizeConfiguration()
162+
{
163+
$container = $this->buildContainer([
164+
'mcp' => [
165+
'page_size' => 50,
166+
],
167+
]);
168+
169+
// Test that the custom page_size parameter is set
170+
$this->assertSame(50, $container->getParameter('mcp.page_size'));
171+
}
172+
173+
public function testMissingHandlerServices()
174+
{
175+
$container = $this->buildContainer([
176+
'mcp' => [
177+
'client_transports' => [
178+
'stdio' => true,
179+
'sse' => false,
180+
],
181+
],
182+
]);
183+
184+
// Currently, only ToolListHandler is registered
185+
$this->assertTrue($container->hasDefinition('mcp.server.request_handler.tool_list'));
186+
187+
// These services should be registered but are currently missing
188+
$this->assertFalse($container->hasDefinition('mcp.server.request_handler.resource_list'));
189+
$this->assertFalse($container->hasDefinition('mcp.server.request_handler.prompt_list'));
190+
}
191+
146192
private function buildContainer(array $configuration): ContainerBuilder
147193
{
148194
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)