Skip to main content
Glama

select-account

Choose a specific Microsoft account to access Microsoft Graph API services across multiple tenants, enabling interaction with Microsoft 365 resources.

Instructions

Select a specific Microsoft account to use

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesThe account ID to select

Implementation Reference

  • Registration of the MCP 'select-account' tool, including schema (accountId: string) and handler that calls AuthManager.selectAccount() and formats response.
    server.tool( 'select-account', 'Select a specific Microsoft account to use', { accountId: z.string().describe('The account ID to select'), }, async ({ accountId }) => { try { const success = await authManager.selectAccount(accountId); if (success) { return { content: [ { type: 'text', text: JSON.stringify({ message: `Selected 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 select account: ${(error as Error).message}`, }), }, ], }; } } );
  • Core implementation of account selection logic in AuthManager: locates account by ID, updates selectedAccountId, persists to storage (keytar/file), clears token cache for refresh.
    async selectAccount(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; } this.selectedAccountId = accountId; await this.saveSelectedAccount(); // Clear cached tokens to force refresh with new account this.accessToken = null; this.tokenExpiry = null; logger.info(`Selected account: ${account.username} (${accountId})`); return true; }
  • src/server.ts:82-84 (registration)
    Calls registerAuthTools to register all authentication tools including 'select-account' on the MCP server.
    // 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