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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the authentication method. It doesn't disclose behavioral traits like required permissions, whether this persists credentials, rate limits, or what happens on success/failure. The description adds minimal context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and uses precise technical terminology ('device code flow') without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an authentication tool with no annotations and no output schema, the description is insufficient. It doesn't explain what authentication provides access to, what credentials are stored, how long sessions last, or what the tool returns. Given the complexity of authentication and lack of structured data, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage and only one optional parameter, the description doesn't need to explain parameters. The schema fully documents the 'force' parameter, so baseline is high. The description focuses appropriately on the tool's purpose rather than parameter details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Authenticate') and target ('with Microsoft'), using the precise authentication method ('device code flow'). It distinguishes from siblings like 'verify-login' or 'logout' by specifying the authentication mechanism.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies this tool is for initial authentication, but doesn't explicitly state when to use it versus alternatives like 'verify-login' (for checking status) or 'select-account' (for switching accounts). No explicit exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/m365-mcp-suite'

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