@mindstone/mcp-server-microsoft-mail 0.1.0
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.
- package/CHANGELOG.md +26 -0
- package/LICENSE +97 -0
- package/README.md +77 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +72 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/mail.d.ts +65 -0
- package/dist/mail.d.ts.map +1 -0
- package/dist/mail.js +233 -0
- package/dist/mail.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +12 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +359 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +63 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +218 -0
- package/dist/utils.js.map +1 -0
- package/package.json +55 -0
- package/server.json +71 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@mindstone/mcp-server-microsoft-mail` are documented here.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Planned
|
|
10
|
+
- Migrate to `@mindstone/mcp-server-microsoft-shared` from its npm-registry version once `0.1.0` of the shared package is published; the `0.1.0` cohort port currently consumes the shared package as a packed `file:` dependency.
|
|
11
|
+
- Tighten Zod validation of Microsoft Graph response payloads in `0.2.0` or later.
|
|
12
|
+
|
|
13
|
+
## [0.1.0] - 2026-05-19
|
|
14
|
+
|
|
15
|
+
Initial public release of the Microsoft 365 Outlook Mail MCP server. Twelve tools across mail listing, search, send, reply, forward, draft, move, and delete via Microsoft Graph.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Twelve mail tools: `authenticate_microsoft_account`, `list_emails`, `get_email`, `send_email`, `search_emails`, `reply_to_email`, `forward_email`, `delete_email`, `list_folders`, `move_email`, `create_reply_draft`, `create_draft`.
|
|
19
|
+
- Host-orchestrated OAuth handoff: `authenticate_microsoft_account` returns the structured `auth_required` envelope so the host runs the desktop OAuth flow.
|
|
20
|
+
- Token-refresh fail-closed mode via `MICROSOFT_DISABLE_REFRESH=1` (defaults to off; the cloud surface flips it on so tokens cannot rotate without the desktop session).
|
|
21
|
+
- Cohort 60s upstream-request timeout with `MICROSOFT_REQUEST_TIMEOUT_MS` override; abort signals compose via `AbortSignal.any()`.
|
|
22
|
+
|
|
23
|
+
### Security
|
|
24
|
+
- Uses the new `McpServer + registerTool + Zod` SDK pattern (cohort `MCP_SERVER_STANDARD`).
|
|
25
|
+
- Reads version from `package.json` via `createRequire(import.meta.url)`, so the reported server version cannot drift from the npm artifact.
|
|
26
|
+
- Internal-reference scan enforced as part of `npm run build` to block host-internal bridge symbols and workspace paths from shipping in the published tarball.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Mindstone Learning Limited
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
**Licensor**: Mindstone Learning Limited
|
|
18
|
+
|
|
19
|
+
### The Software
|
|
20
|
+
|
|
21
|
+
The "Software" is each version of the software that we make available under
|
|
22
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
23
|
+
Conditions with the Software.
|
|
24
|
+
|
|
25
|
+
**Software**: Microsoft 365 Mail MCP Server
|
|
26
|
+
|
|
27
|
+
### License Grant
|
|
28
|
+
|
|
29
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
30
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
31
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
32
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
33
|
+
|
|
34
|
+
### Permitted Purpose
|
|
35
|
+
|
|
36
|
+
A Permitted Purpose is any purpose other than a Competing Use. A "Competing
|
|
37
|
+
Use" means making the Software available to third parties as a commercial
|
|
38
|
+
hosted service that directly competes with any product or service provided by
|
|
39
|
+
the Licensor.
|
|
40
|
+
|
|
41
|
+
### Patents
|
|
42
|
+
|
|
43
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
44
|
+
patents, the license grant above includes a license under our patents. If you
|
|
45
|
+
make a claim against any party that the Software infringes or contributes to
|
|
46
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
47
|
+
immediately.
|
|
48
|
+
|
|
49
|
+
### Redistribution
|
|
50
|
+
|
|
51
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
52
|
+
the Software.
|
|
53
|
+
|
|
54
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
55
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
56
|
+
remove any copyright notices provided in or with the Software.
|
|
57
|
+
|
|
58
|
+
### Disclaimer
|
|
59
|
+
|
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
61
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
62
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
63
|
+
|
|
64
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
65
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, OF
|
|
66
|
+
ANY CHARACTER INCLUDING DAMAGES FOR LOSS OF GOODWILL, LOST PROFITS, LOST SALES
|
|
67
|
+
OR BUSINESS, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, LOST CONTENT,
|
|
68
|
+
DATA OR DATA USE, BREACH OF DUTY OF GOOD FAITH, OR ANY AND ALL OTHER DAMAGES
|
|
69
|
+
OR LOSSES OF ANY KIND OR NATURE WHATSOEVER (WHETHER DIRECT, INDIRECT, SPECIAL,
|
|
70
|
+
COLLATERAL, INCIDENTAL, CONSEQUENTIAL OR OTHERWISE) ARISING OUT OF OR IN
|
|
71
|
+
CONNECTION WITH THE SOFTWARE OR THIS LICENSE, EVEN IF SUCH PARTY SHALL HAVE
|
|
72
|
+
BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
73
|
+
|
|
74
|
+
### Trademark
|
|
75
|
+
|
|
76
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
77
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
78
|
+
trademarks, trade names, service marks or product names.
|
|
79
|
+
|
|
80
|
+
## Change Date
|
|
81
|
+
|
|
82
|
+
Four years from the date the Software is made available under these Terms and
|
|
83
|
+
Conditions: **2030-05-19**
|
|
84
|
+
|
|
85
|
+
## Change License
|
|
86
|
+
|
|
87
|
+
MIT License
|
|
88
|
+
|
|
89
|
+
## License Details
|
|
90
|
+
|
|
91
|
+
| Parameter | Value |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Licensor | Mindstone Learning Limited |
|
|
94
|
+
| Software | Microsoft 365 Mail MCP Server |
|
|
95
|
+
| Use Limitation | Competing Use |
|
|
96
|
+
| Change Date | 2030-05-19 |
|
|
97
|
+
| Change License | MIT |
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @mindstone/mcp-server-microsoft-mail
|
|
2
|
+
|
|
3
|
+
[](./LICENSE)
|
|
4
|
+
|
|
5
|
+
Microsoft 365 Outlook Mail MCP server — list, search, read, send, reply, forward, draft, move, and delete email via the Microsoft Graph API.
|
|
6
|
+
|
|
7
|
+
Host-orchestrated OAuth, per-account credentials on disk, and a structured `auth_required` handoff so the host drives the sign-in flow rather than the server.
|
|
8
|
+
|
|
9
|
+
## Status
|
|
10
|
+
|
|
11
|
+
- **Version:** [0.1.0](./CHANGELOG.md)
|
|
12
|
+
- **Auth:** OAuth (host-orchestrated) ([`MS_CLIENT_ID`](./server.json))
|
|
13
|
+
- **Tools:** 12 (list, search, get, send, reply, forward, draft, move, delete, folders)
|
|
14
|
+
- **Surface:** cloud-api
|
|
15
|
+
- **Shared library:** [`@mindstone/mcp-server-microsoft-shared`](../../packages/mcp-server-microsoft-shared)
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
- Node.js 20+
|
|
20
|
+
- npm
|
|
21
|
+
- A host application that performs the Microsoft OAuth flow and writes per-account token files into `${MS_CONFIG_DIR}/credentials/${sanitised-email}.token.json` and an `${MS_CONFIG_DIR}/accounts.json` index. This server reads those files; it does not initiate OAuth itself.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
cd <path-to-repo>/connectors/microsoft-mail
|
|
27
|
+
npm install
|
|
28
|
+
npm run build
|
|
29
|
+
node dist/index.js
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Once published:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx -y @mindstone/mcp-server-microsoft-mail
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
This server runs alongside a host application that owns the Microsoft 365 OAuth flow. The host writes credentials to disk; this server reads them.
|
|
41
|
+
|
|
42
|
+
### Required environment variables
|
|
43
|
+
|
|
44
|
+
| Name | Description |
|
|
45
|
+
| ---- | ----------- |
|
|
46
|
+
| `MS_CLIENT_ID` | Microsoft Entra (Azure AD) application client ID. |
|
|
47
|
+
| `MS_CONFIG_DIR` | Path to the per-user Microsoft config directory (`credentials/`, `accounts.json`). |
|
|
48
|
+
|
|
49
|
+
### Optional environment variables
|
|
50
|
+
|
|
51
|
+
| Name | Description | Default |
|
|
52
|
+
| ---- | ----------- | ------- |
|
|
53
|
+
| `MS_ACCOUNT_EMAIL` | Account email when running in multi-account per-instance mode. | First account in `accounts.json`. |
|
|
54
|
+
| `MS_MCP_PACKAGE_ID` | Logical package ID surfaced in error responses. | `Microsoft365Mail` |
|
|
55
|
+
| `MICROSOFT_REQUEST_TIMEOUT_MS` | Override the upstream Microsoft Graph request timeout (max `300000` ms). | `60000` |
|
|
56
|
+
| `MICROSOFT_DISABLE_REFRESH` | Set to `1` to disable token refresh on this surface. Tools fail closed with the structured `auth_required` response so the host can drive reauth. Cloud surfaces set this to `1`. | unset |
|
|
57
|
+
|
|
58
|
+
## Tools
|
|
59
|
+
|
|
60
|
+
| Tool | Description |
|
|
61
|
+
| ---- | ----------- |
|
|
62
|
+
| `authenticate_microsoft_account` | Emit the structured `auth_required` handoff so the host runs the Microsoft 365 OAuth flow. |
|
|
63
|
+
| `list_emails` | List emails in a folder, ordered by most recent. |
|
|
64
|
+
| `get_email` | Read a single email by message ID. |
|
|
65
|
+
| `send_email` | Send a new email message. |
|
|
66
|
+
| `search_emails` | Search emails using Microsoft Search syntax. |
|
|
67
|
+
| `reply_to_email` | Reply (or reply-all) to an existing email. |
|
|
68
|
+
| `forward_email` | Forward an email to additional recipients. |
|
|
69
|
+
| `delete_email` | Move an email to Deleted Items, or hard-delete it. |
|
|
70
|
+
| `list_folders` | List mail folders. |
|
|
71
|
+
| `move_email` | Move an email to a different folder. |
|
|
72
|
+
| `create_reply_draft` | Save a draft reply to an existing email. |
|
|
73
|
+
| `create_draft` | Save a new standalone draft email. |
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
[FSL-1.1-MIT](./LICENSE) — Functional Source License, MIT Future License (4-year transition). Free for non-competing use; relicenses to MIT after the transition window.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Client, type TokenProvider } from '@mindstone/mcp-server-microsoft-shared';
|
|
2
|
+
export declare function getGraphClient(): Client;
|
|
3
|
+
export declare function getTokenProvider(): TokenProvider;
|
|
4
|
+
/**
|
|
5
|
+
* Invoke a Graph operation with a single retry on HTTP 401: cached token is
|
|
6
|
+
* invalidated and the operation is retried so a transient stale-cache hit
|
|
7
|
+
* doesn't fail the tool call. Mirrors the bundled `microsoft-mail` retry
|
|
8
|
+
* semantics in `resources/mcp/microsoft-mail/src/index.ts`.
|
|
9
|
+
*
|
|
10
|
+
* The composed `signal` is threaded into both the initial attempt and the
|
|
11
|
+
* post-401 retry so a host cancellation or cohort timeout aborts the in-flight
|
|
12
|
+
* Graph request regardless of which attempt is active.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withGraphRetry<T>(fn: (client: Client, signal: AbortSignal) => Promise<T>, signal: AbortSignal): Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Run a Graph operation under the cohort timeout + caller abort signal.
|
|
17
|
+
*
|
|
18
|
+
* Composes the per-call signal from `extra.signal` (when the MCP host
|
|
19
|
+
* cancelled the request) with `REQUEST_TIMEOUT_MS`, then (a) hands it to the
|
|
20
|
+
* SDK via `GraphRequest.options({ signal })` so the underlying fetch is
|
|
21
|
+
* actually cancelled, and (b) races the SDK promise against the same signal as
|
|
22
|
+
* defence-in-depth in case any middleware path drops the signal. See
|
|
23
|
+
* `runWithSignal` in utils.ts for the race-wrapper rationale.
|
|
24
|
+
*/
|
|
25
|
+
export declare function callGraph<T>(extra: unknown, fn: (client: Client, signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
26
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EAEX,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAC;AA+BhD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACvD,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACtD,OAAO,CAAC,CAAC,CAAC,CAGZ"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createGraphClientWithRetry, createLogger, } from '@mindstone/mcp-server-microsoft-shared';
|
|
2
|
+
import { abortableSignal, extractCallerSignal, runWithSignal } from './utils.js';
|
|
3
|
+
const log = createLogger('microsoft-mail-mcp');
|
|
4
|
+
const MS_CONFIG_DIR = process.env.MS_CONFIG_DIR ?? '';
|
|
5
|
+
const MS_CLIENT_ID = process.env.MS_CLIENT_ID ?? '';
|
|
6
|
+
const MS_ACCOUNT_EMAIL = process.env.MS_ACCOUNT_EMAIL || undefined;
|
|
7
|
+
let cached = null;
|
|
8
|
+
let initError = null;
|
|
9
|
+
function ensureInitialized() {
|
|
10
|
+
if (cached)
|
|
11
|
+
return cached;
|
|
12
|
+
if (initError)
|
|
13
|
+
throw new Error(initError);
|
|
14
|
+
if (!MS_CONFIG_DIR || !MS_CLIENT_ID) {
|
|
15
|
+
initError =
|
|
16
|
+
'Missing required environment variables: MS_CONFIG_DIR, MS_CLIENT_ID. Connect Microsoft 365 via the host application before invoking tools.';
|
|
17
|
+
log.error(initError);
|
|
18
|
+
throw new Error(initError);
|
|
19
|
+
}
|
|
20
|
+
cached = createGraphClientWithRetry({
|
|
21
|
+
configDir: MS_CONFIG_DIR,
|
|
22
|
+
clientId: MS_CLIENT_ID,
|
|
23
|
+
email: MS_ACCOUNT_EMAIL,
|
|
24
|
+
});
|
|
25
|
+
return cached;
|
|
26
|
+
}
|
|
27
|
+
export function getGraphClient() {
|
|
28
|
+
return ensureInitialized().client;
|
|
29
|
+
}
|
|
30
|
+
export function getTokenProvider() {
|
|
31
|
+
return ensureInitialized().tokenProvider;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Invoke a Graph operation with a single retry on HTTP 401: cached token is
|
|
35
|
+
* invalidated and the operation is retried so a transient stale-cache hit
|
|
36
|
+
* doesn't fail the tool call. Mirrors the bundled `microsoft-mail` retry
|
|
37
|
+
* semantics in `resources/mcp/microsoft-mail/src/index.ts`.
|
|
38
|
+
*
|
|
39
|
+
* The composed `signal` is threaded into both the initial attempt and the
|
|
40
|
+
* post-401 retry so a host cancellation or cohort timeout aborts the in-flight
|
|
41
|
+
* Graph request regardless of which attempt is active.
|
|
42
|
+
*/
|
|
43
|
+
export async function withGraphRetry(fn, signal) {
|
|
44
|
+
const { client, tokenProvider } = ensureInitialized();
|
|
45
|
+
try {
|
|
46
|
+
return await fn(client, signal);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
const statusCode = err?.statusCode;
|
|
50
|
+
if (statusCode === 401) {
|
|
51
|
+
log.warn('Got 401, invalidating cached token and retrying');
|
|
52
|
+
tokenProvider.invalidateCachedToken();
|
|
53
|
+
return fn(client, signal);
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Run a Graph operation under the cohort timeout + caller abort signal.
|
|
60
|
+
*
|
|
61
|
+
* Composes the per-call signal from `extra.signal` (when the MCP host
|
|
62
|
+
* cancelled the request) with `REQUEST_TIMEOUT_MS`, then (a) hands it to the
|
|
63
|
+
* SDK via `GraphRequest.options({ signal })` so the underlying fetch is
|
|
64
|
+
* actually cancelled, and (b) races the SDK promise against the same signal as
|
|
65
|
+
* defence-in-depth in case any middleware path drops the signal. See
|
|
66
|
+
* `runWithSignal` in utils.ts for the race-wrapper rationale.
|
|
67
|
+
*/
|
|
68
|
+
export async function callGraph(extra, fn) {
|
|
69
|
+
const signal = abortableSignal(extractCallerSignal(extra));
|
|
70
|
+
return runWithSignal(withGraphRetry(fn, signal), signal);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,YAAY,GAIb,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjF,MAAM,GAAG,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;AAE/C,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;AACtD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;AACpD,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS,CAAC;AAEnE,IAAI,MAAM,GAAgC,IAAI,CAAC;AAC/C,IAAI,SAAS,GAAkB,IAAI,CAAC;AAEpC,SAAS,iBAAiB;IACxB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UAAU,SAAS,CAC7B,KAAc,EACd,EAAuD;IAEvD,MAAM,MAAM,GAAG,eAAe,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,OAAO,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Microsoft 365 Outlook Mail MCP Server.
|
|
4
|
+
*
|
|
5
|
+
* Provides Microsoft 365 mail integration via Model Context Protocol —
|
|
6
|
+
* list, search, read, send, reply, forward, draft, move, and delete email
|
|
7
|
+
* through the Microsoft Graph API.
|
|
8
|
+
*
|
|
9
|
+
* Environment variables (injected by the host):
|
|
10
|
+
* - MS_CONFIG_DIR Path to the per-user Microsoft config dir
|
|
11
|
+
* (credentials/, accounts.json).
|
|
12
|
+
* - MS_CLIENT_ID Microsoft Entra (Azure AD) application client ID.
|
|
13
|
+
* - MS_ACCOUNT_EMAIL Account email when running in multi-account
|
|
14
|
+
* per-instance mode. Optional; falls back to the
|
|
15
|
+
* first account in accounts.json.
|
|
16
|
+
* - MS_MCP_PACKAGE_ID Logical package ID surfaced in error responses.
|
|
17
|
+
* Defaults to "Microsoft365Mail".
|
|
18
|
+
* - MICROSOFT_REQUEST_TIMEOUT_MS Override the default 60s upstream timeout
|
|
19
|
+
* (positive integer ≤ 300000).
|
|
20
|
+
* - MICROSOFT_DISABLE_REFRESH=1 Disable token refresh on this surface; the
|
|
21
|
+
* connector fails-closed with the structured
|
|
22
|
+
* auth_required response so the host can drive
|
|
23
|
+
* reauth.
|
|
24
|
+
*/
|
|
25
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
26
|
+
import { createServer } from './server.js';
|
|
27
|
+
import { SERVER_VERSION } from './types.js';
|
|
28
|
+
if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
29
|
+
console.log(SERVER_VERSION);
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
33
|
+
console.log('Microsoft 365 Outlook Mail MCP Server. Configure MS_CONFIG_DIR + MS_CLIENT_ID and run over stdio from an MCP host.');
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
async function main() {
|
|
37
|
+
const server = createServer();
|
|
38
|
+
const transport = new StdioServerTransport();
|
|
39
|
+
await server.connect(transport);
|
|
40
|
+
console.error('[microsoft-mail-mcp] running on stdio');
|
|
41
|
+
}
|
|
42
|
+
process.on('SIGINT', () => process.exit(0));
|
|
43
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
44
|
+
main().catch((error) => {
|
|
45
|
+
console.error('Fatal error:', error);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACnE,OAAO,CAAC,GAAG,CACT,oHAAoH,CACrH,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;AACzD,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7C,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/mail.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Client } from '@mindstone/mcp-server-microsoft-shared';
|
|
2
|
+
export declare function resolveFolder(folder: string): string;
|
|
3
|
+
export interface ListEmailsArgs {
|
|
4
|
+
folder?: string;
|
|
5
|
+
top?: number;
|
|
6
|
+
filter?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function listEmails(client: Client, args: ListEmailsArgs, signal: AbortSignal): Promise<unknown>;
|
|
9
|
+
export interface GetEmailArgs {
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function getEmail(client: Client, args: GetEmailArgs, signal: AbortSignal): Promise<unknown>;
|
|
13
|
+
export interface SendEmailArgs {
|
|
14
|
+
to: string | string[];
|
|
15
|
+
subject: string;
|
|
16
|
+
body: string;
|
|
17
|
+
cc?: string | string[];
|
|
18
|
+
importance?: 'low' | 'normal' | 'high';
|
|
19
|
+
}
|
|
20
|
+
export declare function sendEmail(client: Client, args: SendEmailArgs, signal: AbortSignal): Promise<unknown>;
|
|
21
|
+
export interface SearchEmailsArgs {
|
|
22
|
+
query: string;
|
|
23
|
+
top?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function searchEmails(client: Client, args: SearchEmailsArgs, signal: AbortSignal): Promise<unknown>;
|
|
26
|
+
export interface ReplyToEmailArgs {
|
|
27
|
+
id: string;
|
|
28
|
+
body: string;
|
|
29
|
+
replyAll?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function replyToEmail(client: Client, args: ReplyToEmailArgs, signal: AbortSignal): Promise<unknown>;
|
|
32
|
+
export interface ForwardEmailArgs {
|
|
33
|
+
id: string;
|
|
34
|
+
to: string | string[];
|
|
35
|
+
comment?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function forwardEmail(client: Client, args: ForwardEmailArgs, signal: AbortSignal): Promise<unknown>;
|
|
38
|
+
export interface DeleteEmailArgs {
|
|
39
|
+
id: string;
|
|
40
|
+
permanent?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function deleteEmail(client: Client, args: DeleteEmailArgs, signal: AbortSignal): Promise<unknown>;
|
|
43
|
+
export interface ListFoldersArgs {
|
|
44
|
+
includeHidden?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function listFolders(client: Client, args: ListFoldersArgs, signal: AbortSignal): Promise<unknown>;
|
|
47
|
+
export interface MoveEmailArgs {
|
|
48
|
+
id: string;
|
|
49
|
+
destinationFolder: string;
|
|
50
|
+
}
|
|
51
|
+
export declare function moveEmail(client: Client, args: MoveEmailArgs, signal: AbortSignal): Promise<unknown>;
|
|
52
|
+
export interface CreateReplyDraftArgs {
|
|
53
|
+
id: string;
|
|
54
|
+
body?: string;
|
|
55
|
+
replyAll?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare function createReplyDraft(client: Client, args: CreateReplyDraftArgs, signal: AbortSignal): Promise<unknown>;
|
|
58
|
+
export interface CreateDraftArgs {
|
|
59
|
+
to?: string | string[];
|
|
60
|
+
subject: string;
|
|
61
|
+
body: string;
|
|
62
|
+
cc?: string | string[];
|
|
63
|
+
}
|
|
64
|
+
export declare function createDraft(client: Client, args: CreateDraftArgs, signal: AbortSignal): Promise<unknown>;
|
|
65
|
+
//# sourceMappingURL=mail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../src/mail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA4B,MAAM,wCAAwC,CAAC;AAgB/F,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGpD;AAOD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAqClB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAoBlB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IA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