Skip to content

Deprecate Server.__init__ handlers for removed capabilities#3002

Merged
Kludex merged 1 commit into
mainfrom
deprecate-server-init-handlers
Jun 26, 2026
Merged

Deprecate Server.__init__ handlers for removed capabilities#3002
Kludex merged 1 commit into
mainfrom
deprecate-server-init-handlers

Conversation

@Kludex

@Kludex Kludex commented Jun 26, 2026

Copy link
Copy Markdown
Member

The 2026-07-28 spec deprecates Logging and Roots (SEP-2577) and the client-to-server progress notification. This deprecates the corresponding lowlevel Server.__init__ handler parameters: on_set_logging_level (Logging), on_roots_list_changed (Roots), and on_progress (client-to-server progress).

What changed

  • Server.__init__ is split into two @overloads: a clean signature without the three deprecated parameters, and a typing_extensions.deprecated overload with them. Passing any of the three resolves to the deprecated overload, so type checkers and IDEs flag it.
  • The real constructor emits MCPDeprecationWarning at runtime when a deprecated handler is passed, with messages matching the existing SEP-2577 / progress wording (so the project's existing filterwarnings ignores already cover them).
  • The non-deprecated overload omits the parameters entirely, keeping the common case warning-free.
  • Existing call sites that intentionally register these handlers (to advertise the capability) carry # pyright: ignore[reportDeprecated]; the stdio subprocess test helper guards construction with warnings.catch_warnings() since the global pytest filter doesn't reach the child process.
  • Documented in docs/migration.md, grouped into the existing SEP-2577 section.

100% coverage on the touched module; pyright, ruff, strict-no-cover, and the full suite pass.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

The 2026-07-28 spec deprecates Logging and Roots (SEP-2577) and the
client-to-server progress notification. Their lowlevel `Server.__init__`
handler parameters - `on_set_logging_level`, `on_roots_list_changed`, and
`on_progress` - are now split into a `typing_extensions.deprecated`
overload, so type checkers and IDEs flag them, and the real constructor
emits `MCPDeprecationWarning` at runtime when one is passed. The
non-deprecated overload omits these parameters, keeping the common case
warning-free.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 12 files

Re-trigger cubic

@Kludex Kludex merged commit ecdf09d into main Jun 26, 2026
36 of 37 checks passed
@Kludex Kludex deleted the deprecate-server-init-handlers branch June 26, 2026 15:51

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — mechanical deprecation following the established SEP-2577 pattern; no behavior change beyond the new warnings.

Extended reasoning...

Overview

The PR deprecates three lowlevel Server.__init__ handler parameters (on_set_logging_level, on_roots_list_changed, on_progress) by splitting the constructor into a clean overload and a typing_extensions.deprecated overload, plus emitting MCPDeprecationWarning at runtime when any of the three is passed. The remaining files are documentation (docs/migration.md) and test/example call sites annotated with # pyright: ignore[reportDeprecated], with the stdio subprocess helper additionally guarding construction with warnings.catch_warnings().

Security risks

None. The change adds overloads and warning emission only; no auth, crypto, transport, or input-handling logic is touched, and no runtime behavior changes for existing handlers — they are still registered exactly as before.

Level of scrutiny

The diff is large in line count, but almost entirely duplicated constructor signatures required by the overload pattern. The substantive change is three warnings.warn calls. The runtime warning messages match the repository's existing filterwarnings ignores in pyproject.toml (.*is deprecated as of 2026-07-28 \(SEP-2577\). and Client-to-server progress is deprecated as of 2026-07-28.*), so the test suite's strict warning configuration is not tripped. No internal SDK code constructs Server with the deprecated parameters, so library consumers using MCPServer are unaffected.

Other factors

This mirrors the deprecation approach already used throughout the SDK for SEP-2577 (same wording, same MCPDeprecationWarning category), the bug-hunting pass found no issues, and the author reports pyright/ruff/full-suite/coverage all passing. The risk profile is low enough that human review adds little here.

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