Deprecate roots, sampling, and logging methods per SEP-2577 (#2926)

This commit is contained in:
Marcelo Trylesinski 2026-06-20 17:25:41 +01:00 • committed by GitHub
commit 4573e4ac33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,7 +29,7 @@ async def test_list_roots_round_trip(connect: Connect) -> None:
async def call_tool(ctx: ServerRequestContext, params: types.CallToolRequestParams) -> CallToolResult:
assert params.name == "show_roots"
result = await ctx.session.list_roots()
result = await ctx.session.list_roots() # pyright: ignore[reportDeprecated]
lines = [f"{root.uri} name={root.name}" for root in result.roots]
return CallToolResult(content=[TextContent(text="\n".join(lines))])
@ -64,7 +64,7 @@ async def test_list_roots_empty(connect: Connect) -> None:
async def call_tool(ctx: ServerRequestContext, params: types.CallToolRequestParams) -> CallToolResult:
assert params.name == "count_roots"
result = await ctx.session.list_roots()
result = await ctx.session.list_roots() # pyright: ignore[reportDeprecated]
return CallToolResult(content=[TextContent(text=str(len(result.roots)))])
server = Server("rooted", on_list_tools=list_tools, on_call_tool=call_tool)
@ -94,7 +94,7 @@ async def test_list_roots_without_callback_is_error(connect: Connect) -> None:
async def call_tool(ctx: ServerRequestContext, params: types.CallToolRequestParams) -> CallToolResult:
assert params.name == "show_roots"
try:
await ctx.session.list_roots()
await ctx.session.list_roots() # pyright: ignore[reportDeprecated]
except MCPError as exc:
return CallToolResult(content=[TextContent(text=f"{exc.error.code}: {exc.error.message}")])
raise NotImplementedError # list_roots cannot succeed without a client callback
@ -122,7 +122,7 @@ async def test_list_roots_callback_error_surfaces_to_the_handler(connect: Connec
async def call_tool(ctx: ServerRequestContext, params: types.CallToolRequestParams) -> CallToolResult:
assert params.name == "show_roots"
try:
await ctx.session.list_roots()
await ctx.session.list_roots() # pyright: ignore[reportDeprecated]
except MCPError as exc:
return CallToolResult(content=[TextContent(text=f"{exc.error.code}: {exc.error.message}")])
raise NotImplementedError # the callback always answers with an error
@ -159,7 +159,7 @@ async def test_roots_list_changed_reaches_server_handler(connect: Connect) -> No
raise NotImplementedError
async with connect(server, list_roots_callback=list_roots) as client:
await client.send_roots_list_changed()
await client.send_roots_list_changed() # pyright: ignore[reportDeprecated]
with anyio.fail_after(5):
await delivered.wait()