mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Silence ty deprecation diagnostics and drop stale sampling doc mentions
This commit is contained in:
parent
1a43a3b8e9
commit
90f2e190d0
6 changed files with 15 additions and 22 deletions
|
|
@ -16,7 +16,7 @@ def fastmcp_server():
|
|||
|
||||
@mcp.tool
|
||||
async def list_roots(context: Context) -> list[str]:
|
||||
result = await context.session.list_roots()
|
||||
result = await context.session.list_roots() # ty: ignore[deprecated]
|
||||
return [str(r.uri) for r in result.roots]
|
||||
|
||||
return mcp
|
||||
|
|
@ -58,11 +58,9 @@ class TestClientRoots:
|
|||
|
||||
async def roots_handler(ctx) -> list[Root]:
|
||||
calls.append(ctx)
|
||||
return [Root(uri="file://from/handler")] # ty: ignore[invalid-argument-type]
|
||||
return [Root(uri="file://from/handler")]
|
||||
|
||||
async with Client(
|
||||
fastmcp_server, mode="legacy", roots=roots_handler
|
||||
) as client:
|
||||
async with Client(fastmcp_server, mode="legacy", roots=roots_handler) as client:
|
||||
result = await client.call_tool("list_roots", {})
|
||||
|
||||
assert len(calls) == 1
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ async def _sample(
|
|||
answering a legacy server, so the stand-in server reaches the SDK session
|
||||
directly.
|
||||
"""
|
||||
result = await context.session.create_message(
|
||||
result = await context.session.create_message( # ty: ignore[deprecated]
|
||||
messages=messages,
|
||||
system_prompt=system_prompt,
|
||||
max_tokens=512,
|
||||
|
|
@ -72,7 +72,9 @@ def fastmcp_server():
|
|||
),
|
||||
SamplingMessage(
|
||||
role="assistant",
|
||||
content=TextContent(type="text", text="How can I assist you today?"),
|
||||
content=TextContent(
|
||||
type="text", text="How can I assist you today?"
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -66,13 +66,13 @@ async def _backend_list_roots(context: Context) -> list[Root]:
|
|||
FastMCP's server API. These helpers reach the SDK session directly to stand
|
||||
in for a legacy upstream, which is the only thing the proxy relay forwards.
|
||||
"""
|
||||
result = await context.session.list_roots()
|
||||
result = await context.session.list_roots() # ty: ignore[deprecated]
|
||||
return result.roots
|
||||
|
||||
|
||||
async def _backend_sample(context: Context) -> str:
|
||||
"""Issue a handshake-era `sampling/createMessage` from a backend server."""
|
||||
result = await context.session.create_message(
|
||||
result = await context.session.create_message( # ty: ignore[deprecated]
|
||||
messages=[
|
||||
SamplingMessage(
|
||||
role="user", content=TextContent(type="text", text="Hello, world!")
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ def test_removed_server_initiated_methods_are_absent(name):
|
|||
def test_server_sampling_handler_kwargs_are_rejected(kwarg):
|
||||
"""The server-side sampling handler existed only to answer `ctx.sample()`."""
|
||||
with pytest.raises(TypeError, match="SEP-2577"):
|
||||
FastMCP("gone", **{kwarg: None})
|
||||
FastMCP("gone", **{kwarg: None}) # ty: ignore[invalid-argument-type]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", MODERN_MODES)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue