60e0ffc959
Upgrade checks / Notify on failure (push) Has been cancelled
Upgrade checks / Close issue on success (push) Has been cancelled
Schema Crash Test / Real-world schema crash test (232K schemas) (push) Has been cancelled
Run static analysis / static_analysis (push) Has been cancelled
Tests / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Tests / Tests with lowest-direct dependencies (push) Has been cancelled
Tests / MCP conformance tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled
Tests / Package install smoke (push) Has been cancelled
Upgrade checks / Static analysis (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Upgrade checks / Integration tests (push) Has been cancelled
Update MCPServerConfig Schema / update-config-schema (push) Has been cancelled
Update SDK Documentation / update-sdk-docs (push) Has been cancelled
30 lines
1.1 KiB
Python
30 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, elicitation_handler=elicitation_handler) as client:
|
|
await client.call_tool("my_tool", {})
|