Skip to main content
Glama

list-accounts

Retrieve all available Microsoft accounts for managing Microsoft 365 services across multiple tenants.

Instructions

List all available Microsoft accounts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The inline handler function for the 'list-accounts' MCP tool. It fetches all accounts using authManager.listAccounts(), identifies the selected one, maps to a simple format, and returns as JSON text content.
    server.tool('list-accounts', 'List all available Microsoft accounts', {}, async () => { try { const accounts = await authManager.listAccounts(); const selectedAccountId = authManager.getSelectedAccountId(); const result = accounts.map((account) => ({ id: account.homeAccountId, username: account.username, name: account.name, selected: account.homeAccountId === selectedAccountId, })); return { content: [ { type: 'text', text: JSON.stringify({ accounts: result }), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: `Failed to list accounts: ${(error as Error).message}` }), }, ], }; } });
  • Registration of the 'list-accounts' tool on the MCP server within registerAuthTools, including empty input schema {} and the handler.
    server.tool('list-accounts', 'List all available Microsoft accounts', {}, async () => { try { const accounts = await authManager.listAccounts(); const selectedAccountId = authManager.getSelectedAccountId(); const result = accounts.map((account) => ({ id: account.homeAccountId, username: account.username, name: account.name, selected: account.homeAccountId === selectedAccountId, })); return { content: [ { type: 'text', text: JSON.stringify({ accounts: result }), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: `Failed to list accounts: ${(error as Error).message}` }), }, ], }; } });
  • AuthManager.listAccounts() method, which retrieves all cached accounts from the MSAL token cache. Called by the tool handler.
    async listAccounts(): Promise<AccountInfo[]> { return await this.msalApp.getTokenCache().getAllAccounts(); }

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