Skip to content

Commit 253db5e

Browse files
Enhance logout to clear MCP OAuth tokens and disconnect all servers
## Problem The logout button only cleared inference provider authentication, leaving MCP OAuth tokens and server connections active. Users remained authenticated to MCP servers after logging out. ## Solution - **Clear MCP OAuth tokens**: Remove OAuth tokens and state for all MCP connections - **Disconnect all servers**: Remove all MCP server connections on logout - **Complete cleanup**: Comprehensive logout that clears all authentication state - **Enhanced confirmation**: Updated dialog to inform users about MCP disconnection ## Technical Implementation - Added MCP context integration to access connections and removal methods - Clear OAuth tokens from localStorage for each OAuth-enabled connection - Remove all MCP servers to properly disconnect and clean up connections - Maintained existing inference provider logout functionality ## User Experience - ✅ **Complete logout**: All authentication state cleared (inference + MCP) - ✅ **Clean slate**: No residual authentication data after logout - ✅ **Clear communication**: User informed about full scope of logout action - ✅ **Security**: No orphaned authentication tokens left behind ## Data Cleared on Logout - Inference provider API keys and OAuth tokens - MCP OAuth tokens and authentication state - Model selection preferences - All active MCP server connections Note: Conversation history remains intact as it's stored separately from auth data. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c726e63 commit 253db5e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/components/ConversationSidebar.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useConversation } from '@/contexts/ConversationContext';
44
import { useInference } from '@/contexts/InferenceContext';
5+
import { useMCP } from '@/contexts/MCPContext';
56

67
export function ConversationSidebar() {
78
const {
@@ -13,14 +14,30 @@ export function ConversationSidebar() {
1314
} = useConversation();
1415

1516
const { clearProvider, provider } = useInference();
17+
const { connections, removeMcpServer } = useMCP();
1618

1719
const handleNewConversation = () => {
1820
createConversation();
1921
};
2022

2123
const handleLogout = () => {
22-
if (confirm('Are you sure you want to log out?')) {
24+
if (confirm('Are you sure you want to log out? This will disconnect all MCP servers and clear your authentication.')) {
25+
// Clear inference provider authentication
2326
clearProvider();
27+
28+
// Clear MCP OAuth tokens for all connections
29+
connections.forEach(connection => {
30+
if (connection.authType === 'oauth') {
31+
// Clear OAuth tokens and state for this connection
32+
localStorage.removeItem(`mcp_oauth_tokens_${connection.id}`);
33+
localStorage.removeItem(`mcp_oauth_state_${connection.id}`);
34+
}
35+
});
36+
37+
// Remove all MCP servers (this will disconnect them)
38+
connections.forEach(connection => {
39+
removeMcpServer(connection.id);
40+
});
2441
}
2542
};
2643

0 commit comments

Comments
 (0)