AI Frameworks·
advanced
·14 min read·Nov 21, 2026·Updated Nov 24, 2026
·Independent maintainer·Verification Charter

MCP Elicitation: Form and URL Mode Guide

Implement MCP elicitation/create in Form and URL modes for human-in-the-loop tool calls. Covers requestedSchema, out-of-band auth, and TypeScript SDK code.

MCPElicitationJSON-RPCOAuthTypeScriptCodexClaudeCursor
Interactive Tool
1-Click Export

Generate & Validate Multi-Client MCP Config

One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.

Open in Generator

MCP Elicitation: Form Mode, URL Mode, and Human-in-the-Loop Tool Calls

Traditional Model Context Protocol (tools/call) execution is strictly one-shot: a client submits JSON arguments, and the server either completes the task or aborts with isError: true. When a deployment tool discovers a missing production approval, an ambiguous target environment, or an expired third-party OAuth token mid-flight, one-shot tools force developers into fragile workarounds—either letting the LLM guess missing inputs or failing the request and burning extra reasoning turns while asking the user to re-prompt manually.

MCP Elicitation (elicitation/create) resolves this limitation by giving servers a standardized protocol mechanism to pause execution and request structured confirmation or out-of-band browser authentication from the human user through the host client. Elicitation separates non-sensitive structured prompts (Form mode) from credential and authorization workflows (URL mode) so secrets never pass through the LLM context window or the MCP client process.

The wire format below follows the 2025-11-25 specification (opens in a new tab), where URL mode was introduced. The current 2026-07-28 specification (opens in a new tab) moves elicitation requests into InputRequiredResult.inputRequests and advertises the capability in _meta.io.modelcontextprotocol/clientCapabilities; verify which revision your client and SDK negotiate before copying these frames.


1. Client Capability Negotiation and Wire Lifecycle

Elicitation is an optional client capability. A server must never request elicitation unless the client advertised support — under 2026-07-28 that support is declared in per-request _meta.io.modelcontextprotocol/clientCapabilities; legacy 2025-11-25 clients declared it in the initialize handshake. Clients can declare support for Form mode, URL mode, or both independently:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-11-25",
    "capabilities": {
      "roots": { "listChanged": true },
      "elicitation": {
        "form": {},
        "url": {}
      }
    },
    "clientInfo": {
      "name": "codex-cli",
      "version": "1.2.3"
    }
  }
}

For backward compatibility with clients built against the earlier 2025-06-18 specification, an empty "elicitation": {} object implies Form mode support only.

End-to-End Request Sequence

diagram

When a server runs over Streamable HTTP (POST /mcp), a 2025-11-25 server either streams server-to-client elicitation/create requests back inside the open text/event-stream response for that tools/call request or, only for URL-mode elicitation, returns -32042 URLElicitationRequiredError so the client can retry after the out-of-band interaction. Under 2026-07-28, the server instead returns an inputRequired result in a single response. See our Streamable HTTP transport guide for SSE response details.


2. Form Mode (mode: "form") and requestedSchema Constraints

Form mode collects non-sensitive parameters directly inside the host UI—for example, selecting a staging vs. production cluster, confirming a migration rollback window, or entering a release ticket ID.

JSON-RPC Wire Payload

The server dispatches elicitation/create with a human-readable message and a requestedSchema object:

json
{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "elicitation/create",
  "params": {
    "mode": "form",
    "message": "Confirm canary rollout parameters for billing-api v2.14.0.",
    "requestedSchema": {
      "type": "object",
      "properties": {
        "environment": {
          "type": "string",
          "title": "Target Environment",
          "description": "Cluster receiving the canary pods",
          "enum": ["staging", "production"],
          "default": "staging"
        },
        "canaryPercent": {
          "type": "integer",
          "title": "Canary Traffic %",
          "minimum": 1,
          "maximum": 50,
          "default": 10
        },
        "notifyOnCall": {
          "type": "boolean",
          "title": "Page On-Call Channel",
          "default": true
        }
      },
      "required": ["environment", "canaryPercent"]
    }
  }
}

The Three Client Response Actions (ElicitResult)

