Ask the user with elicitation
A server can pause mid-tool to request structured input from the user through the client via ctx.elicit.
from mcp.server.fastmcp import Context
from dataclasses import dataclass
@dataclass
class Confirm:
proceed: bool
@mcp.tool()
async def deploy(ctx: Context) -> str:
res = await ctx.elicit(message="Deploy to production?", schema=Confirm)
if res.action == "accept" and res.data.proceed:
return "Deploying..."
return "Cancelled."