Skip to content

feat(tools): support elicitation_callback in McpToolset#6423

Draft
QuentinBisson wants to merge 1 commit into
google:mainfrom
QuentinBisson:feat/mcp-elicitation-callback
Draft

feat(tools): support elicitation_callback in McpToolset#6423
QuentinBisson wants to merge 1 commit into
google:mainfrom
QuentinBisson:feat/mcp-elicitation-callback

Conversation

@QuentinBisson

Copy link
Copy Markdown

Fixes #6422

MCPToolset and MCPSessionManager accept a sampling_callback but expose no way to supply an elicitation callback, even though the MCP Python SDK's ClientSession supports one. Servers that use elicitation — in particular URL-mode elicitation (SEP-1036, spec revision 2025-11-25) for third-party consent / auth challenges — fail opaquely inside the toolset because the client never declares the elicitation capability and has no handler.

What changed

  • McpToolset.__init__ accepts an optional elicitation_callback: ElicitationFnT and forwards it to MCPSessionManager.
  • MCPSessionManager.__init__ accepts the same parameter and forwards it to SessionContext.
  • SessionContext passes it into both ClientSession(...) construction sites (stdio and SSE/Streamable HTTP).

The plumbing mirrors sampling_callback exactly; no behavior changes when the parameter is omitted (the SDK's default callback rejects elicitation requests and the capability is not declared, as before).

Use case

Agent runtimes (kagent) fronting an MCP gateway with per-user OAuth to backends: the gateway raises a URL elicitation when the user must complete a login, and the embedding application maps it to the A2A auth-required task state (A2A spec §7.6). Go twin: google/adk-go#1165.

Tests

Unit tests added in tests/unittests/tools/mcp_tool/:

  • test_mcp_toolset.py: callback stored and forwarded to the session manager; defaults to None.
  • test_mcp_session_manager.py: callback forwarded to SessionContext on session creation.
  • test_session_context.py: callback forwarded into ClientSession kwargs.
$ pytest tests/unittests/tools/mcp_tool/test_mcp_toolset.py \
    tests/unittests/tools/mcp_tool/test_session_context.py \
    tests/unittests/tools/mcp_tool/test_mcp_session_manager.py -q
142 passed, 38 warnings in 14.93s

Formatted with isort + pyink per pre-commit config.

Thread an optional elicitation_callback through McpToolset,
MCPSessionManager, and SessionContext into the underlying
ClientSession, mirroring the existing sampling_callback plumbing.
Providing a callback makes the MCP client declare the elicitation
capability, so servers can use elicitation/create (including URL-mode
elicitation per SEP-1036) for out-of-band flows such as auth
challenges instead of failing opaquely inside the toolset.
@adk-bot adk-bot added the mcp [Component] This issues is related to MCP support label Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mcp [Component] This issues is related to MCP support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCPToolset: no way to supply an elicitation callback, blocking MCP server auth challenges (SEP-1036 URL elicitation)

3 participants