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

# When the Server Needs Something Back

> Explains MCP patterns for server-elicited human input, response encoding, pagination, subscriptions, error handling, and streaming behavior changes.

Alan's server is partway through fulfilling a delayed shipment when it needs human input: Which customer reference should this record use? The MCP (Model Context Protocol) core rule remains: servers do not initiate requests — clients ask and servers respond. Earlier drafts allowed server-initiated requests, but that capability has been removed. MCP provides a clear pattern for a server to "ask" for input while still following the request/response model.

Summary: the server encodes its question inside a successful response, the client prompts the user, and then the client resubmits the original request with the user-provided answers attached.

## MCP exchange types

Every MCP exchange fits one of three patterns:

| Exchange Type | Behavior | Identifier |
| - | - | - |
| Request / response | One request from client → one response from server | Client selects an `id` for the request |
| Notification | One direction only: client → server, no response | No `id` present |
| Streaming | One request → many messages back; ends with final result | Client-supplied `id` for the stream |

## Server-elicited input: how it works

Previously, servers could send requests to clients to elicit input; that feature is removed. Instead, when a server needs input it returns a normal response, but sets `resultType` to `input_required` and includes an `inputRequests` array describing what it needs.

Example server response encoding a question:

```json theme={null}
{
  "resultType": "input_required",
  "inputRequests": [
    {
      "method": "elicitation/create",
      "message": "Customer ref?"
    }
  ]
}
```

The client reads `inputRequests`, prompts the user (Alan), and then reissues the original call as a new client request. Importantly, the client does not send a separate reply message back to the server; instead it resubmits the same operation as a fresh request and includes the user's answers in an `inputResponses` array.

Warning: when resubmitting, the client must use a new request `id`. This separation preserves audit trails and authorization checks.

Always resubmit server-elicited inputs as a new client request using a new `id`, and include user answers in `inputResponses`. Do not attempt to send a separate synchronous reply message to the original server response.

Example client resubmission with `inputResponses`:

```json theme={null}
{
  "id": 7,
  "method": "tools/call",
  "params": {
    "tool": "shipment/fulfill",
    "args": { "shipment_id": 42 },
    "inputResponses": ["CR-2291"]
  }
}
```

Note: only these requests may appear inside an `inputRequests` list:

* `elicitation/create` — for human questions (primary path),
* `sampling/createMessage` — sampling-related (removed in current protocol),
* `roots/list` — root listing (removed in current protocol).

If you need to implement input elicitation today, `elicitation/create` is the supported mechanism.

## Pagination for long results

When any `inputRequests` call (or other server responses) returns many items, responses are paginated. The server returns an `items` array and may include a `nextCursor` string. Clients must treat `nextCursor` as an opaque token — do not parse, decode, or modify it. When requesting the next page, return the token exactly as received.

Example:

```json theme={null}
{
  "items": [ /* ... */ ],
  "nextCursor": "eyJwIjoyfQ"
}
```

If `nextCursor` is omitted (or an empty response), you have reached the last page.

Treat `nextCursor` as an opaque token: never parse or alter it. Use the exact value when requesting the next page.

## Subscriptions and change notifications

A previously separate HTTP GET subscription channel (`resources/subscribe`) has been replaced by a single long-lived method: `subscriptions/listen`. This is a long-lived POST that behaves like a stream and covers:

* tool-change notifications,
* prompt/elicitation changes,
* resource change events,
* resource subscriptions.

To create a listen stream:

```http theme={null}
POST subscriptions/listen
```

The server acknowledges the listen stream and returns a `subscriptionId` for later cancellation.

