Skip to content

Commit 49c0a71

Browse files
feat: deprecate roots, sampling, and logging runtime APIs (SEP-2577) (modelcontextprotocol#2268)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
1 parent 1110a0c commit 49c0a71

9 files changed

Lines changed: 124 additions & 2 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modelcontextprotocol/core': patch
3+
'@modelcontextprotocol/server': patch
4+
'@modelcontextprotocol/client': patch
5+
---
6+
7+
Mark the roots, sampling, and logging runtime APIs as `@deprecated` per SEP-2577 (deprecated as of protocol version 2026-07-28; functional for at least twelve months). Annotates `Server.createMessage`/`listRoots`/`sendLoggingMessage`, `McpServer.sendLoggingMessage`, `Client.setLoggingLevel`/`sendRootsListChanged`, the `ServerContext.mcpReq.log`/`requestSampling` helpers, and the `roots`/`sampling`/`logging` capability schema fields. JSDoc/docs only — no behavior change.

docs/client.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ client.setNotificationHandler('notifications/resources/list_changed', async () =
404404
});
405405
```
406406

407+
> [!WARNING]
408+
> MCP logging (including `setLoggingLevel()` and `notifications/message`) is deprecated as of protocol version 2026-07-28 (SEP-2577). It remains fully functional during the deprecation window (at least twelve months); see the [deprecated features registry](https://modelcontextprotocol.io/specification/draft/deprecated). Servers should migrate to stderr logging (STDIO) or OpenTelemetry.
409+
407410
To control the minimum severity of log messages the server sends, use {@linkcode @modelcontextprotocol/client!client/client.Client#setLoggingLevel | setLoggingLevel()}:
408411

409412
```ts source="../examples/client/src/clientGuide.examples.ts#setLoggingLevel_basic"
@@ -431,6 +434,9 @@ const client = new Client(
431434

432435
### Sampling
433436

437+
> [!WARNING]
438+
> Sampling is deprecated as of protocol version 2026-07-28 (SEP-2577). It remains fully functional during the deprecation window (at least twelve months); see the [deprecated features registry](https://modelcontextprotocol.io/specification/draft/deprecated). Servers should migrate to calling LLM provider APIs directly.
439+
434440
When a server needs an LLM completion during tool execution, it sends a `sampling/createMessage` request to the client (see [Sampling](https://modelcontextprotocol.io/docs/learn/client-concepts#sampling) in the MCP overview). Register a handler to fulfill it:
435441

436442
```ts source="../examples/client/src/clientGuide.examples.ts#sampling_handler"
@@ -472,6 +478,9 @@ For a full form-based elicitation handler with AJV validation, see [`simpleStrea
472478

473479
### Roots
474480

481+
> [!WARNING]
482+
> Roots are deprecated as of protocol version 2026-07-28 (SEP-2577). They remain fully functional during the deprecation window (at least twelve months); see the [deprecated features registry](https://modelcontextprotocol.io/specification/draft/deprecated). Migrate to passing paths via tool parameters, resource URIs, or configuration.
483+
475484
Roots let the client expose filesystem boundaries to the server (see [Roots](https://modelcontextprotocol.io/docs/learn/client-concepts#roots) in the MCP overview). Declare the `roots` capability and register a `roots/list` handler:
476485

477486
```ts source="../examples/client/src/clientGuide.examples.ts#roots_handler"

docs/server.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ server.registerPrompt(
312312

313313
## Logging
314314

315+
> [!WARNING]
316+
> MCP logging is deprecated as of protocol version 2026-07-28 (SEP-2577). It remains fully functional during the deprecation window (at least twelve months); see the [deprecated features registry](https://modelcontextprotocol.io/specification/draft/deprecated). Migrate to stderr logging (STDIO servers) or OpenTelemetry.
317+
315318
Logging lets your server send structured diagnostics — debug traces, progress updates, warnings — to the connected client as notifications (see [Logging](https://modelcontextprotocol.io/specification/latest/server/utilities/logging) in the MCP specification).
316319

317320
Declare the `logging` capability, then call `ctx.mcpReq.log(level, data)` (from {@linkcode @modelcontextprotocol/server!index.ServerContext | ServerContext}) inside any handler:
@@ -384,6 +387,9 @@ MCP is bidirectional — servers can send requests *to* the client during tool e
384387

385388
### Sampling
386389

390+
> [!WARNING]
391+
> Sampling is deprecated as of protocol version 2026-07-28 (SEP-2577). It remains fully functional during the deprecation window (at least twelve months); see the [deprecated features registry](https://modelcontextprotocol.io/specification/draft/deprecated). Migrate to calling LLM provider APIs directly from your server.
392+
387393
Sampling lets a tool handler request an LLM completion from the connected client — the handler describes a prompt and the client returns the model's response (see [Sampling](https://modelcontextprotocol.io/docs/learn/client-concepts#sampling) in the MCP overview). Use sampling when a tool needs the model to generate or transform text mid-execution.
388394

389395
Call `ctx.mcpReq.requestSampling(params)` (from {@linkcode @modelcontextprotocol/server!index.ServerContext | ServerContext}) inside a tool handler:
@@ -478,6 +484,9 @@ For runnable examples, see [`elicitationFormExample.ts`](https://github.com/mode
478484

479485
### Roots
480486

487+
> [!WARNING]
488+
> Roots are deprecated as of protocol version 2026-07-28 (SEP-2577). They remain fully functional during the deprecation window (at least twelve months); see the [deprecated features registry](https://modelcontextprotocol.io/specification/draft/deprecated). Migrate to passing paths via tool parameters, resource URIs, or configuration.
489+
481490
Roots let a tool handler discover the client's workspace directories — for example, to scope a file search or identify project boundaries (see [Roots](https://modelcontextprotocol.io/docs/learn/client-concepts#roots) in the MCP overview). Call {@linkcode @modelcontextprotocol/server!server/server.Server#listRoots | server.server.listRoots()} (requires the client to declare the `roots` capability):
482491

483492
```ts source="../examples/server/src/serverGuide.examples.ts#registerTool_roots"

packages/client/src/client/client.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ export type ClientOptions = ProtocolOptions & {
189189
* `sampling/createMessage` and `elicitation/create`, the handler is automatically wrapped with
190190
* schema validation for both the incoming request and the returned result.
191191
*
192+
* Note: the `roots/list` and `sampling/createMessage` handler surfaces (and the corresponding
193+
* `roots` and `sampling` capabilities) are deprecated as of protocol version 2026-07-28
194+
* (SEP-2577). They remain functional during the deprecation window (at least twelve months).
195+
* Migrate sampling to calling LLM provider APIs directly, and roots to passing paths via tool
196+
* parameters, resource URIs, or configuration.
197+
*
192198
* @example Handling a sampling request
193199
* ```ts source="./client.examples.ts#Client_setRequestHandler_sampling"
194200
* client.setRequestHandler('sampling/createMessage', async request => {
@@ -499,6 +505,8 @@ export class Client extends Protocol<ClientContext> {
499505

500506
protected assertCapabilityForMethod(method: RequestMethod | string): void {
501507
switch (method as ClientRequest['method']) {
508+
// Deprecated as of protocol version 2026-07-28 (SEP-2577); remains
509+
// functional during the deprecation window (at least twelve months).
502510
case 'logging/setLevel': {
503511
if (!this._serverCapabilities?.logging) {
504512
throw new SdkError(SdkErrorCode.CapabilityNotSupported, `Server does not support logging (required for ${method})`);
@@ -562,6 +570,8 @@ export class Client extends Protocol<ClientContext> {
562570

563571
protected assertNotificationCapability(method: NotificationMethod | string): void {
564572
switch (method as ClientNotification['method']) {
573+
// Deprecated as of protocol version 2026-07-28 (SEP-2577); remains
574+
// functional during the deprecation window (at least twelve months).
565575
case 'notifications/roots/list_changed': {
566576
if (!this._capabilities.roots?.listChanged) {
567577
throw new SdkError(
@@ -591,6 +601,8 @@ export class Client extends Protocol<ClientContext> {
591601

592602
protected assertRequestHandlerCapability(method: string): void {
593603
switch (method) {
604+
// Deprecated as of protocol version 2026-07-28 (SEP-2577); remains
605+
// functional during the deprecation window (at least twelve months).
594606
case 'sampling/createMessage': {
595607
if (!this._capabilities.sampling) {
596608
throw new SdkError(
@@ -611,6 +623,8 @@ export class Client extends Protocol<ClientContext> {
611623
break;
612624
}
613625

626+
// Deprecated as of protocol version 2026-07-28 (SEP-2577); remains
627+
// functional during the deprecation window (at least twelve months).
614628
case 'roots/list': {
615629
if (!this._capabilities.roots) {
616630
throw new SdkError(
@@ -637,7 +651,13 @@ export class Client extends Protocol<ClientContext> {
637651
return this._requestWithSchema({ method: 'completion/complete', params }, CompleteResultSchema, options);
638652
}
639653

640-
/** Sets the minimum severity level for log messages sent by the server. */
654+
/**
655+
* Sets the minimum severity level for log messages sent by the server.
656+
*
657+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
658+
* Remains functional during the deprecation window (at least twelve months).
659+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
660+
*/
641661
async setLoggingLevel(level: LoggingLevel, options?: RequestOptions) {
642662
return this._requestWithSchema({ method: 'logging/setLevel', params: { level } }, EmptyResultSchema, options);
643663
}
@@ -935,7 +955,13 @@ export class Client extends Protocol<ClientContext> {
935955
this.setNotificationHandler(notificationMethod, handler);
936956
}
937957

938-
/** Notifies the server that the client's root list has changed. Requires the `roots.listChanged` capability. */
958+
/**
959+
* Notifies the server that the client's root list has changed. Requires the `roots.listChanged` capability.
960+
*
961+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
962+
* Remains functional during the deprecation window (at least twelve months).
963+
* Migrate to passing paths via tool parameters, resource URIs, or configuration.
964+
*/
939965
async sendRootsListChanged() {
940966
return this.notification({ method: 'notifications/roots/list_changed' });
941967
}

packages/core/src/shared/protocol.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ export type ServerContext = BaseContext & {
211211
/**
212212
* Send a log message notification to the client.
213213
* Respects the client's log level filter set via logging/setLevel.
214+
*
215+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
216+
* Remains functional during the deprecation window (at least twelve months).
217+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
214218
*/
215219
log: (level: LoggingLevel, data: unknown, logger?: string) => Promise<void>;
216220

@@ -221,6 +225,10 @@ export type ServerContext = BaseContext & {
221225

222226
/**
223227
* Request LLM sampling from the client.
228+
*
229+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
230+
* Remains functional during the deprecation window (at least twelve months).
231+
* Migrate to calling LLM provider APIs directly.
224232
*/
225233
requestSampling: (
226234
params: CreateMessageRequest['params'],

packages/core/src/types/schemas.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ export const ClientCapabilitiesSchema = z.object({
421421
experimental: z.record(z.string(), JSONObjectSchema).optional(),
422422
/**
423423
* Present if the client supports sampling from an LLM.
424+
*
425+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577); remains
426+
* in the specification for at least twelve months. Migrate to calling LLM
427+
* provider APIs directly.
424428
*/
425429
sampling: z
426430
.object({
@@ -441,6 +445,10 @@ export const ClientCapabilitiesSchema = z.object({
441445
elicitation: ElicitationCapabilitySchema.optional(),
442446
/**
443447
* Present if the client supports listing roots.
448+
*
449+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577); remains
450+
* in the specification for at least twelve months. Migrate to passing paths via
451+
* tool parameters, resource URIs, or configuration.
444452
*/
445453
roots: z
446454
.object({
@@ -486,6 +494,10 @@ export const ServerCapabilitiesSchema = z.object({
486494
experimental: z.record(z.string(), JSONObjectSchema).optional(),
487495
/**
488496
* Present if the server supports sending log messages to the client.
497+
*
498+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577); remains
499+
* in the specification for at least twelve months. Migrate to stderr logging
500+
* (STDIO servers) or OpenTelemetry.
489501
*/
490502
logging: JSONObjectSchema.optional(),
491503
/**

packages/core/src/types/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,23 @@ export type Role = Infer<typeof RoleSchema>;
225225

226226
/* Initialization */
227227
export type Implementation = Infer<typeof ImplementationSchema>;
228+
/**
229+
* Capabilities a client may support.
230+
*
231+
* Note: the `roots` and `sampling` capabilities are deprecated as of protocol
232+
* version 2026-07-28 (SEP-2577); they remain in the specification for at least
233+
* twelve months. See `ClientCapabilitiesSchema`.
234+
*/
228235
export type ClientCapabilities = Infer<typeof ClientCapabilitiesSchema>;
229236
export type InitializeRequestParams = Infer<typeof InitializeRequestParamsSchema>;
230237
export type InitializeRequest = Infer<typeof InitializeRequestSchema>;
238+
/**
239+
* Capabilities a server may support.
240+
*
241+
* Note: the `logging` capability is deprecated as of protocol version
242+
* 2026-07-28 (SEP-2577); it remains in the specification for at least twelve
243+
* months. See `ServerCapabilitiesSchema`.
244+
*/
231245
export type ServerCapabilities = Infer<typeof ServerCapabilitiesSchema>;
232246
export type InitializeResult = Infer<typeof InitializeResultSchema>;
233247
export type InitializedNotification = Infer<typeof InitializedNotificationSchema>;

packages/server/src/server/mcp.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,10 @@ export class McpServer {
926926
* data: 'Processing complete'
927927
* });
928928
* ```
929+
*
930+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
931+
* Remains functional during the deprecation window (at least twelve months).
932+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
929933
*/
930934
async sendLoggingMessage(params: LoggingMessageNotification['params'], sessionId?: string) {
931935
return this.server.sendLoggingMessage(params, sessionId);

packages/server/src/server/server.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ export class Server extends Protocol<ServerContext> {
113113
}
114114
}
115115

116+
/**
117+
* Registers the built-in `logging/setLevel` request handler.
118+
*
119+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
120+
* Remains functional during the deprecation window (at least twelve months).
121+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
122+
*/
116123
private _registerLoggingHandler(): void {
117124
this.setRequestHandler('logging/setLevel', async (request, ctx) => {
118125
const transportSessionId: string | undefined =
@@ -133,6 +140,9 @@ export class Server extends Protocol<ServerContext> {
133140
...ctx,
134141
mcpReq: {
135142
...ctx.mcpReq,
143+
// Deprecated as of protocol version 2026-07-28 (SEP-2577): `log` and
144+
// `requestSampling` remain functional during the deprecation window
145+
// (at least twelve months). See ServerContext for migration guidance.
136146
log: (level, data, logger) => this.sendLoggingMessage({ level, data, logger }),
137147
elicitInput: (params, options) => this.elicitInput(params, options),
138148
requestSampling: (params, options) => this.createMessage(params, options)
@@ -410,18 +420,30 @@ export class Server extends Protocol<ServerContext> {
410420
/**
411421
* Request LLM sampling from the client (without tools).
412422
* Returns single content block for backwards compatibility.
423+
*
424+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
425+
* Remains functional during the deprecation window (at least twelve months).
426+
* Migrate to calling LLM provider APIs directly.
413427
*/
414428
async createMessage(params: CreateMessageRequestParamsBase, options?: RequestOptions): Promise<CreateMessageResult>;
415429

416430
/**
417431
* Request LLM sampling from the client with tool support.
418432
* Returns content that may be a single block or array (for parallel tool calls).
433+
*
434+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
435+
* Remains functional during the deprecation window (at least twelve months).
436+
* Migrate to calling LLM provider APIs directly.
419437
*/
420438
async createMessage(params: CreateMessageRequestParamsWithTools, options?: RequestOptions): Promise<CreateMessageResultWithTools>;
421439

422440
/**
423441
* Request LLM sampling from the client.
424442
* When tools may or may not be present, returns the union type.
443+
*
444+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
445+
* Remains functional during the deprecation window (at least twelve months).
446+
* Migrate to calling LLM provider APIs directly.
425447
*/
426448
async createMessage(
427449
params: CreateMessageRequest['params'],
@@ -576,6 +598,13 @@ export class Server extends Protocol<ServerContext> {
576598
);
577599
}
578600

601+
/**
602+
* Requests the list of roots from the client.
603+
*
604+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
605+
* Remains functional during the deprecation window (at least twelve months).
606+
* Migrate to passing paths via tool parameters, resource URIs, or configuration.
607+
*/
579608
async listRoots(params?: ListRootsRequest['params'], options?: RequestOptions) {
580609
return this._requestWithSchema({ method: 'roots/list', params }, ListRootsResultSchema, options);
581610
}
@@ -586,6 +615,10 @@ export class Server extends Protocol<ServerContext> {
586615
* @see {@linkcode LoggingMessageNotification}
587616
* @param params
588617
* @param sessionId Optional for stateless transports and backward compatibility.
618+
*
619+
* @deprecated Deprecated as of protocol version 2026-07-28 (SEP-2577).
620+
* Remains functional during the deprecation window (at least twelve months).
621+
* Migrate to stderr logging (STDIO servers) or OpenTelemetry.
589622
*/
590623
async sendLoggingMessage(params: LoggingMessageNotification['params'], sessionId?: string) {
591624
if (this._capabilities.logging && !this.isMessageIgnored(params.level, sessionId)) {

0 commit comments

Comments
 (0)