Skip to content

Commit 94e8fef

Browse files
committed
Deprecate roots, sampling, logging
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
1 parent 6a28ebb commit 94e8fef

14 files changed

Lines changed: 244 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ Versioning follows [Semantic Versioning](https://semver.org/); see
3636
`equals` and `hashCode`. With `putAll`, transports can layer their own entries
3737
over the context a user's extractor returns, and comparing contexts was never
3838
a goal; read entries via `get(String)` instead.
39+
- Deprecate the roots, sampling and logging APIs that initiate these features, following
40+
[SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging), which
41+
deprecates them as of the 2026-07-28 specification revision. This covers `McpSyncClient`/`McpAsyncClient`
42+
(`addRoot`, `removeRoot`, `rootsListChangedNotification`, `setLoggingLevel`), the server exchanges
43+
(`createMessage`, `listRoots`, `loggingNotification`), and the `roots`, `sampling` and `logging` capability
44+
builder methods. In the 2026-07-28 API it also covers `InputRequiredResult.builder()`'s `createMessage` and
45+
`listRoots`, and `MetaKeys.LOG_LEVEL`. The builder methods that register handlers for these features
46+
(`roots`, `sampling` and `loggingConsumer(s)` on the client, `rootsChangeHandler(s)` on the server) are not
47+
deprecated, since the specification requires implementations to keep handling them for peers that still use
48+
them. Behavior and the wire format are unchanged.
3949

4050
## 2.0.1 — 2026-08-19
4151

‎docs/client.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ var capabilities = ClientCapabilities.builder()
247247

248248
### Roots Support
249249

250+
!!! warning "Deprecated"
251+
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).
252+
250253
Roots define the boundaries of where servers can operate within the filesystem:
251254

252255
```java
@@ -268,6 +271,9 @@ The roots capability allows servers to:
268271

269272
### Sampling Support
270273

274+
!!! warning "Deprecated"
275+
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).
276+
271277
Sampling enables servers to request LLM interactions ("completions" or "generations") through the client:
272278

273279
```java
@@ -387,6 +393,9 @@ server.sendElicitationComplete(exchange.sessionId(),
387393

388394
### Logging Support
389395

396+
!!! warning "Deprecated"
397+
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).
398+
390399
The client can register a logging consumer to receive log messages from the server and set the minimum logging level to filter messages:
391400

392401
```java

‎docs/server-modern.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,17 +658,21 @@ missing, without running the handler:
658658
=== "Sync"
659659

660660
```java
661-
ClientCapabilities needsSampling = ClientCapabilities.builder().sampling().build();
661+
ClientCapabilities needsForms = ClientCapabilities.builder()
662+
.elicitation(new ClientCapabilities.Elicitation(new ClientCapabilities.Elicitation.Form(), null))
663+
.build();
662664

663-
McpSyncTool summarize = McpSyncTool.of(summarizeDefinition, needsSampling, handler);
665+
McpSyncTool greet = McpSyncTool.of(greetDefinition, needsForms, handler);
664666
```
665667

666668
=== "Async"
667669

668670
```java
669-
ClientCapabilities needsSampling = ClientCapabilities.builder().sampling().build();
671+
ClientCapabilities needsForms = ClientCapabilities.builder()
672+
.elicitation(new ClientCapabilities.Elicitation(new ClientCapabilities.Elicitation.Form(), null))
673+
.build();
670674