![A diagram titled "Listening for Changes" showing a laptop Host with a chat window, a central Model chip icon, and an MCP Server rack with a file labeled v2 and a database. Dashed and curved lines indicate an HTTP GET request and an envelope notification, with a progress bar at 100%.](https://mintcdn.com/kodekloud-c4ac6d9a/0UyWJzvxepsOrybu/images/Model-Context-Protocol-Associate-MCPA-Certification/Messages-Tools-and-Sessions/When-the-Server-Needs-Something-Back/listening-changes-host-chat-model-mcp.jpg?fit=max\&auto=format\&n=0UyWJzvxepsOrybu\&q=85\&s=517a8e054358138c2238aaf51bac9c61)

## Error handling: protocol vs execution

MCP separates errors into two layers:

1. Protocol errors — issues with the message itself (bad JSON, invalid request, unknown method, wrong parameters). These are JSON-RPC errors and are returned as JSON-RPC error objects. The model does not receive these.

2. Execution errors — the request was valid but failed during execution (e.g., warehouse offline, tool invalid). These are returned as successful responses that include `"isError": true` and their content is visible to the model.

Common JSON-RPC protocol error codes:

| Code | Meaning |
| - | - |
| `-32700` | Parse error (bad JSON) |
| `-32600` | Invalid request |
| `-32601` | Method not found |
| `-32602` | Invalid params |
| `-32603` | Internal error |

Example of an execution error (visible to the model):

```json theme={null}
{
  "content": "Warehouse down",
  "isError": true
}
```

Invalid tools (calling a non-existent or unauthorized tool) are treated as execution errors, not protocol errors.

MCP also reserves codes in the `-32020` through `-32099` range for additional protocol-level conditions. Two codes worth remembering:

* `-32020` — header mismatch
* `-32022` — unsupported protocol version

Compatibility note: legacy servers sometimes returned "resource not found" as `-32002`. The new canonical code is `-32602` (same as "Invalid params"). Implementations should accept both the legacy and the new code to remain compatible.

![An infographic titled "Five JSON-RPC Error Codes" showing a host, model, and MCP server workflow with a highlighted missing parameter (shipment\_id?). It lists the five error codes and meanings: -32700 Parse error, -32600 Invalid request, -32601 Method not found, -32602 Invalid params, and -32603 Internal error.](https://mintcdn.com/kodekloud-c4ac6d9a/0UyWJzvxepsOrybu/images/Model-Context-Protocol-Associate-MCPA-Certification/Messages-Tools-and-Sessions/When-the-Server-Needs-Something-Back/jsonrpc-error-codes-missing-parameter.jpg?fit=max\&auto=format\&n=0UyWJzvxepsOrybu\&q=85\&s=1915d34c54de82eb1af1a7055af469b2)

## Streaming behavior changes

Streams are no longer resumable. Previously, a client could reconnect and resume a broken stream using `Last-Event-ID`; that mechanism has been removed. If a stream is interrupted now, the client must reissue the full request under a new request `id`.

![An infographic titled "Streams Don't Resume" showing a laptop host with a chat UI connected to a model chip and an MCP server with a database and progress bar. It also shows received event tiles (1–3) and a highlighted "Last-Event-ID: 3" badge.](https://mintcdn.com/kodekloud-c4ac6d9a/0UyWJzvxepsOrybu/images/Model-Context-Protocol-Associate-MCPA-Certification/Messages-Tools-and-Sessions/When-the-Server-Needs-Something-Back/streams-dont-resume-last-event-id3.jpg?fit=max\&auto=format\&n=0UyWJzvxepsOrybu\&q=85\&s=5a97b3e4347ce438069133d8060c6f6b)

## Quick reference tables

### Allowed `inputRequests` methods

| Method | Purpose | Current status |
| - | - | - |
| `elicitation/create` | Ask a human question and collect a response | Supported (primary) |
| `sampling/createMessage` | Sampling operations | Removed in current protocol |
| `roots/list` | List root items | Removed in current protocol |

### Error codes summary

| Range / Code | Use |
| - | - |
| `-32700` to `-32603` | Standard JSON-RPC protocol errors |
| `-32020` to `-32099` | MCP reserved protocol conditions |
| `-32020` | Header mismatch |
| `-32022` | Unsupported protocol version |
| `-32002` (legacy) | Resource not found (accept for compatibility) |
| `-32602` | Invalid params (current code for resource-not-found cases) |

## Links and references

* JSON-RPC specification: [https://www.jsonrpc.org/specification](https://www.jsonrpc.org/specification)
* MCP design notes and compatibility guidance (internal/implementation docs)

Treat `nextCursor` as an opaque token (do not parse or modify it), always resubmit server-elicited inputs as a new client request ID with `inputResponses`, and reissue streams from scratch if a connection drops.

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/model-context-protocol-associate-mcpa-certification/module/282d97e2-04f7-4beb-8301-695ecb3f3f99/lesson/627079bb-9b11-475a-8bbc-7d1a23c2b8c7)


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