Remove undocumented handler override methods#270
Merged
koic merged 1 commit intomodelcontextprotocol:mainfrom Mar 27, 2026
Merged
Conversation
## Motivation and Context The following public methods allow replacing the SDK's built-in request handlers: - `tools_call_handler` - `tools_list_handler` - `resources_list_handler` - `resources_templates_list_handler` - `prompts_list_handler` - `prompts_get_handler` These were introduced in Internal Release 0.2.0 (modelcontextprotocol@6004f42) as part of "allow setting handlers on Server", before declarative APIs (`define_tool`, `Prompt` class, `Resource` class) were fully established. Now that those declarative APIs exist, these handler overrides are redundant: none are documented in the README.md, and no usage exists outside of the SDK's own tests. These handler overrides also create architectural problems. Since custom handlers cannot receive session context, they would not work correctly with a per-session architecture, such as session-scoped notifications. ### Changes - Removed `tools_call_handler`, `tools_list_handler`, `resources_list_handler`, `resources_templates_list_handler`, `prompts_list_handler`, and `prompts_get_handler` from `Server`. - Removed the associated tests. - Retained `resources_read_handler` (documented in the README.md and actively used in examples and conformance server, because resource reading is application-specific). ## Breaking Change The following methods are removed without a deprecation period: `tools_call_handler`, `tools_list_handler`, `resources_list_handler`, `resources_templates_list_handler`, `prompts_list_handler`, `prompts_get_handler`. These were never documented in the README.md and have no known usage outside of the SDK's own tests. As a result, little to no impact on users is expected, and a deprecation warning would have no practical audience. Users who relied on these should use `define_tool`, prompt/resource registration, or `resources_read_handler` instead.
c4da3a2 to
805e020
Compare
atesgoral
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The following public methods allow replacing the SDK's built-in request handlers:
tools_call_handlertools_list_handlerresources_list_handlerresources_templates_list_handlerprompts_list_handlerprompts_get_handlerThese were introduced in Internal Release 0.2.0 (6004f42) as part of "allow setting handlers on Server", before declarative APIs (
define_tool,Promptclass,Resourceclass) were fully established.Now that those declarative APIs exist, these handler overrides are redundant: none are documented in the README.md, and no usage exists outside of the SDK's own tests.
These handler overrides also create architectural problems. Since custom handlers cannot receive session context, they would not work correctly with a per-session architecture, such as session-scoped notifications.
Changes
tools_call_handler,tools_list_handler,resources_list_handler,resources_templates_list_handler,prompts_list_handler, andprompts_get_handlerfromServer.resources_read_handler(documented in the README.md and actively used in examples and conformance server, because resource reading is application-specific).How Has This Been Tested?
The existing tests were updated and passed.
Breaking Change
The following methods are removed without a deprecation period:
tools_call_handler,tools_list_handler,resources_list_handler,resources_templates_list_handler,prompts_list_handler,prompts_get_handler.These were never documented in the README.md and have no known usage outside of the SDK's own tests. As a result, little to no impact on users is expected, and a deprecation warning would have no practical audience. Users who relied on these should use
define_tool, prompt/resource registration, orresources_read_handlerinstead.Types of changes
Checklist