@chrischall/office-outlook-mcp 0.5.2 → 0.6.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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/mcp.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +23 -6
- package/dist/bundle.js +320 -63
- package/dist/tools/_paging.js +102 -0
- package/dist/tools/mail.js +72 -12
- package/dist/tools/writes.js +35 -25
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/server.json +2 -2
package/dist/tools/_paging.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { McpToolError } from '@chrischall/mcp-utils';
|
|
2
3
|
import { stripOData } from '../view.js';
|
|
3
4
|
/**
|
|
4
5
|
* Paging for every list tool.
|
|
@@ -37,3 +38,104 @@ export function plainCollection(data) {
|
|
|
37
38
|
out.nextLink = next;
|
|
38
39
|
return out;
|
|
39
40
|
}
|
|
41
|
+
export const fromParam = z
|
|
42
|
+
.string()
|
|
43
|
+
.min(1)
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Page oldest first from this point: an ISO 8601 UTC time (e.g. "2026-10-01T00:00:00Z"; one with no zone is read as UTC), or a previous result\'s `next_from` passed unchanged. The result always carries `next_from` and `has_more`.');
|
|
46
|
+
/** Outlook's per-request `$top` ceiling. */
|
|
47
|
+
const MAX_TOP = 1000;
|
|
48
|
+
const FROM_HINT = 'Pass a previous next_from unchanged, or an ISO 8601 time such as 2026-10-01T00:00:00Z (one with no zone is read as UTC).';
|
|
49
|
+
/** An ISO 8601 date, or date-time with or without a zone. */
|
|
50
|
+
const ISO_DATE_TIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/i;
|
|
51
|
+
/**
|
|
52
|
+
* The OData literal for `t` (unquoted), and the canonical form kept in a
|
|
53
|
+
* token. Milliseconds are dropped only when zero — truncating a real fraction
|
|
54
|
+
* would widen `ge` to messages older than the position and repeat them.
|
|
55
|
+
*/
|
|
56
|
+
function utcLiteral(ms) {
|
|
57
|
+
return new Date(ms).toISOString().replace(/\.000Z$/, 'Z');
|
|
58
|
+
}
|
|
59
|
+
function parseTime(raw) {
|
|
60
|
+
if (!ISO_DATE_TIME.test(raw))
|
|
61
|
+
return undefined;
|
|
62
|
+
// A date-time with no zone would parse as LOCAL time; `from` is UTC, so it is pinned there.
|
|
63
|
+
// (A bare date already parses as UTC.)
|
|
64
|
+
const t = /T[\d:.]+$/.test(raw) ? `${raw}Z` : raw;
|
|
65
|
+
const ms = Date.parse(t);
|
|
66
|
+
if (Number.isNaN(ms))
|
|
67
|
+
return undefined;
|
|
68
|
+
// Date.parse rolls 2026-02-30 over to March; a round trip of the date part catches it.
|
|
69
|
+
if (new Date(ms + offsetMs(t)).toISOString().slice(0, 10) !== t.slice(0, 10))
|
|
70
|
+
return undefined;
|
|
71
|
+
return ms;
|
|
72
|
+
}
|
|
73
|
+
/** The zone offset written in `t`, so the calendar date can be checked as written. */
|
|
74
|
+
function offsetMs(t) {
|
|
75
|
+
const m = /([+-])(\d{2}):?(\d{2})$/.exec(t);
|
|
76
|
+
if (!m || /Z$/i.test(t))
|
|
77
|
+
return 0;
|
|
78
|
+
const mins = Number(m[2]) * 60 + Number(m[3]);
|
|
79
|
+
return (m[1] === '-' ? -1 : 1) * mins * 60_000;
|
|
80
|
+
}
|
|
81
|
+
export function encodeFrom(pos) {
|
|
82
|
+
return Buffer.from(JSON.stringify({ t: pos.t, ids: pos.ids }), 'utf8').toString('base64url');
|
|
83
|
+
}
|
|
84
|
+
/** Read `from`: an ISO time, or a `next_from` token. Anything else is a tool error with a hint. */
|
|
85
|
+
export function decodeFrom(from) {
|
|
86
|
+
if (/^\d{4}-/.test(from)) {
|
|
87
|
+
const ms = parseTime(from);
|
|
88
|
+
if (ms === undefined) {
|
|
89
|
+
throw new McpToolError(`\`from\` is not a valid ISO 8601 UTC date-time: ${from}`, { hint: FROM_HINT });
|
|
90
|
+
}
|
|
91
|
+
return { t: utcLiteral(ms), ids: [] };
|
|
92
|
+
}
|
|
93
|
+
let parsed;
|
|
94
|
+
try {
|
|
95
|
+
parsed = /^[A-Za-z0-9_-]+$/.test(from) ? JSON.parse(Buffer.from(from, 'base64url').toString('utf8')) : undefined;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
parsed = undefined;
|
|
99
|
+
}
|
|
100
|
+
const p = parsed;
|
|
101
|
+
const ms = typeof p?.t === 'string' ? parseTime(p.t) : undefined;
|
|
102
|
+
if (ms === undefined ||
|
|
103
|
+
!Array.isArray(p?.ids) ||
|
|
104
|
+
!p.ids.every((id) => typeof id === 'string')) {
|
|
105
|
+
throw new McpToolError('`from` is neither an ISO 8601 time nor a next_from token.', { hint: FROM_HINT });
|
|
106
|
+
}
|
|
107
|
+
return { t: utcLiteral(ms), ids: p.ids };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The `$filter` date bound and `$top` for a page from `pos`. The bound is
|
|
111
|
+
* inclusive (`ge`), so the tied ids come back again: ask for that many extra
|
|
112
|
+
* rows so dropping them still leaves a full page.
|
|
113
|
+
*/
|
|
114
|
+
export function fromQuery(pos, limit) {
|
|
115
|
+
return { bound: `ReceivedDateTime ge ${pos.t}`, top: Math.min(limit + pos.ids.length, MAX_TOP) };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Cut an ascending page fetched with `fromQuery` down to what the caller
|
|
119
|
+
* sees: drop the rows already returned at `pos.t`, keep the first `limit`,
|
|
120
|
+
* and work out the next position. `has_more` is true when rows were left over
|
|
121
|
+
* or the API has another page.
|
|
122
|
+
*/
|
|
123
|
+
export function fromPage(rows, pos, limit, apiHasMore) {
|
|
124
|
+
const seen = new Set(pos.ids);
|
|
125
|
+
const fresh = rows.filter((r) => r.Id === undefined || !seen.has(r.Id));
|
|
126
|
+
const kept = fresh.slice(0, limit);
|
|
127
|
+
const next = nextPosition(kept, pos);
|
|
128
|
+
return { rows: kept, next_from: encodeFrom(next), has_more: fresh.length > limit || apiHasMore };
|
|
129
|
+
}
|
|
130
|
+
function nextPosition(rows, pos) {
|
|
131
|
+
const dated = rows
|
|
132
|
+
.map((r) => ({ id: r.Id, ms: r.ReceivedDateTime ? Date.parse(r.ReceivedDateTime) : NaN }))
|
|
133
|
+
.filter((r) => r.id !== undefined && !Number.isNaN(r.ms));
|
|
134
|
+
if (dated.length === 0)
|
|
135
|
+
return pos;
|
|
136
|
+
const newest = Math.max(...dated.map((r) => r.ms));
|
|
137
|
+
const tied = dated.filter((r) => r.ms === newest).map((r) => r.id);
|
|
138
|
+
// The position did not move: earlier ties at this instant stay excluded.
|
|
139
|
+
const carried = newest === Date.parse(pos.t) ? pos.ids.filter((id) => !tied.includes(id)) : [];
|
|
140
|
+
return { t: utcLiteral(newest), ids: [...carried, ...tied] };
|
|
141
|
+
}
|
package/dist/tools/mail.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { imageResult, mapWithConcurrency, minifiedResult, resolveView, viewParam, McpToolError, } from '@chrischall/mcp-utils';
|
|
3
3
|
import { addr, addrs, cappedRecipients, compactFolder, compactMessage, fullMessage, projectCollection, VIEWS, } from '../view.js';
|
|
4
4
|
import { EVENT_EXPAND, INVITE_GONE, MEETING_MESSAGE_TYPE, resolvedEvent } from './_invite.js';
|
|
5
|
-
import { fetchPage, nextLinkParam, plainCollection } from './_paging.js';
|
|
5
|
+
import { decodeFrom, fetchPage, fromPage, fromParam, fromQuery, nextLinkParam, plainCollection, } from './_paging.js';
|
|
6
6
|
import { mailboxUntrusted, UNTRUSTED_DESCRIPTION_SUFFIX } from './_untrusted.js';
|
|
7
7
|
/**
|
|
8
8
|
* Well-known folder names the API accepts wherever a folder id is taken.
|
|
@@ -146,6 +146,43 @@ function utf8Boundary(buf, max) {
|
|
|
146
146
|
function sinceLiteral(hours) {
|
|
147
147
|
return new Date(Date.now() - hours * 3_600_000).toISOString().replace(/\.\d{3}Z$/, 'Z');
|
|
148
148
|
}
|
|
149
|
+
/** Read `from` once the arguments it cannot be combined with are ruled out. */
|
|
150
|
+
function fromPosition(from, conflicts) {
|
|
151
|
+
if (from === undefined)
|
|
152
|
+
return undefined;
|
|
153
|
+
for (const [name, value] of Object.entries(conflicts)) {
|
|
154
|
+
if (value === undefined)
|
|
155
|
+
continue;
|
|
156
|
+
throw new McpToolError(`\`from\` and \`${name}\` cannot be combined.`, {
|
|
157
|
+
hint: name === 'nextLink'
|
|
158
|
+
? 'To continue a `from` listing, pass its `next_from` as `from`; `nextLink` belongs to the newest-first listing.'
|
|
159
|
+
: `\`from\` pages oldest first by time; drop \`${name}\`, or omit \`from\` for the newest-first listing.`,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return decodeFrom(from);
|
|
163
|
+
}
|
|
164
|
+
/** How `from` reads, shared by both mail listings. */
|
|
165
|
+
const FROM_DESCRIPTION = 'Pass `from` (an ISO 8601 UTC time, or a previous `next_from`) to page OLDEST first from that time instead: the result carries `next_from` (pass it back unchanged as `from` for the next page; on an empty page it is the same position, so it can be polled for new arrivals) and `has_more` (more already waiting), and no nextLink. Backfill: pass an old `from` and keep passing `next_from` until `has_more` is false; then keep polling with the last `next_from` for new mail.';
|
|
166
|
+
/** `outlook_list_messages` with `from`: one oldest-first keyset page. */
|
|
167
|
+
async function listFrom(client, pos, opts) {
|
|
168
|
+
const { bound, top } = fromQuery(pos, opts.limit);
|
|
169
|
+
const data = await client.get(`/me/mailfolders/${folderSegment(opts.folder ?? 'inbox')}/messages`, {
|
|
170
|
+
query: {
|
|
171
|
+
$top: top,
|
|
172
|
+
$select: LIST_SELECT,
|
|
173
|
+
// The date bound leads: Outlook rejects a $filter that does not start with the $orderby property.
|
|
174
|
+
$filter: opts.unreadOnly === true ? `${bound} and IsRead eq false` : bound,
|
|
175
|
+
$orderby: 'ReceivedDateTime asc',
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
const listed = Array.isArray(data?.value) ? data.value : [];
|
|
179
|
+
const page = fromPage(listed, pos, opts.limit, Boolean(data?.['@odata.nextLink']));
|
|
180
|
+
const { '@odata.nextLink': _superseded, ...rest } = data ?? {};
|
|
181
|
+
const body = opts.view === 'raw'
|
|
182
|
+
? { ...rest, value: page.rows }
|
|
183
|
+
: projectCollection({ value: page.rows }, opts.view === 'full' ? fullMessage : compactMessage, 'message');
|
|
184
|
+
return mailboxUntrusted({ ...body, next_from: page.next_from, has_more: page.has_more });
|
|
185
|
+
}
|
|
149
186
|
export function registerMailTools(server, client) {
|
|
150
187
|
server.registerTool('outlook_list_folders', {
|
|
151
188
|
description: 'List mail folders with unread and total counts. Use this to discover folder ids before listing messages; the well-known names (' +
|
|
@@ -170,7 +207,9 @@ export function registerMailTools(server, client) {
|
|
|
170
207
|
return minifiedResult(projectCollection(data, compactFolder, 'mail folder'));
|
|
171
208
|
});
|
|
172
209
|
server.registerTool('outlook_list_messages', {
|
|
173
|
-
description: "List messages in a folder, newest first. Defaults to the inbox. Use `unreadOnly` for a triage view. Bodies are NOT included — call outlook_get_message for one. Note `search` and `unreadOnly` cannot be combined on a first-page request (the API rejects $search with $filter); pass `search` alone to search the whole mailbox. When following a `nextLink`, both are ignored, so echoing them back is harmless. Each message's To list (and Cc, in the full view) holds at most 20 addresses; a longer list adds ToCount/ToTruncated (CcCount/CcTruncated) with the full count — pass view:\"raw\" for every address." +
|
|
210
|
+
description: "List messages in a folder, newest first. Defaults to the inbox. Use `unreadOnly` for a triage view. Bodies are NOT included — call outlook_get_message for one. Note `search` and `unreadOnly` cannot be combined on a first-page request (the API rejects $search with $filter); pass `search` alone to search the whole mailbox. When following a `nextLink`, both are ignored, so echoing them back is harmless. Each message's To list (and Cc, in the full view) holds at most 20 addresses; a longer list adds ToCount/ToTruncated (CcCount/CcTruncated) with the full count — pass view:\"raw\" for every address. " +
|
|
211
|
+
FROM_DESCRIPTION +
|
|
212
|
+
' Cannot combine with `search`, `skip` or `nextLink`.' +
|
|
174
213
|
' ' + UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
175
214
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
176
215
|
inputSchema: z.object({
|
|
@@ -186,9 +225,14 @@ export function registerMailTools(server, client) {
|
|
|
186
225
|
.string()
|
|
187
226
|
.optional()
|
|
188
227
|
.describe('Full-text search across the whole mailbox; cannot combine with unreadOnly on a first page (ignored with nextLink)'),
|
|
228
|
+
from: fromParam,
|
|
189
229
|
nextLink: nextLinkParam,
|
|
190
230
|
}),
|
|
191
|
-
}, async ({ view, folder, limit, skip, unreadOnly, search, nextLink }) => {
|
|
231
|
+
}, async ({ view, folder, limit, skip, unreadOnly, search, from, nextLink }) => {
|
|
232
|
+
const pos = fromPosition(from, { nextLink, search, skip });
|
|
233
|
+
if (pos !== undefined) {
|
|
234
|
+
return listFrom(client, pos, { view: resolveView(view, VIEWS), folder, limit: limit ?? 25, unreadOnly });
|
|
235
|
+
}
|
|
192
236
|
// With nextLink the filters come from the link and are ignored here, so
|
|
193
237
|
// the conflict only matters for a first-page request.
|
|
194
238
|
if (nextLink === undefined && search !== undefined && unreadOnly === true) {
|
|
@@ -240,7 +284,9 @@ export function registerMailTools(server, client) {
|
|
|
240
284
|
return mailboxUntrusted(v === 'full' ? fullMessage(data) : compactMessage(data));
|
|
241
285
|
});
|
|
242
286
|
server.registerTool('outlook_get_unread', {
|
|
243
|
-
description: 'Triage batch: the unread messages in a folder (default inbox), newest first, each WITH its plain-text body (truncated to `maxBodyChars`) in one call — no follow-up outlook_get_message needed. Every item has a `kind`: "mail", "meetingRequest", "meetingCancelled" or "meetingResponse" (a reply to an invite you sent). Requests and cancellations also carry `event` (id, time, organizer, your current `responseStatus`) so the invite can be answered by its event id (when the meeting is no longer on your calendar — already declined, cancelled or deleted — the item has a `hint` instead and there is nothing to respond to). `to`/`cc` list at most 20 addresses; a longer list adds `toCount`/`ccCount` and `toTruncated`/`ccTruncated`. This does NOT mark anything read. Processing loop: read the batch → act on each item (reply, respond to the invite, file, flag — or leave it) → call outlook_mark_read on the plain mail you handled, so the next call returns only what is still new. An invite you answer with outlook_respond_to_invite needs no mark-read: Outlook moves it to Deleted Items under a new id, so its old id would 404. Follow `nextLink` for more.' +
|
|
287
|
+
description: 'Triage batch: the unread messages in a folder (default inbox), newest first, each WITH its plain-text body (truncated to `maxBodyChars`) in one call — no follow-up outlook_get_message needed. Every item has a `kind`: "mail", "meetingRequest", "meetingCancelled" or "meetingResponse" (a reply to an invite you sent). Requests and cancellations also carry `event` (id, time, organizer, your current `responseStatus`) so the invite can be answered by its event id (when the meeting is no longer on your calendar — already declined, cancelled or deleted — the item has a `hint` instead and there is nothing to respond to). `to`/`cc` list at most 20 addresses; a longer list adds `toCount`/`ccCount` and `toTruncated`/`ccTruncated`. This does NOT mark anything read. Processing loop: read the batch → act on each item (reply, respond to the invite, file, flag — or leave it) → call outlook_mark_read on the plain mail you handled, so the next call returns only what is still new. An invite you answer with outlook_respond_to_invite needs no mark-read: Outlook moves it to Deleted Items under a new id, so its old id would 404. Follow `nextLink` for more. ' +
|
|
288
|
+
FROM_DESCRIPTION +
|
|
289
|
+
' Cannot combine with `sinceHours` or `nextLink`.' +
|
|
244
290
|
' ' + UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
245
291
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
246
292
|
inputSchema: z.object({
|
|
@@ -251,7 +297,7 @@ export function registerMailTools(server, client) {
|
|
|
251
297
|
.positive()
|
|
252
298
|
.max(24 * 365)
|
|
253
299
|
.optional()
|
|
254
|
-
.describe('Only mail received in the last N hours'),
|
|
300
|
+
.describe('Only mail received in the last N hours (not with `from`)'),
|
|
255
301
|
includeBody: z
|
|
256
302
|
.boolean()
|
|
257
303
|
.optional()
|
|
@@ -263,12 +309,17 @@ export function registerMailTools(server, client) {
|
|
|
263
309
|
.max(100_000)
|
|
264
310
|
.optional()
|
|
265
311
|
.describe('Truncate each body to this many characters (default 4000); `bodyTruncated` marks a cut'),
|
|
312
|
+
from: fromParam,
|
|
266
313
|
nextLink: nextLinkParam,
|
|
267
314
|
}),
|
|
268
|
-
}, async ({ folder, limit, sinceHours, includeBody, maxBodyChars, nextLink }) => {
|
|
315
|
+
}, async ({ folder, limit, sinceHours, includeBody, maxBodyChars, from, nextLink }) => {
|
|
316
|
+
const pos = fromPosition(from, { nextLink, sinceHours });
|
|
317
|
+
const max = limit ?? 25;
|
|
318
|
+
const keyset = pos !== undefined ? fromQuery(pos, max) : undefined;
|
|
269
319
|
// Outlook rejects a $filter that does not lead with the $orderby
|
|
270
320
|
// property ("InefficientFilter"), so the date bound goes first.
|
|
271
321
|
const filter = [
|
|
322
|
+
keyset?.bound,
|
|
272
323
|
sinceHours !== undefined ? `ReceivedDateTime ge ${sinceLiteral(sinceHours)}` : undefined,
|
|
273
324
|
'IsRead eq false',
|
|
274
325
|
]
|
|
@@ -276,13 +327,15 @@ export function registerMailTools(server, client) {
|
|
|
276
327
|
.join(' and ');
|
|
277
328
|
const data = await fetchPage(client, nextLink, `/me/mailfolders/${folderSegment(folder ?? 'inbox')}/messages`, {
|
|
278
329
|
query: {
|
|
279
|
-
$top:
|
|
330
|
+
$top: keyset?.top ?? max,
|
|
280
331
|
$select: UNREAD_SELECT,
|
|
281
332
|
$filter: filter,
|
|
282
|
-
$orderby: 'ReceivedDateTime desc',
|
|
333
|
+
$orderby: keyset ? 'ReceivedDateTime asc' : 'ReceivedDateTime desc',
|
|
283
334
|
},
|
|
284
335
|
});
|
|
285
|
-
const
|
|
336
|
+
const listed = Array.isArray(data?.value) ? data.value : [];
|
|
337
|
+
const page = pos !== undefined ? fromPage(listed, pos, max, Boolean(data?.['@odata.nextLink'])) : undefined;
|
|
338
|
+
const rows = page?.rows ?? listed;
|
|
286
339
|
const wantBody = includeBody !== false;
|
|
287
340
|
const cap = maxBodyChars ?? 4000;
|
|
288
341
|
const items = await mapWithConcurrency(rows, BODY_CONCURRENCY, async (m) => {
|
|
@@ -334,9 +387,16 @@ export function registerMailTools(server, client) {
|
|
|
334
387
|
return item;
|
|
335
388
|
});
|
|
336
389
|
const out = { count: items.length, items };
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
out.
|
|
390
|
+
if (page !== undefined) {
|
|
391
|
+
// The token supersedes the API link, which would resume newest-first.
|
|
392
|
+
out.next_from = page.next_from;
|
|
393
|
+
out.has_more = page.has_more;
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
const next = data?.['@odata.nextLink'];
|
|
397
|
+
if (next)
|
|
398
|
+
out.nextLink = next;
|
|
399
|
+
}
|
|
340
400
|
return mailboxUntrusted(out);
|
|
341
401
|
});
|
|
342
402
|
server.registerTool('outlook_list_attachments', {
|
package/dist/tools/writes.js
CHANGED
|
@@ -31,6 +31,14 @@ const teamsMeetingParam = z
|
|
|
31
31
|
.boolean()
|
|
32
32
|
.optional()
|
|
33
33
|
.describe('Attach a Microsoft Teams meeting (default true). false leaves it off.');
|
|
34
|
+
/**
|
|
35
|
+
* On update the Teams meeting is opt-in: an edit to an in-person meeting (or one
|
|
36
|
+
* on another provider) must not change how people join it unless asked.
|
|
37
|
+
*/
|
|
38
|
+
const addTeamsMeetingParam = z
|
|
39
|
+
.boolean()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('true adds a Microsoft Teams meeting to an event that lacks one (default false: the way people join is left as it is).');
|
|
34
42
|
const EVENT_STATE_SELECT = 'Id,Subject,IsOrganizer,Start,End,Location,Attendees,IsOnlineMeeting,OnlineMeetingProvider,OnlineMeeting';
|
|
35
43
|
function attendee(Address, Type) {
|
|
36
44
|
return { Type, EmailAddress: { Address } };
|
|
@@ -242,37 +250,32 @@ export function registerWriteTools(server, client) {
|
|
|
242
250
|
return minifiedResult({ sent: true, subject, recipients: recipients || null });
|
|
243
251
|
});
|
|
244
252
|
server.registerTool('outlook_create_draft', {
|
|
245
|
-
description: 'Create a draft message in the Drafts folder without sending it. Returns the created draft, which can be reviewed and sent from Outlook.' +
|
|
246
|
-
' ' +
|
|
247
|
-
|
|
248
|
-
|
|
253
|
+
description: 'Create a draft message in the Drafts folder without sending it. Returns the created draft, which can be reviewed and sent from Outlook. ' +
|
|
254
|
+
'It does not ask to confirm: a draft reaches nobody until it is sent from Outlook. Calling it twice leaves two drafts. ' +
|
|
255
|
+
TIMEOUT_SENTENCE,
|
|
256
|
+
// Self-only and additive, like outlook_reply with draftOnly: nothing is
|
|
257
|
+
// overwritten or sent. Not idempotent: a repeat creates a second draft.
|
|
258
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
249
259
|
inputSchema: z.object({
|
|
250
260
|
to: recipientList,
|
|
251
261
|
cc: recipientList,
|
|
252
262
|
subject: z.string().describe('Subject line'),
|
|
253
263
|
body: z.string().describe('Message body'),
|
|
254
264
|
html: z.boolean().optional().describe('Compose the body as HTML (default: plain text)'),
|
|
255
|
-
confirmToken: confirmTokenParam,
|
|
256
265
|
}),
|
|
257
|
-
}, async ({ to, cc, subject, body, html
|
|
266
|
+
}, async ({ to, cc, subject, body, html }) => {
|
|
258
267
|
const payload = {
|
|
259
268
|
...messageBody(subject, body, html),
|
|
260
269
|
ToRecipients: toRecipients(to),
|
|
261
270
|
...(cc?.length ? { CcRecipients: toRecipients(cc) } : {}),
|
|
262
271
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
request: { method: 'POST', path: '/me/messages', body: payload },
|
|
271
|
-
confirmToken,
|
|
272
|
-
});
|
|
273
|
-
if (gate)
|
|
274
|
-
return gate;
|
|
275
|
-
const created = await client.write('POST', '/me/messages', payload);
|
|
272
|
+
// Nothing leaves the mailbox, so there is no one to protect with a
|
|
273
|
+
// confirmation (same rule as outlook_reply draftOnly). A lost answer
|
|
274
|
+
// says to look in Drafts before retrying, so a retry does not duplicate.
|
|
275
|
+
const create = await writeOrUnknown(() => client.write('POST', '/me/messages', payload), 'Drafts');
|
|
276
|
+
if (!create.ok)
|
|
277
|
+
return create.result;
|
|
278
|
+
const created = create.value;
|
|
276
279
|
return minifiedResult({ created: true, Id: created?.Id, WebLink: created?.WebLink });
|
|
277
280
|
});
|
|
278
281
|
server.registerTool('outlook_mark_read', {
|
|
@@ -507,7 +510,7 @@ export function registerWriteTools(server, client) {
|
|
|
507
510
|
});
|
|
508
511
|
});
|
|
509
512
|
server.registerTool('outlook_update_event', {
|
|
510
|
-
description: 'Update a meeting you organize: retitle, move, relocate, edit the description, or add/remove attendees. Moving only `start` keeps the meeting\'s length.
|
|
513
|
+
description: 'Update a meeting you organize: retitle, move, relocate, edit the description, or add/remove attendees. Moving only `start` keeps the meeting\'s length. It does not add a Microsoft Teams meeting unless you pass `teamsMeeting: true` (on an event that lacks one). Attendees are sent an updated invitation. Only the organizer can update a meeting — an attendee\'s edit would change their own copy alone, so it is refused. The result is verified by re-reading the event.' +
|
|
511
514
|
' ' +
|
|
512
515
|
CONFIRM_FLOW_SENTENCE +
|
|
513
516
|
' ' +
|
|
@@ -530,7 +533,7 @@ export function registerWriteTools(server, client) {
|
|
|
530
533
|
addAttendees: recipientList.describe('Required attendees to add'),
|
|
531
534
|
addOptionalAttendees: recipientList.describe('Optional attendees to add'),
|
|
532
535
|
removeAttendees: recipientList.describe('Attendees to remove'),
|
|
533
|
-
teamsMeeting:
|
|
536
|
+
teamsMeeting: addTeamsMeetingParam,
|
|
534
537
|
confirmToken: confirmTokenParam,
|
|
535
538
|
}),
|
|
536
539
|
}, async (args, ctx) => {
|
|
@@ -603,19 +606,26 @@ export function registerWriteTools(server, client) {
|
|
|
603
606
|
}
|
|
604
607
|
payload.Attendees = next;
|
|
605
608
|
}
|
|
606
|
-
const addTeams = args.teamsMeeting
|
|
609
|
+
const addTeams = args.teamsMeeting === true && !(current && isTeams(current));
|
|
607
610
|
if (addTeams)
|
|
608
611
|
Object.assign(payload, TEAMS);
|
|
609
612
|
if (Object.keys(payload).length === 0) {
|
|
610
613
|
throw new McpToolError('Nothing to update.', {
|
|
611
|
-
hint: 'Pass at least one of subject, start, end, location, body, or
|
|
614
|
+
hint: 'Pass at least one of subject, start, end, location, body, attendee changes, or teamsMeeting: true.',
|
|
612
615
|
});
|
|
613
616
|
}
|
|
614
617
|
const gate = await confirmWrite(ctx, {
|
|
615
618
|
tool: 'outlook_update_event',
|
|
616
619
|
action: 'calendar.update_event',
|
|
617
|
-
message:
|
|
618
|
-
|
|
620
|
+
message: addTeams
|
|
621
|
+
? 'Review and confirm this change (attendees are sent an updated invitation). This will also make it a Microsoft Teams meeting: attendees get a Teams join link.'
|
|
622
|
+
: 'Review and confirm this change (attendees are sent an updated invitation):',
|
|
623
|
+
summary: `Update "${current?.Subject ?? args.id}": ${[
|
|
624
|
+
Object.keys(payload).filter((k) => !(k in TEAMS)).join(', '),
|
|
625
|
+
addTeams ? 'this will also make it a Microsoft Teams meeting' : '',
|
|
626
|
+
]
|
|
627
|
+
.filter((part) => part !== '')
|
|
628
|
+
.join('; ')}`,
|
|
619
629
|
// One signed-in mailbox per server process.
|
|
620
630
|
account: undefined,
|
|
621
631
|
target: args.id,
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrischall/office-outlook-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"mcpName": "io.github.chrischall/office-outlook-mcp",
|
|
5
5
|
"description": "Outlook / Microsoft 365 MCP server for Claude — developed and maintained by AI (Claude Code)",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typecheck": "tsc -p tsconfig.check.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@chrischall/mcp-utils": "^3.0.
|
|
49
|
-
"@fetchproxy/server": "^3.6.
|
|
48
|
+
"@chrischall/mcp-utils": "^3.0.3",
|
|
49
|
+
"@fetchproxy/server": "^3.6.2",
|
|
50
50
|
"@modelcontextprotocol/server": "^2.3.0",
|
|
51
51
|
"dotenv": "^18.0.1",
|
|
52
52
|
"zod": "^4.6.5"
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/chrischall/office-outlook-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.6.1",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@chrischall/office-outlook-mcp",
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.6.1",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|