跪拜 Guibai
← Back to the summary

The Silent Failure of MCP Elicitation: A User's 'Decline' Still Deletes Your Data

In the previous post about Sampling, I wrapped up the three lines of reverse communication: progress notifications are notifications bound to requests; Sampling and Elicitation are requests bound to sessions. At the time I said that line was "complete". That was a lie - I only mentioned Elicitation by name and never tested it even once.

After filling that gap, I found it more dangerous than Sampling. Sampling's failure is "can't borrow a model" - you can see it: the request doesn't go out, it times out, the data doesn't move. Elicitation's failure is the user clicks 'decline' and the data is still deleted, while the tool reports 'deleted' as a success. No error anywhere in the whole process; even the log says "confirmation succeeded".

This post tests Elicitation end to end. It's called "eliciting input" - in plain terms, the tool pauses mid-execution, pops up a form and asks the user: "Are you sure you want to delete?", "Which label?", "Fill in a reason?". That sounds like a clean layer of protection.

Whether the protection holds depends on what you do with the answer after you get it.

What Elicitation looks like

On the server, inside a tool handler, you call elicitInput() mid-execution:

const answer = await server.server.elicitInput({
  mode: "form",
  message: `确定删除《${note.title}》吗?`,
  requestedSchema: {
    type: "object",
    properties: {
      confirm: { type: "boolean", title: "确认删除", default: true },
      reason: { type: "string", title: "删除原因(可选)" },
    },
    required: ["confirm"],
  },
});

This sends a elicitation/create request to the client. The client mounts a handler, pops up the form, and returns the user's answer wrapped in an ElicitResult:

{ action: "accept", content: { confirm: true, reason: "过期了" } }

Note that action - it has three possible values: accept, decline, cancel. That's the key to the entire post.

Everything looks smooth: pop-up, user clicks confirm, get content, execute deletion. I wrote a delete_note_with_confirm tool like this, kept two notes in server memory, asked before deleting, then started testing different user answers.

Happy path: delete only after confirmation

First I ran the standard flow. The client declares the form capability, the handler automatically answers accept, and the server deletes only if action === "accept" and confirm === true:

[cli]  收到 elicitation:确定删除《MCP 的传输层》吗?
[cli]  删除工具结果: 已删除《MCP 的传输层》。原因:探针自动确认
[cli]  剩余笔记: n2 Function Calling 与 MCP

Server log:

[srv] elicitInput 返回 action=accept content={"confirm":true,"reason":"探针自动确认"}
[srv] 已删除 n1

No problem. User agrees, deletion executes, result is correct.

User clicks decline: safe when written correctly

The client answers decline. The server correctly checks the action:

[cli]  收到 elicitation:确定删除《MCP 的传输层》吗?
[cli]  删除工具结果: 用户未确认(decline),未删除《MCP 的传输层》。
[cli]  剩余笔记: n1 MCP 的传输层 | n2 Function Calling 与 MCP

The note is still there. Log:

[srv] elicitInput 返回 action=decline content={}
[srv] 用户 decline,不删除

One detail: in a decline response, content is empty - the user didn't fill the form, so there's no confirm field. If your code reads answer.content.confirm directly, you get undefined. Here I checked action first, so it's safe.

But without checking action: a user's refusal means nothing

Now I removed the server-side check, took the answer as consent, and executed the delete directly. That's how many people write the first version - "I asked, so after asking I delete".

User answers decline:

[cli]  收到 elicitation:确定删除《MCP 的传输层》吗?
[cli]  删除工具结果: 已删除《MCP 的传输层》(naive:没检查用户是否同意)
[cli]  剩余笔记: n2 Function Calling 与 MCP

Server log is even harsher:

[srv] elicitInput 返回 action=decline content={}
[srv] naive 模式:无视 action,直接删了 n1

The user clicked 'decline', the data is gone, the tool reports 'deleted', with no error at all.

Then I tested cancel (user closes the pop-up or presses Esc):

[srv] elicitInput 返回 action=cancel content={}
[srv] naive 模式:无视 action,直接删了 n1

Deleted the same way.

This is the biggest difference between Elicitation and Sampling. In Sampling, failure means "no answer received" - you can always detect it. In Elicitation, you receive a complete, well-formed return value, but the semantics of that value is "no". If you treat it only as "form data" and ignore action, that "no" gets swallowed.

