Sampling and elicitation reverse the usual direction of MCP: the server asks the client to run a model prompt or to put a question in front of the user, and a malicious or compromised server can use both to hijack context, burn tokens or phish credentials. Most MCP security work focuses on tools the client calls. These two features are where the server gets to drive, so the client and the user become the security boundary. This guide covers both features as defined in MCP specification revision 2026-07-28 (checked 27 October 2026), including the new multi round-trip request pattern, the deprecation of sampling, and the URL mode of elicitation used for third-party OAuth and payments. It is written for teams building MCP clients and hosts, teams building servers that ask users for input, and security reviewers approving either.
Key takeaways
- Sampling is deprecated, not gone. Revision 2026-07-28 deprecates sampling under SEP-2577; it stays functional until at least the first revision released on or after 28 July 2027. Do not build new features on it, and turn it off in clients where no approved server needs it.
- Every sampling request is untrusted prompt input. The server writes the messages, the system prompt request and any tool definitions, so treat it like indirect prompt injection with a token bill attached.
- Form mode must never collect secrets. The specification forbids servers from requesting passwords, API keys, access tokens or payment credentials through form mode; those belong in URL mode.
- URL mode is a phishing surface by design. Clients must show the full URL, never prefetch or auto-open it, and open it in a browser context the client and model cannot inspect.
- The server must prove the same user finished the flow. A URL mode OAuth link can be forwarded to another user; servers must check that the person completing it is the person who started it, or tokens end up bound to the wrong account.
How identity and access work in MCP sampling and elicitation
In revision 2026-07-28 MCP became stateless. A server no longer sends its own requests over a session; when it needs something from the client mid-call, it returns an InputRequiredResult (resultType: "input_required") whose inputRequests map may contain sampling/createMessage, elicitation/create or roots/list requests, plus an optional opaque requestState. The client fulfils them and retries the original request with inputResponses and the echoed state. Earlier revisions, up to 2025-11-25, sent the same request types as server-initiated JSON-RPC calls; the security questions are the same either way.
| Feature | What the server can ask for | Who decides | Main abuse |
|---|---|---|---|
| Sampling | A completion from the client's model: messages, optional systemPrompt, maxTokens, model preferences and hints, and since 2025-11-25 a tools array with toolChoice | The client, which MAY modify or ignore the system prompt and context inclusion, and SHOULD keep a human able to deny the request | Prompt injection into the user's model, token theft, covert tool calls, persistent instructions in context |
| Elicitation, form mode | Structured answers to a flat schema of strings, numbers, booleans and enums | The user, who must be able to review, edit, decline or cancel | Social engineering for data the server should not have; links smuggled into text fields |
| Elicitation, URL mode | That the user opens a URL for an out-of-band step such as third-party OAuth, entering an API key on the server's own page, or payment | The user, after the client shows the full URL and asks consent | Phishing pages, pre-authenticated links, account binding to the wrong user |
Capabilities are the first access control
Clients declare support in _meta.io.modelcontextprotocol/clientCapabilities on every request: sampling (with optional sampling.tools) and elicitation (with form, url or both; an empty object means form only). Servers MUST NOT send request types or modes the client has not declared. A client that never declares sampling removes the whole sampling attack surface, which is the right default now the feature is deprecated.
Where the identity boundaries sit
- MCP authorisation versus third-party authorisation: the client's bearer token authorises the client to the MCP server. URL mode elicitation is for the server to obtain its own credential to a third-party API on the user's behalf. The specification states the server MUST NOT rely on URL mode elicitation to authorise users for itself.
- No token passthrough: the server must not reuse the client's token against the third-party service, and third-party credentials MUST NOT transit the client. The server stores them, bound to the verified user identity (for example the
subclaim from the MCP authorisation server). - No self-asserted identity: servers must not trust a user typing "I am [email protected]" into a form; identity comes from authorisation.
See the MCP Authorisation Specification Guide for the client-to-server flow this sits on top of.
Admin roles and privileged access
Neither feature has an administrator in the protocol. The privileged decisions sit in client and host configuration, and those settings deserve the same review as any privileged policy.
- Client policy owners: decide which servers may use sampling at all, whether tools may be offered inside sampling, the maximum
maxTokensand request rate per server, and whether URL mode is enabled. Record these as a per-server policy in your MCP registry or gateway rather than as defaults in each client. - Auto-approval settings: any client option that approves sampling or elicitation without showing the user is a standing privilege grant to the server. Allow it only for internal servers with a named owner, and never for servers that can also reach untrusted content.
- Server operators: the server that stores third-party tokens obtained through URL mode becomes a credential vault. Its operators and its token store need privileged access controls, encryption at rest and break-glass procedures.
- Model and billing owners: sampling spends the client's model budget. The team that owns the model account should see per-server sampling spend, because the requester is not the payer.
Integrations, API tokens and service accounts
URL mode for third-party OAuth
The specification's implementation pattern is: the server generates an authorisation URL as an OAuth client of the third party, binds internal state to the user, sends a URL mode request, the user completes OAuth directly with the third party, the third party redirects back to the server, and the server stores the tokens against the user. The phishing scenario in the specification shows why the binding matters: Alice triggers an elicitation, forwards the link to Bob, Bob authorises, and the tokens land on Alice's session. The prescribed fix is a "connect URL" on the MCP server (for example https://mcp.example.com/connect?...) that checks the browser session's subject matches the subject that started the elicitation before redirecting to the third party.
- Server rules: no credentials or personal data in the URL; never a pre-authenticated URL that grants access by itself; HTTPS outside development; no clickable URLs in form mode fields.
- Client rules: no prefetching of the URL or its metadata; no opening without explicit consent; show the full URL; open it in a context the client and model cannot read (the specification contrasts SFSafariViewController, which is acceptable, with WKWebView, which is not); highlight the domain; warn on Punycode and other ambiguous hosts.
- Completion: in 2026-07-28 the
notifications/elicitation/completemessage andelicitationIdwere removed. The client learns the outcome by retrying, and the server correlates through its ownrequestState. Accept means the user consented to open the link, not that the flow succeeded.
requestState is attacker-controlled
Because requestState round-trips through the client, the specification requires servers to treat it as attacker-controlled input and, where it influences authorisation, resource access or business logic, to protect its integrity with an HMAC or AEAD and reject anything that fails verification. Include replay protections inside the protected payload, and enforce single use server-side for one-time actions. A server that encodes "user=alice, step=authorised" as plain base64 has built a privilege escalation.
Sampling and model credentials
Sampling exists so servers can use a model without holding their own API key. The deprecation's migration path is the opposite: servers integrate directly with LLM provider APIs. That moves a model credential onto the server, so manage it as an NHI with a scoped key, spending limits and rotation. See the LLM API Key Security Guide.
Logging and detection
- Log every input request: server identity, request type (sampling, form, URL), the declared reason (
message), the full URL for URL mode, the user decision (accept, decline, cancel) and the retry outcome. Correlate with the OpenTelemetry trace context that 2026-07-28 reserves in_meta(traceparent,tracestate,baggage). - Sampling content checks: Palo Alto Networks Unit 42 research (December 2025) demonstrated three sampling abuses: hidden instructions that make the model generate extra billed output the user never sees, instructions that persist in conversation context, and covert tool invocation such as writing a file. Its recommended detections include scanning requests for injection markers and hidden content such as zero-width characters or Base64, and flagging unusual token use, high sampling frequency and unexpected tool calls in responses.
- Elicitation content checks: flag form schemas whose field names or descriptions ask for passwords, keys, tokens, card numbers or one-time codes; flag URL mode requests to domains not registered for that server, newly registered domains and Punycode hosts.
- Server side: log
requestStateverification failures and replays, and connect-URL subject mismatches. A mismatch is either a bug or someone forwarding a link to a victim.
Metrics
- Servers with sampling enabled, as a share of approved servers (target: falling towards zero as migration proceeds).
- Sampling tokens consumed per server per day against its budget.
- Form mode requests flagged for credential-like fields (target: zero from approved servers).
- URL mode requests to unregistered domains, and the user accept rate on them.
- Connect-URL subject mismatches and
requestStateintegrity failures per week.
Hardening baseline
Clients and hosts
- Do not declare
samplingunless an approved server needs it; never declaresampling.toolsby default. - Where sampling stays on, show the user the full prompt and the requesting server, allow edit and deny, and show the response before it returns to the server.
- Ignore or replace server-supplied
systemPromptvalues, keepincludeContextat"none"(the other values are deprecated), and never include other servers' context. - Enforce per-server caps on
maxTokens, request rate and tool loop iterations; the specification asks both sides to implement iteration limits. - Render form mode text as plain text with no clickable links, label the requesting server clearly, and block submission when a field looks like a secret.
- For URL mode, apply every client rule in the specification, plus a per-server domain allowlist held in your registry or gateway.
Servers
- Plan migration off sampling now: move to a direct provider integration with a scoped key before the earliest removal date.
- Collect secrets only through URL mode, on your own HTTPS page, bound to the authenticated user.
- Implement the connect-URL check that compares session subject with the elicitation subject.
- Integrity-protect
requestStatewith an HMAC or AEAD, add expiry and replay protection, and never put secrets in it. - Handle decline and cancel without retry loops that pressure users into accepting.
Rollout and rollback
- Inventory which servers send sampling or elicitation requests, using client logs or a gateway in observe mode for two weeks.
- Pilot the restrictive client policy with one team, with sampling off and URL mode limited to allowlisted domains.
- Expand in rings; where a server breaks, grant a time-limited exception tied to a migration ticket rather than re-enabling globally.
- Rollback is per server: re-enable the capability for that server only, with logging on.
Framework mapping
| Risk | OWASP and ATLAS | ATT&CK | NIST SP 800-53 Rev. 5 |
|---|---|---|---|
| Prompt injection through sampling messages | LLM01:2025 Prompt Injection; AML.T0051.001 Indirect; AML.T0080 AI Agent Context Poisoning | Not applicable | SI-10 Information Input Validation |
| Covert tool calls inside sampling | LLM06:2025 Excessive Agency; AML.T0053 AI Agent Tool Invocation; mitigation AML.M0029 Human In-the-Loop for AI Agent Actions | Not applicable | AC-3 Access Enforcement; AC-6 Least Privilege |
| Token and cost abuse | LLM10:2025 Unbounded Consumption; AML.T0034.002 Agentic Resource Consumption | Not applicable | AU-12 Audit Record Generation |
| Phishing via URL mode | AML.T0052 Phishing | T1566.002 Spearphishing Link; T1204.001 Malicious Link | IA-2 Identification and Authentication |
| Third-party tokens bound to the wrong user or leaked | AML.M0033 Input and Output Validation for AI Agent Components | T1528 Steal Application Access Token | SC-28 Protection of Information at Rest; AU-2 Event Logging |
In NIST CSF 2.0 terms these controls sit mainly under PR.AA-05 (access permissions managed with least privilege) and DE.CM-09 (monitoring software and runtime environments).
Common misconfigurations
- Declaring sampling because the SDK makes it easy. A client that advertises
samplingto every server gives all of them a route into the user's model and budget. - Auto-approving sampling for convenience. Removing the human from the loop turns the Unit 42 scenarios from demonstrations into silent abuse.
- Collecting API keys in a form. It breaks a MUST NOT in the specification and puts the secret in client logs and possibly model context.
- Opening URL mode links in an embedded web view. The client or model can then read what the user types, which defeats the purpose of URL mode.
- Skipping the same-user check. Without it, any user can harvest a victim's third-party authorisation by forwarding a link.
- Trusting requestState. Unsigned state that records authorisation decisions lets a malicious client skip steps.
Practitioner checklist
- List every server that uses sampling and set a migration date before the July 2027 earliest removal.
- Turn off the
samplingandsampling.toolscapabilities by default in clients you control. - Require visible human approval and per-server token and rate caps for any remaining sampling.
- Block form mode fields that request secrets and render form text without links.
- Enforce the URL mode client rules and a per-server domain allowlist.
- Verify servers implement the connect-URL same-user check and never use URL mode to authorise users to themselves.
- Require HMAC or AEAD protection, expiry and replay checks on
requestState. - Log all input requests with user decisions and trace context, and review the metrics monthly.
Standards and references
- Model Context Protocol: Elicitation (revision 2026-07-28)
- Model Context Protocol: Sampling (revision 2026-07-28)
- Model Context Protocol: Multi Round-Trip Requests
- Model Context Protocol: Deprecated Features
- Model Context Protocol: SEP-2577 Deprecate Roots, Sampling, and Logging
- Model Context Protocol: Security Best Practices
- OWASP: Top 10 for LLM Applications 2025
- Palo Alto Networks Unit 42: Model Context Protocol attack vectors through sampling
Related NHI Mgmt Group resources: MCP Security Guide · MCP Security Best Practices Explained · MCP Apps Security Guide · MCP Security Testing Guide