UNPKG

@softeria/ms-365-mcp-server

Version:
40 lines (39 loc) 1.36 kB
#!/usr/bin/env node import { parseArgs } from './cli.js'; import logger from './logger.js'; import AuthManager from './auth.js'; import MicrosoftGraphServer from './server.js'; import { version } from './version.js'; async function main() { try { const args = parseArgs(); const authManager = new AuthManager(); await authManager.loadTokenCache(); if (args.login) { await authManager.acquireTokenByDeviceCode(); logger.info('Login completed, testing connection with Graph API...'); const result = await authManager.testLogin(); console.log(JSON.stringify(result)); process.exit(0); } if (args.verifyLogin) { logger.info('Verifying login...'); const result = await authManager.testLogin(); console.log(JSON.stringify(result)); process.exit(0); } if (args.logout) { await authManager.logout(); console.log(JSON.stringify({ message: 'Logged out successfully' })); process.exit(0); } const server = new MicrosoftGraphServer(authManager, args); await server.initialize(version); await server.start(); } catch (error) { logger.error(`Startup error: ${error}`); process.exit(1); } } main();