The protocol delivers the user's refusal to you intact. Whether you use it is your business. This was said once in the tenth post about permissions: the protocol only guarantees "whether it can be called", not "whether it should be called"; here it's "the protocol guarantees that it asked", not "that you listened".

Correct implementation checks two levels

My final correct version uses two layers of checks, both required:

const answer = await server.server.elicitInput({ ... });

// First layer: did the user agree to this interaction?
if (answer.action !== "accept") {
  return { content: [{ type: "text", text: `用户未确认(${answer.action}),未删除。` }] };
}

// Second layer: did the user actually tick the confirmation box?
const confirmed = (answer.content as any)?.confirm;
if (confirmed !== true) {
  return { content: [{ type: "text", text: "用户未勾选确认,未删除。" }] };
}

NOTES.delete(id);  // 走到这里才能删

Two layers look verbose, but each has its purpose:

If you only write the first layer, you'll delete wrongly when the user accepts but doesn't tick. If you only write the second layer, on decline the content is empty and confirm is undefined; that might not equal true with high probability, but you're relying on an accident, not on explicit semantics.

One side note: don't use truthiness checks like if (answer.content?.confirm). Use !== true. Boolean fields coming back from the protocol might be strings or undefined; explicit comparison avoids surprises. The next scenario will hit this face-first.

A pitfall: content that doesn't match the schema makes the server flip

The reason I said "explicit comparison" is that the client's returned data doesn't always play by the rules. I made the client, while accepting, fill the boolean-typed confirm with the string "yes-please":

[cli]  收到 elicitation:确定删除《MCP 的传输层》吗?
[cli]  删除工具结果: 确认失败:MCP error -32602:
       Elicitation response content does not match requested schema: data/confirm must be boolean
[cli]  剩余笔记: n1 MCP 的传输层 | n2 Function Calling 与 MCP

Server log:

[srv] elicitInput 抛错 code=-32602
      MCP error -32602: Elicitation response content does not match requested schema: data/confirm must be boolean

For action === "accept" responses, the SDK validates the content against the schema you declared - your requestedSchema isn't decorative; it really validates the content. If it doesn't match, it throws -32602 InvalidParams.

This behavior has two sides.

The good side: the server won't go ahead and execute with a malformed content. In my experiment the deletion was blocked and the note stayed.

The bad side: this validation only covers the accept branch. decline and cancel have empty content, which doesn't need validation. So you still have to look at action yourself - the validation guards "what was answered" but not "whether it was consented to".

Also, this error is thrown as an exception, not as an isError return. When writing the handler, either wrap it in try/catch or let it bubble up as a protocol error; my version catches it and returns isError: true so the model can read the error clue and correct itself rather than receiving a 500.

Capability declaration: an empty object works too

The fourth pitfall is capability declaration. Here the rules differ from Sampling; only by putting both side by side did I understand.

First I tested declaring nothing (capabilities: {}) and still mounting the handler:

[cli] 挂 handler 抛错: Client does not support elicitation capability (required for elicitation/create)

The SDK stops you at handler mounting - same as Sampling; capability and handler must come as a pair.

But what if you declare elicitation: {} - an empty object that declares neither form nor url? According to the SDK's elicitInput source, it checks this._clientCapabilities?.elicitation?.form; an empty object has no form, so it should report Client does not support form elicitation.

Actual test result:

[cli]  收到 elicitation:确定删除《MCP 的传输层》吗?
[cli]  删除工具结果: 已删除《MCP 的传输层》。原因:探针自动确认

The empty declaration actually works. I dug into the SDK source and found this in getSupportedElicitationModes():

const hasFormCapability = capabilities.form !== undefined;
const hasUrlCapability = capabilities.url !== undefined;
// If neither form nor url are explicitly declared, form mode is supported
// (backwards compatibility)
const supportsFormMode = hasFormCapability || (!hasFormCapability && !hasUrlCapability);

The author added a backward-compatibility rule: if neither form nor url is declared, you're assumed to support form. So elicitation: {} runs.

That "kindness" is dangerous. It means a wrong capability declaration (missing form: {}) won't error, and the feature looks normal. Later, if the protocol tightens up, or you switch to an implementation that doesn't honor this compatibility logic, your client will suddenly break - and you won't be able to remember this line is the cause.

