Handler Template
How It Works
When a server needs user input, it sends an elicitation request with a message prompt and a JSON schema describing the expected response structure. FastMCP automatically converts this schema into a Python dataclass type, making it easy to construct properly typed responses without manually parsing JSON schemas. The handler receives four parameters:Handler Parameters
str
The prompt message to display to the user
type | None
A Python dataclass type that FastMCP created from the server’s JSON schema. Use this to construct your response with proper typing. If the server requests an empty object, this will be
None.ElicitRequestParams
The original MCP elicitation parameters, including the raw JSON schema in
params.requestedSchemaRequestContext
Request context containing metadata about the elicitation request
Response Actions
You can return data directly, which implicitly accepts the elicitation:ElicitResult for explicit control over the action:
accept: User provided valid input. Include the data in thecontentfield.decline: User chose not to provide the requested information. Omitcontent.cancel: User cancelled the entire operation. Omitcontent.

