Skip to main content
Glama

logout

Terminate active Microsoft account sessions to end access to Microsoft 365 services and protect account security.

Instructions

Log out from Microsoft account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool 'logout' handler: executes authManager.logout() and returns JSON text response with success or error message.
    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' }), }, ], }; } });
  • AuthManager.logout(): core implementation that clears MSAL token cache, removes all accounts, deletes stored credentials from keytar or fallback files, and resets auth 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; try { const kt = await getKeytar(); if (kt) { await kt.deletePassword(SERVICE_NAME, TOKEN_CACHE_ACCOUNT); await kt.deletePassword(SERVICE_NAME, SELECTED_ACCOUNT_KEY); } } catch (keytarError) { logger.warn(`Keychain deletion failed: ${(keytarError as Error).message}`); } if (fs.existsSync(FALLBACK_PATH)) { fs.unlinkSync(FALLBACK_PATH); } if (fs.existsSync(SELECTED_ACCOUNT_PATH)) { fs.unlinkSync(SELECTED_ACCOUNT_PATH); } return true; } catch (error) { logger.error(`Error during logout: ${(error as Error).message}`); throw error; } }
  • src/server.ts:81-83 (registration)
    Calls registerAuthTools which includes registration of the 'logout' tool among other auth tools.
    if (shouldRegisterAuthTools) { // Pass graphClient to enable the graph-request tool registerAuthTools(this.server, this.authManager, this.graphClient);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ForITLLC/forit-microsoft-graph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server