Compare: in Sampling, capabilities: { sampling: {} } is an explicit declaration and an explicit check; in Elicitation, elicitation: {} gets silently filled in as form support. The same empty object behaves completely differently between the two capabilities. Don't memorize rules; just write it fully: { elicitation: { form: {} } }.

URL mode: another capability, another failure

Elicitation has two modes. Everything above used form - a structured pop-up form. There's also url - the server provides a link for the user to complete an action in the browser (for example OAuth authorization, a complex form).

URL mode requires a separate declaration elicitation: { url: {} }. I had the server send URL-mode requests, but the client only declared form:

[cli]  删除工具结果: 确认失败:Client does not support url elicitation.

Server log:

[srv] elicitInput 抛错 Client does not support url elicitation.

The client never received the request even once (0 requests) - this check is also done locally at the elicitInput() entry.

So form and url are two independent locks. Declaring form doesn't mean url works, and vice versa. This error is a plain Error, not an McpError with a code; I caught it on the server and converted it to isError: true so the tool call didn't become a 500.

There's also a design trade-off here: URL mode is inherently asynchronous - the user opens the link, operates in the browser, and might come back minutes later. The SDK provides createElicitationCompletionNotifier() to send a completion notification. I didn't test this part this time (it needs a real browser and a callback address). The applicability boundary at the end of the post will note this.

Four failures, one diagnostic table

Here are all the failures I hit, laid out:

Symptom Error / behavior Root cause What to check first
User declines but data is deleted No error, reported as success Didn't check answer.action Whether accept is checked
Handler mounting crashes Client does not support elicitation capability No capability declared at all capabilities.elicitation
Request can't be sent Client does not support form/url elicitation Missing the relevant sub-capability form / url declared separately
Tool throws -32602 response content does not match requested schema Content doesn't match requestedSchema Client return value type

The last one is actually useful protection, not a "pitfall" - but it reminds you that requestedSchema is actually executed, so don't write it carelessly.

When to use Elicitation

The judgment for using Elicitation differs completely from Sampling. Sampling asks "which side does the model sit on"; Elicitation asks "should this decision be made by the user?".

Good fits:

Not good fits:

Writing the server side, remember three things:

  1. When you get the answer, look at action first; both decline and cancel count as "not consented".
  2. After action is accept, validate the key field in content, with explicit comparison (!== true).
  3. Wrap elicitInput() in try/catch, convert thrown errors to isError: true so the model can read and self-heal.

Writing the client side, remember two things:

  1. Declare capability and handler as a pair, write it fully as { elicitation: { form: {} } }; don't rely on the empty-object compatibility logic.
  2. If you use URL mode, declare url separately; form and url are two locks.

Summary

With this, the reverse-communication line is truly complete: progress notifications bind to requests, Sampling and Elicitation bind to sessions. But the three feel completely different: progress notification is "a message can't be sent", Sampling is "a model can't be borrowed", Elicitation is "an answer was received but used wrongly". The further you go, the more the protocol leaves the choice of power to you, and the more the pitfalls hide in your own code rather than in the protocol.

Applicability boundary: The above conclusions are based on local Streamable HTTP with SDK 1.30, a scripted client simulating user responses, and no real UI. URL mode was only tested for the entry-point capability check and local error throwing; I didn't test real browser callbacks or the notifications/elicitation/complete completion notification, which involves external addresses and async waiting - that's another topic. Elicitation's timeout, multi-turn follow-ups, and behavior when combined with task primitives are also not covered. Don't copy the conclusions; first confirm whether your server actually checks action - that one line basically determines what happens after the user clicks "decline".

Comments

Top 1 from juejin.cn, machine-translated. The original thread is authoritative.

GenTang

To add a distinction on capability declaration: the 2025-11-25 version explicitly states that elicitation: {} is equivalent to supporting only form, so this is a protocol-defined backward compatibility, not just the SDK's own fallback. Explicitly writing form: {} is clearer, but it's recommended to change "writing it wrong still doesn't error" to "a compatible form allowed by the spec," distinguishing it from not declaring elicitation at all. Official docs: https://modelcontextprotocol.io/specification/2025-11-25/client/elicitation#capabilities