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);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Remove' implies a destructive mutation, it doesn't specify whether this operation is reversible, what permissions are required, whether it affects active sessions, or what happens on success/failure. The mention of 'cache' hints at data removal rather than account deletion, but this isn't elaborated.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core action and resource, making it immediately scannable and easy to understand.

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

Completeness2/5

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

For a destructive tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'remove' entails (e.g., does it delete data, revoke access, or clear local cache?), what the expected outcome is, or potential side effects. Given the complexity of account management and lack of structured context, more detail is needed.

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?

The input schema has 100% description coverage, with the single parameter 'accountId' clearly documented. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or where to obtain the accountId. Since schema coverage is high, the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the action ('Remove') and target resource ('a Microsoft account from the cache'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'logout' or 'select-account', which might also involve account management operations.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether the account must be logged in or cached first), nor does it clarify relationships with sibling tools like 'logout' (which might handle session termination) or 'list-accounts' (which could show cached accounts).

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/ForITLLC/m365-mcp-suite'

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