Skip to content

[Server][Client] Add SEP-3371 extension registration and custom methods - #777

Open
soyuka wants to merge 1 commit into
modelcontextprotocol:mainfrom
soyuka:feat/sep-3371-extension-registration
Open

soyuka wants to merge 1 commit into
modelcontextprotocol:mainfrom
soyuka:feat/sep-3371-extension-registration

Conversation

@soyuka

@soyuka soyuka commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Registration and custom methods from SEP-3371, on server and client. Middleware needs a design first, it'll come in its own PR.

  • MessageFactory::isCoreMethod(): an extension can't define a core method anymore (tools/call, initialize, ...), "core" being the methods the SDK knows (message registry, server/discover, subscriptions/listen and its ack) so there is no second list to keep in sync.
  • enableExtension(): an extension is validated before anything is stored, so a rejected one leaves nothing installed. This is per extension, in enableExtension($a, $b) a rejected $b doesn't remove $a.
  • DependentExtensionInterface::getRequiredExtensions(): checked on build so the order of enableExtension() calls doesn't matter, a missing one throws Extension "X" requires extension "Y", which is not enabled.
  • ClientExtensionInterface: request and notification handlers for the client. Handler types differ per side, so an extension with methods on both sides ships one class per side sharing the schema messages, which also fits the package split.
  • Client\Builder::enableExtension(): the client now decodes extension messages, before they were dropped with "Failed to parse message".
  • Client::sendRequest() is public (same signature as [Server] Add the Tasks extension (SEP-2663), experimental #776) and Client::notify() is new.
  • ClientGateway::request() is no longer @internal. The gateway is built per handler call from that call's session and keeps nothing else, so it's safe in worker mode.
  • docs/advanced/extensions.md lists the extension points and the SEP number per role, as the SEP asks.

[BC Break] ServerExtensionInterface::getNotificationHandlers(): the SEP wants extensions to bring notification handlers too, I'd rather have one interface per side than a second optional one, and we're pre-1.0 so the deprecation policy allows it. Implementers return [], #776 will need it when rebasing.

Not in this PR, and known limits:

  • no dependency on a core capability, only extension to extension. On the server capabilities are detected at build time and we'd need to decide which view counts.
  • no check for an app handler (addRequestHandler()) targeting an extension method: handlers pick their messages at runtime through supports() and the SEP allows replacing what a method does.
  • on 2026-07-28 the stateless server acknowledges notifications without dispatching them, so extension notification handlers only run on the handshake era.
  • ClientGateway::request() returns the raw Response or Error, and throws without a session or on 2026-07-28 where server to client requests don't exist.
  • the client dispatches a notification to the first handler supporting it, the server to all of them.

SEP-3371: reject extensions defining core methods, install an extension
whole or not at all, let extensions contribute notification handlers
(server, BC break on ServerExtensionInterface) and request/notification
handlers (client), let an extension require others, checked on build,
and expose sending custom requests and notifications on both sides.

This branch has not been deployed

No deployments
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.

1 participant