Skip to main content
Glama

list-accounts

Retrieve all Microsoft accounts accessible through the ForIT Microsoft Graph server to manage Microsoft 365 services across multiple tenants.

Instructions

List all available Microsoft accounts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'list-accounts' MCP tool, including description, empty input schema, and handler function that lists accounts via AuthManager and returns formatted JSON.
    server.tool('list-accounts', 'List all available Microsoft accounts', {}, async () => { try { const accounts = await authManager.listAccounts(); // No 'selected' field - accountId is always required when multiple accounts exist const result = accounts.map((account) => ({ id: account.homeAccountId, username: account.username, name: account.name, })); 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}` }), }, ], }; } });
  • The inline async handler function for the 'list-accounts' tool that executes the logic: fetches accounts from AuthManager, maps to id/username/name, and returns as MCP content.
    server.tool('list-accounts', 'List all available Microsoft accounts', {}, async () => { try { const accounts = await authManager.listAccounts(); // No 'selected' field - accountId is always required when multiple accounts exist const result = accounts.map((account) => ({ id: account.homeAccountId, username: account.username, name: account.name, })); 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}` }), }, ], }; } });
  • Supporting method in AuthManager class that retrieves all cached Microsoft accounts from the MSAL token cache.
    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