UNPKG

@davidmoore-io/ms-365-mcp-server

Version:

Microsoft 365 MCP Server - Fork with pre-authenticated token support

36 lines (35 loc) 1.38 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import logger, { enableConsoleLogging } from './logger.js'; import { registerAuthTools } from './auth-tools.js'; import { registerGraphTools } from './graph-tools.js'; import GraphClient from './graph-client.js'; class MicrosoftGraphServer { constructor(authManager, options = {}) { this.authManager = authManager; this.options = options; this.graphClient = new GraphClient(authManager); this.server = null; } async initialize(version) { this.server = new McpServer({ name: 'Microsoft365MCP', version, }); registerAuthTools(this.server, this.authManager); registerGraphTools(this.server, this.graphClient, this.options.readOnly); } async start() { if (this.options.v) { enableConsoleLogging(); } logger.info('Microsoft 365 MCP Server starting...'); if (this.options.readOnly) { logger.info('Server running in READ-ONLY mode. Write operations are disabled.'); } const transport = new StdioServerTransport(); await this.server.connect(transport); logger.info('Server connected to transport'); } } export default MicrosoftGraphServer;