The client renders the form, validates input locally against requestedSchema, and returns one of three explicit action outcomes:

Response actioncontent PresentMeaning for Tool Handler
acceptYes (matches requestedSchema)User reviewed and submitted the form values. Proceed with execution.
declineNoUser explicitly refused the prompt (for example, clicked "Reject" on a production deploy). Abort cleanly without mutating state.
cancelNoUser dismissed the modal or pressed Esc without deciding. Return a neutral cancellation status.
json
{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "action": "accept",
    "content": {
      "environment": "staging",
      "canaryPercent": 10,
      "notifyOnCall": true
    }
  }
}

Strict Schema & Security Boundaries

To ensure terminal clients (such as OpenAI Codex CLI) and desktop IDEs (Claude Desktop, Cursor) can render reliable native inputs without writing arbitrary HTML form engines, requestedSchema enforces tight JSON Schema restrictions:

  1. ▸Flat Top-Level Object Only: requestedSchema.type must be "object", and properties cannot contain nested objects or nested arrays of objects.
  2. ▸Primitive Property Types: Fields are restricted to "string" (optionally with format: "email" | "uri" | "date" | "date-time" or enum / oneOf), "number", "integer", "boolean", and multi-select "array" of primitive enum strings where supported.
  3. ▸Zero Secrets in Form Mode: Per the MCP specification, servers MUST NOT request passwords, API keys, bearer tokens, or raw payment details via Form mode. Everything submitted in ElicitResult.content flows through the MCP host and can be persisted in session transcripts or returned to the LLM.

3. URL Mode (mode: "url") for Out-of-Band Authorization

When an agent invokes a tool that requires an OAuth 2.1 consent grant, a hardware security key signature, or sensitive API key entry, the interaction must occur out of band in the user's browser so secrets never enter the MCP host memory or model context.

Direct elicitation/create vs. -32042 Error Handling

Servers can trigger URL mode in two ways:

  1. ▸Mid-Tool URL Request (elicitation/create with mode: "url"): Used when the server already holds an active stateful session and needs the user to authorize a sub-action before continuing.
  2. ▸Pre-Flight Rejection (-32042 URLElicitationRequiredError): Used when the tool cannot start until an external credential or consent token exists in the server's backend store.

Every URL mode descriptor includes a unique elicitationId (UUID or cryptographic nonce), a clear message, and the destination url:

json
{
  "jsonrpc": "2.0",
  "id": 19,
  "error": {
    "code": -32042,
    "message": "OAuth authorization is required before deploying to production.",
    "data": {
      "elicitations": [
        {
          "mode": "url",
          "elicitationId": "elicit_9b71c4a2e0d4",
          "url": "https://auth.internal.example.com/oauth/authorize?state=elicit_9b71c4a2e0d4",
          "message": "Sign in to authorize production deployment permissions for this MCP session."
        }
      ]
    }
  }
}

Client Consent & notifications/elicitation/complete

To prevent phishing or open-redirect attacks, compliant MCP clients never auto-open a URL returned by a server. The client MUST show the full URL for examination, MUST make clear which MCP server requested it, and MUST require explicit user confirmation before launching the browser; it SHOULD highlight the domain (auth.internal.example.com) to mitigate subdomain spoofing.

Once the user completes the browser flow and hits your OAuth callback endpoint, the server associates the acquired token with the user's backend session and MAY emit notifications/elicitation/complete (under the 2025-11-25 revision this notification is optional):

json
{
  "jsonrpc": "2.0",
  "method": "notifications/elicitation/complete",
  "params": {
    "elicitationId": "elicit_9b71c4a2e0d4"
  }
}

Upon receiving the notification, the client dismisses any pending authorization prompt and can automatically retry the failed tools/call. For full OAuth 2.1 Protected Resource Metadata and token exchange mechanics, pair URL mode with Dynamic Client Registration and OAuth in MCP.


4. Production TypeScript Implementation (@modelcontextprotocol/sdk)

Install the official MCP TypeScript SDK and Zod:

bash
npm install @modelcontextprotocol/sdk zod
npm install -D typescript @types/node tsx

