fastmcp.server.tasks.elicitation
Background task elicitation support (SEP-1686).
This module provides elicitation capabilities for background tasks running
in Docket workers. Unlike regular MCP requests, background tasks don’t have
an active request context, so elicitation requires special handling:
- Set task status to “input_required” via Redis
- Send notifications/tasks/status with elicitation metadata
- Wait for client to send input via tasks/sendInput
- Resume task execution with the provided input
Functions
elicit_for_task
task_id: The background task IDsession: The MCP ServerSession for this taskmessage: The message to display to the userschema: The JSON schema for the expected responsefastmcp: The FastMCP server instance
- ElicitResult containing the user’s response
RuntimeError: If Docket is not availableMcpError: If the elicitation request fails
relay_elicitation
session: MCP ServerSessionsession_id: Session identifiertask_id: Background task IDelicitation: Elicitation metadata (message, requestedSchema)fastmcp: FastMCP server instance
handle_task_input
task_id: The background task IDsession_id: The MCP session IDaction: The elicitation action (“accept”, “decline”, “cancel”)content: The response content (for “accept” action)fastmcp: The FastMCP server instance
- True if the input was successfully stored, False otherwise

