Skip to main content
Glama

remove-account

Remove cached Microsoft accounts to manage authentication data and free up storage space in the ForIT Microsoft Graph server.

Instructions

Remove a Microsoft account from the cache

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesThe account ID to remove

Implementation Reference

  • MCP tool registration for 'remove-account', including input schema (accountId: string), description, and handler function that delegates to AuthManager.removeAccount and returns success/error message
    server.tool( 'remove-account', 'Remove a Microsoft account from the cache', { accountId: z.string().describe('The account ID to remove'), }, async ({ accountId }) => { try { const success = await authManager.removeAccount(accountId); if (success) { return { content: [ { type: 'text', text: JSON.stringify({ message: `Removed account: ${accountId}` }), }, ], }; } else { return { content: [ { type: 'text', text: JSON.stringify({ error: `Account not found: ${accountId}` }), }, ], }; } } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: `Failed to remove account: ${(error as Error).message}`, }), }, ], }; } } );
  • Input schema validation using Zod for the accountId parameter
    accountId: z.string().describe('The account ID to remove'),
  • Handler function for 'remove-account' tool that calls AuthManager.removeAccount(accountId) and formats the response as MCP content
    async ({ accountId }) => { try { const success = await authManager.removeAccount(accountId); if (success) { return { content: [ { type: 'text', text: JSON.stringify({ message: `Removed account: ${accountId}` }), }, ], }; } else { return { content: [ { type: 'text', text: JSON.stringify({ error: `Account not found: ${accountId}` }), }, ], }; } } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: `Failed to remove account: ${(error as Error).message}`, }), }, ], }; } }
  • Core implementation in AuthManager.removeAccount: finds account by homeAccountId, removes from MSAL token cache, clears selection if needed
    async removeAccount(accountId: string): Promise<boolean> { const accounts = await this.listAccounts(); const account = accounts.find((acc: AccountInfo) => acc.homeAccountId === accountId); if (!account) { logger.error(`Account with ID ${accountId} not found`); return false; } try { await this.msalApp.getTokenCache().removeAccount(account); // If this was the selected account, clear the selection if (this.selectedAccountId === accountId) { this.selectedAccountId = null; await this.saveSelectedAccount(); this.accessToken = null; this.tokenExpiry = null; } logger.info(`Removed account: ${account.username} (${accountId})`); return true; } catch (error) { logger.error(`Failed to remove account ${accountId}: ${(error as Error).message}`); return false; } }
  • src/server.ts:83-84 (registration)
    Call to registerAuthTools which includes the 'remove-account' tool registration (conditional on !options.http || options.enableAuthTools)
    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