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 (registration)Registration of the 'verify-login' MCP tool, including its inline handler function. The handler calls authManager.testLogin() and returns the result as a text content block with JSON stringified output.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-tools.ts:82-93 (handler)The inline async handler function for the 'verify-login' tool that executes the core logic: tests login status via authManager and formats the 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:390-445 (helper)Core helper method AuthManager.testLogin() that implements the login verification logic: acquires token, tests Graph /me endpoint, returns success status with user data or error message.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)TypeScript interface defining the structure of the login test result returned by testLogin(), used as output schema for the verify-login tool.interface LoginTestResult { success: boolean; message: string; userData?: { displayName: string; userPrincipalName: string; }; }
- src/server.ts:83-84 (registration)Call to registerAuthTools which includes registration of verify-login among other auth tools.registerAuthTools(this.server, this.authManager, this.graphClient); }