From 94e8fef2b548f20b18d99cdab7495248184199cb Mon Sep 17 00:00:00 2001 From: Daniel Garnier-Moiroux Date: Fri, 13 Nov 2026 14:35:40 +0100 Subject: [PATCH] Deprecate roots, sampling, logging Signed-off-by: Daniel Garnier-Moiroux --- CHANGELOG.md | 10 +++++ docs/client.md | 9 +++++ docs/server-modern.md | 15 +++++-- docs/server.md | 6 +++ .../client/McpAsyncClient.java | 19 +++++++++ .../client/McpClient.java | 40 +++++++++++++++++++ .../client/McpSyncClient.java | 19 +++++++++ .../modern/McpSchema.java | 35 ++++++++++++++++ .../server/feature/RequiredCapabilities.java | 3 ++ .../server/McpAsyncServer.java | 11 +++++ .../server/McpAsyncServerExchange.java | 18 +++++++++ .../server/McpServer.java | 24 +++++++++++ .../server/McpSyncServerExchange.java | 18 +++++++++ .../modelcontextprotocol/spec/McpSchema.java | 21 ++++++++++ 14 files changed, 244 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74eb267ea..c6f2ca71a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,16 @@ Versioning follows [Semantic Versioning](https://semver.org/); see `equals` and `hashCode`. With `putAll`, transports can layer their own entries over the context a user's extractor returns, and comparing contexts was never a goal; read entries via `get(String)` instead. +- Deprecate the roots, sampling and logging APIs that initiate these features, following + [SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging), which + deprecates them as of the 2026-07-28 specification revision. This covers `McpSyncClient`/`McpAsyncClient` + (`addRoot`, `removeRoot`, `rootsListChangedNotification`, `setLoggingLevel`), the server exchanges + (`createMessage`, `listRoots`, `loggingNotification`), and the `roots`, `sampling` and `logging` capability + builder methods. In the 2026-07-28 API it also covers `InputRequiredResult.builder()`'s `createMessage` and + `listRoots`, and `MetaKeys.LOG_LEVEL`. The builder methods that register handlers for these features + (`roots`, `sampling` and `loggingConsumer(s)` on the client, `rootsChangeHandler(s)` on the server) are not + deprecated, since the specification requires implementations to keep handling them for peers that still use + them. Behavior and the wire format are unchanged. ## 2.0.1 — 2026-08-19 diff --git a/docs/client.md b/docs/client.md index 8a4a2f274..caab19b3d 100644 --- a/docs/client.md +++ b/docs/client.md @@ -247,6 +247,9 @@ var capabilities = ClientCapabilities.builder() ### Roots Support +!!! warning "Deprecated" + Roots are deprecated as of MCP protocol version 2026-07-28 ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)) and may be removed from a protocol revision released on or after 2027-07-28. They still work unchanged in this SDK, and the methods that initiate them are marked `@Deprecated`. Pass directories or files to servers via tool parameters, resource URIs, or server configuration instead. See the [deprecated features registry](https://modelcontextprotocol.io/specification/2026-07-28/deprecated). + Roots define the boundaries of where servers can operate within the filesystem: ```java @@ -268,6 +271,9 @@ The roots capability allows servers to: ### Sampling Support +!!! warning "Deprecated" + Sampling is deprecated as of MCP protocol version 2026-07-28 ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)) and may be removed from a protocol revision released on or after 2027-07-28. It still works unchanged in this SDK, and the methods that initiate it are marked `@Deprecated`. Servers should integrate directly with LLM provider APIs instead. See the [deprecated features registry](https://modelcontextprotocol.io/specification/2026-07-28/deprecated). + Sampling enables servers to request LLM interactions ("completions" or "generations") through the client: ```java @@ -387,6 +393,9 @@ server.sendElicitationComplete(exchange.sessionId(), ### Logging Support +!!! warning "Deprecated" + MCP logging is deprecated as of MCP protocol version 2026-07-28 ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)) and may be removed from a protocol revision released on or after 2027-07-28. It still works unchanged in this SDK, and the methods that initiate it are marked `@Deprecated`. Servers should log to stderr (stdio transport) or use [OpenTelemetry](https://opentelemetry.io/) instead. See the [deprecated features registry](https://modelcontextprotocol.io/specification/2026-07-28/deprecated). + The client can register a logging consumer to receive log messages from the server and set the minimum logging level to filter messages: ```java diff --git a/docs/server-modern.md b/docs/server-modern.md index 3610833f2..c35b3ac28 100644 --- a/docs/server-modern.md +++ b/docs/server-modern.md @@ -658,17 +658,21 @@ missing, without running the handler: === "Sync" ```java - ClientCapabilities needsSampling = ClientCapabilities.builder().sampling().build(); + ClientCapabilities needsForms = ClientCapabilities.builder() + .elicitation(new ClientCapabilities.Elicitation(new ClientCapabilities.Elicitation.Form(), null)) + .build(); - McpSyncTool summarize = McpSyncTool.of(summarizeDefinition, needsSampling, handler); + McpSyncTool greet = McpSyncTool.of(greetDefinition, needsForms, handler); ``` === "Async" ```java - ClientCapabilities needsSampling = ClientCapabilities.builder().sampling().build(); + ClientCapabilities needsForms = ClientCapabilities.builder() + .elicitation(new ClientCapabilities.Elicitation(new ClientCapabilities.Elicitation.Form(), null)) + .build(); - McpAsyncTool summarize = McpAsyncTool.of(summarizeDefinition, needsSampling, handler); + McpAsyncTool greet = McpAsyncTool.of(greetDefinition, needsForms, handler); ``` `McpSyncResource.of(...)` and `McpSyncPrompt.of(...)` take the same optional argument. @@ -748,6 +752,9 @@ travels in `requestState` (see [Carrying State Across Rounds](#carrying-state-ac `createMessage(key, CreateMessageRequest)` and `listRoots(key)`. `InputResponses.get(...)` converts a response to a type of your choice, such as `ElicitResult`, `CreateMessageResult` or `ListRootsResult`; it returns `null` when there is no response under the key and answers malformed responses with an invalid-params error. +`createMessage` and `listRoots` are deprecated, because the 2026-07-28 revision deprecates sampling and roots +([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). Prefer elicitation, +or call an LLM provider API directly from the server. A handler may only request input the client declared it can provide. Requesting anything else is a server bug and is answered with an internal error. Either check `ctx.clientCapabilities()` before asking, or declare the diff --git a/docs/server.md b/docs/server.md index c138e79fc..9ed625b5c 100644 --- a/docs/server.md +++ b/docs/server.md @@ -846,6 +846,9 @@ Completions can be registered for both `PromptReference` and `ResourceReference` ### Using Sampling from a Server +!!! warning "Deprecated" + Sampling is deprecated as of MCP protocol version 2026-07-28 ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)) and may be removed from a protocol revision released on or after 2027-07-28. It still works unchanged in this SDK, and the methods that initiate it are marked `@Deprecated`. Servers should integrate directly with LLM provider APIs instead. See the [deprecated features registry](https://modelcontextprotocol.io/specification/2026-07-28/deprecated). + To use [Sampling capabilities](https://modelcontextprotocol.io/specification/2025-11-25/client/sampling), connect to a client that supports sampling. No special server configuration is needed, but verify client sampling support before making requests. Learn about [client sampling support](client.md#sampling-support). @@ -1097,6 +1100,9 @@ The async equivalent, `McpAsyncServerExchange.ping()`, returns a `Mono` ### Logging Support +!!! warning "Deprecated" + MCP logging is deprecated as of MCP protocol version 2026-07-28 ([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)) and may be removed from a protocol revision released on or after 2027-07-28. It still works unchanged in this SDK, and the methods that initiate it are marked `@Deprecated`. Servers should log to stderr (stdio transport) or use [OpenTelemetry](https://opentelemetry.io/) instead. See the [deprecated features registry](https://modelcontextprotocol.io/specification/2026-07-28/deprecated). + The server provides structured logging capabilities that allow sending log messages to clients with different severity levels. Log notifications can only be sent from within an existing client session, such as tools, resources, and prompts calls. diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java b/mcp-core/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java index cd071b690..8ec3bf338 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java @@ -492,7 +492,12 @@ public Mono ping() { * Adds a new root to the client's root list. * @param root The root to add. * @return A Mono that completes when the root is added and notifications are sent. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public Mono addRoot(Root root) { if (root == null) { @@ -524,7 +529,12 @@ public Mono addRoot(Root root) { * Removes a root from the client's root list. * @param rootUri The URI of the root to remove. * @return A Mono that completes when the root is removed and notifications are sent. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public Mono removeRoot(String rootUri) { if (rootUri == null) { @@ -555,7 +565,12 @@ public Mono removeRoot(String rootUri) { * methods automatically send the roots/list_changed notification if the client is in * an initialized state. * @return A Mono that completes when the notification is sent. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public Mono rootsListChangedNotification() { return this.initializer.withInitialization("sending roots list changed notification", init -> init.mcpSession().sendNotification(McpSchema.METHOD_NOTIFICATION_ROOTS_LIST_CHANGED)); @@ -1109,7 +1124,11 @@ private NotificationHandler asyncLoggingNotificationHandler( * @param loggingLevel The minimum logging level to receive. * @return A Mono that completes when the logging level is set. * @see McpSchema.LoggingLevel + * @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. + * Servers should log to stderr (stdio transport) or use OpenTelemetry instead. */ + @Deprecated public Mono setLoggingLevel(LoggingLevel loggingLevel) { if (loggingLevel == null) { return Mono.error(new IllegalArgumentException("Logging level must not be null")); diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/client/McpClient.java b/mcp-core/src/main/java/io/modelcontextprotocol/client/McpClient.java index 328566a69..adc92f952 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/client/McpClient.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/client/McpClient.java @@ -267,6 +267,10 @@ public SyncSpec clientInfo(Implementation clientInfo) { * Sets the root URIs that this client can access. Roots define the base URIs for * resources that the client can request from the server. For example, a root * might be "file://workspace" for accessing workspace files. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * answering {@code roots/list} for servers that still use roots. * @param roots A list of root definitions. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if roots is null @@ -282,6 +286,10 @@ public SyncSpec roots(List roots) { /** * Sets the root URIs that this client can access, using a varargs parameter for * convenience. This is an alternative to {@link #roots(List)}. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * answering {@code roots/list} for servers that still use roots. * @param roots An array of root definitions. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if roots is null @@ -299,6 +307,10 @@ public SyncSpec roots(Root... roots) { * Sets a custom sampling handler for processing message creation requests. The * sampling handler can modify or validate messages before they are sent to the * server, enabling custom processing logic. + *

+ * Sampling is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * handling {@code sampling/createMessage} for servers that still use sampling. * @param samplingHandler A function that processes message requests and returns * results. Must not be null. * @return This builder instance for method chaining @@ -405,6 +417,10 @@ public SyncSpec promptsChangeConsumer(Consumer> promptsCh * Adds a consumer to be notified when logging messages are received from the * server. This allows the client to react to log messages, such as warnings or * errors, that are sent by the server. + *

+ * Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * handling log messages from servers that still send them. * @param loggingConsumer A consumer that receives logging messages. Must not be * null. * @return This builder instance for method chaining @@ -419,6 +435,10 @@ public SyncSpec loggingConsumer(Consumer l * Adds multiple consumers to be notified when logging messages are received from * the server. This allows the client to react to log messages, such as warnings * or errors, that are sent by the server. + *

+ * Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * handling log messages from servers that still send them. * @param loggingConsumers A list of consumers that receive logging messages. Must * not be null. * @return This builder instance for method chaining @@ -702,6 +722,10 @@ public AsyncSpec clientInfo(Implementation clientInfo) { * Sets the root URIs that this client can access. Roots define the base URIs for * resources that the client can request from the server. For example, a root * might be "file://workspace" for accessing workspace files. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * answering {@code roots/list} for servers that still use roots. * @param roots A list of root definitions. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if roots is null @@ -717,6 +741,10 @@ public AsyncSpec roots(List roots) { /** * Sets the root URIs that this client can access, using a varargs parameter for * convenience. This is an alternative to {@link #roots(List)}. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * answering {@code roots/list} for servers that still use roots. * @param roots An array of root definitions. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if roots is null @@ -734,6 +762,10 @@ public AsyncSpec roots(Root... roots) { * Sets a custom sampling handler for processing message creation requests. The * sampling handler can modify or validate messages before they are sent to the * server, enabling custom processing logic. + *

+ * Sampling is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * handling {@code sampling/createMessage} for servers that still use sampling. * @param samplingHandler A function that processes message requests and returns * results. Must not be null. * @return This builder instance for method chaining @@ -842,6 +874,10 @@ public AsyncSpec promptsChangeConsumer(Function, Mono + * Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * handling log messages from servers that still send them. * @param loggingConsumer A consumer that receives logging messages. Must not be * null. * @return This builder instance for method chaining @@ -856,6 +892,10 @@ public AsyncSpec loggingConsumer(Function + * Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires clients to keep + * handling log messages from servers that still send them. * @param loggingConsumers A list of consumers that receive logging messages. Must * not be null. * @return This builder instance for method chaining diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/client/McpSyncClient.java b/mcp-core/src/main/java/io/modelcontextprotocol/client/McpSyncClient.java index 7e08f83a0..a8a6ddece 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/client/McpSyncClient.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/client/McpSyncClient.java @@ -192,21 +192,36 @@ public McpSchema.InitializeResult initialize() { /** * Send a roots/list_changed notification. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public void rootsListChangedNotification() { withProvidedContext(this.delegate.rootsListChangedNotification()).block(); } /** * Add a roots dynamically. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public void addRoot(McpSchema.Root root) { this.delegate.addRoot(root).block(); } /** * Remove a root dynamically. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public void removeRoot(String rootUri) { this.delegate.removeRoot(rootUri).block(); } @@ -426,7 +441,11 @@ public GetPromptResult getPrompt(GetPromptRequest getPromptRequest) { /** * Client can set the minimum logging level it wants to receive from the server. * @param loggingLevel the min logging level + * @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. + * Servers should log to stderr (stdio transport) or use OpenTelemetry instead. */ + @Deprecated public void setLoggingLevel(McpSchema.LoggingLevel loggingLevel) { withProvidedContext(this.delegate.setLoggingLevel(loggingLevel)).block(); diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/modern/McpSchema.java b/mcp-core/src/main/java/io/modelcontextprotocol/modern/McpSchema.java index feeee1327..bbbf22075 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/modern/McpSchema.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/modern/McpSchema.java @@ -105,6 +105,13 @@ public static final class MetaKeys { public static final String CLIENT_INFO = "io.modelcontextprotocol/clientInfo"; + /** + * @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Servers should log to stderr (stdio transport) or use OpenTelemetry + * instead. + */ + @Deprecated public static final String LOG_LEVEL = "io.modelcontextprotocol/logLevel"; public static final String SERVER_INFO = "io.modelcontextprotocol/serverInfo"; @@ -333,11 +340,25 @@ public Builder experimental(Map experimental) { return this; } + /** + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Pass directories or files to servers via tool parameters, + * resource URIs, or server configuration instead. + */ + @Deprecated public Builder roots() { this.roots = new Roots(); return this; } + /** + * @deprecated Sampling is deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Servers should integrate directly with LLM provider APIs + * instead. + */ + @Deprecated public Builder sampling() { this.sampling = new Sampling(); return this; @@ -1526,11 +1547,25 @@ public Builder elicitUrl(String key, String message, String url) { return this; } + /** + * @deprecated Sampling is deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Servers should integrate directly with LLM provider APIs + * instead. + */ + @Deprecated public Builder createMessage(String key, CreateMessageRequest request) { this.inputRequests.put(key, InputRequest.createMessage(request)); return this; } + /** + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Pass directories or files to servers via tool parameters, + * resource URIs, or server configuration instead. + */ + @Deprecated public Builder listRoots(String key) { this.inputRequests.put(key, InputRequest.listRoots()); return this; diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/modern/server/feature/RequiredCapabilities.java b/mcp-core/src/main/java/io/modelcontextprotocol/modern/server/feature/RequiredCapabilities.java index 07c7e0f83..761f419a0 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/modern/server/feature/RequiredCapabilities.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/modern/server/feature/RequiredCapabilities.java @@ -23,6 +23,9 @@ static McpException check(ClientCapabilities required, McpRequestContext ctx) { return missing != null ? McpException.missingClientCapability(missing) : null; } + // Roots and sampling are deprecated by MCP 2026-07-28 (SEP-2577), but a feature may + // still require them, so a missing one must still be reported. + @SuppressWarnings("deprecation") private static ClientCapabilities missing(ClientCapabilities required, ClientCapabilities declared) { boolean roots = required.supportsRoots() && !declared.supportsRoots(); boolean sampling = required.supportsSampling() && !declared.supportsSampling(); diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java index 32e76264e..ab92c3c55 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java @@ -131,6 +131,7 @@ public class McpAsyncServer { * @param features The MCP server supported features. * @param jsonMapper The JsonMapper to use for JSON serialization/deserialization */ + @SuppressWarnings("deprecation") McpAsyncServer(McpServerTransportProvider mcpTransportProvider, McpJsonMapper jsonMapper, McpServerFeatures.Async features, Duration requestTimeout, McpUriTemplateManagerFactory uriTemplateManagerFactory, JsonSchemaValidator jsonSchemaValidator, @@ -138,6 +139,9 @@ public class McpAsyncServer { this.mcpTransportProvider = mcpTransportProvider; this.jsonMapper = jsonMapper; this.serverInfo = features.serverInfo(); + // Logging is deprecated by MCP 2026-07-28 (SEP-2577) but is part of every + // protocol + // version this server negotiates, so the capability is still always advertised. this.serverCapabilities = features.serverCapabilities().mutate().logging().build(); this.instructions = features.instructions(); this.tools.addAll(withStructuredOutputHandling(jsonSchemaValidator, features.tools())); @@ -163,6 +167,7 @@ public class McpAsyncServer { }); } + @SuppressWarnings("deprecation") McpAsyncServer(McpStreamableServerTransportProvider mcpTransportProvider, McpJsonMapper jsonMapper, McpServerFeatures.Async features, Duration requestTimeout, McpUriTemplateManagerFactory uriTemplateManagerFactory, JsonSchemaValidator jsonSchemaValidator, @@ -170,6 +175,9 @@ public class McpAsyncServer { this.mcpTransportProvider = mcpTransportProvider; this.jsonMapper = jsonMapper; this.serverInfo = features.serverInfo(); + // Logging is deprecated by MCP 2026-07-28 (SEP-2577) but is part of every + // protocol + // version this server negotiates, so the capability is still always advertised. this.serverCapabilities = features.serverCapabilities().mutate().logging().build(); this.instructions = features.instructions(); this.tools.addAll(withStructuredOutputHandling(jsonSchemaValidator, features.tools())); @@ -316,6 +324,9 @@ public void close() { this.mcpTransportProvider.close(); } + // Roots are deprecated by MCP 2026-07-28 (SEP-2577) but still supported for clients + // that declare them. + @SuppressWarnings("deprecation") private McpNotificationHandler asyncRootsListChangedNotificationHandler( List, Mono>> rootsChangeConsumers) { return (exchange, params) -> exchange.listRoots() diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java index 280a3c87a..418ec2d36 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java @@ -137,7 +137,11 @@ public String sessionId() { * @see Sampling * Specification + * @deprecated Sampling is deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. + * Servers should integrate directly with LLM provider APIs instead. */ + @Deprecated public Mono createMessage(McpSchema.CreateMessageRequest createMessageRequest) { if (this.clientCapabilities == null) { return Mono @@ -202,7 +206,12 @@ public Mono createElicitation(McpSchema.ElicitRequest el /** * Retrieves the list of all roots provided by the client. * @return A Mono that emits the list of roots result. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public Mono listRoots() { // @formatter:off @@ -223,7 +232,12 @@ public Mono listRoots() { * Retrieves a paginated list of roots provided by the client. * @param cursor Optional pagination cursor from a previous list request * @return A Mono that emits the list of roots result containing + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public Mono listRoots(String cursor) { return this.session.sendRequest(McpSchema.METHOD_ROOTS_LIST, new McpSchema.PaginatedRequest(cursor), LIST_ROOTS_RESULT_TYPE_REF); @@ -234,7 +248,11 @@ public Mono listRoots(String cursor) { * minimum logging level will be filtered out. * @param loggingMessageNotification The logging message to send * @return A Mono that completes when the notification has been sent + * @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. + * Servers should log to stderr (stdio transport) or use OpenTelemetry instead. */ + @Deprecated public Mono loggingNotification(LoggingMessageNotification loggingMessageNotification) { if (loggingMessageNotification == null) { diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpServer.java b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpServer.java index 2113fdb48..a212bd290 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpServer.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpServer.java @@ -780,6 +780,10 @@ public AsyncSpecification completions(McpServerFeatures.AsyncCompletionSpecif * Registers a consumer that will be notified when the list of roots changes. This * is useful for updating resource availability dynamically, such as when new * files are added or removed. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires servers to keep + * handling roots for clients that still declare them. * @param handler The handler to register. Must not be null. The function's first * argument is an {@link McpAsyncServerExchange} upon which the server can * interact with the connected client. The second argument is the list of roots. @@ -797,6 +801,10 @@ public AsyncSpecification rootsChangeHandler( * Registers multiple consumers that will be notified when the list of roots * changes. This method is useful when multiple consumers need to be registered at * once. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires servers to keep + * handling roots for clients that still declare them. * @param handlers The list of handlers to register. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if consumers is null @@ -813,6 +821,10 @@ public AsyncSpecification rootsChangeHandlers( * Registers multiple consumers that will be notified when the list of roots * changes using varargs. This method provides a convenient way to register * multiple consumers inline. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires servers to keep + * handling roots for clients that still declare them. * @param handlers The handlers to register. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if consumers is null @@ -1422,6 +1434,10 @@ public SyncSpecification completions(McpServerFeatures.SyncCompletionSpecific * Registers a consumer that will be notified when the list of roots changes. This * is useful for updating resource availability dynamically, such as when new * files are added or removed. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires servers to keep + * handling roots for clients that still declare them. * @param handler The handler to register. Must not be null. The function's first * argument is an {@link McpSyncServerExchange} upon which the server can interact * with the connected client. The second argument is the list of roots. @@ -1439,6 +1455,10 @@ public SyncSpecification rootsChangeHandler( * Registers multiple consumers that will be notified when the list of roots * changes. This method is useful when multiple consumers need to be registered at * once. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires servers to keep + * handling roots for clients that still declare them. * @param handlers The list of handlers to register. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if consumers is null @@ -1455,6 +1475,10 @@ public SyncSpecification rootsChangeHandlers( * Registers multiple consumers that will be notified when the list of roots * changes using varargs. This method provides a convenient way to register * multiple consumers inline. + *

+ * Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This + * method is not deprecated because the specification requires servers to keep + * handling roots for clients that still declare them. * @param handlers The handlers to register. Must not be null. * @return This builder instance for method chaining * @throws IllegalArgumentException if consumers is null diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java index 0b9115b79..75d9947cf 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java @@ -77,7 +77,11 @@ public McpTransportContext transportContext() { * @see Sampling * Specification + * @deprecated Sampling is deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. + * Servers should integrate directly with LLM provider APIs instead. */ + @Deprecated public McpSchema.CreateMessageResult createMessage(McpSchema.CreateMessageRequest createMessageRequest) { return this.exchange.createMessage(createMessageRequest).block(); } @@ -103,7 +107,12 @@ public McpSchema.ElicitResult createElicitation(McpSchema.ElicitRequest elicitRe /** * Retrieves the list of all roots provided by the client. * @return The list of roots result. + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public McpSchema.ListRootsResult listRoots() { return this.exchange.listRoots().block(); } @@ -112,7 +121,12 @@ public McpSchema.ListRootsResult listRoots() { * Retrieves a paginated list of roots provided by the client. * @param cursor Optional pagination cursor from a previous list request * @return The list of roots result + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. Pass + * directories or files to servers via tool parameters, resource URIs, or server + * configuration instead. */ + @Deprecated public McpSchema.ListRootsResult listRoots(String cursor) { return this.exchange.listRoots(cursor).block(); } @@ -121,7 +135,11 @@ public McpSchema.ListRootsResult listRoots(String cursor) { * Send a logging message notification to the client. Messages below the current * minimum logging level will be filtered out. * @param loggingMessageNotification The logging message to send + * @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577) + * and may be removed from a protocol revision released on or after 2027-07-28. + * Servers should log to stderr (stdio transport) or use OpenTelemetry instead. */ + @Deprecated public void loggingNotification(LoggingMessageNotification loggingMessageNotification) { this.exchange.loggingNotification(loggingMessageNotification).block(); } diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java b/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java index fa467b213..2471f91e9 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java @@ -739,11 +739,25 @@ public Builder experimental(Map experimental) { return this; } + /** + * @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Pass directories or files to servers via tool parameters, + * resource URIs, or server configuration instead. + */ + @Deprecated public Builder roots(Boolean listChanged) { this.roots = new RootCapabilities(listChanged); return this; } + /** + * @deprecated Sampling is deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Servers should integrate directly with LLM provider APIs + * instead. + */ + @Deprecated public Builder sampling() { this.sampling = new Sampling(); return this; @@ -983,6 +997,13 @@ public Builder experimental(Map experimental) { return this; } + /** + * @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 + * (SEP-2577) and may be removed from a protocol revision released on or after + * 2027-07-28. Servers should log to stderr (stdio transport) or use + * OpenTelemetry instead. + */ + @Deprecated public Builder logging() { this.logging = new LoggingCapabilities(); return this;