ワンクリックで
mcp-elicitation
How to safely use MCP Elicitation (ElicitAsync) in .NET MCP servers
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
How to safely use MCP Elicitation (ElicitAsync) in .NET MCP servers
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
How to implement async credential prompting with proper error handling across multiple implementations (console, MCP elicitation, etc.)
Extract shared code from a .NET Exe project into a class library for multi-project reuse
| name | mcp-elicitation |
| description | How to safely use MCP Elicitation (ElicitAsync) in .NET MCP servers |
| domain | mcp, error-handling |
| confidence | high |
| source | earned — diagnosed and fixed broken elicitation flow |
MCP Elicitation lets a server request structured user input from the client (host). The client must advertise the capability during initialize. If the client doesn't support it, the SDK throws InvalidOperationException — which is easy to miss in catch filters.
Always pre-check client capabilities before calling ElicitAsync:
if (mcpServer.ClientCapabilities?.Elicitation?.Form is null)
throw new InvalidOperationException("Client does not support elicitation.");
ElicitRequestParams.Mode defaults to "form" in SDK 1.1.0 — no need to set it explicitly for form-mode elicitation.
Elicitation is client-advertised, not server-declared. ServerCapabilities has no elicitation property. The client sends { capabilities: { elicitation: { form: {} } } } during initialize.
SDK throws InvalidOperationException, not McpException for capability checks — handle accordingly.
// Good: pre-flight check + defensive catch
private bool IsElicitationSupported() =>
mcpServer.ClientCapabilities?.Elicitation?.Form is not null;
public async Task<T> PromptAsync(CancellationToken ct)
{
if (!IsElicitationSupported())
throw new InvalidOperationException("Client doesn't support elicitation. Workaround: ...");
try { return await mcpServer.ElicitAsync(params, ct); }
catch (InvalidOperationException) when (!IsElicitationSupported()) { /* re-wrap */ }
catch (Exception ex) when (ex is not InvalidOperationException) { /* other failures */ }
}
Don't use catch (Exception ex) when (ex is not InvalidOperationException) as a catch-all — SDK capability errors ARE InvalidOperationException and will slip through.
Don't call ElicitAsync without checking capabilities first — the SDK throws internally, but the error message is generic and not actionable for users.
Don't assume all MCP hosts support elicitation — it's an optional client capability. Always provide a fallback or workaround path.