list_accounts
Retrieve all signed-in Microsoft accounts using the MCP server, enabling AI assistants to interact with Microsoft services via natural language commands.
Instructions
List all signed-in Microsoft accounts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/microsoft_mcp/tools.py:23-29 (handler)The MCP tool handler for list_accounts, decorated with @mcp.tool. It lists all signed-in Microsoft accounts by calling the auth.list_accounts() helper and formatting the results as a list of dicts with username and account_id.@mcp.tool def list_accounts() -> list[dict[str, str]]: """List all signed-in Microsoft accounts""" return [ {"username": acc.username, "account_id": acc.account_id} for acc in auth.list_accounts() ]
- src/microsoft_mcp/auth.py:92-98 (helper)Supporting helper function that retrieves accounts from the MSAL PublicClientApplication's token cache and returns them as a list of Account namedtuples (username and account_id). Used by the list_accounts tool handler.def list_accounts() -> list[Account]: app = get_app() return [ Account(username=a["username"], account_id=a["home_account_id"]) for a in app.get_accounts() ]
- src/microsoft_mcp/server.py:3-3 (registration)Import of mcp from tools.py in server.py, which registers all @mcp.tool decorated functions when the module is imported before mcp.run() is called.from .tools import mcp