> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Server asking back

> Explains server elicitation where a server pauses to request structured input from a client, showing the elicitation flow, examples, JSON Schema usage, UI rendering, and best practices.

This lesson demonstrates elicitation: when a server processing a client request asks for additional structured input (for example, a confirmation) before it can complete the operation. The flow is:

1. Client issues a request for a tool/endpoint.
2. Server responds with an `input_required` response describing the requested inputs.
3. Client gathers the requested input (UI dialog, automated responder, etc.).
4. Client resends the original request with the supplied input.
5. Server finishes processing and returns a `complete` result.

The example below uses a simple "hold shipment" tool inside a shipment-tracker server. First, the client issues a tool call (example request URL shown):

```text theme={null}
127.0.0.1:6274/?MCP_INSPECTOR_API_TOKEN=560f07ddd6e87c1de7695d42701eaad5c67a8b36defe50f46ae89d33919fbd1d
```

The server does not immediately place the hold — it asks for confirmation. The client presents that request to the user as a modal dialog:

![A web app screenshot showing a modal titled "Elicitation Request" asking "Place a hold on PL-4417?" with a confirm checkbox, a yellow warning box about trusting the server, and Cancel / Decline / Submit buttons. The underlying page appears to be a "shipment-tracker" tool interface.](https://mintcdn.com/kodekloud-c4ac6d9a/0UyWJzvxepsOrybu/images/Model-Context-Protocol-Associate-MCPA-Certification/Trust-Boundaries-and-Attacks/Demo-Server-asking-back/elicitation-request-hold-pl-4417-shipment-tracker.jpg?fit=max\&auto=format\&n=0UyWJzvxepsOrybu\&q=85\&s=eb010a1730c31c3ad2f39d2207617cd4)

That modal is the client-side rendering of the server's "input required" response. Instead of returning a final result, the server returns a structured request that describes exactly what input it needs (in this case, a boolean confirmation). The client UI renders the form/modal, collects the user's input, and resubmits the original call including the user's answer.

Example of the server's initial (trimmed) response that requests input:

```json theme={null}
{
  "inputRequests": {
    "confirm": {
      "method": "elicitation/create",
      "params": {
        "message": "Place a hold on PL-4417?",
        "mode": "form",
        "requestedSchema": {
          "type": "object",
          "properties": {
            "confirm": { "type": "boolean" }
          },
          "required": ["confirm"]
        }
      }
    }
  },
  "resultType": "input_required"
}
```

Notes about the response:

* The `resultType` is `input_required` — the server is intentionally pausing the operation until input is supplied.
* The `inputRequests` map identifies named input requests (here, `confirm`) and includes a `requestedSchema` (JSON Schema) describing the expected payload.
* SDKs may use `snake_case` field names (e.g., `input_requests`) that serialize to the wire-format camelCase shown above (`inputRequests`).

Once the client shows the dialog and the user confirms, the client resends the same tool call with the user's response attached. The server then completes the operation and returns a final `complete` result. Example final response after confirmation:

```json theme={null}
{
  "_meta": {
    "io.modelcontextprotocol/serverInfo": {
      "name": "shipment-tracker",
      "version": "5.1.0"
    }
  },
  "content": [
    {
      "text": "Hold placed on PL-4417.",
      "type": "text"
    }
  ],
  "isError": false,
  "resultType": "complete",
  "structuredContent": {
    "result": "Hold placed on PL-4417."
  }
}
```

This is a multi-round extension of the same logical request:
client -> server (`input_required`) -> client (gathers input) -> server (`complete`).

Quick reference table

| Server state (`resultType`) | What server returns | Client action |
| - | - | - |
| `input_required` | `inputRequests` describing the required inputs (JSON Schema, message, mode) | Render UI or automated responder, collect input, reissue the original call with `input_responses`/`inputResponses` |
| `complete` | Final `content` / `structuredContent` with `isError: false` (or error result) | Present final result to user or process programmatically |

Elicitation lets a server pause processing and ask for additional structured input mid-request. Clients should render the `inputRequests` (UI form/dialog or automated handler), collect the requested input, and resend the same logical call with the inputs attached. The server can then finish processing and return a `complete` result.

Server-side example (compact Python)

Below is a minimal server-side example that implements the elicitation behavior. The tool `hold_shipment` returns an `InputRequiredResult` on the first call (asking for confirmation) and the final string result once the confirmation arrives.

```python theme={null}
import sys
# The following imports are illustrative. Replace with your actual MCP server types.
from mcp import MCPServer, Context, InputRequiredResult

server = MCPServer()

@server.tool(description="Place a hold on a shipment. Asks the user to confirm first.")
async def hold_shipment(ref: str, ctx: Context) -> str | InputRequiredResult:
    # Call 1: no answer yet, so return an input-required response (elicitation).
    if ctx.input_responses is None:
        return InputRequiredResult(
            input_requests={
                "confirm": {
                    "method": "elicitation/create",
                    "params": {
                        "message": f"Place a hold on {ref}?",
                        "mode": "form",
                        "requestedSchema": {
                            "type": "object",
                            "properties": {"confirm": {"type": "boolean"}},
                            "required": ["confirm"],
                        },
                    },
                },
            }
        )

    # Call 2: the client resent the same call with the answer attached.
    answer = ctx.input_responses["confirm"]
    if answer.action != "accept" or not answer.content.get("confirm"):
        return f"No hold placed on {ref}. The operator declined."
    return f"Hold placed on {ref}."

if __name__ == "__main__":
    print("shipment-tracker ready on stdio", file=sys.stderr)
    server.serve_io()
```

Key implementation details

* On the first invocation, `ctx.input_responses` is `None`. The tool responds with an `InputRequiredResult` describing the requested input and JSON Schema for validation.
* The client displays the corresponding UI (form/modal) to the human operator or runs an automated responder, then resubmits the original tool call with the answer attached under `input_responses` (wire name: `inputResponses`).
* The server inspects the submitted answer and returns a final `complete` result (or an alternate message/error) based on the input.

Best practices and considerations

* Use structured schemas (JSON Schema) in `requestedSchema` to make client rendering and validation deterministic.
* Include a human-friendly `message` to explain why the input is needed.
* Keep `method` and `params` consistent so clients can handle generic elicitation flows.
* Ensure the client re-sends the original logical request (same tool/parameters) with the `input_responses` included, rather than starting a separate unrelated request.

Further reading

* JSON Schema: [https://json-schema.org/](https://json-schema.org/)
* Model Context Protocol (MCP) patterns and toolkit (search vendor or repo-specific docs for your MCP implementation)

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/model-context-protocol-associate-mcpa-certification/module/31dedbc5-6173-4700-b50e-7a581095c897/lesson/d73cd60d-73b6-4c3d-8624-272a1f1ed06a)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.