Request structured input from users during tool execution through the MCP context.
New in version: 2.10.0
User elicitation allows MCP servers to request structured input from users during tool execution. Instead of requiring all inputs upfront, tools can interactively ask for missing parameters, clarification, or additional context as needed.
mcp
and show how to use the ctx.elicit
method to request user input from an @mcp.tool
-decorated function.ctx.elicit()
method within any tool function to request user input:
action
field indicating how the user responded:
accept
: User provided valid input - data is available in the data
fielddecline
: User chose not to provide the requested information and the data field is None
cancel
: User cancelled the entire operation and the data field is None
action
field:
accept
-ed, the client must send a response that matches the schema.
The MCP spec only supports a limited subset of JSON Schema types for elicitation responses. Specifically, it only supports JSON objects with primitive properties including string
, number
(or integer
), boolean
and enum
fields.
FastMCP makes it easy to request a broader range of types, including scalars (e.g. str
) or no response at all, by automatically wrapping them in MCP-compatible object schemas.
data
field of the ElicitationResult
object.
As a developer, this means you do not have to worry about creating or accessing a structured object when you only need a scalar value.
None
as the response type to indicate that no response is expected. In order to comply with the MCP spec, the client will see a schema requesting an empty object in response. In this case, the data
field of the ElicitationResult
object will be None
when the user accepts the elicitation.
Literal
type or a Python enum as the response type, or by passing a list of strings to the response_type
parameter as a convenient shortcut.
ctx.elicit()
will raise an error indicating that elicitation is not supported.