simply-outlook-mcp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +203 -0
  3. package/dist/auth-utils.d.ts +3 -0
  4. package/dist/auth-utils.js +64 -0
  5. package/dist/common/console-logger.d.ts +11 -0
  6. package/dist/common/console-logger.js +32 -0
  7. package/dist/common/logger.types.d.ts +7 -0
  8. package/dist/common/logger.types.js +2 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +49 -0
  11. package/dist/simply-outlook/graph-service.d.ts +30 -0
  12. package/dist/simply-outlook/graph-service.js +338 -0
  13. package/dist/simply-outlook/graph-service.types.d.ts +28 -0
  14. package/dist/simply-outlook/graph-service.types.js +2 -0
  15. package/dist/simply-outlook-mcp.d.ts +4 -0
  16. package/dist/simply-outlook-mcp.js +50 -0
  17. package/dist/simply-outlook-mcp.types.d.ts +5 -0
  18. package/dist/simply-outlook-mcp.types.js +6 -0
  19. package/dist/tools/create-calendar-event-with-invite.d.ts +4 -0
  20. package/dist/tools/create-calendar-event-with-invite.js +49 -0
  21. package/dist/tools/create-calendar-event.d.ts +4 -0
  22. package/dist/tools/create-calendar-event.js +41 -0
  23. package/dist/tools/get-calendar-events.d.ts +4 -0
  24. package/dist/tools/get-calendar-events.js +61 -0
  25. package/dist/tools/get-outlook-message-content.d.ts +4 -0
  26. package/dist/tools/get-outlook-message-content.js +31 -0
  27. package/dist/tools/get-outlook-messages.d.ts +4 -0
  28. package/dist/tools/get-outlook-messages.js +48 -0
  29. package/dist/tools/reply-outlook-message.d.ts +4 -0
  30. package/dist/tools/reply-outlook-message.js +26 -0
  31. package/dist/tools/search-outlook-messages.d.ts +4 -0
  32. package/dist/tools/search-outlook-messages.js +35 -0
  33. package/dist/tools/send-outlook-message.d.ts +4 -0
  34. package/dist/tools/send-outlook-message.js +22 -0
  35. package/dist/tools/tool-utils.d.ts +93 -0
  36. package/dist/tools/tool-utils.js +133 -0
  37. package/dist/tools/update-calendar-event.d.ts +4 -0
  38. package/dist/tools/update-calendar-event.js +36 -0
  39. package/dist/version.d.ts +1 -0
  40. package/dist/version.js +2 -0
  41. package/package.json +75 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 hmmroger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # Simply Outlook MCP Server
