-
-
Notifications
You must be signed in to change notification settings - Fork 147
[MCP Bundle] Fix services when monolog is not installed #849
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
[MCP Bundle] Fix services when monolog is not installed #849
Conversation
|
@chr-hertel tell me what you think about this solution, but while working on it I was thinking that just require monolog could be even better. I don't see any good reason to not use it. |
|
I think that solution works for me - is this the only place where we'd need that tho? I also wonder about the implementation in the ai/src/mcp-bundle/src/McpBundle.php Lines 113 to 134 in 806d6be
@camilleislasse do you recall why it's |
| return static function (ContainerConfigurator $container): void { | ||
| $container->services() | ||
| ->set('monolog.logger.mcp') | ||
| if (class_exists(\Symfony\Bundle\MonologBundle\MonologBundle::class)) { |
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.
please use in import here instead the FCQN:
| if (class_exists(\Symfony\Bundle\MonologBundle\MonologBundle::class)) { | |
| if (class_exists(MonologBundle::class)) { |
Fixes symfony#830 - Wrap monolog.logger.mcp service creation in class_exists() check - Add ->nullOnInvalid() to setLogger() call - Uniformize logger references in McpCommand and McpController - Update test to skip when MonologBundle is not installed Builds on symfony#849 by @WebMamba
@chr-hertel I don't recall why, probably a mistake on my part |
|
Closing in favor of #864 Thanks |
|
thank's @WebMamba |
Fixes symfony#830 - Wrap monolog.logger.mcp service creation in class_exists() check - Add ->nullOnInvalid() to setLogger() call - Uniformize logger references in McpCommand and McpController - Update test to skip when MonologBundle is not installed Builds on symfony#849 by @WebMamba
This PR was squashed before being merged into the main branch. Discussion ---------- [MCP Bundle] Make MonologBundle optional | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | Fix #830 | License | MIT This PR makes MonologBundle optional dependency for McpBundle. Without it installed, the container compilation was failing with "Parent definition' monolog.logger_prototype' does not exist." ## Changes - Wrap `monolog.logger.mcp` service creation in `class_exists()` check - Add `->nullOnInvalid()` to `setLogger()` call in services.php - Uniformize logger references: both McpCommand and McpController now use `monolog.logger.mcp` with `NULL_ON_INVALID_REFERENCE` - Update test to skip when MonologBundle is not installed ## Credits Builds on the initial work in #849 by `@WebMamba`. That PR protected service creation but the service was still referenced without protection. This PR completes the fix by also protecting the service usage. Commits ------- f3149d6 [MCP Bundle] Make MonologBundle optional
As said on the issue, when monolog is not installed, the container can't compile the services.
The solution here is to register the service only if the bundle is installed