Skip to main content
Glama

logout

Ends the current Microsoft account session in ForIT Microsoft Graph, disconnecting access to Microsoft 365 services across managed tenants.

Instructions

Log out from Microsoft account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the 'logout' tool with the MCP server. Includes empty input schema and an inline handler that calls authManager.logout() to perform the logout and returns a 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' }), }, ], }; } });
  • The inline handler function for the logout tool that executes the core logic: invokes authManager.logout() and formats the MCP 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' }), }, ], }; } });
  • The AuthManager.logout() helper method that clears all accounts from MSAL token cache, removes credentials from keytar/file storage, clears internal state, and handles errors.
    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; }

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