Skip to content

docs: clarify when Client(raise_exceptions=True) actually raises #3287

Open

Description

@HaoChiBao

Description

Client exposes raise_exceptions: bool = False with a code TODO asking when raise_exceptions=True actually raises:

https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/client/client.py (around the raise_exceptions field)

What's missing

There is no clear user-facing documentation of:

  1. Which failure modes are affected (in-process server exceptions vs transport/protocol errors)
  2. How this interacts with ExceptionGroup wrapping from async with Client(...)
  3. Recommended patterns vs catching MCPError inside the context manager (as docs/troubleshooting.md already teaches)

Proposed work

  • Trace current behavior on main for in-memory and HTTP clients
  • Document the real semantics in docs/client/ and/or docs/troubleshooting.md
  • Add a small docs_src example and/or regression test if behavior is surprising
  • Only change runtime behavior if docs reveal a clear bug; prefer docs-first

Related

  • TODO(Marcelo) on Client.raise_exceptions in src/mcp/client/client.py
  • ClientSession Error Handling #1401 ClientSession Error Handling (different surface; has an open PR)
  • troubleshooting ExceptionGroup guidance

Activity

  1. HaoChiBao commented on Aug 11, 2026

    @HaoChiBao
    Author

    I'd like to take this docs-first clarification of Client.raise_exceptions. Plan: trace current behavior on main, document real semantics, add a small example/test only if needed, and avoid runtime changes unless a clear bug appears.

    I searched for open PRs/issues specifically about Client.raise_exceptions documentation and did not find an active duplicate (related error-handling issues like #1401 are a different surface and already have PRs).

    AI-assisted drafting disclosed; I will own the final write-up.

  2. added
    P3Nice to haves, rare edge cases
    on Aug 12, 2026
  3. Ben-Home commented on Aug 18, 2026

    @Ben-Home
  4. added
    v1Affects the v1.x maintenance line
    v2Affects the v2 line (2.x on main)
    on Aug 18, 2026
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

    P3Nice to haves, rare edge casesdocumentationImprovements or additions to documentationv1Affects the v1.x maintenance linev2Affects 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