Skip to main content
Glama

login

Authenticate with Microsoft services using device code flow to access Microsoft Graph API across multiple tenants.

Instructions

Authenticate with Microsoft using device code flow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
forceNoForce a new login even if already logged in

Implementation Reference

  • src/auth-tools.ts:7-57 (registration)
    Primary registration of the 'login' MCP tool, including description, Zod input schema, and the full handler implementation that manages device code login flow via AuthManager.
    server.tool( 'login', 'Authenticate with Microsoft using device code flow', { force: z.boolean().default(false).describe('Force a new login even if already logged in'), }, async ({ force }) => { try { if (!force) { const loginStatus = await authManager.testLogin(); if (loginStatus.success) { return { content: [ { type: 'text', text: JSON.stringify({ status: 'Already logged in', ...loginStatus, }), }, ], }; } } const text = await new Promise<string>((resolve, reject) => { authManager.acquireTokenByDeviceCode(resolve).catch(reject); }); return { content: [ { type: 'text', text: JSON.stringify({ error: 'device_code_required', message: text.trim(), }), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: `Authentication failed: ${(error as Error).message}` }), }, ], }; } } );
  • src/server.ts:80-83 (registration)
    Conditional invocation of registerAuthTools which registers the 'login' tool (and other auth tools) to the MCP server instance.
    const shouldRegisterAuthTools = !this.options.http || this.options.enableAuthTools; if (shouldRegisterAuthTools) { // Pass graphClient to enable the graph-request tool registerAuthTools(this.server, this.authManager, this.graphClient);

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