The following stdio server demonstrates both Form mode confirmation and URL mode UrlElicitationRequiredError handling inside a deployment tool, checking server.server.getClientCapabilities() before issuing elicitInput. The thrown-error pattern is the legacy 2025-11-25 behavior; under 2026-07-28 a server returns an inputRequired result instead:

typescript
// deploy-elicitation-server.ts
import { randomUUID } from "node:crypto";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { UrlElicitationRequiredError } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";

const server = new McpServer({
  name: "release-deployer",
  version: "1.4.0",
});

// Simulated per-session auth store populated by an external OAuth callback server
const authorizedUsers = new Set<string>();

server.registerTool(
  "deploy_service",
  {
    title: "Deploy Service Release",
    description:
      "Deploy a build tag to staging or production after interactive human confirmation.",
    inputSchema: {
      service: z.string().min(1).describe("Service identifier"),
      tag: z.string().min(1).describe("Immutable container image tag"),
      operatorId: z.string().min(1).describe("Caller account identifier"),
    },
  },
  async ({ service, tag, operatorId }) => {
    const clientCaps = server.server.getClientCapabilities();

    // 1. Guard sensitive actions with out-of-band URL Mode Elicitation
    if (!authorizedUsers.has(operatorId)) {
      if (!clientCaps?.elicitation?.url) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: "Client does not support URL mode elicitation; complete OAuth sign-in out of band first.",
            },
          ],
        };
      }

      const elicitationId = randomUUID();
      throw new UrlElicitationRequiredError([
        {
          mode: "url",
          elicitationId,
          url: `https://auth.internal.example.com/oauth/start?elicitationId=${elicitationId}&operator=${encodeURIComponent(operatorId)}`,
          message: `Authorize production deployment rights for ${service}:${tag}.`,
        },
      ]);
    }

    // 2. Verify Form mode capability before requesting structured confirmation
    if (!clientCaps?.elicitation?.form &&
        (!clientCaps?.elicitation || Object.keys(clientCaps.elicitation).length > 0)) {
      return {
        isError: true,
        content: [
          {
            type: "text",
            text: "Client does not advertise elicitation.form capability; cannot confirm deployment parameters.",
          },
        ],
      };
    }

    // 3. Prompt operator with Form Mode (flat primitive schema only)
    const confirmation = await server.server.elicitInput({
      mode: "form",
      message: `Confirm rollout for ${service} (${tag})`,
      requestedSchema: {
        type: "object",
        properties: {
          environment: {
            type: "string",
            title: "Environment",
            enum: ["staging", "production"],
            default: "staging",
          },
          canaryPercent: {
            type: "integer",
            title: "Canary Weight (%)",
            minimum: 1,
            maximum: 100,
            default: 10,
          },
          changeTicket: {
            type: "string",
            title: "Change Ticket ID",
            minLength: 4,
          },
        },
        required: ["environment", "canaryPercent", "changeTicket"],
      },
    });

    if (confirmation.action !== "accept" || !confirmation.content) {
      return {
        content: [
          {
            type: "text",
            text: `Deployment aborted: operator returned action '${confirmation.action}'.`,
          },
        ],
      };
    }

    const { environment, canaryPercent, changeTicket } = confirmation.content;

    return {
      content: [
        {
          type: "text",
          text: JSON.stringify(
            {
              status: "deployed",
              service,
              tag,
              environment,
              canaryPercent,
              changeTicket,
            },
            null,
            2
          ),
        },
      ],
    };
  }
);

async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error("release-deployer MCP server ready on stdio");
}

main().catch((err) => {
  console.error("Fatal server error:", err);
  process.exit(1);
});

On newer Streamable HTTP servers targeting stateless horizontal scaling, verify how your SDK version surfaces interactive prompts — request-scoped helpers or multi-round-trip inputRequired responses — before choosing a push-based elicitInput call.


5. Multi-Host Client Configuration

Register the compiled server or remote Streamable HTTP endpoint across your local clients using standard paths.

OpenAI Codex CLI (~/.codex/config.toml)