2
+
3
+ A Model Context Protocol (MCP) server that enables AI assistants to interact with Microsoft Outlook calendars and emails through the Microsoft Graph API.
4
+
5
+ ## 🚀 Features
6
+
7
+ ### 📅 Calendar Management
8
+ - **Get Calendar Events** - Retrieve calendar events within specified date ranges
9
+ - **Create Calendar Events** - Create personal calendar events
10
+ - **Create Events with Invites** - Create calendar events and send invitations to attendees
11
+ - **Update Calendar Events** - Modify existing calendar events (subject, time, location, etc.)
12
+
13
+ ### 📧 Email Operations
14
+ - **Get Messages** - Fetch recent Outlook messages with date filtering
15
+ - **Get Message Content** - Retrieve full content of specific messages by ID
16
+ - **Search Messages** - Search emails by keywords (sender, subject, content)
17
+ - **Send Messages** - Send new emails to specified recipients
18
+ - **Reply to Messages** - Reply to existing email messages
19
+ - **Pagination Support** - Handle large result sets with skip/limit parameters
20
+
21
+ ### ⚙️ Configuration
22
+ - **Selective Tool Control** - Enable/disable individual tools via environment variables
23
+ - **Environment Configuration** - Flexible setup via environment variables
24
+ - **TypeScript Support** - Full type definitions included
25
+
26
+ ## 📋 Prerequisites
27
+
28
+ - [**Node.js**](https://nodejs.org/) 20.19.0 or higher
29
+ - **Azure AD Application**:
30
+ - `Calendars.ReadWrite` - Read and write calendar events
31
+ - `Mail.Read` - Read email messages
32
+ - `Mail.Send` - Send email messages
33
+ - `User.Read` - Read user profile information
34
+
35
+ ## 🛠️ Installation
36
+
37
+ ### Using npx (Recommended)
38
+ No installation required! Simply use `npx` to run the latest version:
39
+
40
+ ### Global Installation (Optional)
41
+ If you prefer to install globally:
42
+
43
+ ```bash
44
+ npm install -g simply-outlook-mcp
45
+ ```
46
+
47
+ ### From Source
48
+ For development or customization:
49
+
50
+ ```bash
51
+ npm install
52
+ npm run build
53
+ ```
54
+
55
+ ## 🔧 Setup
56
+
57
+ > [!NOTE]
58
+ > **Security Best Practice**: We recommend creating your own Azure AD application rather than using a client ID from an unknown 3rd party or untrusted publisher.
59
+ >
60
+ > This MCP server runs locally. The code that uses the Microsoft Graph access tokens stays on your machine. The Azure AD / Entra "client ID" you supply only tells the directory *which* app registration to issue tokens for. If you reuse an arbitrary or third‑party client ID, you do **not** automatically leak your tokens to that party, but you *are* accepting several avoidable risks tied to the *app registration* that they control.
61
+ >
62
+ > **What a third party CAN change later if you use their client ID:**
63
+ > - Display name / branding you see during future consent prompts (could lower your guard)
64
+ > - The set of requested delegated scopes (you may click "Accept" again out of habit)
65
+ > - Publisher domain / verification state (influences user trust signals)
66
+ > - Authentication settings (enabling flows they host to phish you for tokens)
67
+ >
68
+
69
+ ### 1. Azure AD Application Registration
70
+
71
+ 1. Go to the [Azure Portal](https://portal.azure.com/)
72
+ 2. Navigate to **Microsoft Entra ID** > **Manage** > **App registrations**
73
+ 3. Click **New registration**
74
+ 4. Configure:
75
+ - **Name**: (Any name you like, will show up in the consent dialog)
76
+ - **Supported account types**: `Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)`
77
+ - **Redirect URI**: Leave blank
78
+ 5. After creation, in the application resource view, note down client ID in the **Overview** page:
79
+ - **Application (client) ID**
80
+ 6. In the application resource view, go to **Manage** > **Authentication** page:
81
+ - Toggle `Enable the following mobile and desktop flows` to `Yes`
82
+
83
+ > [!NOTE]
84
+ > The scopes currently requested by this MCP are designed to work with personal Microsoft account (MSA).
85
+
86
+ ### 2. Authentication Setup
87
+
88
+ ```bash
89
+ npx simply-outlook-mcp --auth --client_id YOUR_CLIENT_ID
90
+ ```
91
+
92
+ This will open a browser for device authentication. Sign in with your Microsoft account that has access to the Outlook data you want to manage.
93
+
94
+ ## 🚀 Usage
95
+
96
+ ### Using with MCP Clients
97
+
98
+ The server implements the Model Context Protocol and can be used with any MCP-compatible AI assistant.
99
+
100
+ ### Example configuration for Claude Desktop:
101
+
102
+ ```json
103
+ {
104
+ "mcpServers": {
105
+ "simply-outlook-mcp": {
106
+ "command": "npx",
107
+ "args": [
108
+ "-y",
109
+ "simply-outlook-mcp"
110
+ ],
111
+ "env": {
112
+ "SIMPLY_OUTLOOK_MCP_CLIENT_ID": "your-client-id",
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ ### VS Code
120
+
121
+ ```json
122
+ {
123
+ "servers": {
124
+ "simply-outlook-mcp": {
125
+ "type": "stdio",
126
+ "command": "npx",
127
+ "args": [
128
+ "-y",
129
+ "simply-outlook-mcp"
130
+ ],
131
+ "env": {
132
+ "SIMPLY_OUTLOOK_MCP_CLIENT_ID": "your-client-id"
133
+ }
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ ## Environment Variables
140
+
141
+ The following environment variables can be used to configure the MCP server:
142
+
143
+ ### Required Variables
144
+
145
+ | Variable | Description | Example |
146
+ |----------|-------------|---------|
147
+ | `SIMPLY_OUTLOOK_MCP_CLIENT_ID` | Azure AD Application (client) ID | `12345678-1234-1234-1234-123456789012` |
148
+
149
+ ### Optional Variables
150
+
151
+ | Variable | Description | Default | Example |
152
+ |----------|-------------|---------|---------|
153
+ | `SIMPLY_OUTLOOK_MCP_TENANT_ID` | Ignore this, for advance usage if you create single tenant or MSA only app | `common` | |
154
+ | `SIMPLY_OUTLOOK_MCP_DISABLED_TOOLS` | Comma-separated list of tools to disable | None | `get-calendar-events,send-outlook-message` |
155
+
156
+ ### Tool Names for Disabling
157
+
158
+ You can disable specific tools by adding their names to the `SIMPLY_OUTLOOK_MCP_DISABLED_TOOLS` environment variable:
159
+
160
+ **Calendar Tools:**
161
+ - `get-calendar-events` - Retrieve calendar events
162
+ - `create-calendar-event` - Create personal calendar events
163
+ - `create-calendar-event-with-invite` - Create events with invitations
164
+ - `update-calendar-event` - Modify existing calendar events
165
+
166
+ **Email Tools:**
167
+ - `get-outlook-messages` - Fetch recent messages
168
+ - `get-outlook-message-content` - Get full message content
169
+ - `search-outlook-messages` - Search emails by keywords
170
+ - `send-outlook-message` - Send new emails
171
+ - `reply-outlook-message` - Reply to existing emails
172
+
173
+ ### Example Configuration
174
+
175
+ ```json
176
+ {
177
+ "mcpServers": {
178
+ "outlook": {
179
+ "command": "npx",
180
+ "args": [
181
+ "-y",
182
+ "simply-outlook-mcp"
183
+ ],
184
+ "env": {
185
+ "SIMPLY_OUTLOOK_MCP_CLIENT_ID": "12345678-1234-1234-1234-123456789012",
186
+ "SIMPLY_OUTLOOK_MCP_DISABLED_TOOLS": "create-calendar-event-with-invite,update-calendar-event,send-outlook-message,reply-outlook-message"
187
+ }
188
+ }
189
+ }
190
+ }
191
+ ```
192
+
193
+ > [!TIP]
194
+ > **Disabling Tools**: You can disable tools you don't need for security or functionality reasons. For example, disable email sending tools (`send-outlook-message,reply-outlook-message`) if you only want read-only email access.
195
+
196
+ ## License
197
+
198
+ MIT License - see [LICENSE](LICENSE) file for details.
199
+
200
+ ## Support
201
+
202
+ - GitHub Issues: [Report bugs or request features](https://github.com/hmmroger/simply-outlook-mcp/issues)
203
+ - Repository: [https://github.com/hmmroger/simply-outlook-mcp](https://github.com/hmmroger/simply-outlook-mcp)
@@ -0,0 +1,3 @@
1
+ import { DeviceCodeCredential, DeviceCodePromptCallback } from "@azure/identity";
2
+ export declare const authenticate: (clientId: string, scopes: string[], tenantId?: string, isForce?: boolean) => Promise<void>;
3
+ export declare const getDeviceCredential: (clientId: string, tenantId?: string, isForce?: boolean, promptCallback?: DeviceCodePromptCallback) => DeviceCodeCredential;
@@ -0,0 +1,64 @@
1
+ import fs from "fs";
2
+ import { DeviceCodeCredential, useIdentityPlugin } from "@azure/identity";
3
+ import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
4
+ import EventEmitter, { once } from "events";
5
+ useIdentityPlugin(cachePersistencePlugin);
6
+ const AUTH_RECORD_FILE = ".simply-outlook-mcp";
7
+ export const authenticate = async (clientId, scopes, tenantId, isForce) => {
8
+ const deviceCodeEvent = new EventEmitter();
9
+ const deviceCodeCred = getDeviceCredential(clientId, tenantId, isForce, (info) => {
10
+ deviceCodeEvent.emit("code", info);
11
+ });
12
+ try {
13
+ await deviceCodeCred.getToken(scopes);
14
+ const authRecord = getAuthRecord();
15
+ console.error(`Authenticated as ${authRecord?.username}`);
16
+ return;
17
+ }
18
+ catch (error) {
19
+ // no op
20
+ }
21
+ const authPromise = deviceCodeCred.authenticate(scopes);
22
+ const [code] = await once(deviceCodeEvent, "code");
23
+ const deviceCodeInfo = code;
24
+ console.error(deviceCodeInfo.message);
25
+ const newAuthRecord = await authPromise;
26
+ if (!newAuthRecord) {
27
+ throw new Error("Authentication failed.");
28
+ }
29
+ fs.writeFileSync(getAuthRecordFile(), JSON.stringify(newAuthRecord));
30
+ console.error(`Authenticated as ${newAuthRecord.username}`);
31
+ };
32
+ export const getDeviceCredential = (clientId, tenantId, isForce, promptCallback) => {
33
+ const authRecord = isForce ? undefined : getAuthRecord();
34
+ const deviceCodeCred = new DeviceCodeCredential({
35
+ clientId,
36
+ tenantId: tenantId || "common",
37
+ userPromptCallback: promptCallback,
38
+ tokenCachePersistenceOptions: { enabled: true, name: "simply-outlook-mcp" },
39
+ authenticationRecord: authRecord,
40
+ disableAutomaticAuthentication: true,
41
+ });
42
+ return deviceCodeCred;
43
+ };
44
+ const getUserDataFolder = () => {
45
+ const folder = process.env.APPDATA?.replace?.(/(.Roaming)*$/, "\\Local") ?? process.env.HOME;
46
+ if (!folder) {
47
+ throw new Error("User data folder not defined.");
48
+ }
49
+ return folder;
50
+ };
51
+ const getAuthRecordFile = () => {
52
+ return `${getUserDataFolder()}/${AUTH_RECORD_FILE}`;
53
+ };
54
+ const getAuthRecord = () => {
55
+ try {
56
+ const authRecJson = fs.readFileSync(getAuthRecordFile(), { encoding: "utf8" });
57
+ return JSON.parse(authRecJson);
58
+ }
59
+ catch (_error) {
60
+ console.error("Auth record not available.");
61
+ }
62
+ return undefined;
63
+ };
64
+ //# sourceMappingURL=auth-utils.js.map
@@ -0,0 +1,11 @@
1
+ import { ILogger } from "./logger.types.js";
2
+ export declare class ConsoleLogger implements ILogger {
3
+ private readonly useErrorOutput?;
4
+ private moduleName;
5
+ constructor(moduleName?: string, useErrorOutput?: boolean | undefined);
6
+ debug(message: string): void;
7
+ info(message: string): void;
8
+ warning(message: string): void;
9
+ error(message: string, error?: unknown): void;
10
+ createLogger(name: string): ILogger;
11
+ }
@@ -0,0 +1,32 @@
1
+ export class ConsoleLogger {
2
+ useErrorOutput;
3
+ moduleName;
4
+ constructor(moduleName, useErrorOutput) {
5
+ this.useErrorOutput = useErrorOutput;
6
+ this.moduleName = moduleName || "";
7
+ }
8
+ debug(message) {
9
+ if (process.env.NODE_ENV !== "production") {
10
+ const timestamp = new Date().toISOString();
11
+ const output = `[DEBUG] [${timestamp}]: ${message}`;
12
+ this.useErrorOutput ? console.error(output) : console.log(output);
13
+ }
14
+ }
15
+ info(message) {
16
+ const timestamp = new Date().toISOString();
17
+ const output = `[INFO] [${timestamp}]: ${this.moduleName ? this.moduleName + ": " : ""}${message}`;
18
+ this.useErrorOutput ? console.error(output) : console.log(output);
19
+ }
20
+ warning(message) {
21
+ const timestamp = new Date().toISOString();
22
+ console.warn(`[WARNING] [${timestamp}]: ${this.moduleName ? this.moduleName + ": " : ""}${message}`);
23
+ }
24
+ error(message, error) {
25
+ const timestamp = new Date().toISOString();
26
+ console.error(`[ERROR] [${timestamp}]: ${this.moduleName ? this.moduleName + ": " : ""}${message}`, error);
27
+ }
28
+ createLogger(name) {
29
+ return new ConsoleLogger(name, this.useErrorOutput);
30
+ }
31
+ }
32
+ //# sourceMappingURL=console-logger.js.map
@@ -0,0 +1,7 @@
1
+ export interface ILogger {
2
+ debug(message: string): void;
3
+ info(message: string): void;
4
+ warning(message: string): void;
5
+ error(message: string, error?: unknown): void;
6
+ createLogger(name: string): ILogger;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=logger.types.js.map
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ import { config } from "dotenv";
3
+ import yargs from "yargs/yargs";
4
+ import { hideBin } from "yargs/helpers";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { createMcpServer, SIMPLY_OUTLOOK_MCP_SCOPES } from "./simply-outlook-mcp.js";
7
+ import { SimplyOutlookMcpEnvs } from "./simply-outlook-mcp.types.js";
8
+ import { authenticate, getDeviceCredential } from "./auth-utils.js";
9
+ config({ quiet: true });
10
+ const main = async () => {
11
+ const argv = yargs(hideBin(process.argv))
12
+ .option("auth", {
13
+ type: "boolean",
14
+ description: "Initialize and save authentication record.",
15
+ })
16
+ .option("force", {
17
+ type: "boolean",
18
+ description: "Re-initialize authentication to switch account.",
19
+ implies: ["auth"],
20
+ })
21
+ .option("client_id", {
22
+ type: "string",
23
+ description: "Application ID created in Azure portal.",
24
+ })
25
+ .option("tenant_id", {
26
+ type: "string",
27
+ description: "Application's tenant ID.",
28
+ })
29
+ .parseSync();
30
+ const clientId = argv.client_id || process.env[SimplyOutlookMcpEnvs.SIMPLY_OUTLOOK_MCP_CLIENT_ID];
31
+ if (!clientId) {
32
+ throw new Error("Missing client ID.");
33
+ }
34
+ const tenantId = argv.tenant_id || process.env[SimplyOutlookMcpEnvs.SIMPLY_OUTLOOK_MCP_TENANT_ID];
35
+ if (argv.auth) {
36
+ await authenticate(clientId, SIMPLY_OUTLOOK_MCP_SCOPES, tenantId, argv.force);
37
+ return;
38
+ }
39
+ const credential = getDeviceCredential(clientId, tenantId, argv.force);
40
+ const server = await createMcpServer(credential);
41
+ const transport = new StdioServerTransport();
42
+ await server.connect(transport);
43
+ console.error("Simply Outlook MCP Server running on stdio.");
44
+ };
45
+ main().catch((error) => {
46
+ console.error("Fatal error in main():", error);
47
+ process.exit(1);
48
+ });
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,30 @@
1
+ import { TokenCredential } from "@azure/identity";
2
+ import { ILogger } from "../common/logger.types.js";
3
+ import { CalendarEventData, DateTimeRange, MailMessageData } from "./graph-service.types.js";
4
+ export declare class GraphService {
5
+ private readonly logger;
6
+ private readonly tokenCredential;
7
+ private readonly scopes;
8
+ private graphClient;
9
+ private domPurify;
10
+ private nhm;
11
+ private marked;
12
+ private mailFolders;
13
+ private filterFolderIds;
14
+ constructor(logger: ILogger, tokenCredential: TokenCredential, scopes: string[]);
15
+ isAuthenticated(): Promise<boolean>;
16
+ getCalendarEvents(startDateTimeRange?: DateTimeRange, limit?: number, skip?: number): Promise<CalendarEventData[]>;
17
+ createCalendarEvent(subject: string, content: string, utcStartDate: string, utcEndDate: string, userEmails?: string[], location?: string, isMeeting?: boolean): Promise<CalendarEventData>;
18
+ updateCalendarEvent(id: string, content?: string, subject?: string, utcStartDate?: string, utcEndDate?: string, location?: string): Promise<CalendarEventData>;
19
+ getOutlookMessages(receivedDateTimeRange?: DateTimeRange, searchQuery?: string, limit?: number, skip?: number): Promise<MailMessageData[]>;
20
+ getOutlookMessageById(id: string): Promise<MailMessageData>;
21
+ sendOutlookMessage(subject: string, content: string, recipientEmails: string[]): Promise<void>;
22
+ replyOutlookMessage(replyMessageId: string, content: string): Promise<void>;
23
+ private getMailFolders;
24
+ private getFilterFolderIds;
25
+ private parseHtmlToMarkdown;
26
+ private parseMarkdownToHtml;
27
+ private isCalendarEventData;
28
+ private isMailMessageData;
29
+ private isMailFolderData;
30
+ }