m365_userrealm
Detect the authentication type for a domain's Microsoft 365 tenant, returning namespace type, federation brand, and authentication endpoints.
Instructions
Detect authentication type for a domain's Microsoft 365 tenant. Returns namespace type (Managed/Federated), federation brand name, and auth endpoints.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain to check user realm for |
Implementation Reference
- src/m365/index.ts:57-83 (handler)The core execution function for m365_userrealm. Calls Microsoft's getuserrealm.srf API to detect authentication type (Managed/Federated) for a domain. Returns namespace type, federation brand name, auth URLs, and cloud instance name.
export async function m365UserRealm(domain: string): Promise<M365UserRealmResult> { try { const res = await fetch( `https://login.microsoftonline.com/getuserrealm.srf?login=test@${encodeURIComponent(domain)}&json=1`, ); if (!res.ok) return { domain, found: false }; const data = await res.json(); // NameSpaceType 0 = Unknown, 1 = Managed, 2 = Federated let namespaceType: string | undefined; if (data.NameSpaceType === "Managed" || data.NameSpaceType === 1) namespaceType = "Managed"; else if (data.NameSpaceType === "Federated" || data.NameSpaceType === 2) namespaceType = "Federated"; else if (data.NameSpaceType !== undefined) namespaceType = String(data.NameSpaceType); return { domain, found: namespaceType !== undefined, namespaceType, federationBrandName: data.FederationBrandName, federationActiveAuthUrl: data.AuthURL ?? data.STSAuthUrl, cloudInstanceName: data.CloudInstanceName ?? data.CloudInstanceIssuerUri, }; } catch { return { domain, found: false }; } } - src/m365/index.ts:13-20 (schema)Interface M365UserRealmResult defining the return type: domain, found, namespaceType, federationBrandName, federationActiveAuthUrl, cloudInstanceName.
interface M365UserRealmResult { domain: string; found: boolean; namespaceType?: string; // "Managed" or "Federated" federationBrandName?: string; federationActiveAuthUrl?: string; cloudInstanceName?: string; } - src/protocol/tools.ts:448-455 (registration)ToolDef registration for m365_userrealm. Defines name ('m365_userrealm'), description, schema (zod: domain string), and execute handler that calls m365UserRealm().
const m365UserRealmTool: ToolDef = { name: "m365_userrealm", description: "Detect authentication type for a domain's Microsoft 365 tenant. Returns namespace type (Managed/Federated), federation brand name, and auth endpoints.", schema: { domain: z.string().describe("Domain to check user realm for"), }, execute: async (args) => json(await m365UserRealm(args.domain as string)), }; - src/protocol/tools.ts:528-528 (registration)Tool registered in the allTools array export (line 528: m365UserRealmTool) that makes it available to the MCP server.
m365UserRealmTool, - src/index.ts:34-34 (registration)Tool listed under 'Microsoft 365' category for CLI help/--list display (no API key required).
{ label: "Microsoft 365", env: null, tools: ["m365_tenant", "m365_userrealm"] },