toml
[mcp_servers.release_deployer]
command = "npx"
args = ["-y", "tsx", "/absolute/path/to/deploy-elicitation-server.ts"]
startup_timeout_sec = 20
tool_timeout_sec = 180

For remote servers running Streamable HTTP:

toml
[mcp_servers.remote_release_deployer]
url = "https://mcp.internal.example.com/mcp"
bearer_token_env_var = "MCP_DEPLOY_TOKEN"

Claude Desktop and Cursor (mcp.json)

json
{
  "mcpServers": {
    "release-deployer": {
      "command": "npx",
      "args": ["-y", "tsx", "/absolute/path/to/deploy-elicitation-server.ts"]
    }
  }
}

Test interactive elicitation prompts locally before wiring desktop hosts by running the official MCP Inspector:

bash
npx @modelcontextprotocol/inspector --cli npx -y tsx /absolute/path/to/deploy-elicitation-server.ts

6. Troubleshooting Elicitation Failures

Error or SymptomRoot CauseRemediation
-32602 Invalid params on elicitation/createServer sent elicitation/create with a mode the host did not declare in capabilities.elicitation during initialize (the 2025-11-25 spec requires -32602; a host with no handler for the method may instead answer -32601).Inspect server.server.getClientCapabilities()?.elicitation first and fall back to returning isError: true or -32042 instructions.
-32602 Invalid params on Form schemarequestedSchema included nested object properties, arbitrary arrays of objects, or unsupported JSON Schema keywords.Flatten requestedSchema to top-level string, number, integer, boolean, and flat enum fields.
Client-side tool timeout while the user reads the formHuman confirmation took longer than the host's tool-call timeout. This is a local transport/tool timeout, not a standard MCP error code. Under MCP 2026-07-28, only -32000 to -32019 are implementation-defined; -32020 to -32099 are reserved by the specification.Increase tool_timeout_sec in ~/.codex/config.toml (default 60s) or emit notifications/progress frames where supported by the host transport.
OAuth callback completes, but agent stallsThe client is waiting on the optional notifications/elicitation/complete notification that the server did not send. Per the 2025-11-25 spec clients SHOULD also offer manual retry controls.Call server.server.notification({ method: "notifications/elicitation/complete", params: { elicitationId } }) immediately after token exchange, and give users a manual retry path.

7. External References

Ready to Deploy?

Build your full agent toolstack in the Visual Generator

Combine MCP servers with databases, search APIs, and memory graphs in a single configuration file.

Customize in Generator
Developer Verification & Feedback
0 reports

Did this setup guide work with your AI host?

Help test this configuration across Claude, Cursor, and Codex CLI. Be the first to report:

MCP Elicitation: Form and URL Mode Guide FAQ

Why does requestedSchema reject nested JSON objects in MCP Form mode?

MCP clients span terminal UIs like OpenAI Codex CLI and desktop forms in Claude Desktop and Cursor. Restricting requestedSchema to flat top-level objects with primitive types (string, number, integer, boolean, and flat enum) guarantees every compliant client can render native input prompts without an arbitrary recursive form engine.

When should an MCP server use URL mode instead of Form mode for user input?

Use URL mode whenever an operation involves passwords, API keys, OAuth 2.1 consent, or payment credentials. The MCP specification prohibits collecting secrets in Form mode because ElicitResult.content transits through the host application and can enter LLM conversation transcripts.

What causes -32601 Method not found when a tool invokes elicitation/create?

The connected host did not declare capabilities.elicitation during the initial initialize handshake. Always check server.server.getClientCapabilities()?.elicitation before calling elicitInput, and return an actionable isError: true response or -32042 URLElicitationRequiredError when the capability is absent.

RT✓

Written by Rad Tome

Independent maintainer, MCP Codex

Specializing in Model Context Protocol (MCP) integrations, autonomous AI agent orchestration, and distributed developer toolchains. Researches and benchmarks production MCP client-server architectures across OpenAI Codex, Claude, and Cursor.

Editorial Integrity: Package names verified via npm registry API. Repositories verified via GitHub REST API.
Verification Charter →

Related Guides