client-side.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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