MCP elicitation
Some MCP servers need to ask the person a question in the middle of a tool call, for example "this will delete 12 files, continue?", a missing parameter, or a browser step at a URL. MCP calls this elicitation. The gateway sits between the server and the client, so it passes the question down to the client and the answer back up, inside the same tool call. Nothing has to be configured on the gateway for this to work.
A real-world scenario
A developer uses a desktop assistant connected to the gateway and asks it to deploy a service through an MCP server. The server wants an explicit confirmation before it deploys to production, so it sends a form elicitation. The assistant shows the developer a dialog with the question, the developer confirms, the answer travels back through the gateway to the server and the deployment goes ahead. If the same request came from a client that cannot show dialogs, the server would receive a clear error instead of waiting forever, and could fall back to refusing the deployment.
Steps
-
In the Admin UI open MCP Servers under AI Gateway, click the server, and open its MCP Tools tab. Find a tool that asks for confirmation, for example a deploy or delete tool, and note its name.
-
Start a session on
/mcpthat declares form elicitation ininitialize. The response headers carry the session id inmcp-session-id.curl -si http://localhost:4000/mcp \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Accept: application/json, text/event-stream" \-H "Content-Type: application/json" \-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{"elicitation":{}},"clientInfo":{"name":"curl","version":"1.0"}}}'export MCP_SESSION_ID="<mcp-session-id from the response headers>" -
Call the tool in the same session. Keep this request open, because the question arrives on its event stream.
curl -sN http://localhost:4000/mcp \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Mcp-Session-Id: $MCP_SESSION_ID" \-H "Accept: application/json, text/event-stream" \-H "Content-Type: application/json" \-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"deploy-service","arguments":{"environment":"production"}}}'The stream shows an
elicitation/createrequest from the server with its ownid, itsmessageand the form fields it wants. -
From a second terminal, send the answer with that
idin the same session.curl -s http://localhost:4000/mcp \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Mcp-Session-Id: $MCP_SESSION_ID" \-H "Accept: application/json, text/event-stream" \-H "Content-Type: application/json" \-d '{"jsonrpc":"2.0","id":"<id of the elicitation/create request>","result":{"action":"accept","content":{"confirm":true}}}' -
Open Logs in the Admin UI. The whole round trip shows as one tool call.
Expected result: the open stream from step 3 ends with the tool result once the answer from step 4 reaches the server. If you leave out "elicitation":{} in step 2, the tool call ends instead with the Downstream client has not advertised elicitation support error described under Errors.
In practice a client that supports elicitation, such as a recent desktop assistant or an MCP inspector, does steps 2 to 4 for you and shows the question as a dialog.
How the relay works
- The client connects to
/mcpand declares in itsinitializerequest which elicitation kinds it supports, forms, URLs, both or neither. - The model or the user calls a tool, and the upstream server answers with an elicitation request instead of a result.
- The gateway checks the capabilities the client declared. A form elicitation is forwarded as a form if the client declared form support, and a URL elicitation as a URL if the client declared URL support. The relay is bound to the request that triggered it, so the answer reaches the right call even when several are in flight on one session.
- The client shows the question, the user answers, and the gateway returns the answer to the server, which completes the tool call.
Expected result: the tool call completes with the server's result once the user has answered. A client that does not advertise elicitation makes the server receive an invalid request error that names the missing capability, so the server can fall back rather than hang.
To see it work, connect a client that supports elicitation, such as a recent desktop assistant or an MCP inspector, open MCP Servers in the Admin UI and the MCP Tools tab of a server whose tools ask for confirmation, and call such a tool from the client. The whole round trip appears as one tool call on the Logs page. The playground on the MCP Tools tab, the REST bridge and chat completion callers have no MCP client to ask, so a tool that needs an answer fails there with "MCP elicitation requires a connected downstream MCP client".
The whole round trip is bounded by the MCP client timeout, 60 seconds by default and configurable with the SPANWAY_MCP_CLIENT_TIMEOUT environment variable.
export SPANWAY_MCP_CLIENT_TIMEOUT=180
Errors
| Error | Meaning | Fix |
|---|---|---|
Downstream client has not advertised elicitation support | The client did not declare elicitation at initialize, so the gateway refused the server's request. | Use a client that supports elicitation, or a tool that does not ask questions. |
Downstream client does not support form elicitation or ... URL elicitation | The client declared only the other kind. | Same as above. The server receives this as an invalid request error and can fall back. |
MCP elicitation timed out waiting for the downstream client | The user did not answer within SPANWAY_MCP_CLIENT_TIMEOUT. | Answer sooner, or raise the timeout for tools that need a browser step. |
MCP elicitation requires a connected downstream MCP client | The call came from the playground, the REST bridge or a chat completion request, which have no MCP client to ask. | Call the tool from an MCP client that supports elicitation. |
Unsupported MCP elicitation parameters | The server asked for a kind of question the gateway does not relay. | Update the server, or use a tool that does not ask. |
MCP elicitation failed while communicating with the downstream client | The client dropped or answered with an error while the question was being relayed. | Reconnect the client and try again. The gateway log has a WARNING line. |
MCP elicitation is not available | The MCP library in this gateway build has no elicitation support. | Run the current Spanway image, which includes it. |
Logs
| Level | Line | What it means | Action |
|---|---|---|---|
| WARNING | MCP elicitation: downstream relay failed | Relaying a server's question to the client failed, and the server got "MCP elicitation failed while communicating with the downstream client". | None if it is rare. If it repeats for one client, update the client. |
Related
- MCP gateway for connecting clients.
- MCP access control for sessions and how they are listed.
- Human approval for approvals handled by the gateway itself rather than by the client.