Skip to content

[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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TomHart
Copy link

@TomHart TomHart commented Jul 19, 2025

Q A
Bug fix? no
New feature? yes
Docs? yes
Issues N/A
License MIT

Add a Compiler Pass to find tools and register them in the ToolChain

@TomHart TomHart mentioned this pull request Jul 19, 2025
@TomHart TomHart changed the title Compiler pass for tools [McpBundle] Compiler pass for tools Jul 19, 2025
@TomHart TomHart force-pushed the compiler_pass_for_tools branch from c61b564 to 58536bd Compare July 19, 2025 23:35
@TomHart TomHart force-pushed the compiler_pass_for_tools branch 2 times, most recently from da439c8 to b1c22fe Compare July 20, 2025 09:33
@chr-hertel chr-hertel added the MCP Bundle Issues & PRs about the MCP SDK integration bundle label Jul 20, 2025
Copy link
Contributor

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @TomHart for working on this - this will def improve the usability with the bundle 👍
i left some comment and i think it would be great to rebase this on #165 - will merge that PR after some tests

@TomHart TomHart force-pushed the compiler_pass_for_tools branch 2 times, most recently from cd6c9f1 to 220575f Compare July 21, 2025 22:17
@TomHart
Copy link
Author

TomHart commented Jul 21, 2025

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.

@OskarStark
Copy link
Contributor

Could be a follow up PR, but I would like to have an attribute for this like in the agent

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
@TomHart TomHart force-pushed the compiler_pass_for_tools branch from 3b01c9b to 20ef42c Compare July 22, 2025 09:57
@TomHart
Copy link
Author

TomHart commented Jul 22, 2025

@chr-hertel my bad on missing the strict types, updated now and rebased into 1 commit

@OskarStark OskarStark requested a review from chr-hertel July 22, 2025 10:20
@@ -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')]
Copy link
Member

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 all Autoconfigure* 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.

return;
}

$definition = new Definition(ToolChain::class);
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MCP Bundle Issues & PRs about the MCP SDK integration bundle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants