Skip to content

Consider extensible pattern for protocol flow-control exceptions #1788

Closed

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.

Activity

  1. added
    v2Affects the v2 line (2.x on main)
    enhancementRequest for a new feature that's not currently supported
    ready for workEnough information for someone to start working on
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Dec 15, 2025
  2. the-ayyi commented on Dec 17, 2025

    @the-ayyi

    Hi Felix, trying to help out here. Before proceeding, I'd like to clarify a couple of design points:

    1. It seems that mcp/server/lowlevel/server.py is the central exception handling point. wanna double confirm it's the only point where all tool-raised exceptions are caught and wrapped.

    2. Given this is tagged v2, is the expectation that we should use the extensible pattern immediately on the main branch, or should we continue with the specific except UrlElicitationRequiredError: raise from Fix for Url Elicitation issue 1768 #1780 for the current v1.x branch and reserve this refactoring for a dedicated v2 development branch?

  3. felixweinberger commented on Dec 17, 2025

    @felixweinberger
    ContributorAuthor

    Hi Felix, trying to help out here. Before proceeding, I'd like to clarify a couple of design points:

    1. It seems that mcp/server/lowlevel/server.py is the central exception handling point. wanna double confirm it's the only point where all tool-raised exceptions are caught and wrapped.
    2. Given this is tagged v2, is the expectation that we should use the extensible pattern immediately on the main branch, or should we continue with the specific except UrlElicitationRequiredError: raise from Fix for Url Elicitation issue 1768 #1780 for the current v1.x branch and reserve this refactoring for a dedicated v2 development branch?

    Deferring to @maxisbey on these questions as he's coordinating v2 for Python.

  4. the-ayyi commented on Dec 19, 2025

    @the-ayyi

    I have a drafting PR: #1800. @maxisbey Any thoughts on this ticket?

  5. added
    needs decisionIssue is actionable, needs maintainer decision on whether to implement
    and removed
    ready for workEnough information for someone to start working on
    on Apr 17, 2026
  6. maxisbey commented on Aug 10, 2026

    @maxisbey
    Contributor

    This landed as part of v2, which is now released (via #2928) — closing. Feel free to reopen if there's something still outstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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 supportedneeds decisionIssue is actionable, needs maintainer decision on whether to implementv2Affects the v2 line (2.x on main)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions