This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm install- ALWAYS run first to install dependenciesnpm start- Start the MCP servernpm run auth-server- Start the OAuth authentication server on port 3333 (required for authentication)npm run test-mode- Start the server in test mode with mock datanpm run inspect- Use MCP Inspector to test the server interactivelynpm test- Run Jest tests./test-modular-server.sh- Test the server using MCP Inspector./test-direct.sh- Direct testing scriptnpx kill-port 3333- Kill process using port 3333 if auth server won't start
This is a modular MCP (Model Context Protocol) server that provides Claude with access to Microsoft Outlook via the Microsoft Graph API. The architecture is organized into functional modules:
index.js- Main entry point that combines all module tools and handles MCP protocolconfig.js- Centralized configuration including API endpoints, field selections, and authentication settingsoutlook-auth-server.js- Standalone OAuth server for authentication flow
Each module exports tools and handlers:
auth/- OAuth 2.0 authentication with token managementcalendar/- Calendar operations (list, create, accept, decline, delete events)email/- Email management (list, search, read, send, mark as read)folder/- Folder operations (list, create, move)rules/- Email rules managementutils/- Shared utilities including Graph API client and OData helpers
- Token Management: Tokens stored in
~/.outlook-mcp-tokens.json - Graph API Client:
utils/graph-api.jshandles all Microsoft Graph API calls with proper OData encoding - Test Mode: Mock data responses when
USE_TEST_MODE=true - Modular Tools: Each module exports tools array that gets combined in main server
- Azure app registration required with specific permissions (Mail.Read, Mail.Send, Calendars.ReadWrite, etc.)
- Start auth server:
npm run auth-server - Use authenticate tool to get OAuth URL
- Complete browser authentication
- Tokens automatically stored and refreshed
- For .env file: Use
MS_CLIENT_IDandMS_CLIENT_SECRET - For Claude Desktop config: Use
OUTLOOK_CLIENT_IDandOUTLOOK_CLIENT_SECRET - Important: Always use the client secret VALUE from Azure, not the Secret ID
- Copy
.env.exampleto.envand populate with real Azure credentials - Default timezone is "Central European Standard Time"
- Default page size is 25, max results 50
- Missing dependencies: Always run
npm installfirst - Wrong secret: Use Azure secret VALUE, not ID (AADSTS7000215 error)
- Auth server not running: Start
npm run auth-serverbefore authenticating - Port conflicts: Use
npx kill-port 3333if port is in use
Set USE_TEST_MODE=true to use mock data instead of real API calls. Mock responses are defined in utils/mock-data.js.
The Graph API client properly handles OData filters with URI encoding. Filters are processed separately from other query parameters to ensure correct escaping of special characters.
- Authentication failures return "UNAUTHORIZED" error
- Graph API errors include status codes and response details
- Token expiration triggers re-authentication flow
- Empty API responses are handled gracefully (returns '{}' if empty)