verify-login
Check current Microsoft authentication status to verify login validity before accessing Microsoft 365 services across multiple tenants.
Instructions
Check current Microsoft authentication status
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/auth-tools.ts:82-93 (handler)The inline handler and registration for the 'verify-login' MCP tool. It calls AuthManager.testLogin() and returns the result as a text content block with JSON stringified response.server.tool('verify-login', 'Check current Microsoft authentication status', {}, async () => { const testResult = await authManager.testLogin(); return { content: [ { type: 'text', text: JSON.stringify(testResult), }, ], }; });
- src/auth.ts:374-429 (helper)The core helper method AuthManager.testLogin() that implements the login verification logic: acquires an access token, tests it against the Microsoft Graph /me endpoint, and returns a structured result indicating success and user info.async testLogin(): Promise<LoginTestResult> { try { logger.info('Testing login...'); const token = await this.getToken(); if (!token) { logger.error('Login test failed - no token received'); return { success: false, message: 'Login failed - no token received', }; } logger.info('Token retrieved successfully, testing Graph API access...'); try { const response = await fetch('https://graph.microsoft.com/v1.0/me', { headers: { Authorization: `Bearer ${token}`, }, }); if (response.ok) { const userData = await response.json(); logger.info('Graph API user data fetch successful'); return { success: true, message: 'Login successful', userData: { displayName: userData.displayName, userPrincipalName: userData.userPrincipalName, }, }; } else { const errorText = await response.text(); logger.error(`Graph API user data fetch failed: ${response.status} - ${errorText}`); return { success: false, message: `Login successful but Graph API access failed: ${response.status}`, }; } } catch (graphError) { logger.error(`Error fetching user data: ${(graphError as Error).message}`); return { success: false, message: `Login successful but Graph API access failed: ${(graphError as Error).message}`, }; } } catch (error) { logger.error(`Login test failed: ${(error as Error).message}`); return { success: false, message: `Login failed: ${(error as Error).message}`, }; } }
- src/auth.ts:129-136 (schema)Type definition for the LoginTestResult returned by testLogin(), defining the output structure used by the verify-login tool.interface LoginTestResult { success: boolean; message: string; userData?: { displayName: string; userPrincipalName: string; }; }