Skip to main content
Glama
badchars

osint-mcp-server

by badchars

m365_tenant

Discover Microsoft 365 tenant information including tenant ID, region, and OpenID configuration endpoints for a specified domain.

Instructions

Discover Microsoft 365 tenant information for a domain. Returns tenant ID, region, and OpenID configuration endpoints.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain to check for M365 tenant

Implementation Reference

  • The m365Tenant function performs the core logic for the 'm365_tenant' tool by fetching OpenID configuration from Microsoft's servers.
    export async function m365Tenant(domain: string): Promise<M365TenantResult> {
      try {
        const res = await fetch(
          `https://login.microsoftonline.com/${encodeURIComponent(domain)}/v2.0/.well-known/openid-configuration`,
        );
        if (!res.ok) return { domain, found: false };
    
        const data = await res.json();
        const issuer: string = data.issuer ?? "";
    
        // Extract tenant ID from issuer URL: https://login.microsoftonline.com/{tenant-id}/v2.0
        const tenantMatch = issuer.match(/\/([0-9a-f-]{36})\//);
        const tenantId = tenantMatch?.[1];
    
        // Extract region from tenant_region_scope
        const region = data.tenant_region_scope;
    
        return {
          domain,
          found: true,
          tenantId,
          issuer,
          authorizationEndpoint: data.authorization_endpoint,
          tokenEndpoint: data.token_endpoint,
          region,
        };
      } catch {
        return { domain, found: false };
      }
    }
  • The M365TenantResult interface defines the output structure for the 'm365_tenant' tool.
    interface M365TenantResult {
      domain: string;
      found: boolean;
      tenantId?: string;
      issuer?: string;
      authorizationEndpoint?: string;
      tokenEndpoint?: string;
      region?: string;
    }
  • The 'm365_tenant' tool is registered in src/protocol/tools.ts, mapping the name and schema to the implementation.
    const m365TenantTool: ToolDef = {
      name: "m365_tenant",
      description: "Discover Microsoft 365 tenant information for a domain. Returns tenant ID, region, and OpenID configuration endpoints.",
      schema: {
        domain: z.string().describe("Domain to check for M365 tenant"),
      },
      execute: async (args) => json(await m365Tenant(args.domain as string)),
    };

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/badchars/osint-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server