Skip to content
mentoor

Topic 1 of 5 · 5 min read

Asking users for input with elicitation

Goal: Choose form or URL elicitation for a described input need and write a request that never collects a secret through the form.

Elicitation lets an MCP server pause a tool call and ask the user a question through the client: use form mode for plain answers and URL mode for anything secret.

Check yourself · 1 of 3

A server needs the user's payment card number to finish a purchase tool. Which elicitation approach does the spec require?

Choose one answer

Why it matters

A create_release tool needs a version number, and a deploy tool needs a yes or no. Without elicitation the model guesses the missing argument, or the server fails with a vague error. Elicitation puts the question in front of the person who can answer it, in the client's own interface.

How to do it

  1. Check what the client supports. A client lists elicitation in its capabilities with form, url or both. An empty elicitation object means form mode only. Never send a mode the client did not declare.
  2. Use form mode for simple answers. You send a message and a requestedSchema. The schema is a flat object: properties may be strings, numbers, booleans or enums, and the only arrays allowed are multi-select enums. No nesting. Strings may use the formats email, uri, date and date-time. Form data passes through the client.
  3. Use URL mode for secrets. You send mode: "url", a message and a url. The user opens the page in a browser, and the data they type never reaches the client. The spec says servers must not collect passwords, API keys, access tokens or payment credentials with a form. Name, email and username are not banned.
  4. Handle three outcomes. The user can accept (with content for a form), decline or cancel. Decline and cancel are normal answers, not errors.
  5. Remember what the client must show. It must say which server is asking, offer clear decline and cancel options, let the user edit a form before sending, and for URL mode show the target host and get consent first.

In the 2026-07-28 revision, the request travels inside an input_required result, which the next topic covers.

Before and after

Weak: the server asks for a key in a form.

{
  "method": "elicitation/create",
  "params": {
    "mode": "form",
    "message": "Paste your Stripe secret key",
    "requestedSchema": {
      "type": "object",
      "properties": { "key": { "type": "string" } }
    }
  }
}

Fixed: the server sends the user to its own page.

{
  "method": "elicitation/create",
  "params": {
    "mode": "url",
    "message": "Connect your Stripe account to enable refunds",
    "url": "https://billing.example.com/connect/stripe"
  }
}

What goes wrong

  • Secrets in a form. The key is now visible to the client and its logs.
  • Nested schemas. A schema with an object inside an object is outside the allowed subset, and clients may reject it.
  • Treating decline as failure. The tool should return a clear "cancelled by user" result, not retry the question.

Examples

A confirmation with a choice

A deploy tool asks which environment and whether to run migrations:

{
  "mode": "form",
  "message": "Deploy build 482?",
  "requestedSchema": {
    "type": "object",
    "properties": {
      "environment": { "type": "string", "enum": ["staging", "production"] },
      "runMigrations": { "type": "boolean", "default": false }
    },
    "required": ["environment"]
  }
}

Both fields are flat and need no secret, so form mode fits.

Third-party authorization

A calendar tool needs access to the user's Google Calendar. The server sends a URL-mode request pointing at its own OAuth start page. The client shows accounts.example.com, the user consents, and the token stays between the user's browser and the server. This is separate from the authorization between the client and the MCP server.

Key points

  • Form mode collects simple structured answers through the client, and the data is visible to it.
  • URL mode sends the user to a page in the browser, so the entered data never passes through the client.
  • Servers must not request passwords, API keys, access tokens or payment credentials in form mode.
  • A form schema is a flat object of strings, numbers, booleans and enums, with multi-select enums as the only arrays.
  • A user can accept, decline or cancel, and the server must treat all three as valid outcomes.
  • Clients must show which server is asking and, for URL mode, the target host before the user consents.

Common mistakes

  • Asking for an API key or password in a form because the schema field is easy to write.
  • Sending a URL-mode request to a client that declared only form mode.
  • Designing a schema with nested objects or arrays of objects, which the flat subset does not allow.
  • Treating decline or cancel as an error and asking the same question again.

Check yourself · 2 of 3

Which requestedSchema is allowed in a form-mode elicitation request?

Choose one answer

Check yourself · 3 of 3

A user closes the dialog for a form-mode elicitation without answering. What should the server do?

Choose one answer

Practice items, not counted towards your mastery.

Start here