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
3 changes: 2 additions & 1 deletion src/mcp-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^11.5"
"phpunit/phpunit": "^11.5",
"symfony/monolog-bundle": "^3.10"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
9 changes: 2 additions & 7 deletions src/mcp-bundle/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@

return static function (ContainerConfigurator $container): void {
$container->services()
->set('monolog.logger.mcp')
->parent('monolog.logger_prototype')
->args(['mcp'])
->tag('monolog.logger', ['channel' => 'mcp'])

->set('mcp.server.builder', Builder::class)
->factory([Server::class, 'builder'])
->call('setServerInfo', [param('mcp.app'), param('mcp.version')])
->call('setPaginationLimit', [param('mcp.pagination_limit')])
->call('setInstructions', [param('mcp.instructions')])
->call('setLogger', [service('monolog.logger.mcp')])
->call('setEventDispatcher', [service('event_dispatcher')])
->call('setSession', [service('mcp.session.store')])
->call('setDiscovery', [param('kernel.project_dir'), param('mcp.discovery.scan_dirs'), param('mcp.discovery.exclude_dirs')])
->call('setLogger', [service('logger')])
->tag('monolog.logger', ['channel' => 'mcp'])

->set('mcp.server', Server::class)
->factory([service('mcp.server.builder'), 'build'])

;
};
2 changes: 1 addition & 1 deletion src/mcp-bundle/src/Command/McpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class McpCommand extends Command
{
public function __construct(
private readonly Server $server,
private readonly LoggerInterface $logger,
private readonly ?LoggerInterface $logger = null,
) {
parent::__construct();
}
Expand Down
9 changes: 5 additions & 4 deletions src/mcp-bundle/src/McpBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
Expand Down Expand Up @@ -116,7 +115,8 @@ private function configureClient(array $transports, array $httpConfig, Container
new Reference('mcp.server'),
new Reference('logger'),
])
->addTag('console.command');
->addTag('console.command')
->addTag('monolog.logger', ['channel' => 'mcp']);
}

if ($transports['http']) {
Expand All @@ -127,10 +127,11 @@ private function configureClient(array $transports, array $httpConfig, Container
new Reference('mcp.http_foundation_factory'),
new Reference('mcp.psr17_factory'),
new Reference('mcp.psr17_factory'),
new Reference('monolog.logger.mcp', ContainerInterface::NULL_ON_INVALID_REFERENCE),
new Reference('logger'),
])
->setPublic(true)
->addTag('controller.service_arguments');
->addTag('controller.service_arguments')
->addTag('monolog.logger', ['channel' => 'mcp']);
}

$container->register('mcp.server.route_loader', RouteLoader::class)
Expand Down
13 changes: 0 additions & 13 deletions src/mcp-bundle/tests/DependencyInjection/McpBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ public function testCustomConfiguration()
$this->assertSame('This server provides weather and calendar tools', $container->getParameter('mcp.instructions'));
}

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

$this->assertTrue($container->hasDefinition('monolog.logger.mcp'));

$definition = $container->getDefinition('monolog.logger.mcp');
$this->assertInstanceOf(\Symfony\Component\DependencyInjection\ChildDefinition::class, $definition);
$this->assertSame('monolog.logger_prototype', $definition->getParent());
$this->assertSame(['mcp'], $definition->getArguments());
$this->assertTrue($definition->hasTag('monolog.logger'));
}

#[DataProvider('provideClientTransportsConfiguration')]
public function testClientTransportsConfiguration(array $config, array $expectedServices)
{
Expand Down
Loading