Repository navigation
[Server] Compatibility of Capabilities with Symfony's Container #67
Description
Activity
- addedServerIssues & PRs related to the Server componentIssues & PRs related to the Server component
on Sep 14, 2025 - added a parent issue
on Sep 14, 2025 It's slightly different from what was in PHP-MCP package (for some reason I was using it before swapping to this one), but it still persists.
"exception": { "class": "ArgumentCountError", "message": "Too few arguments to function App\\Tools\\SearchTool::__construct(), 0 passed in /home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/Capability/Registry/ReferenceHandler.php on line 75 and exactly 1 expected", "code": 0, "file": "/home/ineersa/mcp-servers/browser-mcp/src/Tools/SearchTool.php:17", "trace": [ "/home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/Capability/Registry/ReferenceHandler.php:75", "/home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/Capability/Registry/ReferenceHandler.php:36", "/home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/Capability/Registry.php:232", "/home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/Server/RequestHandler/CallToolHandler.php:47", "/home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/JsonRpc/Handler.php:160", "/home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/JsonRpc/Handler.php:106", "/home/ineersa/mcp-servers/browser-mcp/vendor/mcp/sdk/src/Server.php:50", "/home/ineersa/mcp-servers/browser-mcp/src/Command/BrowserMcpCommand.php:91", "/home/ineersa/mcp-servers/browser-mcp/vendor/symfony/console/Command/Command.php:318", "/home/ineersa/mcp-servers/browser-mcp/vendor/symfony/console/Application.php:1110", "/home/ineersa/mcp-servers/browser-mcp/vendor/symfony/framework-bundle/Console/Application.php:123", "/home/ineersa/mcp-servers/browser-mcp/vendor/symfony/console/Application.php:359", "/home/ineersa/mcp-servers/browser-mcp/vendor/symfony/framework-bundle/Console/Application.php:77", "/home/ineersa/mcp-servers/browser-mcp/vendor/symfony/console/Application.php:194", "/home/ineersa/mcp-servers/browser-mcp/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49", "/home/ineersa/mcp-servers/browser-mcp/vendor/autoload_runtime.php:29", "/home/ineersa/mcp-servers/browser-mcp/bin/browser-mcp:15" ] }
When we try to resolve how to get tool handler we will call
->container->has(CLASSNAME)private function getClassInstance(string $className): object { if (null !== $this->container && $this->container->has($className)) { return $this->container->get($className); } return new $className(); }
While this will work with containers like PHP-DI for example, it won't work with Symfony.
All services inside Symfony container are private, so->container->has(CLASSNAME)will returnfalseunless it explicitly set as public.I don't really see how to fix it, since it's not a bug.
Maybe there should be Symfony specific documentation which will explicitly say that Tools/Resources/Prompts must be public if they have any dependencies:For example this in
services.yamlwill fix those issuesservices: ... # Make ALL services in App\Tools\ public App\Tools\: resource: '../src/Tools' public: true
That's alright, we can use a locator build with the services that have the attributes on them - that'll work :)
I'll take care while patching up the mcp-bundleReacted by ineersaThis should be solved with the bundle - fair to close @ineersa?
This should be solved with the bundle - fair to close @ineersa?
Sure! I need to try bundle =)
Closing for now - feel free to re-open if there are issues with the bundle.
Hi,
I'm facing the same error, for others reading this, I think the discussion mentions the "bundle".
Passing container and using ->get() won't work with Symfony by default since services are private.
only way to make it work is to set service public.