Skip to content

Consider extensible pattern for protocol flow-control exceptions #1788

@felixweinberger

Description

@felixweinberger

PR #1780 adds specific except UrlElicitationRequiredError: raise blocks in tool handlers to prevent this exception from being wrapped as a tool error.

Per SEP-1036, UrlElicitationRequiredError is not a regular error—it's a protocol-level flow control mechanism equivalent to elicitation/create. It needs to propagate as a JSON-RPC error response.

If more continuation-style exceptions are added in the future, consider an attribute-based pattern:

class McpError(Exception):
    propagate_through_tool_handlers: bool = False

class UrlElicitationRequiredError(McpError):
    propagate_through_tool_handlers = True

For now, YAGNI applies—we only have one such case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featureenhancementRequest for a new feature that's not currently supportedready for workEnough information for someone to start working onv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions