-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Feature/add enable disable methods tools #728
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
base: main
Are you sure you want to change the base?
Feature/add enable disable methods tools #728
Conversation
…ble-methods-tools
@@ -72,4 +72,7 @@ async def call_tool( | ||
if not tool: | ||
raise ToolError(f"Unknown tool: {name}") | ||
|
||
if not tool.enabled: |
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.
Should we add similar checks in call_tool() and get_tool() as well?
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.
For call_tool() we already have the necessary validation checking if the tool is enabled.
And for get_tool(), I think we don't need to add this validation. We retrieve in get_tool() and validate in call_tool() where the tool is actually used.
This keeps the code cleaner and lets us access disabled tools when needed (for inspection, etc).
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 believe it needs a spec change as well. Do we already have a PR for it?
I've added it to the README in this commit: |
Added the ability to dynamically enable and disable tools at runtime with client notifications.
Motivation and Context
This change allows developers to temporarily restrict access to specific tools without removing them from the tool manager. This is useful for implementing feature flags, managing resource availability, or controlling access to functionality based on runtime conditions.
How Has This Been Tested?
Breaking Changes
The tool list now includes the enabled state of each tool. However, all tools are initialized with enabled=True by default, maintaining backward compatibility with existing code.
Types of changes
Checklist