User Elicitation
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.
Most of the examples in this document assume you have a FastMCP server instance named mcp
and show how to use the ctx.elicit
method to request user input from an @mcp.tool
-decorated function.
What is Elicitation?
Elicitation enables tools to pause execution and request specific information from users. This is particularly useful for:
- Missing parameters: Ask for required information not provided initially
- Clarification requests: Get user confirmation or choices for ambiguous scenarios
- Progressive disclosure: Collect complex information step-by-step
- Dynamic workflows: Adapt tool behavior based on user responses
For example, a file management tool might ask “Which directory should I create?” or a data analysis tool might request “What date range should I analyze?”
Basic Usage
Use the ctx.elicit()
method within any tool function to request user input:
Method Signature
Context Elicitation Method
Elicitation Actions
The elicitation result contains an action
field indicating how the user responded:
accept
: User provided valid input - data is available in thedata
fielddecline
: User chose not to provide the requested information and the data field isNone
cancel
: User cancelled the entire operation and the data field isNone
FastMCP also provides typed result classes for pattern matching on the action
field:
Response Types
The server must send a schema to the client indicating the type of data it expects in response to the elicitation request. If the request is 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
), by automatically wrapping them in MCP-compatible object schemas.
Scalar Types
You can request simple scalar data types for basic input, such as a string, integer, or boolean.
When you request a scalar type, FastMCP automatically wraps it in an object schema for MCP spec compatibility. Clients will see a corresponding schema requesting a single “value” field of the requested type. Once clients respond, the provided object is “unwrapped” and the scalar value is returned to your tool function as the 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.
Constrained Options
Often you’ll want to constrain the user’s response to a specific set of values. You can do this by using a 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.
Structured Responses
You can request structured data with multiple fields by using a dataclass, typed dict, or Pydantic model as the response type. Note that the MCP spec only supports shallow objects with scalar (string, number, boolean) or enum properties.
Multi-Turn Elicitation
Tools can make multiple elicitation calls to gather information progressively:
Client Requirements
Elicitation requires the client to implement an elicitation handler. See Client Elicitation for details on how clients can handle these requests.
If a client doesn’t support elicitation, calls to ctx.elicit()
will raise an error indicating that elicitation is not supported.