Skip to content

Commit b304131

Browse files
committed
Use capability-level deprecation messages for roots and sampling
The logging deprecations name the feature ("The logging capability is deprecated as of ..."); roots and sampling still named the individual method. Switch `list_roots`, `send_roots_list_changed`, `sample`, and `create_message` to the same capability-level wording so every SEP-2577 warning is consistent.
1 parent 24cb7b0 commit b304131

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/mcp/client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ async def list_tools(self, *, cursor: str | None = None, meta: RequestParamsMeta
316316
"""List available tools from the server."""
317317
return await self.session.list_tools(params=PaginatedRequestParams(cursor=cursor, _meta=meta))
318318

319-
@deprecated("`send_roots_list_changed` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
319+
@deprecated("The roots capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
320320
async def send_roots_list_changed(self) -> None:
321321
"""Send a notification that the roots list has changed."""
322322
# TODO(Marcelo): Currently, there is no way for the server to handle this. We should add support.

src/mcp/client/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ async def list_tools(self, *, params: types.PaginatedRequestParams | None = None
551551

552552
return result
553553

554-
@deprecated("`send_roots_list_changed` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
554+
@deprecated("The roots capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
555555
async def send_roots_list_changed(self) -> None:
556556
"""Send a roots/list_changed notification."""
557557
await self.send_notification(types.RootsListChangedNotification())

src/mcp/server/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async def send_resource_updated(self, uri: str | AnyUrl) -> None:
156156
)
157157

158158
@overload
159-
@deprecated("`create_message` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
159+
@deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
160160
async def create_message(
161161
self,
162162
messages: list[types.SamplingMessage],
@@ -176,7 +176,7 @@ async def create_message(
176176
...
177177

178178
@overload
179-
@deprecated("`create_message` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
179+
@deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
180180
async def create_message(
181181
self,
182182
messages: list[types.SamplingMessage],
@@ -195,7 +195,7 @@ async def create_message(
195195
"""Overload: With tools, returns array-capable content."""
196196
...
197197

198-
@deprecated("`create_message` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
198+
@deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
199199
async def create_message(
200200
self,
201201
messages: list[types.SamplingMessage],
@@ -272,7 +272,7 @@ async def create_message(
272272
metadata=metadata_obj,
273273
)
274274

275-
@deprecated("`list_roots` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
275+
@deprecated("The roots capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
276276
async def list_roots(self) -> types.ListRootsResult:
277277
"""Send a roots/list request."""
278278
if self._stateless:

src/mcp/shared/peer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def notify(self, method: str, params: Mapping[str, Any] | None) -> None:
8585
await self._outbound.notify(method, params)
8686

8787
@overload
88-
@deprecated("`sample` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
88+
@deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
8989
async def sample(
9090
self,
9191
messages: list[SamplingMessage],
@@ -103,7 +103,7 @@ async def sample(
103103
opts: CallOptions | None = None,
104104
) -> CreateMessageResult: ...
105105
@overload
106-
@deprecated("`sample` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
106+
@deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
107107
async def sample(
108108
self,
109109
messages: list[SamplingMessage],
@@ -120,7 +120,7 @@ async def sample(
120120
meta: Meta | None = None,
121121
opts: CallOptions | None = None,
122122
) -> CreateMessageResultWithTools: ...
123-
@deprecated("`sample` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
123+
@deprecated("The sampling capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
124124
async def sample(
125125
self,
126126
messages: list[SamplingMessage],
@@ -200,7 +200,7 @@ async def elicit_url(
200200
result = await self.send_raw_request("elicitation/create", dump_params(params, meta), opts)
201201
return ElicitResult.model_validate(result, by_name=False)
202202

203-
@deprecated("`list_roots` is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
203+
@deprecated("The roots capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
204204
async def list_roots(self, *, meta: Meta | None = None, opts: CallOptions | None = None) -> ListRootsResult:
205205
"""Send a `roots/list` request.
206206

tests/shared/test_peer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async def test_peer_list_roots_is_deprecated_sep_2577():
152152
peer = ClientPeer(client)
153153
with anyio.fail_after(5):
154154
with pytest.warns(
155-
MCPDeprecationWarning, match=r"`list_roots` is deprecated as of 2026-07-28 \(SEP-2577\)\."
155+
MCPDeprecationWarning, match=r"The roots capability is deprecated as of 2026-07-28 \(SEP-2577\)\."
156156
):
157157
await peer.list_roots() # pyright: ignore[reportDeprecated]
158158
assert rec.seen[0][0] == "roots/list"

0 commit comments

Comments
 (0)