mcp-elicitation-demo
Integrates with an OpenAI-compatible LLM endpoint, configured via .env or per-session settings, to power LLM-backed tools such as entity extraction.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-elicitation-demo
A minimal demo of MCP Elicitation built with uv + FastAPI + FastMCP + python-dotenv, plus several ordinary MCP tools — and a built-in web chat UI to try everything from the browser.
Server: FastAPI app with a FastMCP streamable HTTP MCP endpoint at
/mcpClients: MCP Python SDK demo client (auto / interactive) + browser chat UI
LLM: any OpenAI-compatible endpoint via
.env(default:zai-org/GLM-5.3-Flash)
Tools
Tool | Kind | Notes |
| plain | No user interaction |
| elicitation | Asks only for the MISSING booking fields (name / party size / date / time / seating enum / extras multi-select); details already present in the user's message are passed as arguments and never re-asked |
| elicitation | Yes/No confirmation |
| elicitation | Asks age / income / debt ratio, returns a toy verdict |
| plain + LLM | Calls the configured LLM to extract entities |
Related MCP server: dat-ai-mcp
Quick start
# 1. Copy env template and fill in your key
cp .env.example .env
# 2. Install dependencies (creates .venv automatically)
uv sync
# 3. Start the server
uv run uvicorn src.mcp_elicitation_demo.server:app --port 8000
# 4a. Open the chat UI
# http://127.0.0.1:8000/
# 4b. Or run the terminal demo client
uv run python -m mcp_elicitation_demo.demo_client --auto # auto-accept elicitations
uv run python -m mcp_elicitation_demo.demo_client --auto-decline # auto-DECLINE elicitations
uv run python -m mcp_elicitation_demo.demo_client # interactive prompts
uv run python -m mcp_elicitation_demo.demo_client --ping-llm # check LLM endpointThe MCP endpoint is http://127.0.0.1:8000/mcp (streamable HTTP); health check at /healthz.
How elicitation works
The client registers an
elicitation_callbackwhen creating the MCPClient.A server tool calls
ctx.elicit(message=..., response_type=SomeModel)mid-execution.The SDK sends an
elicitation/createrequest to the client; the callback builds anElicitResultwithaction=accept/decline/canceland optionalcontent.The tool inspects the result — an
AcceptedElicitation(with.data), a decline or a cancel — and continues accordingly.
Protocol note (important)
This demo pins the MCP client to mode="legacy" (classic initialize handshake,
handshake-era protocol version). The newest MCP protocol (2026-07-28) removed the
server-initiated elicitation back-channel in favor of a client-driven
"input required" retry loop (SEP-2322); fastmcp 4.x raises
elicitation via server-initiated requests is unavailable on 2026-07-28 connections
when ctx.elicit() is called on such a connection. The legacy handshake keeps the
classic ctx.elicit() flow that most tutorials describe.
Two fastmcp 4.x API details worth knowing:
ctx.elicit()takesresponse_type=(notschema=) and returns typed results:AcceptedElicitation/DeclinedElicitation/CancelledElicitation.Scalar
response_types (e.g.bool) are wrapped as{"value": ...}on the wire; the client must answer{"value": true}rather than a bare boolean.
Web chat UI
The landing page is a mobile-first, single-file chat app:
Thinking block — the model's reasoning stream (e.g. GLM
reasoning_content) flows into a collapsible "thinking" card that auto-collapses when done.Tool cards — one card per call with separate Input / Output tabs, a spinner while running and a green dot when finished.
Elicitation modal — the form is generated from the requested schema: text / number inputs, native date/time pickers (
format), radio groups for enums and checkbox groups for multi-select arrays (titles via SEP-1330oneOf [{const,title}]), a checkbox for boolean confirms, with submit / decline / cancel actions. JSON-Schema constraints map to native HTML validation (required,pattern,min/max,minLength/maxLength,step); invalid input blocks submit.Smart forms — the system prompt carries today's date and instructs the model to pass already-known details as tool arguments, so
book_tableelicits ONLY the missing fields ("book a table in Kunming for 4" never asks for party size again; with full info no modal appears at all).Settings drawer (top-right ⚙️) — override base URL / API key / model per browser session (stored in
localStorage); empty fields fall back to the server.envdefaults.GET /api/configexposes the non-secret defaults.Extras: streamed tokens with a typing cursor, Enter to send / Shift+Enter for newline, auto-growing composer, safe-area insets, and session reset.
Configuration (.env)
Key | Example |
|
|
|
|
|
|
Architecture
Browser chat UI ─► POST /api/chat (SSE) ─► ChatSession (GLM function-calling loop)
│ └── built-in MCP Client ──► /mcp (self)
│ ├── plain tools run directly
│ └── elicitation tools → ctx.elicit()
│ → SSE event → browser modal form
│ → POST /api/elicitation/respond
Terminal demo client ─► POST/GET/DELETE /mcp (JSON-RPC + SSE)
FastAPI also serves / (chat UI) and /healthzChat bridge (chat.py) implementation notes:
True streaming — the LLM runs with
stream=True; reasoning and answer deltas are forwarded asreasoning_delta/assistant_delta; streamed tool calls are assembled byindex. Blocking LLM calls run inasyncio.to_threadso elicitation events keep flowing.LLM overrides —
POST /api/chatacceptsllm_override: {base_url, api_key, model}to override.envper session.Elicitation bridge — an SSE
elicitationevent opens the browser modal; the answer POSTs to/api/elicitation/respondand resolves anasyncio.Futureback into the tool.SSE pitfall — the end-of-stream sentinel must go through the same
loop.call_soon_threadsafe(queue.put_nowait, ...)channel as events; a directqueue.put_nowaitovertakes already-scheduled events and truncates the stream.
FastMCP 4.x integration notes baked into server.py:
mcp.http_app(transport="streamable-http")replaces the oldstreamable_http_app(); itslifespanmust be passed to FastAPI (FastAPI(lifespan=mcp_app.lifespan)) or every request fails with "Task group is not initialized".http_app()already serves the JSON-RPC route at/mcp, so the FastAPI mount target is"/"and route registration must come before the mount.
Notes
Keep
max_tokensgenerous (>= 1024) for reasoning-style models such aszai-org/GLM-5.3-Flash; otherwise replies can be cut off mid-reasoning.The server never logs or stores the API key; it stays in
.env(or in the browser'slocalStoragewhen overridden).
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Build your own tools from chat: design, test and host them on a shareable MCP server URL.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that runs in the browser, letting web pages register custom tools and prompts and expose them to an MCP client over WebSocket. Enables agents to drive UI, call page-scoped APIs, and get human-in-the-loop confirmation.7 npmMIT
- AlicenseAqualityDmaintenanceProvides browser automation, audio transcription, and LLM chat as MCP tools for any agent.7MIT
- FlicenseNot gradedqualityCmaintenanceMCP server that wraps agent-browser to let LLMs control a real browser, providing tools for navigation, interaction, reading page content, accessibility snapshots, screenshots, and session management.1-
- FlicenseNot gradedqualityDmaintenanceEnables browser-based AI chat interfaces to use local MCP tools by injecting a tool-call protocol into the page and executing approved filesystem, shell, and downstream MCP tool calls from a local daemon.-