Skip to content

Commit 587770d

Browse files
committed
Deprecate roots, sampling, and logging APIs
Mark roots, sampling, and logging schema elements, client/server configuration APIs, and related runtime methods as deprecated for the 2026-07-28 MCP specification update. Keep behavior unchanged while surfacing standard Java deprecation warnings to downstream consumers.
1 parent 30f1adf commit 587770d

9 files changed

Lines changed: 132 additions & 8 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,9 @@ 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 in the 2026-07-28 MCP specification.
495496
*/
497+
@Deprecated
496498
public Mono<Void> addRoot(Root root) {
497499

498500
if (root == null) {
@@ -524,7 +526,9 @@ public Mono<Void> addRoot(Root root) {
524526
* Removes a root from the client's root list.
525527
* @param rootUri The URI of the root to remove.
526528
* @return A Mono that completes when the root is removed and notifications are sent.
529+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
527530
*/
531+
@Deprecated
528532
public Mono<Void> removeRoot(String rootUri) {
529533

530534
if (rootUri == null) {
@@ -555,7 +559,9 @@ public Mono<Void> removeRoot(String rootUri) {
555559
* methods automatically send the roots/list_changed notification if the client is in
556560
* an initialized state.
557561
* @return A Mono that completes when the notification is sent.
562+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
558563
*/
564+
@Deprecated
559565
public Mono<Void> rootsListChangedNotification() {
560566
return this.initializer.withInitialization("sending roots list changed notification",
561567
init -> init.mcpSession().sendNotification(McpSchema.METHOD_NOTIFICATION_ROOTS_LIST_CHANGED));
@@ -1110,7 +1116,9 @@ private NotificationHandler asyncLoggingNotificationHandler(
11101116
* @param loggingLevel The minimum logging level to receive.
11111117
* @return A Mono that completes when the logging level is set.
11121118
* @see McpSchema.LoggingLevel
1119+
* @deprecated Logging is deprecated in the 2026-07-28 MCP specification.
11131120
*/
1121+
@Deprecated
11141122
public Mono<Void> setLoggingLevel(LoggingLevel loggingLevel) {
11151123
if (loggingLevel == null) {
11161124
return Mono.error(new IllegalArgumentException("Logging level must not be null"));

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ public SyncSpec clientInfo(Implementation clientInfo) {
270270
* @param roots A list of root definitions. Must not be null.
271271
* @return This builder instance for method chaining
272272
* @throws IllegalArgumentException if roots is null
273+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
273274
*/
275+
@Deprecated
274276
public SyncSpec roots(List<Root> roots) {
275277
Assert.notNull(roots, "Roots must not be null");
276278
for (Root root : roots) {
@@ -286,7 +288,9 @@ public SyncSpec roots(List<Root> roots) {
286288
* @return This builder instance for method chaining
287289
* @throws IllegalArgumentException if roots is null
288290
* @see #roots(List)
291+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
289292
*/
293+
@Deprecated
290294
public SyncSpec roots(Root... roots) {
291295
Assert.notNull(roots, "Roots must not be null");
292296
for (Root root : roots) {
@@ -303,7 +307,9 @@ public SyncSpec roots(Root... roots) {
303307
* results. Must not be null.
304308
* @return This builder instance for method chaining
305309
* @throws IllegalArgumentException if samplingHandler is null
310+
* @deprecated Sampling is deprecated in the 2026-07-28 MCP specification.
306311
*/
312+
@Deprecated
307313
public SyncSpec sampling(Function<CreateMessageRequest, CreateMessageResult> samplingHandler) {
308314
Assert.notNull(samplingHandler, "Sampling handler must not be null");
309315
this.samplingHandler = samplingHandler;
@@ -408,7 +414,9 @@ public SyncSpec promptsChangeConsumer(Consumer<List<McpSchema.Prompt>> promptsCh
408414
* @param loggingConsumer A consumer that receives logging messages. Must not be
409415
* null.
410416
* @return This builder instance for method chaining
417+
* @deprecated Logging is deprecated in the 2026-07-28 MCP specification.
411418
*/
419+
@Deprecated
412420
public SyncSpec loggingConsumer(Consumer<McpSchema.LoggingMessageNotification> loggingConsumer) {
413421
Assert.notNull(loggingConsumer, "Logging consumer must not be null");
414422
this.loggingConsumers.add(loggingConsumer);
@@ -422,7 +430,9 @@ public SyncSpec loggingConsumer(Consumer<McpSchema.LoggingMessageNotification> l
422430
* @param loggingConsumers A list of consumers that receive logging messages. Must
423431
* not be null.
424432
* @return This builder instance for method chaining
433+
* @deprecated Logging is deprecated in the 2026-07-28 MCP specification.
425434
*/
435+
@Deprecated
426436
public SyncSpec loggingConsumers(List<Consumer<McpSchema.LoggingMessageNotification>> loggingConsumers) {
427437
Assert.notNull(loggingConsumers, "Logging consumers must not be null");
428438
this.loggingConsumers.addAll(loggingConsumers);
@@ -689,7 +699,9 @@ public AsyncSpec clientInfo(Implementation clientInfo) {
689699
* @param roots A list of root definitions. Must not be null.
690700
* @return This builder instance for method chaining
691701
* @throws IllegalArgumentException if roots is null
702+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
692703
*/
704+
@Deprecated
693705
public AsyncSpec roots(List<Root> roots) {
694706
Assert.notNull(roots, "Roots must not be null");
695707
for (Root root : roots) {
@@ -705,7 +717,9 @@ public AsyncSpec roots(List<Root> roots) {
705717
* @return This builder instance for method chaining
706718
* @throws IllegalArgumentException if roots is null
707719
* @see #roots(List)
720+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
708721
*/
722+
@Deprecated
709723
public AsyncSpec roots(Root... roots) {
710724
Assert.notNull(roots, "Roots must not be null");
711725
for (Root root : roots) {
@@ -722,7 +736,9 @@ public AsyncSpec roots(Root... roots) {
722736
* results. Must not be null.
723737
* @return This builder instance for method chaining
724738
* @throws IllegalArgumentException if samplingHandler is null
739+
* @deprecated Sampling is deprecated in the 2026-07-28 MCP specification.
725740
*/
741+
@Deprecated
726742
public AsyncSpec sampling(Function<CreateMessageRequest, Mono<CreateMessageResult>> samplingHandler) {
727743
Assert.notNull(samplingHandler, "Sampling handler must not be null");
728744
this.samplingHandler = samplingHandler;
@@ -829,7 +845,9 @@ public AsyncSpec promptsChangeConsumer(Function<List<McpSchema.Prompt>, Mono<Voi
829845
* @param loggingConsumer A consumer that receives logging messages. Must not be
830846
* null.
831847
* @return This builder instance for method chaining
848+
* @deprecated Logging is deprecated in the 2026-07-28 MCP specification.
832849
*/
850+
@Deprecated
833851
public AsyncSpec loggingConsumer(Function<McpSchema.LoggingMessageNotification, Mono<Void>> loggingConsumer) {
834852
Assert.notNull(loggingConsumer, "Logging consumer must not be null");
835853
this.loggingConsumers.add(loggingConsumer);
@@ -843,7 +861,9 @@ public AsyncSpec loggingConsumer(Function<McpSchema.LoggingMessageNotification,
843861
* @param loggingConsumers A list of consumers that receive logging messages. Must
844862
* not be null.
845863
* @return This builder instance for method chaining
864+
* @deprecated Logging is deprecated in the 2026-07-28 MCP specification.
846865
*/
866+
@Deprecated
847867
public AsyncSpec loggingConsumers(
848868
List<Function<McpSchema.LoggingMessageNotification, Mono<Void>>> loggingConsumers) {
849869
Assert.notNull(loggingConsumers, "Logging consumers must not be null");

mcp-core/src/main/java/io/modelcontextprotocol/client/McpClientFeatures.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ class McpClientFeatures {
6868
* in the {@code requestedSchema}.
6969
*/
7070
record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities clientCapabilities,
71-
Map<String, McpSchema.Root> roots, List<Function<List<McpSchema.Tool>, Mono<Void>>> toolsChangeConsumers,
71+
@Deprecated Map<String, McpSchema.Root> roots,
72+
List<Function<List<McpSchema.Tool>, Mono<Void>>> toolsChangeConsumers,
7273
List<Function<List<McpSchema.Resource>, Mono<Void>>> resourcesChangeConsumers,
7374
List<Function<List<McpSchema.ResourceContents>, Mono<Void>>> resourcesUpdateConsumers,
7475
List<Function<List<McpSchema.Prompt>, Mono<Void>>> promptsChangeConsumers,
75-
List<Function<McpSchema.LoggingMessageNotification, Mono<Void>>> loggingConsumers,
76+
@Deprecated List<Function<McpSchema.LoggingMessageNotification, Mono<Void>>> loggingConsumers,
7677
List<Function<McpSchema.ProgressNotification, Mono<Void>>> progressConsumers,
7778
List<Function<McpSchema.ElicitationCompleteNotification, Mono<Void>>> elicitationCompleteConsumers,
78-
Function<McpSchema.CreateMessageRequest, Mono<McpSchema.CreateMessageResult>> samplingHandler,
79+
@Deprecated Function<McpSchema.CreateMessageRequest, Mono<McpSchema.CreateMessageResult>> samplingHandler,
7980
Function<McpSchema.ElicitFormRequest, Mono<McpSchema.ElicitResult>> formElicitationHandler,
8081
Function<McpSchema.ElicitUrlRequest, Mono<McpSchema.ElicitResult>> urlElicitationHandler,
8182
boolean enableCallToolSchemaCaching, boolean applyElicitationDefaults) {
@@ -95,7 +96,10 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
9596
* @param applyElicitationDefaults whether the client should fill in missing
9697
* fields of an accepted {@code ElicitResult.content} with the {@code default}
9798
* values declared in the {@code requestedSchema}.
99+
* @deprecated Roots, sampling, and logging are deprecated in the 2026-07-28 MCP
100+
* specification.
98101
*/
102+
@Deprecated
99103
public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities clientCapabilities,
100104
Map<String, McpSchema.Root> roots,
101105
List<Function<List<McpSchema.Tool>, Mono<Void>>> toolsChangeConsumers,
@@ -137,6 +141,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
137141
/**
138142
* @deprecated Only exists for backwards-compatibility purposes.
139143
*/
144+
@Deprecated
140145
public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities clientCapabilities,
141146
Map<String, McpSchema.Root> roots,
142147
List<Function<List<McpSchema.Tool>, Mono<Void>>> toolsChangeConsumers,
@@ -248,14 +253,14 @@ public static Async fromSync(Sync syncSpec) {
248253
* in the {@code requestedSchema}.
249254
*/
250255
public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities clientCapabilities,
251-
Map<String, McpSchema.Root> roots, List<Consumer<List<McpSchema.Tool>>> toolsChangeConsumers,
256+
@Deprecated Map<String, McpSchema.Root> roots, List<Consumer<List<McpSchema.Tool>>> toolsChangeConsumers,
252257
List<Consumer<List<McpSchema.Resource>>> resourcesChangeConsumers,
253258
List<Consumer<List<McpSchema.ResourceContents>>> resourcesUpdateConsumers,
254259
List<Consumer<List<McpSchema.Prompt>>> promptsChangeConsumers,
255-
List<Consumer<McpSchema.LoggingMessageNotification>> loggingConsumers,
260+
@Deprecated List<Consumer<McpSchema.LoggingMessageNotification>> loggingConsumers,
256261
List<Consumer<McpSchema.ProgressNotification>> progressConsumers,
257262
List<Consumer<McpSchema.ElicitationCompleteNotification>> elicitationCompleteConsumers,
258-
Function<McpSchema.CreateMessageRequest, McpSchema.CreateMessageResult> samplingHandler,
263+
@Deprecated Function<McpSchema.CreateMessageRequest, McpSchema.CreateMessageResult> samplingHandler,
259264
Function<McpSchema.ElicitFormRequest, McpSchema.ElicitResult> formElicitationHandler,
260265
Function<McpSchema.ElicitUrlRequest, McpSchema.ElicitResult> urlElicitationHandler,
261266
boolean enableCallToolSchemaCaching, boolean applyElicitationDefaults) {
@@ -277,7 +282,10 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
277282
* @param applyElicitationDefaults whether the client should fill in missing
278283
* fields of an accepted {@code ElicitResult.content} with the {@code default}
279284
* values declared in the {@code requestedSchema}.
285+
* @deprecated Roots, sampling, and logging are deprecated in the 2026-07-28 MCP
286+
* specification.
280287
*/
288+
@Deprecated
281289
public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities clientCapabilities,
282290
Map<String, McpSchema.Root> roots, List<Consumer<List<McpSchema.Tool>>> toolsChangeConsumers,
283291
List<Consumer<List<McpSchema.Resource>>> resourcesChangeConsumers,
@@ -318,6 +326,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
318326
/**
319327
* @deprecated Only exists for backwards-compatibility purposes.
320328
*/
329+
@Deprecated
321330
public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities clientCapabilities,
322331
Map<String, McpSchema.Root> roots, List<Consumer<List<McpSchema.Tool>>> toolsChangeConsumers,
323332
List<Consumer<List<McpSchema.Resource>>> resourcesChangeConsumers,

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

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

193193
/**
194194
* Send a roots/list_changed notification.
195+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
195196
*/
197+
@Deprecated
196198
public void rootsListChangedNotification() {
197199
withProvidedContext(this.delegate.rootsListChangedNotification()).block();
198200
}
199201

200202
/**
201203
* Add a roots dynamically.
204+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
202205
*/
206+
@Deprecated
203207
public void addRoot(McpSchema.Root root) {
204208
this.delegate.addRoot(root).block();
205209
}
206210

207211
/**
208212
* Remove a root dynamically.
213+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
209214
*/
215+
@Deprecated
210216
public void removeRoot(String rootUri) {
211217
this.delegate.removeRoot(rootUri).block();
212218
}
@@ -426,7 +432,9 @@ public GetPromptResult getPrompt(GetPromptRequest getPromptRequest) {
426432
/**
427433
* Client can set the minimum logging level it wants to receive from the server.
428434
* @param loggingLevel the min logging level
435+
* @deprecated Logging is deprecated in the 2026-07-28 MCP specification.
429436
*/
437+
@Deprecated
430438
public void setLoggingLevel(McpSchema.LoggingLevel loggingLevel) {
431439
withProvidedContext(this.delegate.setLoggingLevel(loggingLevel)).block();
432440

mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ public Mono<McpSchema.ListRootsResult> listRoots(String cursor) {
234234
* minimum logging level will be filtered out.
235235
* @param loggingMessageNotification The logging message to send
236236
* @return A Mono that completes when the notification has been sent
237+
* @deprecated Logging is deprecated in the 2026-07-28 MCP specification.
237238
*/
239+
@Deprecated
238240
public Mono<Void> loggingNotification(LoggingMessageNotification loggingMessageNotification) {
239241

240242
if (loggingMessageNotification == null) {

mcp-core/src/main/java/io/modelcontextprotocol/server/McpServer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,9 @@ public AsyncSpecification<S> completions(McpServerFeatures.AsyncCompletionSpecif
745745
* interact with the connected client. The second argument is the list of roots.
746746
* @return This builder instance for method chaining
747747
* @throws IllegalArgumentException if consumer is null
748+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
748749
*/
750+
@Deprecated
749751
public AsyncSpecification<S> rootsChangeHandler(
750752
BiFunction<McpAsyncServerExchange, List<McpSchema.Root>, Mono<Void>> handler) {
751753
Assert.notNull(handler, "Consumer must not be null");
@@ -761,7 +763,9 @@ public AsyncSpecification<S> rootsChangeHandler(
761763
* @return This builder instance for method chaining
762764
* @throws IllegalArgumentException if consumers is null
763765
* @see #rootsChangeHandler(BiFunction)
766+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
764767
*/
768+
@Deprecated
765769
public AsyncSpecification<S> rootsChangeHandlers(
766770
List<BiFunction<McpAsyncServerExchange, List<McpSchema.Root>, Mono<Void>>> handlers) {
767771
Assert.notNull(handlers, "Handlers list must not be null");
@@ -777,7 +781,9 @@ public AsyncSpecification<S> rootsChangeHandlers(
777781
* @return This builder instance for method chaining
778782
* @throws IllegalArgumentException if consumers is null
779783
* @see #rootsChangeHandlers(List)
784+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
780785
*/
786+
@Deprecated
781787
public AsyncSpecification<S> rootsChangeHandlers(
782788
@SuppressWarnings("unchecked") BiFunction<McpAsyncServerExchange, List<McpSchema.Root>, Mono<Void>>... handlers) {
783789
Assert.notNull(handlers, "Handlers list must not be null");
@@ -1347,7 +1353,9 @@ public SyncSpecification<S> completions(McpServerFeatures.SyncCompletionSpecific
13471353
* with the connected client. The second argument is the list of roots.
13481354
* @return This builder instance for method chaining
13491355
* @throws IllegalArgumentException if consumer is null
1356+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
13501357
*/
1358+
@Deprecated
13511359
public SyncSpecification<S> rootsChangeHandler(
13521360
BiConsumer<McpSyncServerExchange, List<McpSchema.Root>> handler) {
13531361
Assert.notNull(handler, "Consumer must not be null");
@@ -1363,7 +1371,9 @@ public SyncSpecification<S> rootsChangeHandler(
13631371
* @return This builder instance for method chaining
13641372
* @throws IllegalArgumentException if consumers is null
13651373
* @see #rootsChangeHandler(BiConsumer)
1374+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
13661375
*/
1376+
@Deprecated
13671377
public SyncSpecification<S> rootsChangeHandlers(
13681378
List<BiConsumer<McpSyncServerExchange, List<McpSchema.Root>>> handlers) {
13691379
Assert.notNull(handlers, "Handlers list must not be null");
@@ -1379,7 +1389,9 @@ public SyncSpecification<S> rootsChangeHandlers(
13791389
* @return This builder instance for method chaining
13801390
* @throws IllegalArgumentException if consumers is null
13811391
* @see #rootsChangeHandlers(List)
1392+
* @deprecated Roots are deprecated in the 2026-07-28 MCP specification.
13821393
*/
1394+
@Deprecated
13831395
public SyncSpecification<S> rootsChangeHandlers(
13841396
BiConsumer<McpSyncServerExchange, List<McpSchema.Root>>... handlers) {
13851397
Assert.notNull(handlers, "Handlers list must not be null");

mcp-core/src/main/java/io/modelcontextprotocol/server/McpServerFeatures.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
4444
Map<String, McpServerFeatures.AsyncResourceTemplateSpecification> resourceTemplates,
4545
Map<String, McpServerFeatures.AsyncPromptSpecification> prompts,
4646
Map<McpSchema.CompleteReference, McpServerFeatures.AsyncCompletionSpecification> completions,
47-
List<BiFunction<McpAsyncServerExchange, List<McpSchema.Root>, Mono<Void>>> rootsChangeConsumers,
47+
@Deprecated List<BiFunction<McpAsyncServerExchange, List<McpSchema.Root>, Mono<Void>>> rootsChangeConsumers,
4848
String instructions) {
4949

5050
/**
@@ -58,7 +58,10 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
5858
* @param rootsChangeConsumers The list of consumers that will be notified when
5959
* the roots list changes
6060
* @param instructions The server instructions text
61+
* @deprecated Roots and logging are deprecated in the 2026-07-28 MCP
62+
* specification.
6163
*/
64+
@Deprecated
6265
Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities serverCapabilities,
6366
List<McpServerFeatures.AsyncToolSpecification> tools, Map<String, AsyncResourceSpecification> resources,
6467
Map<String, McpServerFeatures.AsyncResourceTemplateSpecification> resourceTemplates,
@@ -161,7 +164,8 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
161164
Map<String, McpServerFeatures.SyncResourceTemplateSpecification> resourceTemplates,
162165
Map<String, McpServerFeatures.SyncPromptSpecification> prompts,
163166
Map<McpSchema.CompleteReference, McpServerFeatures.SyncCompletionSpecification> completions,
164-
List<BiConsumer<McpSyncServerExchange, List<McpSchema.Root>>> rootsChangeConsumers, String instructions) {
167+
@Deprecated List<BiConsumer<McpSyncServerExchange, List<McpSchema.Root>>> rootsChangeConsumers,
168+
String instructions) {
165169

166170
/**
167171
* Create an instance and validate the arguments.
@@ -174,7 +178,10 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
174178
* @param rootsChangeConsumers The list of consumers that will be notified when
175179
* the roots list changes
176180
* @param instructions The server instructions text
181+
* @deprecated Roots and logging are deprecated in the 2026-07-28 MCP
182+
* specification.
177183
*/
184+
@Deprecated
178185
Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities serverCapabilities,
179186
List<McpServerFeatures.SyncToolSpecification> tools,
180187
Map<String, McpServerFeatures.SyncResourceSpecification> resources,

0 commit comments

Comments
 (0)