-
-
Notifications
You must be signed in to change notification settings - Fork 38
[McpBundle] Compiler pass for tools #168
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
Conversation
c61b564
to
58536bd
Compare
da439c8
to
b1c22fe
Compare
src/mcp-bundle/src/DependencyInjection/ContainerBuilder/MCPToolChainCompilerPass.php
Outdated
Show resolved
Hide resolved
src/mcp-bundle/src/DependencyInjection/ContainerBuilder/MCPToolChainCompilerPass.php
Outdated
Show resolved
Hide resolved
src/mcp-bundle/src/DependencyInjection/ContainerBuilder/MCPToolChainCompilerPass.php
Outdated
Show resolved
Hide resolved
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.
cd6c9f1
to
220575f
Compare
You're welcome @chr-hertel. I believe I've address everything you mentioned if you'd like to take another look whenever you have time. |
Could be a follow up PR, but I would like to have an attribute for this like in the agent |
src/mcp-bundle/src/DependencyInjection/ContainerBuilder/McpToolChainCompilerPass.php
Outdated
Show resolved
Hide resolved
3b01c9b
to
20ef42c
Compare
@chr-hertel my bad on missing the strict types, updated now and rebased into 1 commit |
src/mcp-bundle/doc/index.rst
Outdated
@@ -63,6 +63,11 @@ Configuration | |||
sse: | |||
url: 'http://localhost:8000/sse' # URL to SSE endpoint of MCP server | |||
|
|||
To add your tools to the MCP server, add the following tag:: | |||
|
|||
#[AutoconfigureTag('mcp.tool')] |
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.
this is not the right recommendation IMO:
AutoconfigureTag
(like allAutoconfigure*
attributes) is about defining an autoconfiguration rule applying on all child types (its original intent is to be used on interfaces). Recommending to use it to apply a tag on a service directly is a bad idea, as it can have unintended side effects for non-final classes (as it will also impact autoconfigured services defined with child classes)- if the goal is to automatically tag autoconfigured services implementing ToolExecutorInterface with the
mcp.tool
to make it simpler for projects adding a custom tool, the solution is for the MCP bundle to register an autoconfiguration rule for ToolExecutorInterface, so that projects only need to implement the interface and be done with it.
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.
I was thinking of using the attribute because it's currently hard to decide which interface is the right indicator for the tag here
@Nyholm, it would be the Symfony\AI\McpSdk\Capability\Tool\IdentifierInterface
, right?
return; | ||
} | ||
|
||
$definition = new Definition(ToolChain::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.
you could always define a mcp.tool_chain
service using a tagged iterator, and then defining a ToolExecutorInterface
alias pointing at it (which projects can still override if they don't want to rely on the tool chain).
There is no need for this compiler pass IMO.
Sorry for the slow response, I've had tonsillitis so took some time to recover. So if I've understood correct (as some of these things are new to me), I'd create a definition of mcp.tool_chain:
arguments:
$executors: !tagged_iterator mcp.tool
Symfony\AI\McpSdk\Capability\Tool\ToolExecutorInterface: mcp.tool_chain And then apply the is that correct @chr-hertel @stof? |
@TomHart no worries at all, hope you're well again 🤞 You are correct here, two things are needed a) registering based on the For a) we can't simply add the For b) i think you could just move the service definition from the compiler pass into the bundle class as well and use |
I've changed it around now. I couldn't get it working with the Not sure why PHPUnit is failing, could it be re-tried to just see if it's a blip? Finally, had to change from |
Looks good to me now, can you please rebase - I just merged #165 |
Address comments lint Update src/mcp-bundle/CHANGELOG.md Co-authored-by: Oskar Stark <[email protected]> Update src/mcp-bundle/CHANGELOG.md Co-authored-by: Oskar Stark <[email protected]> Update src/mcp-bundle/doc/index.rst Co-authored-by: Oskar Stark <[email protected]> Update src/mcp-bundle/doc/index.rst Co-authored-by: Oskar Stark <[email protected]> Remove strict types Change the approach used, removing the compiler pass lint
c408cc5
to
0a77af8
Compare
Amazing! Done! |
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.
Looks good & works! :)
Thank you @TomHart. |
@chr-hertel what's the best way to find the best priority issues to work on? |
If you're up for something to just on, I'd always point to #16. I think Stores we're quite good progressed lately, but there are quite some Platforms that only are a draft, like OpenRouter or Replicate, but also some missing completely, like Deepseek or Perplexity. One of my priority topics would be #167 - feel free to have a look at that PR and open PRs against that. And other than that, the Store component has two extension points that could use some love, especially the Happy to guide you more if you tell me what's interesting to you :) |
Add a Compiler Pass to find tools and register them in the ToolChain