Skip to content

Commit 8be6d90

Browse files
authored
Merge pull request #722 from cliffhall/align-oauth-flows
Align Quick OAuth Flow and Simple Connect Flow with Guided OAuth Flow behavior
2 parents 6330cb4 + 28c0bf1 commit 8be6d90

File tree

8 files changed

+24
-12
lines changed

8 files changed

+24
-12
lines changed

cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"devDependencies": {},
2323
"dependencies": {
24-
"@modelcontextprotocol/sdk": "^1.17.2",
24+
"@modelcontextprotocol/sdk": "^1.17.3",
2525
"commander": "^13.1.0",
2626
"spawn-rx": "^5.1.2"
2727
}

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"cleanup:e2e": "node e2e/global-teardown.js"
2626
},
2727
"dependencies": {
28-
"@modelcontextprotocol/sdk": "^1.17.2",
28+
"@modelcontextprotocol/sdk": "^1.17.3",
2929
"@radix-ui/react-checkbox": "^1.1.4",
3030
"@radix-ui/react-dialog": "^1.1.3",
3131
"@radix-ui/react-icons": "^1.3.0",

client/src/lib/auth.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ export const clearClientInformationFromSessionStorage = ({
102102
};
103103

104104
export class InspectorOAuthClientProvider implements OAuthClientProvider {
105-
constructor(protected serverUrl: string) {
105+
constructor(
106+
protected serverUrl: string,
107+
scope?: string,
108+
) {
109+
this.scope = scope;
106110
// Save the server URL to session storage
107111
sessionStorage.setItem(SESSION_KEYS.SERVER_URL, serverUrl);
108112
}
113+
scope: string | undefined;
109114

110115
get redirectUrl() {
111116
return window.location.origin + "/oauth/callback";
@@ -119,6 +124,7 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
119124
response_types: ["code"],
120125
client_name: "MCP Inspector",
121126
client_uri: "https://github.com/modelcontextprotocol/inspector",
127+
scope: this.scope ?? "",
122128
};
123129
}
124130

client/src/lib/hooks/useConnection.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,6 @@ export function useConnection({
319319

320320
const handleAuthError = async (error: unknown) => {
321321
if (is401Error(error)) {
322-
const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
323-
324322
let scope = oauthScope?.trim();
325323
if (!scope) {
326324
// Only discover resource metadata when we need to discover scopes
@@ -334,6 +332,10 @@ export function useConnection({
334332
}
335333
scope = await discoverScopes(sseUrl, resourceMetadata);
336334
}
335+
const serverAuthProvider = new InspectorOAuthClientProvider(
336+
sseUrl,
337+
scope,
338+
);
337339

338340
const result = await auth(serverAuthProvider, {
339341
serverUrl: sseUrl,

client/src/lib/oauth-state-machine.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
177177
authorizationCode: context.state.authorizationCode,
178178
codeVerifier,
179179
redirectUri: context.provider.redirectUrl,
180-
resource: context.state.resource ?? undefined,
180+
resource: context.state.resource
181+
? context.state.resource instanceof URL
182+
? context.state.resource
183+
: new URL(context.state.resource)
184+
: undefined,
181185
});
182186

183187
context.provider.saveTokens(tokens);

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@modelcontextprotocol/inspector-cli": "^0.16.4",
5151
"@modelcontextprotocol/inspector-client": "^0.16.4",
5252
"@modelcontextprotocol/inspector-server": "^0.16.4",
53-
"@modelcontextprotocol/sdk": "^1.17.2",
53+
"@modelcontextprotocol/sdk": "^1.17.3",
5454
"concurrently": "^9.2.0",
5555
"open": "^10.2.0",
5656
"shell-quote": "^1.8.3",

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"typescript": "^5.6.2"
2828
},
2929
"dependencies": {
30-
"@modelcontextprotocol/sdk": "^1.17.2",
30+
"@modelcontextprotocol/sdk": "^1.17.3",
3131
"cors": "^2.8.5",
3232
"express": "^5.1.0",
3333
"ws": "^8.18.0",

0 commit comments

Comments
 (0)