from fastmcp import Client
from fastmcp.client.elicitation import ElicitResult
async def basic_elicitation_handler(message: str,
response_type: type,
params, context):
print(f"Server asks: {message}")
# Simple text input for demonstration
user_response = input("Your response: ")
if not user_response:
# No response, use ElicitResult explicitly
return ElicitResult(action="decline")
# Use the response_type dataclass to
# create a properly structured response
# FastMCP handles the conversion from JSON schema to Python type
return response_type(value=user_response)
# assuming STDIO transport
client = Client(
"server-file.py",
elicitation_handler=basic_elicitation_handler
)
decline in case of no response
pass the handler
return the response