Skip to content

Commit b8fdf10

Browse files
christsoclaude
andcommitted
fix: add type safety and changeset
- Fix TypeScript error by properly typing json as unknown - Add changeset for the patch release Fixes modelcontextprotocol#1342 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 521bbc8 commit b8fdf10

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎.changeset/oauth-error-http200.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modelcontextprotocol/client': patch
3+
---
4+
5+
Fix OAuth error handling for servers returning errors with HTTP 200 status
6+
7+
Some OAuth servers (e.g., GitHub) return error responses with HTTP 200 status instead of 4xx. The SDK now checks for an `error` field in the JSON response before attempting to parse it as tokens, providing users with meaningful error messages.

‎packages/client/src/client/auth.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,11 @@ async function executeTokenRequest(
10861086
throw await parseErrorResponse(response);
10871087
}
10881088

1089-
const json = await response.json();
1089+
const json: unknown = await response.json();
10901090

10911091
// Some OAuth servers (e.g., GitHub) return error responses with HTTP 200 status.
10921092
// Check for error field before attempting to parse as tokens.
1093-
if (json.error) {
1093+
if (typeof json === 'object' && json !== null && 'error' in json) {
10941094
throw await parseErrorResponse(JSON.stringify(json));
10951095
}
10961096

0 commit comments

Comments
 (0)