Skip to content

Conversation

@maxisbey
Copy link
Contributor

@maxisbey maxisbey commented Jan 5, 2026

Address review feedback from PR #1827 that was auto-merged before comments could be addressed.

Motivation and Context

PR #1827 introduced stateless mode error handling but received review feedback from @Kludex that couldn't be addressed before auto-merge. This PR implements that feedback:

  1. Replace the private _require_stateful_mode() helper with a specific StatelessModeNotSupported exception and inline checks
  2. Add match= parameter to pytest.raises() calls for more specific error matching
  3. Create fixtures to reduce test boilerplate

How Has This Been Tested?

  • All 8 stateless mode tests pass
  • Pyright type checking passes
  • Ruff linting passes

Breaking Changes

None - StatelessModeNotSupported inherits from RuntimeError, so existing code catching RuntimeError will continue to work.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Changes made:

  • Added StatelessModeNotSupported exception to mcp.shared.exceptions
  • Replaced _require_stateful_mode() helper with inline checks in ServerSession
  • Created stateless_session and stateful_session fixtures in tests
  • Added match= to all pytest.raises() calls
  • Added test for the exception's method attribute

Address review feedback from PR #1827:

- Create StatelessModeNotSupported exception that inherits from RuntimeError
- Replace _require_stateful_mode() helper with inline checks in each method
- Add match= parameter to pytest.raises() calls for more specific error matching
- Create stateless_session and stateful_session fixtures to reduce test boilerplate
- Add test for exception's method attribute

Claude-Generated-By: Claude Code (cli/claude-opus-4-5=100%)
Claude-Steers: 7
Claude-Permission-Prompts: 26
Claude-Escapes: 1
@maxisbey maxisbey requested a review from Kludex January 5, 2026 18:07
@maxisbey maxisbey added bug Something isn't working P3 Nice to haves, rare edge cases labels Jan 5, 2026
Copy link
Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks better. 👍

Please read my comment on the other PR, but feel free to do what you think is best.

@maxisbey maxisbey merged commit 37de501 into main Jan 6, 2026
21 checks passed
@maxisbey maxisbey deleted the fix-stateless-mode-review-comments branch January 6, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working P3 Nice to haves, rare edge cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants