mcp: Deprecate roots, sampling and logging (SEP-2577) (#1017)

Fixes #1013
This commit is contained in:
Guglielmo Colombo 2026-06-23 11:11:08 +02:00 • committed by GitHub
commit b6649db4f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -69,6 +69,11 @@ func compareLevels(l1, l2 LoggingLevel) int {
}
// LoggingHandlerOptions are options for a LoggingHandler.
//
// Deprecated: the logging feature is deprecated as of protocol version
// 2026-07-28 (SEP-2577). It remains functional during the deprecation window
// (at least twelve months). See
// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging.
type LoggingHandlerOptions struct {
// The value for the "logger" field of logging notifications.
LoggerName string
@ -79,6 +84,11 @@ type LoggingHandlerOptions struct {
}
// A LoggingHandler is a [slog.Handler] for MCP.
//
// Deprecated: the logging feature is deprecated as of protocol version
// 2026-07-28 (SEP-2577). It remains functional during the deprecation window
// (at least twelve months). See
// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging.
type LoggingHandler struct {
opts LoggingHandlerOptions
ss *ServerSession
@ -101,6 +111,11 @@ func ensureLogger(l *slog.Logger) *slog.Logger {
// NewLoggingHandler creates a [LoggingHandler] that logs to the given [ServerSession] using a
// [slog.JSONHandler].
//
// Deprecated: the logging feature is deprecated as of protocol version
// 2026-07-28 (SEP-2577). It remains functional during the deprecation window
// (at least twelve months). See
// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging.
func NewLoggingHandler(ss *ServerSession, opts *LoggingHandlerOptions) *LoggingHandler {
var buf bytes.Buffer
jsonHandler := slog.NewJSONHandler(&buf, &slog.HandlerOptions{