Skip to content

Commit 7cad9a0

Browse files
authored
Merge pull request modelcontextprotocol#280 from max-stytch/max/disconnect
fix: Disconnecting should clear oauth state
2 parents 3aa8753 + 7c8f292 commit 7cad9a0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

client/src/lib/auth.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,16 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
8888

8989
return verifier;
9090
}
91+
92+
clear() {
93+
sessionStorage.removeItem(
94+
getServerSpecificKey(SESSION_KEYS.CLIENT_INFORMATION, this.serverUrl),
95+
);
96+
sessionStorage.removeItem(
97+
getServerSpecificKey(SESSION_KEYS.TOKENS, this.serverUrl),
98+
);
99+
sessionStorage.removeItem(
100+
getServerSpecificKey(SESSION_KEYS.CODE_VERIFIER, this.serverUrl),
101+
);
102+
}
91103
}

client/src/lib/hooks/useConnection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ export function useConnection({
396396

397397
const disconnect = async () => {
398398
await mcpClient?.close();
399+
const authProvider = new InspectorOAuthClientProvider(sseUrl);
400+
authProvider.clear();
399401
setMcpClient(null);
400402
setConnectionStatus("disconnected");
401403
setCompletionsSupported(false);

0 commit comments

Comments
 (0)