Topic 5 of 5 · 5 min read
Migrating off sampling, roots and logging
Goal: Rewrite a server design that relies on sampling, roots or protocol logging to use the recommended replacements.
The 2026-07-28 revision deprecates Roots, Sampling and Logging: they still work, but new servers should not use them, and each has a plain replacement. Deprecated is not removed. Under the project's lifecycle policy a feature stays in the Deprecated state for a minimum of twelve months before it can be removed.
Check yourself · 1 of 3
What does it mean that Sampling is Deprecated in the 2026-07-28 revision?
Why it matters
A server written today against sampling or roots will work with current clients and then become a migration job. The changelog says new implementations should not add support for these features. Treating them as stable is the common mistake, and ripping them out without a path for older clients is the other.
The replacements
| Deprecated | Use instead |
|---|---|
| Roots (the client tells the server which directories it may touch) | Pass directories or files as tool parameters or resource URIs, or put them in server configuration. |
| Sampling (the server asks the client's model to generate text) | Call an LLM provider API directly from the server, with the server's own credentials and budget. |
Logging (logging/setLevel and notifications/message) |
Log to stderr for stdio servers, or use OpenTelemetry. |
Two related changes sit in the same revision. HTTP+SSE moves to Deprecated in favour of Streamable HTTP. The includeContext values thisServer and allServers are deprecated, so omit the field or use none.
How to migrate
- Find the dependencies. Search for
sampling/createMessage,roots/listandnotifications/message. - Make the scope explicit. A tool that read "the first root" now takes a
pathargument and checks it against an allowed base directory on the server. - Own the model call. Sampling used the user's model and quota. A direct call uses yours, so decide who pays, set a cost cap and handle provider errors yourself.
- Keep older clients working during the window. Check what the client declared before using a deprecated feature. Use the old path only when the client supports it and the new path is not available.
- Remove the old path when the window ends. Put the date in a comment or task.
Before and after
- const roots = await ctx.listRoots();
- const base = roots[0].uri;
+ // path comes from the tool call, checked against SERVER_ALLOWED_DIR
+ const base = resolveInside(SERVER_ALLOWED_DIR, args.path);
What goes wrong
- Silent cost shift. Replacing sampling with a provider call moves tokens to your bill.
- Weaker path checks. A path argument needs validation that roots once provided.
- Dropping old clients. Removing the sampling path breaks clients that have not updated yet.
Examples
Summary tool using sampling
- const summary = await ctx.sample({ prompt: `Summarize: ${text}`, maxTokens: 300 });
+ const summary = await llm.complete({
+ model: process.env.SUMMARY_MODEL,
+ prompt: `Summarize: ${text}`,
+ maxTokens: 300,
+ });
The tool keeps its behaviour, but the server now holds the provider key, sets the token limit and pays for the call.
Logging for a stdio server
A server that sent notifications/message for every request now writes structured lines to stderr. For a remote server it emits OpenTelemetry traces and logs. In this revision logging/setLevel is removed, and a request can carry a log level in _meta, so the old setter cannot be relied on for new code.
Key points
- Roots, Sampling and Logging are Deprecated in 2026-07-28: they still work, but new implementations should not adopt them.
- Replace roots with tool parameters, resource URIs or server configuration, and sampling with direct calls to a model provider.
- Replace protocol logging with stderr for stdio servers or OpenTelemetry.
- Deprecated features stay for a minimum twelve-month window under the lifecycle policy before they can be removed.
- Moving from sampling to your own provider call changes who pays and who handles errors.
- Keep an old path for older clients only while the window lasts, and gate it on declared client capabilities.
Common mistakes
- Assuming deprecated means removed and deleting the feature while older clients still use it.
- Replacing sampling with a provider call without a budget or error handling.
- Replacing roots with a path argument and not validating it against an allowed directory.
- Adding new sampling or roots support to a server because an old tutorial shows it.
Check yourself · 2 of 3
A server used roots/list to find the project folder. What does the changelog suggest instead?
Check yourself · 3 of 3
A team replaces sampling/createMessage with a direct call to a model provider. What changes for the server owner?
Practice items, not counted towards your mastery.
Start here
- MCP elicitation specification (2026-07-28) (opens in a new tab)StandardFree
The normative rules for form and URL mode, the flat schema subset and what clients must show the user.
- MCP multi round-trip requests (2026-07-28) (opens in a new tab)StandardFree
Defines InputRequiredResult, inputRequests, inputResponses and the integrity rules for requestState.
- MCP Tasks extension overview (opens in a new tab)DocsFree
Task lifecycle, tasks/get polling, tasks/update input and when a server should return a task.
More for this topic
- MCP deprecated features registry (2026-07-28) (opens in a new tab)StandardFree
The current list of Deprecated features and what to use instead.
- MCP feature lifecycle and deprecation policy (opens in a new tab)StandardFree
Defines Active, Deprecated and Removed states and the minimum deprecation window.
- MCP specification changelog, 2026-07-28 revision (opens in a new tab)DocsFree
Lists the breaking change to server requests, the Tasks move and the deprecation of Roots, Sampling and Logging.