-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Feature/add enable disable methods tools #728
Conversation
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: |
Thank you for this contribution. While dynamic tool enabling/disabling could be useful for testing, we're closing this PR because:
For testing, we recommend using different server configurations or mocking at the application level instead. |
I understand concerns about API complexity, but I'd like to offer a real-world perspective. The TypeScript MCP SDK already implements this pattern via the RegisteredTool type with methods like Their docs show a practical example for progressive auth: const putMessageTool = server.tool("putMessage", /* ... */);
putMessageTool.disable(); // User must authenticate first
const upgradeAuthTool = server.tool("upgradeAuth", /* ... */, async ({ permission }) => {
const { ok, previous } = await upgradeAuthAndStoreToken(permission);
if (previous === "read") putMessageTool.enable();
if (permission === "admin") upgradeAuthTool.remove();
}); This approach cleanly supports stateful logic, e.g., enabling tools based on auth state or feature flags, without complex conditions or restarts. It’s not just for testing; it solves real production needs where server behavior must adapt dynamically. |
Please can you expand on this? The Typescript Feature mentioned is for Dynamic Servers, is the intention here to support it in Python SDK? |
Yes, this feature implements the same Dynamic Servers capability from the TypeScript sdk.
Implementation:
|
5d49487
to
6b098e4
Compare
…/davidsp/field-wording improve wording for _meta field
Hi @davila7 thank you for this contribution! I believe this would constitute an enhancement of the actual MCP spec and would therefore need to go through a SEP to make sure we keep SDKs in sync and equivalent. However, I understand this is actually trying to create parity between Typescript and Python SDKs. Is this a feature we introduced in Typescript without it being in the actual MCP Spec? I at least can't find this explicit capability in the spec itself. @dsp-ant @ihrpr any thoughts in this case where we had a feature added to one SDK that may have been done before the SEP process was clearly established? Should we block on actually adding the feature to the spec here or prefer parity between SDKs? |
Coming back to this one again, I believe we have a similar PR up that's more recent with more engagement: #1322 I'm going to close this one as a potential duplicate - feel free to chime in on that PR or submit another if you disagree. |
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