mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 15:19:10 +02:00
Client negotiates the newest mutual protocol era by default (probe server/discover, fall back to the initialize handshake). ProxyClient and the inspect utility explicitly pin the handshake era so proxy forwarding and server_info reads are unchanged. SSE and multi-server config transports are legacy-only. extensions= and result_claims= (SEP-2133) are thin passthroughs to the SDK session.
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""Tests for deprecated elicitation behavior."""
|
|
|
|
from typing import Any, cast
|
|
|
|
import pytest
|
|
|
|
from fastmcp import Context, FastMCP
|
|
from fastmcp.client.client import Client
|
|
from fastmcp.client.elicitation import ElicitResult
|
|
from fastmcp.exceptions import FastMCPDeprecationWarning
|
|
from fastmcp.server.elicitation import AcceptedElicitation
|
|
|
|
|
|
async def test_elicitation_none_response_type_warns_deprecation():
|
|
"""Passing response_type=None is deprecated — warn at call time."""
|
|
mcp = FastMCP("TestServer")
|
|
|
|
@mcp.tool
|
|
async def my_tool(context: Context) -> dict[str, Any]:
|
|
with pytest.warns(FastMCPDeprecationWarning, match="response_type"):
|
|
result = await context.elicit(message="", response_type=None)
|
|
assert isinstance(result, AcceptedElicitation)
|
|
return cast(dict[str, Any], result.data)
|
|
|
|
async def elicitation_handler(message, response_type, params, ctx):
|
|
return ElicitResult(action="accept", content={})
|
|
|
|
async with Client(
|
|
mcp, mode="legacy", elicitation_handler=elicitation_handler
|
|
) as client:
|
|
await client.call_tool("my_tool", {})
|