logout
Sign out of your Microsoft account to end the current session.
Instructions
Log out from Microsoft account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/auth-tools.ts:75-96 (handler)The MCP tool registration for 'logout' – defines the tool handler that calls authManager.logout() and returns success/failure JSON response.
server.tool('logout', 'Log out from Microsoft account', {}, async () => { try { await authManager.logout(); return { content: [ { type: 'text', text: JSON.stringify({ message: 'Logged out successfully' }), }, ], }; } catch { return { content: [ { type: 'text', text: JSON.stringify({ error: 'Logout failed' }), }, ], }; } }); - src/auth.ts:839-857 (helper)The actual logout logic: clears MSAL token cache accounts, removes cached token/account data from storage, and resets in-memory state.
async logout(): Promise<boolean> { try { const accounts = await this.msalApp.getTokenCache().getAllAccounts(); for (const account of accounts) { await this.msalApp.getTokenCache().removeAccount(account); } this.accessToken = null; this.tokenExpiry = null; this.selectedAccountId = null; await this.storage.delete('token-cache'); await this.storage.delete('selected-account'); return true; } catch (error) { logger.error(`Error during logout: ${(error as Error).message}`); throw error; } } - src/auth-tools.ts:75-96 (registration)The 'logout' tool is registered via server.tool() in the registerAuthTools function in src/auth-tools.ts.
server.tool('logout', 'Log out from Microsoft account', {}, async () => { try { await authManager.logout(); return { content: [ { type: 'text', text: JSON.stringify({ message: 'Logged out successfully' }), }, ], }; } catch { return { content: [ { type: 'text', text: JSON.stringify({ error: 'Logout failed' }), }, ], }; } }); - src/auth-tools.ts:75-75 (schema)The 'logout' tool's schema: no input parameters (empty object {}) and returns JSON text content.
server.tool('logout', 'Log out from Microsoft account', {}, async () => { - src/cli.ts:20-20 (helper)CLI option definition for --logout flag used outside MCP tool mode (non-HTTP/stdio CLI mode).
.option('--logout', 'Log out and clear saved credentials')