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

# Elicitation

> Handle interactive user input requests from MCP servers

Servers can ask the client for user input mid-tool-call via `elicitation/create`. Two modes:

* **Form** — structured fields with a JSON schema
* **URL** — redirect the user to an external page (required for credentials/OAuth)

## Setup

```typescript theme={null}
import { stdin, stdout } from "node:process";
import { createInterface } from "node:readline/promises";
import {
  acceptWithDefaults,
  MCPClient,
  type OnElicitationCallback,
} from "@mcp-use/client";

const onElicitation: OnElicitationCallback = async (params) => {
  if (params.mode === "url") {
    // The tool call continues as soon as this returns, so accept only after
    // the user has finished the external flow.
    console.log(`Visit: ${params.url}`);
    const prompt = createInterface({ input: stdin, output: stdout });
    await prompt.question("Press Enter after you finish in the browser. ");
    prompt.close();
    return { action: "accept" };
  }
  // Form mode — collect fields from params.requestedSchema
  return acceptWithDefaults(params);
};

const client = new MCPClient(
  { mcpServers: { demo: { url: "http://localhost:3000/mcp" } } },
  { onElicitation },
);
```

The second constructor argument is available only in the Node.js entry. In a
browser build, set `onElicitation` at the top level of the configuration or on
an individual server configuration instead.

## Helpers

These helpers are exported only by the Node.js entry of `@mcp-use/client`. The
browser entry and `@mcp-use/client/react` do not export them.

| Helper | Purpose |
| - | - |
| `acceptWithDefaults(params)` | Accept using schema defaults |
| `accept(content)` | Accept with user content |
| `decline()`, `cancel()` | Reject or dismiss |
| `validate(params, content)` | Client-side validation |
| `getDefaults`, `applyDefaults` | Work with schema defaults |

## React

The helpers above are not available in a browser build, so handle the request
directly. This handler waits for the user to finish a URL request and accepts
form requests with their schema defaults:

```tsx theme={null}
import { useMcp, type ElicitResult } from "@mcp-use/client/react";

const mcp = useMcp({
  url: "http://localhost:3000/mcp",
  onElicitation: async (params): Promise<ElicitResult> => {
    if (params.mode === "url") {
      window.open(params.url, "_blank", "noopener");
      // The tool call continues as soon as this resolves, so accept only
      // after the user confirms they finished the external flow.
      const finished = window.confirm(
        `${params.message}\n\nSelect OK after you finish in the new tab.`
      );
      return { action: finished ? "accept" : "cancel" };
    }
    const content: NonNullable<ElicitResult["content"]> = {};
    for (const [name, field] of Object.entries(
      params.requestedSchema.properties
    )) {
      if (field.default !== undefined) content[name] = field.default;
    }
    return { action: "accept", content };
  },
});
```

With the provider, use `pendingElicitationRequests` and `approveElicitation` / `rejectElicitation`.

Without an `onElicitation` handler, tool calls that require input will fail.

## Reference

Server-side: [Elicitation](/v2/typescript/server/elicitation)


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