verify-login
Check your current authentication status with Microsoft 365 to confirm you are logged in and have access to Microsoft services.
Instructions
Check current Microsoft authentication status
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/auth-tools.ts:98-117 (handler)The actual handler function for the 'verify-login' tool. Calls authManager.testLogin() and returns the result as JSON.
server.tool('verify-login', 'Check current Microsoft authentication status', {}, async () => { let testResult: Awaited<ReturnType<AuthManager['testLogin']>>; try { testResult = await authManager.testLogin(); } catch (error) { testResult = { success: false, message: `Login failed: ${(error as Error).message}`, }; } return { content: [ { type: 'text', text: JSON.stringify(testResult), }, ], }; }); - src/auth-tools.ts:5-5 (registration)The registerAuthTools function registers the 'verify-login' tool on the server via server.tool().
export function registerAuthTools(server: McpServer, authManager: AuthManager): void { - src/auth.ts:354-361 (schema)The LoginTestResult interface defining the shape of the return value from testLogin().
interface LoginTestResult { success: boolean; message: string; userData?: { displayName: string; userPrincipalName: string; }; } - src/auth.ts:780-835 (helper)The testLogin() method on AuthManager that actually performs the login verification by getting a token and testing Graph API access.
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 secrets = await getSecrets(); const cloudEndpoints = getCloudEndpoints(secrets.cloudType); const response = await fetch(`${cloudEndpoints.graphApi}/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}`, };