Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ 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 by
[SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
The SDK continues to support them for compatibility.

New releases of the SDK target only supported versions of Go. See
https://go.dev/doc/devel/release#policy for more information.

Expand Down
2 changes: 2 additions & 0 deletions conformance/everything-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
package main

import (
Expand Down
6 changes: 6 additions & 0 deletions docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

## Roots

> **Note:** The roots feature is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> The SDK continues to support roots for compatibility.

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:
Expand Down Expand Up @@ -77,6 +80,9 @@ func Example_roots() {

## Sampling

> **Note:** The sampling feature is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> The SDK continues to support sampling for compatibility.

[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:
Expand Down
3 changes: 3 additions & 0 deletions docs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ _ = mcp.NewServer(&mcp.Implementation{Name: "server"}, &mcp.ServerOptions{

### Logging

> **Note:** The logging feature is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> The SDK continues to support logging for compatibility.
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.)
Expand Down
3 changes: 3 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ SDK, as well as inspecting MCP traffic.

## Collecting MCP logs

> **Note:** `LoggingTransport` is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> It remains available for debugging.
For [stdio](protocol.md#stdio-transport) transport connections, you can also
inspect MCP traffic using a `LoggingTransport`:

Expand Down
2 changes: 2 additions & 0 deletions examples/server/distributed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// Example:
//
// ./distributed -http=localhost:8080 -child_ports=8081,8082
//
//lint:file-ignore SA1019 example server exercises deprecated SEP-2577 APIs
package main

import (
Expand Down
2 changes: 2 additions & 0 deletions examples/server/everything/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
package main

import (
Expand Down
1 change: 1 addition & 0 deletions examples/server/memory/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

//lint:file-ignore SA1019 example server exercises deprecated SEP-2577 APIs
package main

import (
Expand Down
1 change: 1 addition & 0 deletions examples/server/sequentialthinking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

//lint:file-ignore SA1019 example server exercises deprecated SEP-2577 APIs
package main

import (
Expand Down
6 changes: 6 additions & 0 deletions internal/docs/client.src.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

## Roots

> **Note:** The roots feature is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> The SDK continues to support roots for compatibility.

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:
Expand All @@ -26,6 +29,9 @@ method. To receive notifications about root changes, set

## Sampling

> **Note:** The sampling feature is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> The SDK continues to support sampling for compatibility.

[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:
Expand Down
3 changes: 3 additions & 0 deletions internal/docs/server.src.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ requests.

### Logging

> **Note:** The logging feature is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> The SDK continues to support logging for compatibility.
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.)
Expand Down
3 changes: 3 additions & 0 deletions internal/docs/troubleshooting.src.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ SDK, as well as inspecting MCP traffic.

## Collecting MCP logs

> **Note:** `LoggingTransport` is deprecated by [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
> It remains available for debugging.
For [stdio](protocol.md#stdio-transport) transport connections, you can also
inspect MCP traffic using a `LoggingTransport`:

Expand Down
4 changes: 4 additions & 0 deletions internal/readme/README.src.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ 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 by
[SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577).
The SDK continues to support them for compatibility.

New releases of the SDK target only supported versions of Go. See
https://go.dev/doc/devel/release#policy for more information.

Expand Down
20 changes: 16 additions & 4 deletions mcp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ 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: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
CreateMessageHandler func(context.Context, *CreateMessageRequest) (*CreateMessageResult, error)
// CreateMessageWithToolsHandler handles incoming sampling/createMessage
// requests that may involve tool use. It returns
Expand All @@ -95,6 +97,8 @@ type ClientOptions struct {
//
// It is a panic to set both CreateMessageHandler and
// CreateMessageWithToolsHandler.
//
// Deprecated: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
CreateMessageWithToolsHandler func(context.Context, *CreateMessageWithToolsRequest) (*CreateMessageWithToolsResult, error)
// ElicitationHandler handles incoming requests for elicitation/create.
//
Expand Down Expand Up @@ -152,10 +156,11 @@ 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)
// Deprecated: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
LoggingMessageHandler func(context.Context, *LoggingMessageRequest)
ProgressNotificationHandler func(context.Context, *ProgressNotificationClientRequest)
// MultiRoundTrip configures the automatic MultiRoundTrip (Multi Round-Trip Requests) middleware.
Expand Down Expand Up @@ -577,6 +582,8 @@ 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: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
func (c *Client) AddRoots(roots ...*Root) {
// Only notify if something could change.
if len(roots) == 0 {
Expand All @@ -589,6 +596,8 @@ 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: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
func (c *Client) RemoveRoots(uris ...string) {
changeAndNotify(c, notificationRootsListChanged, &RootsListChangedParams{},
func() bool { return c.roots.remove(uris...) })
Expand Down Expand Up @@ -1203,6 +1212,9 @@ func (cs *ClientSession) CallTool(ctx context.Context, params *CallToolParams) (
return handleSend[*CallToolResult](ctx, methodCallTool, newClientRequest(cs, orZero[Params](params)))
}

// SetLoggingLevel sets the minimum log level for the server session.
//
// Deprecated: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
func (cs *ClientSession) SetLoggingLevel(ctx context.Context, params *SetLoggingLevelParams) error {
_, err := handleSend[*emptyResult](ctx, methodSetLevel, newClientRequest(cs, orZero[Params](params)))
return err
Expand Down
8 changes: 7 additions & 1 deletion mcp/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func compareLevels(l1, l2 LoggingLevel) int {
}

// LoggingHandlerOptions are options for a LoggingHandler.
//
// Deprecated: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
type LoggingHandlerOptions struct {
// The value for the "logger" field of logging notifications.
LoggerName string
Expand All @@ -79,6 +81,8 @@ type LoggingHandlerOptions struct {
}

// A LoggingHandler is a [slog.Handler] for MCP.
//
// Deprecated: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
type LoggingHandler struct {
opts LoggingHandlerOptions
ss *ServerSession
Expand All @@ -101,6 +105,8 @@ func ensureLogger(l *slog.Logger) *slog.Logger {

// NewLoggingHandler creates a [LoggingHandler] that logs to the given [ServerSession] using a
// [slog.JSONHandler].
//
// Deprecated: SEP-2577 deprecates this API. It may be removed in a future release of this SDK.
func NewLoggingHandler(ss *ServerSession, opts *LoggingHandlerOptions) *LoggingHandler {
var buf bytes.Buffer
jsonHandler := slog.NewJSONHandler(&buf, &slog.HandlerOptions{
Expand Down Expand Up @@ -194,5 +200,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)
}
6 changes: 3 additions & 3 deletions mcp/mrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
30 changes: 30 additions & 0 deletions mcp/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ 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 deprecated roots feature (SEP-2577). Remains on the wire for compatibility.
type RootCapabilities struct {
// ListChanged reports whether the client supports notifications for
// changes to the roots list.
Expand Down Expand Up @@ -466,6 +468,8 @@ 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.
//
// Part of the deprecated roots feature (SEP-2577). Remains on the wire for compatibility.
Roots struct {
// ListChanged reports whether the client supports notifications for
// changes to the roots list.
Expand All @@ -474,6 +478,8 @@ type ClientCapabilities struct {
// RootsV2 is present if the client supports roots. When capabilities are explicitly configured via [ClientOptions.Capabilities]
RootsV2 *RootCapabilities `json:"-"`
// Sampling is present if the client supports sampling from an LLM.
//
// Part of the deprecated sampling feature (SEP-2577). Remains on the wire for compatibility.
Sampling *SamplingCapabilities `json:"sampling,omitempty"`
// Elicitation is present if the client supports elicitation from the server.
Elicitation *ElicitationCapabilities `json:"elicitation,omitempty"`
Expand Down Expand Up @@ -641,6 +647,9 @@ type CompleteResult struct {

func (*CompleteResult) isResult() {}

// CreateMessageParams holds parameters for a sampling/create_message request.
//
// Part of the deprecated sampling feature (SEP-2577). Remains on the wire for compatibility.
type CreateMessageParams struct {
// This property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
Expand Down Expand Up @@ -681,6 +690,8 @@ 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 deprecated sampling feature (SEP-2577). Remains on the wire for compatibility.
type CreateMessageWithToolsParams struct {
Meta `json:"_meta,omitempty"`
IncludeContext string `json:"includeContext,omitempty"`
Expand Down Expand Up @@ -782,6 +793,8 @@ 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 deprecated sampling feature (SEP-2577). Remains on the wire for compatibility.
type CreateMessageResult struct {
// This property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
Expand Down Expand Up @@ -828,6 +841,8 @@ 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 deprecated sampling feature (SEP-2577). Remains on the wire for compatibility.
type CreateMessageWithToolsResult struct {
Meta `json:"_meta,omitempty"`
Content []Content `json:"content"`
Expand Down Expand Up @@ -1233,6 +1248,8 @@ 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 deprecated roots feature (SEP-2577). Remains on the wire for compatibility.
type ListRootsResult struct {
// This property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
Expand Down Expand Up @@ -1277,8 +1294,13 @@ 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 deprecated logging feature (SEP-2577). Remains on the wire for compatibility.
type LoggingLevel string

// LoggingMessageParams holds parameters for a logging notification.
//
// Part of the deprecated logging feature (SEP-2577). Remains on the wire for compatibility.
type LoggingMessageParams struct {
// This property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
Expand Down Expand Up @@ -1652,6 +1674,8 @@ type ResourceTemplate struct {
type Role string

// Represents a root directory or file that the server can operate on.
//
// Part of the deprecated roots feature (SEP-2577). Remains on the wire for compatibility.
type Root struct {
// See [specification/2025-06-18/basic/index#general-fields] for notes on _meta
// usage.
Expand Down Expand Up @@ -1681,6 +1705,8 @@ func (x *RootsListChangedParams) SetProgressToken(t any) { setProgressToken(x, t
// below directly above ClientCapabilities.

// SamplingCapabilities describes the client's support for sampling.
//
// Part of the deprecated sampling feature (SEP-2577). Remains on the wire for compatibility.
type SamplingCapabilities struct {
// Context indicates the client supports includeContext values other than "none".
Context *SamplingContextCapabilities `json:"context,omitempty"`
Expand Down Expand Up @@ -2028,6 +2054,8 @@ type Implementation struct {
type CompletionCapabilities struct{}

// LoggingCapabilities describes the server's support for sending log messages to the client.
//
// Part of the deprecated logging feature (SEP-2577). Remains on the wire for compatibility.
type LoggingCapabilities struct{}

// PromptCapabilities describes the server's support for prompts.
Expand Down Expand Up @@ -2071,6 +2099,8 @@ type ServerCapabilities struct {
// suggestions.
Completions *CompletionCapabilities `json:"completions,omitempty"`
// Logging is present if the server supports log messages.
//
// Part of the deprecated logging feature (SEP-2577). Remains on the wire for compatibility.
Logging *LoggingCapabilities `json:"logging,omitempty"`
// Prompts is present if the server supports prompts.
Prompts *PromptCapabilities `json:"prompts,omitempty"`
Expand Down
Loading
Loading