Skip to content

Remove undocumented handler override methods#270

Merged
koic merged 1 commit intomodelcontextprotocol:mainfrom
koic:remove_undocumented_handler_override_methods
Mar 27, 2026
Merged

Remove undocumented handler override methods#270
koic merged 1 commit intomodelcontextprotocol:mainfrom
koic:remove_undocumented_handler_override_methods

Conversation

@koic
Copy link
Copy Markdown
Member

@koic koic commented Mar 26, 2026

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 (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).

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, or resources_read_handler instead.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## 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.
@koic koic force-pushed the remove_undocumented_handler_override_methods branch from c4da3a2 to 805e020 Compare March 26, 2026 03:14
@koic koic merged commit a9e4514 into modelcontextprotocol:main Mar 27, 2026
11 checks passed
@koic koic deleted the remove_undocumented_handler_override_methods branch March 27, 2026 15:24
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.

2 participants