Skip to content

feat: enhance load_mcp_tools to support loading specific tool names #241

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 4 commits into
base: main
Choose a base branch
from

Conversation

msamon-nrg
Copy link

@msamon-nrg msamon-nrg commented Jun 27, 2025

Summary

This PR updates the load_mcp_tools function in tools.py to support loading a specific subset of tools by their IDs. It also adds new unit tests to verify this behavior.

Details

Feature:

The load_mcp_tools function now accepts an optional tool_names argument (a list of string tool names/IDs).
If tool_names is provided and not empty, only tools with matching names are loaded.
If tool_names is empty or not provided, all available tools are loaded (existing behavior).

Tests:

Added test_load_mcp_tools_with_no_tool_names_e2e to verify that all tools are loaded when no IDs are specified.
Added test_load_mcp_tools_with_specific_tool_names_e2e to verify that only the specified tools are loaded when IDs are provided.

Motivation

This change allows users to selectively load only the tools they need, improving efficiency and flexibility when working with large sets of MCP tools.

Additional Notes

All new and existing tests pass with the updated implementation.

@eyurtsev eyurtsev self-assigned this Jun 27, 2025
@eyurtsev
Copy link
Collaborator

Overall looks good. I'd like to move away from unit tests into end to end tests since the abstraction is so thin.

@msamon-nrg
Copy link
Author

Ok @eyurtsev are there any examples of end to end tests in the repo already?

@eyurtsev
Copy link
Collaborator

Yes -- git grep for with run_streamable_http(server) -- it's in the same file as you've added tests.

We'll also need to replace tool_ids with tool_names to match the mcp spec.

@msamon-nrg
Copy link
Author

Conflict resolved. This PR is ready for another review @eyurtsev

@msamon-nrg msamon-nrg changed the title feat: enhance load_mcp_tools to support loading specific tool IDs feat: enhance load_mcp_tools to support loading specific tool names Jul 25, 2025
@grantmca
Copy link

I like this, it would be really nice if we could get a public method for listing MCP tools. That way we could filter on _meta and only convert the tools we want (Or on name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants