-
-
Notifications
You must be signed in to change notification settings - Fork 137
[MCP Bundle] Make MonologBundle optional #864
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
9fa5c11
ecea6d6
a8500ca
ddf1694
b920d78
724a27e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,14 +24,16 @@ class McpCommand extends Command | |||||||||
| { | ||||||||||
| public function __construct( | ||||||||||
| private readonly Server $server, | ||||||||||
| private readonly LoggerInterface $logger, | ||||||||||
| private readonly ?LoggerInterface $logger = null, | ||||||||||
| ) { | ||||||||||
| parent::__construct(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| protected function execute(InputInterface $input, OutputInterface $output): int | ||||||||||
| { | ||||||||||
| $transport = new StdioTransport(logger: $this->logger); | ||||||||||
| $transport = $this->logger | ||||||||||
| ? new StdioTransport(logger: $this->logger) | ||||||||||
| : new StdioTransport(); | ||||||||||
|
||||||||||
| $transport = $this->logger | |
| ? new StdioTransport(logger: $this->logger) | |
| : new StdioTransport(); | |
| $transport = new StdioTransport(logger: $this->logger === null ? NullLogger() : $this->logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry the reviews are in the wrong order I miss clicked 😅
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,12 +35,18 @@ public function __construct( | |
|
|
||
| public function handle(Request $request): Response | ||
| { | ||
| $transport = new StreamableHttpTransport( | ||
| $this->httpMessageFactory->createRequest($request), | ||
| $this->responseFactory, | ||
| $this->streamFactory, | ||
| logger: $this->logger, | ||
| ); | ||
| $transport = $this->logger | ||
| ? new StreamableHttpTransport( | ||
| $this->httpMessageFactory->createRequest($request), | ||
| $this->responseFactory, | ||
| $this->streamFactory, | ||
| logger: $this->logger, | ||
|
||
| ) | ||
| : new StreamableHttpTransport( | ||
| $this->httpMessageFactory->createRequest($request), | ||
| $this->responseFactory, | ||
| $this->streamFactory, | ||
| ); | ||
|
|
||
| return $this->httpFoundationFactory->createResponse( | ||
| $this->server->run($transport), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| use PHPUnit\Framework\Attributes\DataProvider; | ||
| use PHPUnit\Framework\TestCase; | ||
| use Symfony\AI\McpBundle\McpBundle; | ||
| use Symfony\Bundle\MonologBundle\MonologBundle; | ||
| use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
|
||
| class McpBundleTest extends TestCase | ||
|
|
@@ -49,6 +50,10 @@ public function testCustomConfiguration() | |
|
|
||
| public function testMcpLoggerServiceIsCreated() | ||
| { | ||
| if (!class_exists(MonologBundle::class)) { | ||
| $this->markTestSkipped('MonologBundle is not installed'); | ||
| } | ||
|
|
||
|
||
| $container = $this->buildContainer([]); | ||
|
|
||
| $this->assertTrue($container->hasDefinition('monolog.logger.mcp')); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that the bundle class exists does not mean that the bundle is loaded/enabled.