671-
McpAsyncTool summarize = McpAsyncTool.of(summarizeDefinition, needsSampling, handler);
675+
McpAsyncTool greet = McpAsyncTool.of(greetDefinition, needsForms, handler);
672676
```
673677

674678
`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
748752
`createMessage(key, CreateMessageRequest)` and `listRoots(key)`. `InputResponses.get(...)` converts a response
749753
to a type of your choice, such as `ElicitResult`, `CreateMessageResult` or `ListRootsResult`; it returns `null`
750754
when there is no response under the key and answers malformed responses with an invalid-params error.
755+
`createMessage` and `listRoots` are deprecated, because the 2026-07-28 revision deprecates sampling and roots
756+
([SEP-2577](https://modelcontextprotocol.io/seps/2577-deprecate-roots-sampling-and-logging)). Prefer elicitation,
757+
or call an LLM provider API directly from the server.
751758

752759
A handler may only request input the client declared it can provide. Requesting anything else is a server bug
753760
and is answered with an internal error. Either check `ctx.clientCapabilities()` before asking, or declare the

‎docs/server.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,9 @@ Completions can be registered for both `PromptReference` and `ResourceReference`
846846

847847
### Using Sampling from a Server
848848

849+
!!! warning "Deprecated"
850+
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).
851+
849852
To use [Sampling capabilities](https://modelcontextprotocol.io/specification/2025-11-25/client/sampling), connect to a client that supports sampling.
850853
No special server configuration is needed, but verify client sampling support before making requests.
851854
Learn about [client sampling support](client.md#sampling-support).
@@ -1097,6 +1100,9 @@ The async equivalent, `McpAsyncServerExchange.ping()`, returns a `Mono<Object>`
10971100

10981101
### Logging Support
10991102

1103+
!!! warning "Deprecated"
1104+
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).
1105+
11001106
The server provides structured logging capabilities that allow sending log messages to clients with different severity levels.
11011107
Log notifications can only be sent from within an existing client session, such as tools, resources, and prompts calls.
11021108

‎mcp-core/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,12 @@ public Mono<Object> ping() {
492492
* Adds a new root to the client's root list.
493493
* @param root The root to add.
494494
* @return A Mono that completes when the root is added and notifications are sent.
495+
* @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
496+
* and may be removed from a protocol revision released on or after 2027-07-28. Pass
497+
* directories or files to servers via tool parameters, resource URIs, or server
498+
* configuration instead.
495499
*/
500+
@Deprecated
496501
public Mono<Void> addRoot(Root root) {
497502

498503
if (root == null) {
@@ -524,7 +529,12 @@ public Mono<Void> addRoot(Root root) {
524529
* Removes a root from the client's root list.
525530
* @param rootUri The URI of the root to remove.
526531
* @return A Mono that completes when the root is removed and notifications are sent.
532+
* @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
533+
* and may be removed from a protocol revision released on or after 2027-07-28. Pass
534+
* directories or files to servers via tool parameters, resource URIs, or server
535+
* configuration instead.
527536
*/
537+
@Deprecated
528538
public Mono<Void> removeRoot(String rootUri) {
529539

530540
if (rootUri == null) {
@@ -555,7 +565,12 @@ public Mono<Void> removeRoot(String rootUri) {
555565
* methods automatically send the roots/list_changed notification if the client is in
556566
* an initialized state.
557567
* @return A Mono that completes when the notification is sent.
568+
* @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
569+
* and may be removed from a protocol revision released on or after 2027-07-28. Pass
570+
* directories or files to servers via tool parameters, resource URIs, or server
571+
* configuration instead.
558572
*/
573+
@Deprecated
559574
public Mono<Void> rootsListChangedNotification() {
560575
return this.initializer.withInitialization("sending roots list changed notification",
561576
init -> init.mcpSession().sendNotification(McpSchema.METHOD_NOTIFICATION_ROOTS_LIST_CHANGED));
@@ -1109,7 +1124,11 @@ private NotificationHandler asyncLoggingNotificationHandler(
11091124
* @param loggingLevel The minimum logging level to receive.
11101125
* @return A Mono that completes when the logging level is set.
11111126
* @see McpSchema.LoggingLevel
1127+
* @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
1128+
* and may be removed from a protocol revision released on or after 2027-07-28.
1129+
* Servers should log to stderr (stdio transport) or use OpenTelemetry instead.
11121130
*/
1131+
@Deprecated
11131132
public Mono<Void> setLoggingLevel(LoggingLevel loggingLevel) {
11141133
if (loggingLevel == null) {
11151134
return Mono.error(new IllegalArgumentException("Logging level must not be null"));

‎mcp-core/src/main/java/io/modelcontextprotocol/client/McpClient.java‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ public SyncSpec clientInfo(Implementation clientInfo) {
267267
* Sets the root URIs that this client can access. Roots define the base URIs for
268268
* resources that the client can request from the server. For example, a root
269269
* might be "file://workspace" for accessing workspace files.
270+
* <p>
271+
* Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
272+
* method is not deprecated because the specification requires clients to keep
273+
* answering {@code roots/list} for servers that still use roots.
270274
* @param roots A list of root definitions. Must not be null.
271275
* @return This builder instance for method chaining
272276
* @throws IllegalArgumentException if roots is null
@@ -282,6 +286,10 @@ public SyncSpec roots(List<Root> roots) {
282286
/**
283287
* Sets the root URIs that this client can access, using a varargs parameter for
284288
* convenience. This is an alternative to {@link #roots(List)}.
289+
* <p>
290+
* Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
291+
* method is not deprecated because the specification requires clients to keep
292+
* answering {@code roots/list} for servers that still use roots.
285293
* @param roots An array of root definitions. Must not be null.
286294
* @return This builder instance for method chaining
287295
* @throws IllegalArgumentException if roots is null
@@ -299,6 +307,10 @@ public SyncSpec roots(Root... roots) {
299307
* Sets a custom sampling handler for processing message creation requests. The
300308
* sampling handler can modify or validate messages before they are sent to the
301309
* server, enabling custom processing logic.
310+
* <p>
311+
* Sampling is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
312+
* method is not deprecated because the specification requires clients to keep
313+
* handling {@code sampling/createMessage} for servers that still use sampling.
302314
* @param samplingHandler A function that processes message requests and returns
303315
* results. Must not be null.
304316
* @return This builder instance for method chaining
@@ -405,6 +417,10 @@ public SyncSpec promptsChangeConsumer(Consumer<List<McpSchema.Prompt>> promptsCh
405417
* Adds a consumer to be notified when logging messages are received from the
406418
* server. This allows the client to react to log messages, such as warnings or
407419
* errors, that are sent by the server.
420+
* <p>
421+
* Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
422+
* method is not deprecated because the specification requires clients to keep
423+
* handling log messages from servers that still send them.
408424
* @param loggingConsumer A consumer that receives logging messages. Must not be
409425
* null.
410426
* @return This builder instance for method chaining
@@ -419,6 +435,10 @@ public SyncSpec loggingConsumer(Consumer<McpSchema.LoggingMessageNotification> l
419435
* Adds multiple consumers to be notified when logging messages are received from
420436
* the server. This allows the client to react to log messages, such as warnings
421437
* or errors, that are sent by the server.
438+
* <p>
439+
* Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
440+
* method is not deprecated because the specification requires clients to keep
441+
* handling log messages from servers that still send them.
422442
* @param loggingConsumers A list of consumers that receive logging messages. Must
423443
* not be null.
424444
* @return This builder instance for method chaining
@@ -702,6 +722,10 @@ public AsyncSpec clientInfo(Implementation clientInfo) {
702722
* Sets the root URIs that this client can access. Roots define the base URIs for
703723
* resources that the client can request from the server. For example, a root
704724
* might be "file://workspace" for accessing workspace files.
725+
* <p>
726+
* Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
727+
* method is not deprecated because the specification requires clients to keep
728+
* answering {@code roots/list} for servers that still use roots.
705729
* @param roots A list of root definitions. Must not be null.
706730
* @return This builder instance for method chaining
707731
* @throws IllegalArgumentException if roots is null
@@ -717,6 +741,10 @@ public AsyncSpec roots(List<Root> roots) {
717741
/**
718742
* Sets the root URIs that this client can access, using a varargs parameter for
719743
* convenience. This is an alternative to {@link #roots(List)}.
744+
* <p>
745+
* Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
746+
* method is not deprecated because the specification requires clients to keep
747+
* answering {@code roots/list} for servers that still use roots.
720748
* @param roots An array of root definitions. Must not be null.
721749
* @return This builder instance for method chaining
722750
* @throws IllegalArgumentException if roots is null
@@ -734,6 +762,10 @@ public AsyncSpec roots(Root... roots) {
734762
* Sets a custom sampling handler for processing message creation requests. The
735763
* sampling handler can modify or validate messages before they are sent to the
736764
* server, enabling custom processing logic.
765+
* <p>
766+
* Sampling is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
767+
* method is not deprecated because the specification requires clients to keep
768+
* handling {@code sampling/createMessage} for servers that still use sampling.
737769
* @param samplingHandler A function that processes message requests and returns
738770
* results. Must not be null.
739771
* @return This builder instance for method chaining
@@ -842,6 +874,10 @@ public AsyncSpec promptsChangeConsumer(Function<List<McpSchema.Prompt>, Mono<Voi
842874
* Adds a consumer to be notified when logging messages are received from the
843875
* server. This allows the client to react to log messages, such as warnings or
844876
* errors, that are sent by the server.
877+
* <p>
878+
* Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
879+
* method is not deprecated because the specification requires clients to keep
880+
* handling log messages from servers that still send them.
845881
* @param loggingConsumer A consumer that receives logging messages. Must not be
846882
* null.
847883
* @return This builder instance for method chaining
@@ -856,6 +892,10 @@ public AsyncSpec loggingConsumer(Function<McpSchema.LoggingMessageNotification,
856892
* Adds multiple consumers to be notified when logging messages are received from
857893
* the server. This allows the client to react to log messages, such as warnings
858894
* or errors, that are sent by the server.
895+
* <p>
896+
* Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577). This
897+
* method is not deprecated because the specification requires clients to keep
898+
* handling log messages from servers that still send them.
859899
* @param loggingConsumers A list of consumers that receive logging messages. Must
860900
* not be null.
861901
* @return This builder instance for method chaining

‎mcp-core/src/main/java/io/modelcontextprotocol/client/McpSyncClient.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,36 @@ public McpSchema.InitializeResult initialize() {
192192

193193
/**
194194
* Send a roots/list_changed notification.
195+
* @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
196+
* and may be removed from a protocol revision released on or after 2027-07-28. Pass
197+
* directories or files to servers via tool parameters, resource URIs, or server
198+
* configuration instead.
195199
*/
200+
@Deprecated
196201
public void rootsListChangedNotification() {
197202
withProvidedContext(this.delegate.rootsListChangedNotification()).block();
198203
}
199204

200205
/**
201206
* Add a roots dynamically.
207+
* @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
208+
* and may be removed from a protocol revision released on or after 2027-07-28. Pass
209+
* directories or files to servers via tool parameters, resource URIs, or server
210+
* configuration instead.
202211
*/
212+
@Deprecated
203213
public void addRoot(McpSchema.Root root) {
204214
this.delegate.addRoot(root).block();
205215
}
206216

207217
/**
208218
* Remove a root dynamically.
219+
* @deprecated Roots are deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
220+
* and may be removed from a protocol revision released on or after 2027-07-28. Pass
221+
* directories or files to servers via tool parameters, resource URIs, or server
222+
* configuration instead.
209223
*/
224+
@Deprecated
210225
public void removeRoot(String rootUri) {
211226
this.delegate.removeRoot(rootUri).block();
212227
}
@@ -426,7 +441,11 @@ public GetPromptResult getPrompt(GetPromptRequest getPromptRequest) {
426441
/**
427442
* Client can set the minimum logging level it wants to receive from the server.
428443
* @param loggingLevel the min logging level
444+
* @deprecated Logging is deprecated as of MCP protocol version 2026-07-28 (SEP-2577)
445+
* and may be removed from a protocol revision released on or after 2027-07-28.
446+
* Servers should log to stderr (stdio transport) or use OpenTelemetry instead.
429447
*/
448+
@Deprecated
430449
public void setLoggingLevel(McpSchema.LoggingLevel loggingLevel) {
431450
withProvidedContext(this.delegate.setLoggingLevel(loggingLevel)).block();
432451

0 commit comments

Comments
 (0)