From 3878012c38bd98e775662712eeab97310c3cca1d Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Sun, 21 Jun 2026 17:33:59 +0000 Subject: [PATCH 1/3] feat: deprecate roots, sampling, and logging features per SEP-2577 and suppress staticcheck warnings --- README.md | 7 ++ conformance/everything-server/main.go | 2 + docs/client.md | 14 ++++ docs/server.md | 7 ++ docs/troubleshooting.md | 6 ++ examples/server/distributed/main.go | 2 + examples/server/everything/main.go | 2 + internal/docs/client.src.md | 14 ++++ internal/docs/server.src.md | 7 ++ internal/docs/troubleshooting.src.md | 6 ++ internal/readme/README.src.md | 7 ++ mcp/capabilities_test.go | 2 + mcp/client.go | 48 ++++++++++++-- mcp/client_example_test.go | 2 + mcp/client_test.go | 2 + mcp/logging.go | 20 +++++- mcp/mcp_test.go | 2 + mcp/mrtr.go | 6 +- mcp/mrtr_test.go | 2 + mcp/protocol.go | 93 ++++++++++++++++++++++++++- mcp/sampling_test.go | 2 + mcp/server.go | 53 ++++++++++++++- mcp/server_example_test.go | 2 + mcp/streamable_test.go | 2 + 24 files changed, 300 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ffaf33e1..f9bf4eb9 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,13 @@ The following table shows which versions of the Go SDK support which versions of \*\* Partial support for 2025-11-25 (client side OAuth and Sampling with tools not available). +The roots, sampling, and logging features are deprecated as of protocol version +2026-07-28 by +[SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging). +The SDK continues to support them for compatibility during the deprecation +window (at least twelve months). See the individual feature documentation for +migration guidance. + New releases of the SDK target only supported versions of Go. See https://go.dev/doc/devel/release#policy for more information. diff --git a/conformance/everything-server/main.go b/conformance/everything-server/main.go index 70bd4bcd..b815b566 100644 --- a/conformance/everything-server/main.go +++ b/conformance/everything-server/main.go @@ -5,6 +5,8 @@ // The conformance server implements features required for MCP conformance testing. // It mirrors the functionality of the TypeScript conformance server at // https://github.com/modelcontextprotocol/conformance/blob/main/examples/servers/typescript/everything-server.ts +// +//lint:file-ignore SA1019 conformance server exercises deprecated SEP-2577 APIs (roots, sampling, logging). package main import ( diff --git a/docs/client.md b/docs/client.md index 565fae96..cb96ff9b 100644 --- a/docs/client.md +++ b/docs/client.md @@ -10,6 +10,13 @@ ## Roots +> **Note:** The roots feature is deprecated as of protocol version 2026-07-28 +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). +> It remains fully functional during the deprecation window (at least twelve +> months). The SDK continues to support roots for compatibility. New code +> should pass paths via tool parameters, resource URIs, or configuration +> instead. + MCP allows clients to specify a set of filesystem ["roots"](https://modelcontextprotocol.io/specification/2025-06-18/client/roots). The SDK supports this as follows: @@ -77,6 +84,13 @@ func Example_roots() { ## Sampling +> **Note:** The sampling feature is deprecated as of protocol version +> 2026-07-28 +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). +> It remains fully functional during the deprecation window (at least twelve +> months). The SDK continues to support sampling for compatibility. Servers +> that need LLM completions should call LLM provider APIs directly. + [Sampling](https://modelcontextprotocol.io/specification/2025-06-18/client/sampling) is a way for servers to leverage the client's AI capabilities. It is implemented in the SDK as follows: diff --git a/docs/server.md b/docs/server.md index 8fe6bd37..a24a58ea 100644 --- a/docs/server.md +++ b/docs/server.md @@ -474,6 +474,13 @@ _ = mcp.NewServer(&mcp.Implementation{Name: "server"}, &mcp.ServerOptions{ ### Logging +> **Note:** The logging feature is deprecated as of protocol version +> 2026-07-28 +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). +> It remains fully functional during the deprecation window (at least twelve +> months). The SDK continues to support logging for compatibility. Servers +> should migrate to stderr logging (for STDIO transports) or OpenTelemetry. + MCP servers can send logging messages to MCP clients. (This form of logging is distinct from server-side logging, where the server produces logs that remain server-side, for use by server maintainers.) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 1a0c3679..59af4175 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -21,6 +21,12 @@ SDK, as well as inspecting MCP traffic. ## Collecting MCP logs +> **Note:** `LoggingTransport` is a debugging tool that records JSON-RPC +> traffic; it is **not** the deprecated MCP logging feature +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)), +> which concerns `logging/setLevel` and `notifications/message`. +> `LoggingTransport` is unaffected by that deprecation. + For [stdio](protocol.md#stdio-transport) transport connections, you can also inspect MCP traffic using a `LoggingTransport`: diff --git a/examples/server/distributed/main.go b/examples/server/distributed/main.go index 0e5dfe51..888cba54 100644 --- a/examples/server/distributed/main.go +++ b/examples/server/distributed/main.go @@ -16,6 +16,8 @@ // Example: // // ./distributed -http=localhost:8080 -child_ports=8081,8082 +// +//lint:file-ignore SA1019 example server exercises deprecated SEP-2577 logging API for demonstration. package main import ( diff --git a/examples/server/everything/main.go b/examples/server/everything/main.go index e7634ced..a08cac83 100644 --- a/examples/server/everything/main.go +++ b/examples/server/everything/main.go @@ -3,6 +3,8 @@ // license that can be found in the LICENSE file. // The everything server implements all supported features of an MCP server. +// +//lint:file-ignore SA1019 example server exercises deprecated SEP-2577 APIs (roots, sampling, logging) for demonstration. package main import ( diff --git a/internal/docs/client.src.md b/internal/docs/client.src.md index f6ae786f..213078d5 100644 --- a/internal/docs/client.src.md +++ b/internal/docs/client.src.md @@ -4,6 +4,13 @@ ## Roots +> **Note:** The roots feature is deprecated as of protocol version 2026-07-28 +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). +> It remains fully functional during the deprecation window (at least twelve +> months). The SDK continues to support roots for compatibility. New code +> should pass paths via tool parameters, resource URIs, or configuration +> instead. + MCP allows clients to specify a set of filesystem ["roots"](https://modelcontextprotocol.io/specification/2025-06-18/client/roots). The SDK supports this as follows: @@ -26,6 +33,13 @@ method. To receive notifications about root changes, set ## Sampling +> **Note:** The sampling feature is deprecated as of protocol version +> 2026-07-28 +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). +> It remains fully functional during the deprecation window (at least twelve +> months). The SDK continues to support sampling for compatibility. Servers +> that need LLM completions should call LLM provider APIs directly. + [Sampling](https://modelcontextprotocol.io/specification/2025-06-18/client/sampling) is a way for servers to leverage the client's AI capabilities. It is implemented in the SDK as follows: diff --git a/internal/docs/server.src.md b/internal/docs/server.src.md index 26dba5a5..744015fc 100644 --- a/internal/docs/server.src.md +++ b/internal/docs/server.src.md @@ -236,6 +236,13 @@ requests. ### Logging +> **Note:** The logging feature is deprecated as of protocol version +> 2026-07-28 +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). +> It remains fully functional during the deprecation window (at least twelve +> months). The SDK continues to support logging for compatibility. Servers +> should migrate to stderr logging (for STDIO transports) or OpenTelemetry. + MCP servers can send logging messages to MCP clients. (This form of logging is distinct from server-side logging, where the server produces logs that remain server-side, for use by server maintainers.) diff --git a/internal/docs/troubleshooting.src.md b/internal/docs/troubleshooting.src.md index 83342032..ed06fe5b 100644 --- a/internal/docs/troubleshooting.src.md +++ b/internal/docs/troubleshooting.src.md @@ -20,6 +20,12 @@ SDK, as well as inspecting MCP traffic. ## Collecting MCP logs +> **Note:** `LoggingTransport` is a debugging tool that records JSON-RPC +> traffic; it is **not** the deprecated MCP logging feature +> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)), +> which concerns `logging/setLevel` and `notifications/message`. +> `LoggingTransport` is unaffected by that deprecation. + For [stdio](protocol.md#stdio-transport) transport connections, you can also inspect MCP traffic using a `LoggingTransport`: diff --git a/internal/readme/README.src.md b/internal/readme/README.src.md index d419b022..84126ad3 100644 --- a/internal/readme/README.src.md +++ b/internal/readme/README.src.md @@ -43,6 +43,13 @@ The following table shows which versions of the Go SDK support which versions of \*\* Partial support for 2025-11-25 (client side OAuth and Sampling with tools not available). +The roots, sampling, and logging features are deprecated as of protocol version +2026-07-28 by +[SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging). +The SDK continues to support them for compatibility during the deprecation +window (at least twelve months). See the individual feature documentation for +migration guidance. + New releases of the SDK target only supported versions of Go. See https://go.dev/doc/devel/release#policy for more information. diff --git a/mcp/capabilities_test.go b/mcp/capabilities_test.go index 01ff45fa..b8456168 100644 --- a/mcp/capabilities_test.go +++ b/mcp/capabilities_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. +//lint:file-ignore SA1019 tests exercise deprecated SEP-2577 APIs (roots, sampling, logging). + package mcp import ( diff --git a/mcp/client.go b/mcp/client.go index b89b9625..8e00bb49 100644 --- a/mcp/client.go +++ b/mcp/client.go @@ -82,6 +82,12 @@ type ClientOptions struct { // &SamplingCapabilities{}. If [ClientOptions.Capabilities] is set and has a // non nil value for [ClientCapabilities.Sampling], that value overrides the // inferred capability. + // + // Deprecated: the sampling feature is deprecated as of protocol version + // 2026-07-28 (SEP-2577). It remains functional during the deprecation + // window (at least twelve months). Migrate to calling LLM provider APIs + // directly from your server. See + // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. CreateMessageHandler func(context.Context, *CreateMessageRequest) (*CreateMessageResult, error) // CreateMessageWithToolsHandler handles incoming sampling/createMessage // requests that may involve tool use. It returns @@ -95,6 +101,12 @@ type ClientOptions struct { // // It is a panic to set both CreateMessageHandler and // CreateMessageWithToolsHandler. + // + // Deprecated: the sampling feature is deprecated as of protocol version + // 2026-07-28 (SEP-2577). It remains functional during the deprecation + // window (at least twelve months). Migrate to calling LLM provider APIs + // directly from your server. See + // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. CreateMessageWithToolsHandler func(context.Context, *CreateMessageWithToolsRequest) (*CreateMessageWithToolsResult, error) // ElicitationHandler handles incoming requests for elicitation/create. // @@ -152,10 +164,18 @@ type ClientOptions struct { // ElicitationCompleteHandler handles incoming notifications for notifications/elicitation/complete. ElicitationCompleteHandler func(context.Context, *ElicitationCompleteNotificationRequest) // Handlers for notifications from the server. - ToolListChangedHandler func(context.Context, *ToolListChangedRequest) - PromptListChangedHandler func(context.Context, *PromptListChangedRequest) - ResourceListChangedHandler func(context.Context, *ResourceListChangedRequest) - ResourceUpdatedHandler func(context.Context, *ResourceUpdatedNotificationRequest) + ToolListChangedHandler func(context.Context, *ToolListChangedRequest) + PromptListChangedHandler func(context.Context, *PromptListChangedRequest) + ResourceListChangedHandler func(context.Context, *ResourceListChangedRequest) + ResourceUpdatedHandler func(context.Context, *ResourceUpdatedNotificationRequest) + // LoggingMessageHandler handles incoming notifications/message + // notifications from the server. + // + // 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). Migrate to consuming stderr output + // (for STDIO servers) or OpenTelemetry. See + // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. LoggingMessageHandler func(context.Context, *LoggingMessageRequest) ProgressNotificationHandler func(context.Context, *ProgressNotificationClientRequest) // MultiRoundTrip configures the automatic MultiRoundTrip (Multi Round-Trip Requests) middleware. @@ -577,6 +597,12 @@ func (cs *ClientSession) startKeepalive(interval time.Duration) { // AddRoots adds the given roots to the client, // replacing any with the same URIs, // and notifies any connected servers. +// +// Deprecated: the roots feature is deprecated as of protocol version +// 2026-07-28 (SEP-2577). It remains functional during the deprecation window +// (at least twelve months). Migrate to passing paths via tool parameters, +// resource URIs, or configuration. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (c *Client) AddRoots(roots ...*Root) { // Only notify if something could change. if len(roots) == 0 { @@ -589,6 +615,12 @@ func (c *Client) AddRoots(roots ...*Root) { // RemoveRoots removes the roots with the given URIs, // and notifies any connected servers if the list has changed. // It is not an error to remove a nonexistent root. +// +// Deprecated: the roots feature is deprecated as of protocol version +// 2026-07-28 (SEP-2577). It remains functional during the deprecation window +// (at least twelve months). Migrate to passing paths via tool parameters, +// resource URIs, or configuration. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (c *Client) RemoveRoots(uris ...string) { changeAndNotify(c, notificationRootsListChanged, &RootsListChangedParams{}, func() bool { return c.roots.remove(uris...) }) @@ -1203,6 +1235,14 @@ func (cs *ClientSession) CallTool(ctx context.Context, params *CallToolParams) ( return handleSend[*CallToolResult](ctx, methodCallTool, newClientRequest(cs, orZero[Params](params))) } +// SetLoggingLevel sets the minimum severity level for log messages sent by +// the server. +// +// 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). Migrate to consuming stderr output (for STDIO +// servers) or OpenTelemetry. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (cs *ClientSession) SetLoggingLevel(ctx context.Context, params *SetLoggingLevelParams) error { _, err := handleSend[*emptyResult](ctx, methodSetLevel, newClientRequest(cs, orZero[Params](params))) return err diff --git a/mcp/client_example_test.go b/mcp/client_example_test.go index cc7146c2..33b0a449 100644 --- a/mcp/client_example_test.go +++ b/mcp/client_example_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. +//lint:file-ignore SA1019 examples exercise deprecated SEP-2577 APIs (roots, sampling) for demonstration. + package mcp_test import ( diff --git a/mcp/client_test.go b/mcp/client_test.go index d6f02323..c540a02b 100644 --- a/mcp/client_test.go +++ b/mcp/client_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. +//lint:file-ignore SA1019 tests exercise deprecated SEP-2577 APIs (roots, sampling, logging). + package mcp import ( diff --git a/mcp/logging.go b/mcp/logging.go index e77c6e11..e17fc9fa 100644 --- a/mcp/logging.go +++ b/mcp/logging.go @@ -69,6 +69,12 @@ 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). Migrate to stderr logging (for STDIO servers) or +// OpenTelemetry. 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 +85,12 @@ 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). Migrate to stderr logging (for STDIO servers) or +// OpenTelemetry. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type LoggingHandler struct { opts LoggingHandlerOptions ss *ServerSession @@ -101,6 +113,12 @@ 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). Migrate to stderr logging (for STDIO servers) or +// OpenTelemetry. 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{ @@ -194,5 +212,5 @@ func (h *LoggingHandler) handle(ctx context.Context, r slog.Record) error { // documentation says not to. // In this case logging is a service to clients, not a means for debugging the // server, so we want to cancel the log message. - return h.ss.Log(ctx, params) + return h.ss.log(ctx, params) } diff --git a/mcp/mcp_test.go b/mcp/mcp_test.go index 5c8e7d12..5d08752c 100644 --- a/mcp/mcp_test.go +++ b/mcp/mcp_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. +//lint:file-ignore SA1019 tests exercise deprecated SEP-2577 APIs (roots, sampling, logging). + package mcp import ( diff --git a/mcp/mrtr.go b/mcp/mrtr.go index 8ad5f1ae..49b7d074 100644 --- a/mcp/mrtr.go +++ b/mcp/mrtr.go @@ -185,11 +185,11 @@ func fulfillServerInputRequest(ctx context.Context, ss *ServerSession, ir InputR case *ElicitParams: return ss.Elicit(ctx, p) case *CreateMessageParams: - return ss.CreateMessageWithTools(ctx, createMessageParamsToWithTools(p)) + return ss.createMessageWithTools(ctx, createMessageParamsToWithTools(p)) case *CreateMessageWithToolsParams: - return ss.CreateMessageWithTools(ctx, p) + return ss.createMessageWithTools(ctx, p) case *ListRootsParams: - return ss.ListRoots(ctx, p) + return ss.listRoots(ctx, p) default: return nil, fmt.Errorf("unknown input request type: %T", ir) } diff --git a/mcp/mrtr_test.go b/mcp/mrtr_test.go index 230eb3bf..8f58ff20 100644 --- a/mcp/mrtr_test.go +++ b/mcp/mrtr_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the license // that can be found in the LICENSE file. +//lint:file-ignore SA1019 tests exercise deprecated SEP-2577 APIs (roots, sampling, logging). + package mcp import ( diff --git a/mcp/protocol.go b/mcp/protocol.go index 54472123..8e43282e 100644 --- a/mcp/protocol.go +++ b/mcp/protocol.go @@ -439,6 +439,10 @@ func (x *CancelledParams) GetProgressToken() any { return getProgressToken(x) } func (x *CancelledParams) SetProgressToken(t any) { setProgressToken(x, t) } // RootCapabilities describes a client's support for roots. +// +// Part of the roots feature, deprecated by SEP-2577. Remains on the wire for +// compatibility during the deprecation window (at least twelve months). See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type RootCapabilities struct { // ListChanged reports whether the client supports notifications for // changes to the roots list. @@ -466,14 +470,26 @@ type ClientCapabilities struct { // Deprecated: use RootsV2. As described in #607, Roots should have been a // pointer to a RootCapabilities value. Roots will be continue to be // populated, but any new fields will only be added in the RootsV2 field. + // + // The roots feature itself is also deprecated by SEP-2577; see RootsV2. Roots struct { // ListChanged reports whether the client supports notifications for // changes to the roots list. ListChanged bool `json:"listChanged,omitempty"` } `json:"roots,omitempty"` - // RootsV2 is present if the client supports roots. When capabilities are explicitly configured via [ClientOptions.Capabilities] + // RootsV2 is present if the client supports roots. When capabilities are explicitly configured via [ClientOptions.Capabilities]. + // + // The roots feature is deprecated by SEP-2577; the capability remains on the + // wire for compatibility during the deprecation window (at least twelve + // months). See + // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. RootsV2 *RootCapabilities `json:"-"` // Sampling is present if the client supports sampling from an LLM. + // + // The sampling feature is deprecated by SEP-2577; the capability remains on + // the wire for compatibility during the deprecation window (at least twelve + // months). See + // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. Sampling *SamplingCapabilities `json:"sampling,omitempty"` // Elicitation is present if the client supports elicitation from the server. Elicitation *ElicitationCapabilities `json:"elicitation,omitempty"` @@ -641,6 +657,11 @@ type CompleteResult struct { func (*CompleteResult) isResult() {} +// CreateMessageParams holds parameters for a sampling/createMessage request. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type CreateMessageParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -681,6 +702,10 @@ func (x *CreateMessageParams) SetProgressToken(t any) { setProgressToken(x, t) } // and messages that support array content (for parallel tool calls). // // Use with [ServerSession.CreateMessageWithTools]. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type CreateMessageWithToolsParams struct { Meta `json:"_meta,omitempty"` IncludeContext string `json:"includeContext,omitempty"` @@ -741,6 +766,10 @@ func (p *CreateMessageWithToolsParams) toBase() (*CreateMessageParams, error) { // object for compatibility with pre-2025-11-25 implementations. When // unmarshaling, a single JSON content object is accepted and wrapped in a // one-element slice. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type SamplingMessageV2 struct { Content []Content `json:"content"` Role Role `json:"role"` @@ -782,6 +811,10 @@ func (m *SamplingMessageV2) UnmarshalJSON(data []byte) error { // The client should inform the user before returning the sampled message, to // allow them to inspect the response (human in the loop) and decide whether to // allow the server to see it. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type CreateMessageResult struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -828,6 +861,10 @@ func (r *CreateMessageResult) UnmarshalJSON(data []byte) error { // // When unmarshaling, a single JSON content object is accepted and wrapped in a // one-element slice, for compatibility with clients that return a single block. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type CreateMessageWithToolsResult struct { Meta `json:"_meta,omitempty"` Content []Content `json:"content"` @@ -1233,6 +1270,10 @@ func (x *ListRootsParams) SetProgressToken(t any) { setProgressToken(x, t) } // The client's response to a roots/list request from the server. This result // contains an array of Root objects, each representing a root directory or file // that the server can operate on. +// +// Part of the roots feature, deprecated by SEP-2577. Remains on the wire for +// compatibility during the deprecation window (at least twelve months). See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type ListRootsResult struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -1277,8 +1318,18 @@ func (x *ListToolsResult) nextCursorPtr() *string { return &x.NextCursor } // // These map to syslog message severities, as specified in RFC-5424: // https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 +// +// Part of the logging feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type LoggingLevel string +// LoggingMessageParams holds the parameters for a notifications/message +// notification. +// +// Part of the logging feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type LoggingMessageParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -1301,6 +1352,10 @@ func (x *LoggingMessageParams) SetProgressToken(t any) { setProgressToken(x, t) // // Keys not declared here are currently left unspecified by the spec and are up // to the client to interpret. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type ModelHint struct { // A hint for a model name. // @@ -1327,6 +1382,10 @@ type ModelHint struct { // These preferences are always advisory. The client may ignore them. It is also // up to the client to decide how to interpret these preferences and how to // balance them against other considerations. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type ModelPreferences struct { // How much to prioritize cost when selecting a model. A value of 0 means cost // is not important, while a value of 1 means cost is the most important factor. @@ -1652,6 +1711,10 @@ type ResourceTemplate struct { type Role string // Represents a root directory or file that the server can operate on. +// +// Part of the roots feature, deprecated by SEP-2577. Remains on the wire for +// compatibility during the deprecation window (at least twelve months). See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type Root struct { // See [specification/2025-06-18/basic/index#general-fields] for notes on _meta // usage. @@ -1681,6 +1744,10 @@ func (x *RootsListChangedParams) SetProgressToken(t any) { setProgressToken(x, t // below directly above ClientCapabilities. // SamplingCapabilities describes the client's support for sampling. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type SamplingCapabilities struct { // Context indicates the client supports includeContext values other than "none". Context *SamplingContextCapabilities `json:"context,omitempty"` @@ -1689,9 +1756,15 @@ type SamplingCapabilities struct { } // SamplingContextCapabilities indicates the client supports context inclusion. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). type SamplingContextCapabilities struct{} // SamplingToolsCapabilities indicates the client supports tool use in sampling. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). type SamplingToolsCapabilities struct{} // ToolChoice controls how the model uses tools during sampling. @@ -1721,6 +1794,10 @@ type URLElicitationCapabilities struct{} // // For assistant messages, Content may be text, image, audio, or tool_use. // For user messages, Content may be text, image, audio, or tool_result. +// +// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type SamplingMessage struct { Content Content `json:"content"` Role Role `json:"role"` @@ -1746,6 +1823,11 @@ func (m *SamplingMessage) UnmarshalJSON(data []byte) error { return nil } +// SetLoggingLevelParams holds parameters for a logging/setLevel request. +// +// Part of the logging feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type SetLoggingLevelParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -2028,6 +2110,10 @@ type Implementation struct { type CompletionCapabilities struct{} // LoggingCapabilities describes the server's support for sending log messages to the client. +// +// Part of the logging feature, deprecated by SEP-2577. Remains on the wire +// for compatibility during the deprecation window (at least twelve months). +// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type LoggingCapabilities struct{} // PromptCapabilities describes the server's support for prompts. @@ -2071,6 +2157,11 @@ type ServerCapabilities struct { // suggestions. Completions *CompletionCapabilities `json:"completions,omitempty"` // Logging is present if the server supports log messages. + // + // The logging feature is deprecated by SEP-2577; the capability remains on + // the wire for compatibility during the deprecation window (at least + // twelve months). See + // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. Logging *LoggingCapabilities `json:"logging,omitempty"` // Prompts is present if the server supports prompts. Prompts *PromptCapabilities `json:"prompts,omitempty"` diff --git a/mcp/sampling_test.go b/mcp/sampling_test.go index bdffd452..79c8213e 100644 --- a/mcp/sampling_test.go +++ b/mcp/sampling_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. +//lint:file-ignore SA1019 tests exercise deprecated SEP-2577 sampling APIs. + package mcp // TODO: move other sampling-related tests to this file. diff --git a/mcp/server.go b/mcp/server.go index a53cb647..e0bf23d0 100644 --- a/mcp/server.go +++ b/mcp/server.go @@ -70,6 +70,12 @@ type ServerOptions struct { // If zero, defaults to [DefaultPageSize]. PageSize int // If non-nil, called when "notifications/roots/list_changed" is received. + // + // Deprecated: the roots feature is deprecated as of protocol version + // 2026-07-28 (SEP-2577). It remains functional during the deprecation + // window (at least twelve months). Migrate to passing paths via tool + // parameters, resource URIs, or configuration. See + // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. RootsListChangedHandler func(context.Context, *RootsListChangedRequest) // If non-nil, called when "notifications/progress" is received. ProgressNotificationHandler func(context.Context, *ProgressNotificationServerRequest) @@ -979,7 +985,7 @@ func fileResourceHandler(dir string) ResourceHandler { defer util.Wrapf(&err, "reading resource %s", req.Params.URI) // TODO(#25): use a memoizing API here. - rootRes, err := req.Session.ListRoots(ctx, nil) + rootRes, err := req.Session.listRoots(ctx, nil) if err != nil { return nil, fmt.Errorf("listing roots: %w", err) } @@ -1304,7 +1310,20 @@ func (ss *ServerSession) Ping(ctx context.Context, params *PingParams) error { } // ListRoots lists the client roots. +// +// Deprecated: the roots feature is deprecated as of protocol version +// 2026-07-28 (SEP-2577). It remains functional during the deprecation window +// (at least twelve months). Migrate to passing paths via tool parameters, +// resource URIs, or configuration. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) ListRoots(ctx context.Context, params *ListRootsParams) (*ListRootsResult, error) { + return ss.listRoots(ctx, params) +} + +// listRoots is the unexported implementation of ListRoots, used by the SDK's +// own call sites so they don't trip staticcheck SA1019 on the deprecated +// public method. +func (ss *ServerSession) listRoots(ctx context.Context, params *ListRootsParams) (*ListRootsResult, error) { if err := ss.checkInitialized(methodListRoots); err != nil { return nil, err } @@ -1316,6 +1335,12 @@ func (ss *ServerSession) ListRoots(ctx context.Context, params *ListRootsParams) // If the client returns multiple content blocks (e.g. parallel tool calls), // CreateMessage returns an error. Use [ServerSession.CreateMessageWithTools] // for tool-enabled sampling. +// +// Deprecated: the sampling feature is deprecated as of protocol version +// 2026-07-28 (SEP-2577). It remains functional during the deprecation window +// (at least twelve months). Migrate to calling LLM provider APIs directly +// from your server. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) CreateMessage(ctx context.Context, params *CreateMessageParams) (*CreateMessageResult, error) { if err := ss.checkInitialized(methodCreateMessage); err != nil { return nil, err @@ -1353,7 +1378,20 @@ func (ss *ServerSession) CreateMessage(ctx context.Context, params *CreateMessag // returning a [CreateMessageWithToolsResult] that supports array content // (for parallel tool calls). Use this instead of [ServerSession.CreateMessage] // when the request includes tools. +// +// Deprecated: the sampling feature is deprecated as of protocol version +// 2026-07-28 (SEP-2577). It remains functional during the deprecation window +// (at least twelve months). Migrate to calling LLM provider APIs directly +// from your server. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) CreateMessageWithTools(ctx context.Context, params *CreateMessageWithToolsParams) (*CreateMessageWithToolsResult, error) { + return ss.createMessageWithTools(ctx, params) +} + +// createMessageWithTools is the unexported implementation of +// CreateMessageWithTools, used by the SDK's own call sites so they don't trip +// staticcheck SA1019 on the deprecated public method. +func (ss *ServerSession) createMessageWithTools(ctx context.Context, params *CreateMessageWithToolsParams) (*CreateMessageWithToolsResult, error) { if err := ss.checkInitialized(methodCreateMessage); err != nil { return nil, err } @@ -1454,7 +1492,20 @@ type logLevelContextKey struct{} // originating request's `_meta` field (SEP-2575); an absent or empty value // suppresses the message per spec. For old-protocol requests, the level is // taken from the session state set via `logging/setLevel`. +// +// 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). Migrate to stderr logging (for STDIO servers) or +// OpenTelemetry. See +// https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) Log(ctx context.Context, params *LoggingMessageParams) error { + return ss.log(ctx, params) +} + +// log is the unexported implementation of Log, used by the SDK's own call +// sites (notably [LoggingHandler]) so they don't trip staticcheck SA1019 on +// the deprecated public method. +func (ss *ServerSession) log(ctx context.Context, params *LoggingMessageParams) error { logLevel, ok := ctx.Value(logLevelContextKey{}).(LoggingLevel) if !ok { ss.mu.Lock() diff --git a/mcp/server_example_test.go b/mcp/server_example_test.go index db04920b..808be5af 100644 --- a/mcp/server_example_test.go +++ b/mcp/server_example_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. +//lint:file-ignore SA1019 examples exercise deprecated SEP-2577 logging APIs for demonstration. + package mcp_test import ( diff --git a/mcp/streamable_test.go b/mcp/streamable_test.go index 79934b4d..37b2b626 100644 --- a/mcp/streamable_test.go +++ b/mcp/streamable_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. +//lint:file-ignore SA1019 tests exercise deprecated SEP-2577 APIs (roots, sampling, logging). + package mcp import ( From 8ec7c0330087cd41771f27e350fb868307dc81c1 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 22 Jun 2026 11:57:29 +0000 Subject: [PATCH 2/3] docs: update protocol deprecation notices and add IncludeContext to CreateMessageWithToolsParams --- mcp/content.go | 10 +++ mcp/logging.go | 2 +- mcp/mrtr.go | 6 +- mcp/protocol.go | 181 +++++++++++++++++++++++++++++++----------------- mcp/server.go | 43 ++---------- 5 files changed, 136 insertions(+), 106 deletions(-) diff --git a/mcp/content.go b/mcp/content.go index 39c25ffd..7af90fe7 100644 --- a/mcp/content.go +++ b/mcp/content.go @@ -189,6 +189,11 @@ func (c *EmbeddedResource) fromWire(wire *wireContent) { // ToolUseContent represents a request from the assistant to invoke a tool. // This content type is only valid in sampling messages. +// +// Deprecated: the sampling 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 ToolUseContent struct { // ID is a unique identifier for this tool use, used to match with ToolResultContent. ID string @@ -229,6 +234,11 @@ func (c *ToolUseContent) fromWire(wire *wireContent) { // ToolResultContent represents the result of a tool invocation. // This content type is only valid in sampling messages with role "user". +// +// Deprecated: the sampling 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 ToolResultContent struct { // ToolUseID references the ID from the corresponding ToolUseContent. ToolUseID string diff --git a/mcp/logging.go b/mcp/logging.go index e17fc9fa..20a497dc 100644 --- a/mcp/logging.go +++ b/mcp/logging.go @@ -212,5 +212,5 @@ func (h *LoggingHandler) handle(ctx context.Context, r slog.Record) error { // documentation says not to. // In this case logging is a service to clients, not a means for debugging the // server, so we want to cancel the log message. - return h.ss.log(ctx, params) + return h.ss.Log(ctx, params) } diff --git a/mcp/mrtr.go b/mcp/mrtr.go index 49b7d074..8ad5f1ae 100644 --- a/mcp/mrtr.go +++ b/mcp/mrtr.go @@ -185,11 +185,11 @@ func fulfillServerInputRequest(ctx context.Context, ss *ServerSession, ir InputR case *ElicitParams: return ss.Elicit(ctx, p) case *CreateMessageParams: - return ss.createMessageWithTools(ctx, createMessageParamsToWithTools(p)) + return ss.CreateMessageWithTools(ctx, createMessageParamsToWithTools(p)) case *CreateMessageWithToolsParams: - return ss.createMessageWithTools(ctx, p) + return ss.CreateMessageWithTools(ctx, p) case *ListRootsParams: - return ss.listRoots(ctx, p) + return ss.ListRoots(ctx, p) default: return nil, fmt.Errorf("unknown input request type: %T", ir) } diff --git a/mcp/protocol.go b/mcp/protocol.go index 8e43282e..cc061f47 100644 --- a/mcp/protocol.go +++ b/mcp/protocol.go @@ -440,8 +440,9 @@ func (x *CancelledParams) SetProgressToken(t any) { setProgressToken(x, t) } // RootCapabilities describes a client's support for roots. // -// Part of the roots feature, deprecated by SEP-2577. Remains on the wire for -// compatibility during the deprecation window (at least twelve months). See +// Deprecated: the roots 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 RootCapabilities struct { // ListChanged reports whether the client supports notifications for @@ -477,18 +478,19 @@ type ClientCapabilities struct { // changes to the roots list. ListChanged bool `json:"listChanged,omitempty"` } `json:"roots,omitempty"` - // RootsV2 is present if the client supports roots. When capabilities are explicitly configured via [ClientOptions.Capabilities]. + // RootsV2 is present if the client supports roots. When capabilities are + // explicitly configured via [ClientOptions.Capabilities]. // - // The roots feature is deprecated by SEP-2577; the capability remains on the - // wire for compatibility during the deprecation window (at least twelve - // months). See + // Deprecated: the roots 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. RootsV2 *RootCapabilities `json:"-"` // Sampling is present if the client supports sampling from an LLM. // - // The sampling feature is deprecated by SEP-2577; the capability remains on - // the wire for compatibility during the deprecation window (at least twelve - // months). See + // Deprecated: the sampling 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. Sampling *SamplingCapabilities `json:"sampling,omitempty"` // Elicitation is present if the client supports elicitation from the server. @@ -659,9 +661,10 @@ func (*CompleteResult) isResult() {} // CreateMessageParams holds parameters for a sampling/createMessage request. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 CreateMessageParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -669,10 +672,11 @@ type CreateMessageParams struct { // A request to include context from one or more MCP servers (including the // caller), to be attached to the prompt. The client may ignore this request. // - // The default is "none". Values "thisServer" and - // "allServers" are soft-deprecated. Servers SHOULD only use these values if - // the client declares ClientCapabilities.sampling.context. These values may - // be removed in future spec releases. + // The default is "none". The values "thisServer" and "allServers" are + // deprecated as of protocol version 2025-11-25 (SEP-2596) and will be + // removed no later than the sampling feature itself (SEP-2577). Servers + // SHOULD omit this field or use "none". See + // https://modelcontextprotocol.io/seps/2596-feature-lifecycle-and-deprecation-policy. IncludeContext string `json:"includeContext,omitempty"` // The maximum number of tokens to sample, as requested by the server. The // client may choose to sample fewer tokens than requested. @@ -703,11 +707,20 @@ func (x *CreateMessageParams) SetProgressToken(t any) { setProgressToken(x, t) } // // Use with [ServerSession.CreateMessageWithTools]. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 CreateMessageWithToolsParams struct { - Meta `json:"_meta,omitempty"` + Meta `json:"_meta,omitempty"` + // IncludeContext requests inclusion of context from one or more MCP servers. + // + // The default is "none". The values "thisServer" and "allServers" are + // deprecated as of protocol version 2025-11-25 (SEP-2596) and will be + // removed no later than the sampling feature itself (SEP-2577). Servers + // SHOULD omit this field or use "none", and SHOULD only use the deprecated + // values if the client declares ClientCapabilities.Sampling.Context. See + // https://modelcontextprotocol.io/seps/2596-feature-lifecycle-and-deprecation-policy. IncludeContext string `json:"includeContext,omitempty"` MaxTokens int64 `json:"maxTokens"` // Messages supports array content for tool_use and tool_result blocks. @@ -767,9 +780,10 @@ func (p *CreateMessageWithToolsParams) toBase() (*CreateMessageParams, error) { // unmarshaling, a single JSON content object is accepted and wrapped in a // one-element slice. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 SamplingMessageV2 struct { Content []Content `json:"content"` Role Role `json:"role"` @@ -812,9 +826,10 @@ func (m *SamplingMessageV2) UnmarshalJSON(data []byte) error { // allow them to inspect the response (human in the loop) and decide whether to // allow the server to see it. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 CreateMessageResult struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -862,9 +877,10 @@ func (r *CreateMessageResult) UnmarshalJSON(data []byte) error { // When unmarshaling, a single JSON content object is accepted and wrapped in a // one-element slice, for compatibility with clients that return a single block. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 CreateMessageWithToolsResult struct { Meta `json:"_meta,omitempty"` Content []Content `json:"content"` @@ -1255,6 +1271,12 @@ type ListResourcesResult struct { func (x *ListResourcesResult) isResult() {} func (x *ListResourcesResult) nextCursorPtr() *string { return &x.NextCursor } +// ListRootsParams holds parameters for a roots/list request. +// +// Deprecated: the roots 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 ListRootsParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -1271,8 +1293,9 @@ func (x *ListRootsParams) SetProgressToken(t any) { setProgressToken(x, t) } // contains an array of Root objects, each representing a root directory or file // that the server can operate on. // -// Part of the roots feature, deprecated by SEP-2577. Remains on the wire for -// compatibility during the deprecation window (at least twelve months). See +// Deprecated: the roots 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 ListRootsResult struct { // This property is reserved by the protocol to allow clients and servers to @@ -1319,17 +1342,19 @@ func (x *ListToolsResult) nextCursorPtr() *string { return &x.NextCursor } // These map to syslog message severities, as specified in RFC-5424: // https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 // -// Part of the logging feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// 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 LoggingLevel string // LoggingMessageParams holds the parameters for a notifications/message // notification. // -// Part of the logging feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// 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 LoggingMessageParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -1353,9 +1378,10 @@ func (x *LoggingMessageParams) SetProgressToken(t any) { setProgressToken(x, t) // Keys not declared here are currently left unspecified by the spec and are up // to the client to interpret. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 ModelHint struct { // A hint for a model name. // @@ -1383,9 +1409,10 @@ type ModelHint struct { // up to the client to decide how to interpret these preferences and how to // balance them against other considerations. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 ModelPreferences struct { // How much to prioritize cost when selecting a model. A value of 0 means cost // is not important, while a value of 1 means cost is the most important factor. @@ -1712,8 +1739,9 @@ type Role string // Represents a root directory or file that the server can operate on. // -// Part of the roots feature, deprecated by SEP-2577. Remains on the wire for -// compatibility during the deprecation window (at least twelve months). See +// Deprecated: the roots 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 Root struct { // See [specification/2025-06-18/basic/index#general-fields] for notes on _meta @@ -1729,6 +1757,13 @@ type Root struct { URI string `json:"uri"` } +// RootsListChangedParams holds parameters for a notifications/roots/list_changed +// notification. +// +// Deprecated: the roots 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 RootsListChangedParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -1745,9 +1780,10 @@ func (x *RootsListChangedParams) SetProgressToken(t any) { setProgressToken(x, t // SamplingCapabilities describes the client's support for sampling. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 SamplingCapabilities struct { // Context indicates the client supports includeContext values other than "none". Context *SamplingContextCapabilities `json:"context,omitempty"` @@ -1757,17 +1793,26 @@ type SamplingCapabilities struct { // SamplingContextCapabilities indicates the client supports context inclusion. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). +// Deprecated: the sampling 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 SamplingContextCapabilities struct{} // SamplingToolsCapabilities indicates the client supports tool use in sampling. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). +// Deprecated: the sampling 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 SamplingToolsCapabilities struct{} // ToolChoice controls how the model uses tools during sampling. +// +// Deprecated: the sampling 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 ToolChoice struct { // Mode controls tool invocation behavior: // - "auto": Model decides whether to use tools (default) @@ -1795,9 +1840,10 @@ type URLElicitationCapabilities struct{} // For assistant messages, Content may be text, image, audio, or tool_use. // For user messages, Content may be text, image, audio, or tool_result. // -// Part of the sampling feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// Deprecated: the sampling 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 SamplingMessage struct { Content Content `json:"content"` Role Role `json:"role"` @@ -1825,9 +1871,10 @@ func (m *SamplingMessage) UnmarshalJSON(data []byte) error { // SetLoggingLevelParams holds parameters for a logging/setLevel request. // -// Part of the logging feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// 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 SetLoggingLevelParams struct { // This property is reserved by the protocol to allow clients and servers to // attach additional metadata to their responses. @@ -2111,9 +2158,10 @@ type CompletionCapabilities struct{} // LoggingCapabilities describes the server's support for sending log messages to the client. // -// Part of the logging feature, deprecated by SEP-2577. Remains on the wire -// for compatibility during the deprecation window (at least twelve months). -// See https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. +// 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 LoggingCapabilities struct{} // PromptCapabilities describes the server's support for prompts. @@ -2158,9 +2206,9 @@ type ServerCapabilities struct { Completions *CompletionCapabilities `json:"completions,omitempty"` // Logging is present if the server supports log messages. // - // The logging feature is deprecated by SEP-2577; the capability remains on - // the wire for compatibility during the deprecation window (at least - // twelve months). See + // 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. Logging *LoggingCapabilities `json:"logging,omitempty"` // Prompts is present if the server supports prompts. @@ -2242,6 +2290,11 @@ const ( // MetaKeyClientCapabilities carries the client's [ClientCapabilities]. MetaKeyClientCapabilities = "io.modelcontextprotocol/clientCapabilities" // MetaKeyLogLevel identifies the desired log level for the request. + // + // 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. MetaKeyLogLevel = "io.modelcontextprotocol/logLevel" ) diff --git a/mcp/server.go b/mcp/server.go index e0bf23d0..88534ad9 100644 --- a/mcp/server.go +++ b/mcp/server.go @@ -985,7 +985,7 @@ func fileResourceHandler(dir string) ResourceHandler { defer util.Wrapf(&err, "reading resource %s", req.Params.URI) // TODO(#25): use a memoizing API here. - rootRes, err := req.Session.listRoots(ctx, nil) + rootRes, err := req.Session.ListRoots(ctx, nil) if err != nil { return nil, fmt.Errorf("listing roots: %w", err) } @@ -1317,13 +1317,6 @@ func (ss *ServerSession) Ping(ctx context.Context, params *PingParams) error { // resource URIs, or configuration. See // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) ListRoots(ctx context.Context, params *ListRootsParams) (*ListRootsResult, error) { - return ss.listRoots(ctx, params) -} - -// listRoots is the unexported implementation of ListRoots, used by the SDK's -// own call sites so they don't trip staticcheck SA1019 on the deprecated -// public method. -func (ss *ServerSession) listRoots(ctx context.Context, params *ListRootsParams) (*ListRootsResult, error) { if err := ss.checkInitialized(methodListRoots); err != nil { return nil, err } @@ -1385,13 +1378,6 @@ func (ss *ServerSession) CreateMessage(ctx context.Context, params *CreateMessag // from your server. See // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) CreateMessageWithTools(ctx context.Context, params *CreateMessageWithToolsParams) (*CreateMessageWithToolsResult, error) { - return ss.createMessageWithTools(ctx, params) -} - -// createMessageWithTools is the unexported implementation of -// CreateMessageWithTools, used by the SDK's own call sites so they don't trip -// staticcheck SA1019 on the deprecated public method. -func (ss *ServerSession) createMessageWithTools(ctx context.Context, params *CreateMessageWithToolsParams) (*CreateMessageWithToolsResult, error) { if err := ss.checkInitialized(methodCreateMessage); err != nil { return nil, err } @@ -1477,15 +1463,6 @@ func (ss *ServerSession) Elicit(ctx context.Context, params *ElicitParams) (*Eli return res, nil } -// logLevelContextKey carries the per-request log level from -// [ServerSession.handle] to [ServerSession.Log] for new-protocol -// (>= 2026-06-30) requests. The level is scoped to a single in-flight request -// — including handler goroutines that call [ServerSession.Log] concurrently — -// rather than to the session, which avoids races between concurrent requests -// and aligns with SEP-2575's per-request opt-in model. The value type is -// [LoggingLevel]; an empty string means the request opted out of log messages. -type logLevelContextKey struct{} - // Log sends a log message to the client. // // For new-protocol (>= 2026-06-30) requests, the level is taken from the @@ -1499,19 +1476,9 @@ type logLevelContextKey struct{} // OpenTelemetry. See // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) Log(ctx context.Context, params *LoggingMessageParams) error { - return ss.log(ctx, params) -} - -// log is the unexported implementation of Log, used by the SDK's own call -// sites (notably [LoggingHandler]) so they don't trip staticcheck SA1019 on -// the deprecated public method. -func (ss *ServerSession) log(ctx context.Context, params *LoggingMessageParams) error { - logLevel, ok := ctx.Value(logLevelContextKey{}).(LoggingLevel) - if !ok { - ss.mu.Lock() - logLevel = ss.state.LogLevel - ss.mu.Unlock() - } + ss.mu.Lock() + logLevel := ss.state.LogLevel + ss.mu.Unlock() if logLevel == "" { // The spec is unclear, but seems to imply that no log messages are sent until the client // sets the level. @@ -1686,7 +1653,7 @@ func (ss *ServerSession) handle(ctx context.Context, req *jsonrpc.Request) (any, ctx = context.WithValue(ctx, idContextKey{}, req.ID) // For new-protocol requests, propagate the per-request log level. if validatedMeta.usesNewProtocol { - ctx = context.WithValue(ctx, logLevelContextKey{}, validatedMeta.logLevel) + ss.setLevel(ctx, &SetLoggingLevelParams{Level: validatedMeta.logLevel}) } return handleReceive(ctx, ss, req) } From 641d732c9c4638770a21489ea6985dede5968f30 Mon Sep 17 00:00:00 2001 From: guglielmoc Date: Mon, 22 Jun 2026 12:15:24 +0000 Subject: [PATCH 3/3] docs: remove redundant migration guidance from logging deprecation notices and clean up troubleshooting documentation --- docs/troubleshooting.md | 6 ------ internal/docs/troubleshooting.src.md | 6 ------ mcp/client.go | 3 +-- mcp/logging.go | 9 +++------ mcp/protocol.go | 10 +--------- mcp/server.go | 3 +-- 6 files changed, 6 insertions(+), 31 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 59af4175..1a0c3679 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -21,12 +21,6 @@ SDK, as well as inspecting MCP traffic. ## Collecting MCP logs -> **Note:** `LoggingTransport` is a debugging tool that records JSON-RPC -> traffic; it is **not** the deprecated MCP logging feature -> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)), -> which concerns `logging/setLevel` and `notifications/message`. -> `LoggingTransport` is unaffected by that deprecation. - For [stdio](protocol.md#stdio-transport) transport connections, you can also inspect MCP traffic using a `LoggingTransport`: diff --git a/internal/docs/troubleshooting.src.md b/internal/docs/troubleshooting.src.md index ed06fe5b..83342032 100644 --- a/internal/docs/troubleshooting.src.md +++ b/internal/docs/troubleshooting.src.md @@ -20,12 +20,6 @@ SDK, as well as inspecting MCP traffic. ## Collecting MCP logs -> **Note:** `LoggingTransport` is a debugging tool that records JSON-RPC -> traffic; it is **not** the deprecated MCP logging feature -> ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)), -> which concerns `logging/setLevel` and `notifications/message`. -> `LoggingTransport` is unaffected by that deprecation. - For [stdio](protocol.md#stdio-transport) transport connections, you can also inspect MCP traffic using a `LoggingTransport`: diff --git a/mcp/client.go b/mcp/client.go index 8be33a0d..2c6e13d8 100644 --- a/mcp/client.go +++ b/mcp/client.go @@ -173,8 +173,7 @@ type ClientOptions struct { // // 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). Migrate to consuming stderr output - // (for STDIO servers) or OpenTelemetry. See + // window (at least twelve months). See // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. LoggingMessageHandler func(context.Context, *LoggingMessageRequest) ProgressNotificationHandler func(context.Context, *ProgressNotificationClientRequest) diff --git a/mcp/logging.go b/mcp/logging.go index 20a497dc..402e2432 100644 --- a/mcp/logging.go +++ b/mcp/logging.go @@ -72,8 +72,7 @@ func compareLevels(l1, l2 LoggingLevel) int { // // 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). Migrate to stderr logging (for STDIO servers) or -// OpenTelemetry. See +// (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. @@ -88,8 +87,7 @@ type LoggingHandlerOptions struct { // // 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). Migrate to stderr logging (for STDIO servers) or -// OpenTelemetry. See +// (at least twelve months). See // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type LoggingHandler struct { opts LoggingHandlerOptions @@ -116,8 +114,7 @@ func ensureLogger(l *slog.Logger) *slog.Logger { // // 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). Migrate to stderr logging (for STDIO servers) or -// OpenTelemetry. See +// (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 diff --git a/mcp/protocol.go b/mcp/protocol.go index 8d3860c8..29d12331 100644 --- a/mcp/protocol.go +++ b/mcp/protocol.go @@ -712,15 +712,7 @@ func (x *CreateMessageParams) SetProgressToken(t any) { setProgressToken(x, t) } // (at least twelve months). See // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. type CreateMessageWithToolsParams struct { - Meta `json:"_meta,omitempty"` - // IncludeContext requests inclusion of context from one or more MCP servers. - // - // The default is "none". The values "thisServer" and "allServers" are - // deprecated as of protocol version 2025-11-25 (SEP-2596) and will be - // removed no later than the sampling feature itself (SEP-2577). Servers - // SHOULD omit this field or use "none", and SHOULD only use the deprecated - // values if the client declares ClientCapabilities.Sampling.Context. See - // https://modelcontextprotocol.io/seps/2596-feature-lifecycle-and-deprecation-policy. + Meta `json:"_meta,omitempty"` IncludeContext string `json:"includeContext,omitempty"` MaxTokens int64 `json:"maxTokens"` // Messages supports array content for tool_use and tool_result blocks. diff --git a/mcp/server.go b/mcp/server.go index 317fe6ad..f095915c 100644 --- a/mcp/server.go +++ b/mcp/server.go @@ -1472,8 +1472,7 @@ func (ss *ServerSession) Elicit(ctx context.Context, params *ElicitParams) (*Eli // // 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). Migrate to stderr logging (for STDIO servers) or -// OpenTelemetry. See +// (at least twelve months). See // https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging. func (ss *ServerSession) Log(ctx context.Context, params *LoggingMessageParams) error { ss.mu.Lock()