Skip to content

fix(client): map bare HTTP 401/403 to distinguishable JSON-RPC errors - #3276

Open
sgoel2be24-cyber wants to merge 2 commits into
modelcontextprotocol:mainfrom
sgoel2be24-cyber:fix/streamable-http-401-unauthorized
Open

fix(client): map bare HTTP 401/403 to distinguishable JSON-RPC errors#3276
sgoel2be24-cyber wants to merge 2 commits into
modelcontextprotocol:mainfrom
sgoel2be24-cyber:fix/streamable-http-401-unauthorized

Conversation

@sgoel2be24-cyber

@sgoel2be24-cyber sgoel2be24-cyber commented Aug 10, 2026

Copy link
Copy Markdown

Bare auth failures were collapsing into the generic "Server returned an error response" fallback, so agents could not handle operation-specific denials without tearing down the session. Surface Unauthorized/Forbidden with http_status metadata instead.

Fixes #1295

Motivation and Context

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

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

Bare auth failures were collapsing into the generic "Server returned an
error response" fallback, so agents could not handle operation-specific
denials without tearing down the session. Surface Unauthorized/Forbidden
with http_status metadata instead.

Fixes modelcontextprotocol#1295

Co-authored-by: Cursor <cursoragent@cursor.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@sgoel2be24-cyber

Copy link
Copy Markdown
Author

Thanks — noting the relationship to #3278.

#3278 correctly treats hang/teardown (#2110) as orthogonal to status-code distinguishability. This PR remains scoped to the residual #1295 ask: bare 401/403 should surface as Unauthorized/Forbidden (with http_status metadata) instead of the generic "Server returned an error response".

Happy to rebase onto the new status_error_data() helper as soon as #3278 lands, so the 401/403 mapping lives in that single place rather than inline in _handle_post_request.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

401 in Streamable HTTP should be handled gracefully

1 participant