intellicrack.ui.mcp_elicitation_dialog

Dialog answering an MCP server’s request for information from the operator.

A server may pause mid-call and ask for something it needs: a directory to work in, a confirmation, a choice between options. The protocol calls this elicitation, and it arrives in one of two shapes. A form request carries a small JSON Schema describing the fields it wants; a URL request asks the operator to go somewhere and come back.

Three answers exist and they are not interchangeable. Accepting returns the values. Declining says no to the request while leaving the call running. Cancelling abandons the exchange. Closing the window is a cancel, never an accept, so a dismissed dialog can never be read as consent.

A server must never ask for a credential this way. The dialog says so, every time, because the operator is the only one who can tell whether a field labelled “API key” is a legitimate request.

ElicitValue = str | int | float | bool | list[str] | None

What one answered field may carry, matching the protocol’s content type.

class McpElicitationDialog[source]

Bases: QDialog

Collects one server’s requested values, or refuses on the operator’s behalf.

The form follows the schema the server sent: each field gets the editor its type calls for, an optional field left alone is omitted rather than sent with an invented value, and every bound the schema states – length, range, pattern, format, item count – is checked before anything is sent. A field that fails says why beside itself.

Emits answered(action: str) with accept, decline or cancel once the operator has decided.

__init__(server_id, params, parent=None)[source]

Initialize the elicitation dialog.

Parameters:
  • server_id (str) – The server asking.

  • params (ElicitRequestParams) – The form or URL request the server sent.

  • parent (QWidget | None) – Parent widget.

Return type:

None

property action: str

The operator’s answer.

Returns:

accept, decline, or cancel. A dialog that was closed without an answer reports cancel.

Return type:

str

property content: dict[str, str | int | float | bool | list[str] | None]

The values the operator supplied.

Returns:

The answered fields, empty unless the operator accepted a form.

Return type:

dict[str, ElicitValue]

property is_url_request: bool

Whether the server asked the operator to visit an address.

Returns:

True for a URL-mode request.

Return type:

bool

to_result()[source]

Render the operator’s answer as a protocol result.

Returns:

The result to return to the server. Content is attached only when a form was accepted; a URL-mode acceptance carries none, because the interaction happens out of band.

Return type:

ElicitResult

closeEvent(a0)[source]

Treat closing the window as a cancellation.

Parameters:

a0 (QCloseEvent | None) – The close event.

Return type:

None

build_declined_result()[source]

Build the answer used when no operator is available to ask.

Returns:

A declining result. Declining is the safe answer: it refuses the request without pretending the operator supplied anything.

Return type:

ElicitResult

async resolve_elicitation(future, timeout_s, *, on_abandon=None)[source]

Await the operator’s answer, declining if they never give one.

Parameters:
  • future (Future[ElicitResult]) – Future the GUI thread resolves once the dialog is answered.

  • timeout_s (float) – How long to wait before giving up.

  • on_abandon (Callable[[], None] | None) – Called when the wait is given up on, by timing out or by the caller being cancelled, so the question can be taken off the screen rather than left open for an answer nobody will read.

Returns:

The operator’s answer, or a decline on timeout.

Return type:

ElicitResult

Raises:

CancelledError – If the caller is cancelled while the operator is still deciding.