Skip to main content

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​

  1. 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.

  2. Start a session on /mcp that declares form elicitation in initialize. The response headers carry the session id in mcp-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>"
  3. 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/create request from the server with its own id, its message and the form fields it wants.

  4. From a second terminal, send the answer with that id in 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}}}'
  5. 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​

  1. The client connects to /mcp and declares in its initialize request which elicitation kinds it supports, forms, URLs, both or neither.
  2. The model or the user calls a tool, and the upstream server answers with an elicitation request instead of a result.
  3. 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.
  4. 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​

ErrorMeaningFix
Downstream client has not advertised elicitation supportThe 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 elicitationThe 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 clientThe 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 clientThe 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 parametersThe 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 clientThe 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 availableThe MCP library in this gateway build has no elicitation support.Run the current Spanway image, which includes it.

Logs​

LevelLineWhat it meansAction
WARNINGMCP elicitation: downstream relay failedRelaying 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.