Skip to main content
Glama

remove-account

Remove a cached Microsoft account by specifying its email address or account ID. Use list-accounts to see available accounts before removal.

Instructions

Remove a Microsoft account from the cache. Accepts email address (e.g. user@outlook.com) or account ID. Use list-accounts to discover available accounts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountYesEmail address or account ID of the account to remove

Implementation Reference

  • MCP tool registration for 'remove-account'. Defines the tool's schema (accepts 'account' string via Zod) and handler function that calls authManager.removeAccount(). Returns success/error messages.
    server.tool(
      'remove-account',
      'Remove a Microsoft account from the cache. Accepts email address (e.g. user@outlook.com) or account ID. Use list-accounts to discover available accounts.',
      {
        account: z.string().describe('Email address or account ID of the account to remove'),
      },
      async ({ account }) => {
        try {
          const success = await authManager.removeAccount(account);
          if (success) {
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({ message: `Removed account: ${account}` }),
                },
              ],
            };
          } else {
            return {
              content: [
                {
                  type: 'text',
                  text: JSON.stringify({ error: `Failed to remove account from cache: ${account}` }),
                },
              ],
              isError: true,
            };
          }
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  error: `Failed to remove account: ${(error as Error).message}`,
                }),
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Input schema for 'remove-account' tool: requires a single 'account' string parameter (email or account ID).
    {
      account: z.string().describe('Email address or account ID of the account to remove'),
    },
  • AuthManager.removeAccount() implementation. Resolves the account by identifier (email or homeAccountId), removes it from MSAL token cache, clears selection if it was the selected account, and saves state.
    async removeAccount(identifier: string): Promise<boolean> {
      const account = await this.resolveAccount(identifier);
    
      try {
        await this.msalApp.getTokenCache().removeAccount(account);
    
        // If this was the selected account, clear the selection
        if (this.selectedAccountId === account.homeAccountId) {
          this.selectedAccountId = null;
          await this.saveSelectedAccount();
          this.accessToken = null;
          this.tokenExpiry = null;
        }
    
        logger.info(`Removed account: ${account.username} (${account.homeAccountId})`);
        return true;
      } catch (error) {
        logger.error(`Failed to remove account ${identifier}: ${(error as Error).message}`);
        return false;
      }
    }
  • AuthManager.resolveAccount() helper used by removeAccount. Matches identifier against username (case-insensitive) or homeAccountId, throws if not found.
    async resolveAccount(identifier: string): Promise<AccountInfo> {
      const accounts = await this.msalApp.getTokenCache().getAllAccounts();
    
      if (accounts.length === 0) {
        throw new Error('No accounts found. Please login first.');
      }
    
      const lowerIdentifier = identifier.toLowerCase();
    
      // Try username (email) match first
      let account =
        accounts.find((a: AccountInfo) => a.username?.toLowerCase() === lowerIdentifier) ?? null;
    
      // Fall back to homeAccountId match
      if (!account) {
        account = accounts.find((a: AccountInfo) => a.homeAccountId === identifier) ?? null;
      }
    
      if (!account) {
        const availableAccounts = accounts
          .map((a: AccountInfo) => a.username || a.name || 'unknown')
          .join(', ');
        throw new Error(
          `Account '${identifier}' not found. Available accounts: ${availableAccounts}`
        );
      }
    
      return account;
    }
  • src/server.ts:103-106 (registration)
    Registration trigger: registerAuthTools() is called from server.ts, conditionally based on HTTP mode and enableAuthTools flag.
    const shouldRegisterAuthTools = !this.options.http || this.options.enableAuthTools;
    if (shouldRegisterAuthTools) {
      registerAuthTools(server, this.authManager);
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description notes that removal is from the cache, which is a key behavioral trait. However, without annotations, more detail (e.g., about reversibility, required permissions) would be beneficial.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences with no fluff: the first states the purpose, the second provides parameter and sibling guidance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool, it covers the core purpose and parameter usage, but lacks information about return values, prerequisites (e.g., being logged in), or potential side effects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, the baseline is 3. The description adds an example email and clarifies that account ID is also accepted, providing marginal extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Remove a Microsoft account from the cache') and the resource affected, distinguishing it from related tools like login, logout, and select-account.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It mentions using list-accounts to discover available accounts, providing some guidance, but does not explicitly state when not to use this tool or alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Softeria/ms-365-mcp-server'

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