Skip to content

Proposal: export urlElicitationMiddleware #1492

Closed

Description

@QuentinBisson

Checklist

  • I searched the existing issues, and this has not been reported before.
  • This is a real problem that I ran into myself, using the latest release of the SDK.
  • I ran into it in a production system, not in a toy example, a benchmark, or an automated or AI-driven scan of the code.
  • I (a human) examined the relevant SDK code, and wrote or reviewed every line of this report. It is not unreviewed AI output.
  • This report is brief and concise, and sticks to the facts needed to understand the problem.

What problem are you trying to solve?

Our client handles URL mode elicitations in its ElicitationHandler. On 2026-07-28 the input requests of a tool result reach that handler. On 2025-11-25 a -32042 error does not: CallTool returns the *jsonrpc.Error, so we decode its elicitations data ourselves to get the same ElicitParams.

urlElicitationMiddleware in mcp/client.go already turns -32042 into handler calls, but it is unexported (see its TODO(rfindley) about exporting it). It returns a handler error wrapped, so it also works for a client that can't wait in-process: our handler returns an error carrying the URL and we pause the task for a person.

Where did you hit this?

kagent's Go ADK agent runtime relays an MCP server's URL elicitation to the person as an A2A input-required task (kagent-dev/kagent#3500).

What would help?

Export the middleware, e.g. func URLElicitationMiddleware() Middleware, or an option on ClientOptions that installs it. A smaller alternative: an exported helper that decodes -32042 data into []*ElicitParams, the inverse of URLElicitationRequiredError.

AI assistance: used to check the SDK code paths and draft this report.

Activity

  1. guglielmo-san commented on Nov 4, 2026

    @guglielmo-san
    Contributor

    @QuentinBisson, Thanks for the report.
    I'd lean toward the smaller decoder helper :

    // ParseURLElicitationRequiredError extracts the URL-mode elicitation requests
    // from err if err wraps a *jsonrpc.Error with code CodeURLElicitationRequired (-32042).
    //
    // If err does not have code CodeURLElicitationRequired, it returns (nil, false, nil).
    // If err has code CodeURLElicitationRequired, ok is true and a non-nil error is
    // returned if the error data is malformed or contains non-URL elicitations.
    func ParseURLElicitationRequiredError(err error) (elicitations []*ElicitParams, ok bool, parseErr error)

    Would ParseURLElicitationRequiredError work well for your kagent integration?

  2. guglielmo-san commented on Nov 4, 2026

    @guglielmo-san
    Contributor

    I have also decided to remove urlElicitationMiddleware in #1494
    It was not used, and it is meaningful only for an outdated version of the protocol

  3. QuentinBisson commented on Nov 4, 2026

    @QuentinBisson
    ContributorAuthor

    Yes, that works for us. It replaces the hand-rolled decode in kagent's ADK runtime. A few details we'd rely on:

    • Match with errors.As. call() already wraps the *jsonrpc.Error (calling %q: %w), and ADK's mcptoolset wraps it again.
    • A -32042 with missing data gives ok=true and a parseErr, since the schema makes data required.
    • On mode: URLElicitationRequiredError treats an empty mode as form and panics, while ServerSession.Elicit infers "url" from URL/ElicitationID. Should the parser follow the spec strictly (mode: "url" and elicitationId required), or apply inferElicitMode? Strict seems right to me, and the constructor could then infer the same way Elicit does.

    Happy to send the PR if you'd like.

  4. guglielmo-san commented on Nov 4, 2026

    @guglielmo-san
    Contributor

    Yes lets keep the strict mode.
    I assigned the Issue to you, you can now send a PR

  5. added a commit that references this issue on Nov 6, 2026
    5ea06a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions