@mcp-z/mcp-outlook 1.1.2 → 2.0.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/README.md +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mcp/prompts/draft-email.d.cts +2 -3
- package/dist/cjs/mcp/prompts/draft-email.d.ts +2 -3
- package/dist/cjs/mcp/prompts/draft-email.js.map +1 -1
- package/dist/cjs/mcp/prompts/query-syntax.d.cts +2 -3
- package/dist/cjs/mcp/prompts/query-syntax.d.ts +2 -3
- package/dist/cjs/mcp/prompts/query-syntax.js.map +1 -1
- package/dist/cjs/mcp/resources/email.d.cts +6 -5
- package/dist/cjs/mcp/resources/email.d.ts +6 -5
- package/dist/cjs/mcp/resources/email.js +2 -2
- package/dist/cjs/mcp/resources/email.js.map +1 -1
- package/dist/cjs/mcp/tools/categories-list.d.cts +1 -1
- package/dist/cjs/mcp/tools/categories-list.d.ts +1 -1
- package/dist/cjs/mcp/tools/categories-list.js +2 -2
- package/dist/cjs/mcp/tools/categories-list.js.map +1 -1
- package/dist/cjs/mcp/tools/label-add.d.cts +1 -1
- package/dist/cjs/mcp/tools/label-add.d.ts +1 -1
- package/dist/cjs/mcp/tools/label-add.js +2 -2
- package/dist/cjs/mcp/tools/label-add.js.map +1 -1
- package/dist/cjs/mcp/tools/label-delete.d.cts +1 -1
- package/dist/cjs/mcp/tools/label-delete.d.ts +1 -1
- package/dist/cjs/mcp/tools/label-delete.js +3 -3
- package/dist/cjs/mcp/tools/label-delete.js.map +1 -1
- package/dist/cjs/mcp/tools/labels-list.d.cts +1 -1
- package/dist/cjs/mcp/tools/labels-list.d.ts +1 -1
- package/dist/cjs/mcp/tools/labels-list.js +2 -2
- package/dist/cjs/mcp/tools/labels-list.js.map +1 -1
- package/dist/cjs/mcp/tools/message-get.d.cts +1 -1
- package/dist/cjs/mcp/tools/message-get.d.ts +1 -1
- package/dist/cjs/mcp/tools/message-get.js +2 -3
- package/dist/cjs/mcp/tools/message-get.js.map +1 -1
- package/dist/cjs/mcp/tools/message-mark-read.d.cts +1 -1
- package/dist/cjs/mcp/tools/message-mark-read.d.ts +1 -1
- package/dist/cjs/mcp/tools/message-mark-read.js +3 -3
- package/dist/cjs/mcp/tools/message-mark-read.js.map +1 -1
- package/dist/cjs/mcp/tools/message-move-to-trash.d.cts +1 -1
- package/dist/cjs/mcp/tools/message-move-to-trash.d.ts +1 -1
- package/dist/cjs/mcp/tools/message-move-to-trash.js +6 -6
- package/dist/cjs/mcp/tools/message-move-to-trash.js.map +1 -1
- package/dist/cjs/mcp/tools/message-respond.d.cts +1 -1
- package/dist/cjs/mcp/tools/message-respond.d.ts +1 -1
- package/dist/cjs/mcp/tools/message-respond.js +3 -3
- package/dist/cjs/mcp/tools/message-respond.js.map +1 -1
- package/dist/cjs/mcp/tools/message-search.d.cts +1 -1
- package/dist/cjs/mcp/tools/message-search.d.ts +1 -1
- package/dist/cjs/mcp/tools/message-search.js +1 -2
- package/dist/cjs/mcp/tools/message-search.js.map +1 -1
- package/dist/cjs/mcp/tools/message-send.d.cts +1 -1
- package/dist/cjs/mcp/tools/message-send.d.ts +1 -1
- package/dist/cjs/mcp/tools/message-send.js +3 -3
- package/dist/cjs/mcp/tools/message-send.js.map +1 -1
- package/dist/cjs/mcp/tools/messages-export-csv.d.cts +1 -1
- package/dist/cjs/mcp/tools/messages-export-csv.d.ts +1 -1
- package/dist/cjs/mcp/tools/messages-export-csv.js +1 -2
- package/dist/cjs/mcp/tools/messages-export-csv.js.map +1 -1
- package/dist/cjs/setup/http.d.cts +1 -1
- package/dist/cjs/setup/http.d.ts +1 -1
- package/dist/cjs/setup/http.js +28 -18
- package/dist/cjs/setup/http.js.map +1 -1
- package/dist/cjs/setup/stdio.d.cts +1 -1
- package/dist/cjs/setup/stdio.d.ts +1 -1
- package/dist/cjs/setup/stdio.js +1 -2
- package/dist/cjs/setup/stdio.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mcp/prompts/draft-email.d.ts +2 -3
- package/dist/esm/mcp/prompts/draft-email.js.map +1 -1
- package/dist/esm/mcp/prompts/query-syntax.d.ts +2 -3
- package/dist/esm/mcp/prompts/query-syntax.js.map +1 -1
- package/dist/esm/mcp/resources/email.d.ts +6 -5
- package/dist/esm/mcp/resources/email.js +1 -1
- package/dist/esm/mcp/resources/email.js.map +1 -1
- package/dist/esm/mcp/tools/categories-list.d.ts +1 -1
- package/dist/esm/mcp/tools/categories-list.js +2 -2
- package/dist/esm/mcp/tools/categories-list.js.map +1 -1
- package/dist/esm/mcp/tools/label-add.d.ts +1 -1
- package/dist/esm/mcp/tools/label-add.js +2 -2
- package/dist/esm/mcp/tools/label-add.js.map +1 -1
- package/dist/esm/mcp/tools/label-delete.d.ts +1 -1
- package/dist/esm/mcp/tools/label-delete.js +3 -3
- package/dist/esm/mcp/tools/label-delete.js.map +1 -1
- package/dist/esm/mcp/tools/labels-list.d.ts +1 -1
- package/dist/esm/mcp/tools/labels-list.js +2 -2
- package/dist/esm/mcp/tools/labels-list.js.map +1 -1
- package/dist/esm/mcp/tools/message-get.d.ts +1 -1
- package/dist/esm/mcp/tools/message-get.js +3 -4
- package/dist/esm/mcp/tools/message-get.js.map +1 -1
- package/dist/esm/mcp/tools/message-mark-read.d.ts +1 -1
- package/dist/esm/mcp/tools/message-mark-read.js +3 -3
- package/dist/esm/mcp/tools/message-mark-read.js.map +1 -1
- package/dist/esm/mcp/tools/message-move-to-trash.d.ts +1 -1
- package/dist/esm/mcp/tools/message-move-to-trash.js +6 -6
- package/dist/esm/mcp/tools/message-move-to-trash.js.map +1 -1
- package/dist/esm/mcp/tools/message-respond.d.ts +1 -1
- package/dist/esm/mcp/tools/message-respond.js +3 -3
- package/dist/esm/mcp/tools/message-respond.js.map +1 -1
- package/dist/esm/mcp/tools/message-search.d.ts +1 -1
- package/dist/esm/mcp/tools/message-search.js +2 -3
- package/dist/esm/mcp/tools/message-search.js.map +1 -1
- package/dist/esm/mcp/tools/message-send.d.ts +1 -1
- package/dist/esm/mcp/tools/message-send.js +3 -3
- package/dist/esm/mcp/tools/message-send.js.map +1 -1
- package/dist/esm/mcp/tools/messages-export-csv.d.ts +1 -1
- package/dist/esm/mcp/tools/messages-export-csv.js +2 -3
- package/dist/esm/mcp/tools/messages-export-csv.js.map +1 -1
- package/dist/esm/setup/http.d.ts +1 -1
- package/dist/esm/setup/http.js +22 -12
- package/dist/esm/setup/http.js.map +1 -1
- package/dist/esm/setup/stdio.d.ts +1 -1
- package/dist/esm/setup/stdio.js +1 -2
- package/dist/esm/setup/stdio.js.map +1 -1
- package/package.json +7 -13
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mcp-z/mcp-outlook
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server for Outlook integration with OAuth authentication, message search, and batch operations
|
|
4
4
|
|
|
5
5
|
## Common uses
|
|
6
6
|
|
|
@@ -206,3 +206,7 @@ TOKEN_STORE_URI=redis://localhost:6379 mcp-outlook
|
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
A protocol whose adapter is missing fails at startup naming the package to install.
|
|
209
|
+
|
|
210
|
+
### Documentation
|
|
211
|
+
|
|
212
|
+
[API Docs](https://mcp-z.github.io/mcp-outlook)
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/index.ts"],"sourcesContent":["import { handleVersionHelp } from './setup/version-help.ts';\nimport type { ServerConfig } from './types.ts';\n\nexport { MS_SCOPE } from './constants.ts';\nexport * as mcp from './mcp/index.ts';\n// Export input schemas for documentation visibility\nexport type { Input as CategoriesListInput } from './mcp/tools/categories-list.ts';\nexport { inputSchema as categoriesListInputSchema } from './mcp/tools/categories-list.ts';\nexport type { Input as LabelsListInput } from './mcp/tools/labels-list.ts';\nexport { inputSchema as labelsListInputSchema } from './mcp/tools/labels-list.ts';\nexport * as schemas from './schemas/index.ts';\nexport * as setup from './setup/index.ts';\nexport type { AuthMiddleware, OAuthAdapters, OAuthRuntimeDeps } from './setup/oauth-microsoft.ts';\nexport * from './types.ts';\n\nexport async function startServer(config: ServerConfig): Promise<void> {\n // createHTTPServer/createStdioServer pull in @
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/index.ts"],"sourcesContent":["import { handleVersionHelp } from './setup/version-help.ts';\nimport type { ServerConfig } from './types.ts';\n\nexport { MS_SCOPE } from './constants.ts';\nexport * as mcp from './mcp/index.ts';\n// Export input schemas for documentation visibility\nexport type { Input as CategoriesListInput } from './mcp/tools/categories-list.ts';\nexport { inputSchema as categoriesListInputSchema } from './mcp/tools/categories-list.ts';\nexport type { Input as LabelsListInput } from './mcp/tools/labels-list.ts';\nexport { inputSchema as labelsListInputSchema } from './mcp/tools/labels-list.ts';\nexport * as schemas from './schemas/index.ts';\nexport * as setup from './setup/index.ts';\nexport type { AuthMiddleware, OAuthAdapters, OAuthRuntimeDeps } from './setup/oauth-microsoft.ts';\nexport * from './types.ts';\n\nexport async function startServer(config: ServerConfig): Promise<void> {\n // createHTTPServer/createStdioServer pull in @mcp-z/server and every mcp/tools/*.ts\n // (@microsoft/microsoft-graph-client included); deferred so a --version/--help run never reaches them.\n const { createHTTPServer } = await import('./setup/http.ts');\n const { createStdioServer } = await import('./setup/stdio.ts');\n const { logger, close } = config.transport.type === 'stdio' ? await createStdioServer(config) : await createHTTPServer(config);\n\n process.on('SIGINT', async () => {\n await close();\n process.exit(0);\n });\n\n logger.info(`Server started with ${config.transport.type} transport`);\n await new Promise(() => {});\n}\n\nexport default async function main(): Promise<void> {\n // Check for help/version flags FIRST, before config parsing\n const versionHelpResult = handleVersionHelp(process.argv);\n if (versionHelpResult.handled) {\n console.log(versionHelpResult.output);\n process.exit(0);\n }\n\n // Only parse config if no help/version flags. config.ts's own heavy imports (@mcp-z/oauth-microsoft,\n // @mcp-z/server) are deferred internally, so this static-looking call stays cheap until here.\n const { createConfig } = await import('./setup/config.ts');\n const config = createConfig();\n await startServer(config);\n}\n\nif (process.argv[1] === new URL(import.meta.url).pathname) {\n main();\n}\n"],"names":["MS_SCOPE","categoriesListInputSchema","inputSchema","main","labelsListInputSchema","mcp","schemas","setup","startServer","config","createHTTPServer","createStdioServer","logger","close","transport","type","process","on","exit","info","Promise","versionHelpResult","createConfig","handleVersionHelp","argv","handled","console","log","output","URL","pathname"],"mappings":";;;;;;;;;;;QAGSA;eAAAA,qBAAQ;;QAIOC;eAAfC,6BAAW;;QAwBpB;eAA8BC;;QAtBNC;eAAfF,yBAAW;;QALRG;;;QAMAC;;;QACAC;;;QAIUC;eAAAA;;;6BAfY;2BAGT;+DACJ;gCAGoC;4BAEJ;gEAC5B;gEACF;qBAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,SAAeA,YAAYC,MAAoB;;YAG5CC,kBACAC,mBACkBF,MAAlBG,QAAQC;;;;oBAFa;;wBAAM;2EAAA,QAAO;;;;oBAAlCH,mBAAqB,cAArBA;oBACsB;;wBAAM;2EAAA,QAAO;;;;oBAAnCC,oBAAsB,cAAtBA;yBACkBF,CAAAA,OAAOK,SAAS,CAACC,IAAI,KAAK,OAAM,GAAhCN;;;;oBAAoC;;wBAAME,kBAAkBF;;;2BAAxB;;;;;;oBAAkC;;wBAAMC,iBAAiBD;;;2BAAvB;;;oBAAtEA,aAAlBG,SAAkBH,KAAlBG,QAAQC,QAAUJ,KAAVI;oBAEhBG,QAAQC,EAAE,CAAC,UAAU;;;;;wCACnB;;4CAAMJ;;;wCAAN;wCACAG,QAAQE,IAAI,CAAC;;;;;;wBACf;;oBAEAN,OAAOO,IAAI,CAAC,AAAC,uBAA4C,OAAtBV,OAAOK,SAAS,CAACC,IAAI,EAAC;oBACzD;;wBAAM,IAAIK,QAAQ,YAAO;;;oBAAzB;;;;;;IACF;;AAEe,SAAejB;;YAEtBkB,mBAQEC,cACFb;;;;oBAVN,4DAA4D;oBACtDY,oBAAoBE,IAAAA,gCAAiB,EAACP,QAAQQ,IAAI;oBACxD,IAAIH,kBAAkBI,OAAO,EAAE;wBAC7BC,QAAQC,GAAG,CAACN,kBAAkBO,MAAM;wBACpCZ,QAAQE,IAAI,CAAC;oBACf;oBAIyB;;wBAAM;2EAAA,QAAO;;;;oBAA9BI,eAAiB,cAAjBA;oBACFb,SAASa;oBACf;;wBAAMd,YAAYC;;;oBAAlB;;;;;;IACF;;AAEA,IAAIO,QAAQQ,IAAI,CAAC,EAAE,KAAK,IAAIK,IAAI,qDAAiBC,QAAQ,EAAE;IACzD3B;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
1
|
+
import type { ServerContext } from '@mcp-z/server';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
export default function createPrompt(): {
|
|
5
4
|
name: string;
|
|
@@ -12,7 +11,7 @@ export default function createPrompt(): {
|
|
|
12
11
|
};
|
|
13
12
|
handler: (args: {
|
|
14
13
|
[x: string]: unknown;
|
|
15
|
-
}, _extra:
|
|
14
|
+
}, _extra: ServerContext) => Promise<{
|
|
16
15
|
messages: ({
|
|
17
16
|
role: "system";
|
|
18
17
|
content: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
1
|
+
import type { ServerContext } from '@mcp-z/server';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
export default function createPrompt(): {
|
|
5
4
|
name: string;
|
|
@@ -12,7 +11,7 @@ export default function createPrompt(): {
|
|
|
12
11
|
};
|
|
13
12
|
handler: (args: {
|
|
14
13
|
[x: string]: unknown;
|
|
15
|
-
}, _extra:
|
|
14
|
+
}, _extra: ServerContext) => Promise<{
|
|
16
15
|
messages: ({
|
|
17
16
|
role: "system";
|
|
18
17
|
content: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/prompts/draft-email.ts"],"sourcesContent":["import type { PromptModule } from '@mcp-z/server';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/prompts/draft-email.ts"],"sourcesContent":["import type { PromptModule, ServerContext } from '@mcp-z/server';\nimport { z } from 'zod';\n\nexport default function createPrompt() {\n const argsSchema = z.object({\n context: z.string().min(1).describe('Email context to draft response for'),\n tone: z.string().optional().describe('Email tone (default: professional)'),\n });\n\n const config = {\n description: 'Draft an email response',\n argsSchema: argsSchema.shape,\n };\n\n const handler = async (args: { [x: string]: unknown }, _extra: ServerContext) => {\n const { context, tone } = argsSchema.parse(args);\n return {\n messages: [\n { role: 'system' as const, content: { type: 'text' as const, text: 'You are an expert email assistant.' } },\n { role: 'user' as const, content: { type: 'text' as const, text: `Draft a ${tone || 'professional'} email:\\n\\n${context}` } },\n ],\n };\n };\n\n return {\n name: 'draft-email',\n config,\n handler,\n } satisfies PromptModule;\n}\n"],"names":["createPrompt","argsSchema","z","object","context","string","min","describe","tone","optional","config","description","shape","handler","args","_extra","parse","messages","role","content","type","text","name"],"mappings":";;;;+BAGA;;;eAAwBA;;;mBAFN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,SAASA;IACtB,IAAMC,aAAaC,MAAC,CAACC,MAAM,CAAC;QAC1BC,SAASF,MAAC,CAACG,MAAM,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;QACpCC,MAAMN,MAAC,CAACG,MAAM,GAAGI,QAAQ,GAAGF,QAAQ,CAAC;IACvC;IAEA,IAAMG,SAAS;QACbC,aAAa;QACbV,YAAYA,WAAWW,KAAK;IAC9B;IAEA,IAAMC,UAAU,iBAAOC,MAAgCC;;gBAC3Bd,mBAAlBG,SAASI;;gBAASP,oBAAAA,WAAWe,KAAK,CAACF,OAAnCV,UAAkBH,kBAAlBG,SAASI,OAASP,kBAATO;gBACjB;;oBAAO;wBACLS,QAAQ;4BACN;gCAAEC,MAAM;gCAAmBC,SAAS;oCAAEC,MAAM;oCAAiBC,MAAM;gCAAqC;4BAAE;4BAC1G;gCAAEH,MAAM;gCAAiBC,SAAS;oCAAEC,MAAM;oCAAiBC,MAAM,AAAC,WAA8CjB,OAApCI,QAAQ,gBAAe,eAAqB,OAARJ;gCAAU;4BAAE;;oBAEhI;;;QACF;;IAEA,OAAO;QACLkB,MAAM;QACNZ,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
1
|
+
import type { ServerContext } from '@mcp-z/server';
|
|
3
2
|
export default function createPrompt(): {
|
|
4
3
|
name: string;
|
|
5
4
|
config: {
|
|
@@ -7,7 +6,7 @@ export default function createPrompt(): {
|
|
|
7
6
|
};
|
|
8
7
|
handler: (_args: {
|
|
9
8
|
[x: string]: unknown;
|
|
10
|
-
}, _extra:
|
|
9
|
+
}, _extra: ServerContext) => Promise<{
|
|
11
10
|
messages: {
|
|
12
11
|
role: "user";
|
|
13
12
|
content: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
1
|
+
import type { ServerContext } from '@mcp-z/server';
|
|
3
2
|
export default function createPrompt(): {
|
|
4
3
|
name: string;
|
|
5
4
|
config: {
|
|
@@ -7,7 +6,7 @@ export default function createPrompt(): {
|
|
|
7
6
|
};
|
|
8
7
|
handler: (_args: {
|
|
9
8
|
[x: string]: unknown;
|
|
10
|
-
}, _extra:
|
|
9
|
+
}, _extra: ServerContext) => Promise<{
|
|
11
10
|
messages: {
|
|
12
11
|
role: "user";
|
|
13
12
|
content: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/prompts/query-syntax.ts"],"sourcesContent":["import type { PromptModule } from '@mcp-z/server';\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/prompts/query-syntax.ts"],"sourcesContent":["import type { PromptModule, ServerContext } from '@mcp-z/server';\n\nexport default function createPrompt() {\n const config = {\n description: 'Reference guide for Outlook query syntax',\n };\n\n const handler = async (_args: { [x: string]: unknown }, _extra: ServerContext) => {\n return {\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: `# Outlook Query Syntax Reference\n\n## Logical Operators\n- \\`$and\\`: Array of conditions that ALL must match\n- \\`$or\\`: Array of conditions where ANY must match\n- \\`$not\\`: Condition that must NOT match\n\n## Email Address Fields\n- \\`from\\`, \\`to\\`, \\`cc\\`, \\`bcc\\`: String or field operators\n\n## Content Fields\n- \\`subject\\`: Search subject line\n- \\`body\\`: Search message body\n- \\`text\\`: Search all text content\n- \\`exactPhrase\\`: Strict exact phrase matching (KQL); wrap the phrase in quotes to keep the words together.\n\n## Search Semantics\n- Including fields such as subject, text, body, exactPhrase, or kqlQuery runs a Microsoft Graph $search. The structured filters (from, to, cc, bcc, categories, label, hasAttachment, etc.) are then applied client-side after the matching messages arrive, so those rules run once the search hits are returned.\n\n## Boolean Flags\n- \\`hasAttachment\\`: true/false\n- \\`isRead\\`: true/false\n\n## Date Range\n\\`\\`\\`json\n{ \"date\": { \"$gte\": \"2024-01-01\", \"$lt\": \"2024-12-31\" } }\n\\`\\`\\`\n\n## Outlook-Specific\n- \\`categories\\`: work, personal, family, travel, important, urgent\n- \\`label\\`: User categories (case-sensitive, use outlook-categories-list to discover)\n- \\`importance\\`: high, normal, low\n- \\`kqlQuery\\`: Escape hatch for advanced KQL syntax\n\n## Field Operators (for multi-value fields)\n- \\`$any\\`: OR - matches if ANY value matches\n- \\`$all\\`: AND - matches if ALL values match\n- \\`$none\\`: NOT - matches if NONE match\n\n## Example Queries\n\\`\\`\\`json\n// Unread from specific sender\n{ \"from\": \"boss@company.com\", \"isRead\": false }\n\n// High importance with attachment\n{ \"importance\": \"high\", \"hasAttachment\": true }\n\n// Multiple senders\n{ \"from\": { \"$any\": [\"alice@example.com\", \"bob@example.com\"] } }\n\n// Complex: work OR important category, unread\n{ \"$and\": [\n { \"categories\": { \"$any\": [\"work\", \"important\"] } },\n { \"isRead\": false }\n]}\n\\`\\`\\``,\n },\n },\n ],\n };\n };\n\n return {\n name: 'query-syntax',\n config,\n handler,\n } satisfies PromptModule;\n}\n"],"names":["createPrompt","config","description","handler","_args","_extra","messages","role","content","type","text","name"],"mappings":";;;;+BAEA;;;eAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAT,SAASA;IACtB,IAAMC,SAAS;QACbC,aAAa;IACf;IAEA,IAAMC,UAAU,iBAAOC,OAAiCC;;;gBACtD;;oBAAO;wBACLC,QAAQ;4BACN;gCACEC,MAAM;gCACNC,SAAS;oCACPC,MAAM;oCACNC,MAAM;gCAwDR;4BACF;;oBAEJ;;;QACF;;IAEA,OAAO;QACLC,MAAM;QACNV,QAAAA;QACAE,SAAAA;IACF;AACF"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import type { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
1
|
+
import type { ReadResourceResult, ServerContext } from '@mcp-z/server';
|
|
2
|
+
import { ResourceTemplate } from '@mcp-z/server';
|
|
4
3
|
export default function createResource(): {
|
|
5
4
|
name: string;
|
|
6
5
|
template: ResourceTemplate;
|
|
7
|
-
config: import("@modelcontextprotocol/
|
|
6
|
+
config: import("@modelcontextprotocol/server").ResourceMetadata & {
|
|
7
|
+
cacheHint?: import("@modelcontextprotocol/server").CacheHint;
|
|
8
|
+
};
|
|
8
9
|
handler: (uri: URL, variables: {
|
|
9
10
|
id: string;
|
|
10
|
-
}, extra:
|
|
11
|
+
}, extra: ServerContext) => Promise<ReadResourceResult>;
|
|
11
12
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import type { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
1
|
+
import type { ReadResourceResult, ServerContext } from '@mcp-z/server';
|
|
2
|
+
import { ResourceTemplate } from '@mcp-z/server';
|
|
4
3
|
export default function createResource(): {
|
|
5
4
|
name: string;
|
|
6
5
|
template: ResourceTemplate;
|
|
7
|
-
config: import("@modelcontextprotocol/
|
|
6
|
+
config: import("@modelcontextprotocol/server").ResourceMetadata & {
|
|
7
|
+
cacheHint?: import("@modelcontextprotocol/server").CacheHint;
|
|
8
|
+
};
|
|
8
9
|
handler: (uri: URL, variables: {
|
|
9
10
|
id: string;
|
|
10
|
-
}, extra:
|
|
11
|
+
}, extra: ServerContext) => Promise<ReadResourceResult>;
|
|
11
12
|
};
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _email = require("@mcp-z/email");
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
12
13
|
var _microsoftgraphclient = require("@microsoft/microsoft-graph-client");
|
|
13
|
-
var _mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
14
14
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
15
15
|
try {
|
|
16
16
|
var info = gen[key](arg);
|
|
@@ -137,7 +137,7 @@ function _ts_generator(thisArg, body) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
function createResource() {
|
|
140
|
-
var template = new
|
|
140
|
+
var template = new _server.ResourceTemplate('outlook://messages/{id}', {
|
|
141
141
|
list: undefined
|
|
142
142
|
});
|
|
143
143
|
var config = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/resources/email.ts"],"sourcesContent":["import { normalizeDateToISO as toIsoUtc } from '@mcp-z/email';\nimport type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport type { ResourceConfig, ResourceModule } from '@mcp-z/server';\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/resources/email.ts"],"sourcesContent":["import { normalizeDateToISO as toIsoUtc } from '@mcp-z/email';\nimport type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport type { ReadResourceResult, ResourceConfig, ResourceModule, ServerContext } from '@mcp-z/server';\nimport { ResourceTemplate } from '@mcp-z/server';\nimport { Client } from '@microsoft/microsoft-graph-client';\nimport type * as MicrosoftGraph from '@microsoft/microsoft-graph-types';\n\nexport default function createResource() {\n const template = new ResourceTemplate('outlook://messages/{id}', {\n list: undefined,\n });\n const config: ResourceConfig = {\n description: 'Outlook message metadata (lightweight: id, subject, from, to, date)',\n mimeType: 'application/json',\n };\n\n const handler = async (uri: URL, variables: { id: string }, extra: ServerContext): Promise<ReadResourceResult> => {\n try {\n const { logger, authContext } = extra as unknown as EnrichedExtra;\n\n logger.info(variables, 'outlook-email resource fetch');\n\n const graph = Client.initWithMiddleware({ authProvider: authContext.auth });\n const message = (await graph.api(`/me/messages/${encodeURIComponent(variables.id)}`).get()) as MicrosoftGraph.Message;\n\n // Build message data\n const toAddresses = message.toRecipients?.map((r) => r.emailAddress?.address).filter(Boolean);\n const toStr = toAddresses && toAddresses.length > 0 ? toAddresses.join(', ') : '';\n\n // Return lightweight metadata only (no body/snippet)\n const metadata = {\n id: message.id ?? variables.id,\n subject: message.subject ?? '',\n from: message.from?.emailAddress?.address ?? '',\n to: toStr,\n date: toIsoUtc(message.receivedDateTime) || message.receivedDateTime || '',\n };\n\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(metadata),\n },\n ],\n };\n } catch (e) {\n const { logger } = extra as unknown as EnrichedExtra;\n logger.error(e as Record<string, unknown>, 'outlook-email resource fetch failed');\n const error = e as { message?: unknown };\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({ error: String(error?.message ?? e) }),\n },\n ],\n };\n }\n };\n\n return {\n name: 'email',\n template,\n config,\n handler,\n } satisfies ResourceModule;\n}\n"],"names":["createResource","template","ResourceTemplate","list","undefined","config","description","mimeType","handler","uri","variables","extra","message","logger","authContext","graph","toAddresses","toStr","metadata","e","error","info","Client","initWithMiddleware","authProvider","auth","api","encodeURIComponent","id","get","toRecipients","map","r","emailAddress","address","filter","Boolean","length","join","subject","from","to","date","toIsoUtc","receivedDateTime","contents","href","text","JSON","stringify","String","name"],"mappings":";;;;+BAOA;;;eAAwBA;;;qBAPuB;sBAGd;oCACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGR,SAASA;IACtB,IAAMC,WAAW,IAAIC,wBAAgB,CAAC,2BAA2B;QAC/DC,MAAMC;IACR;IACA,IAAMC,SAAyB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C,KAAKA,IAAIqC,IAAI;wCACbvC,UAAU;wCACVwC,MAAMC,KAAKC,SAAS,CAAC/B;oCACvB;;4BAEJ;;;wBACOC;wBACCN,UAAWF,MAAXE;wBACRA,QAAOO,KAAK,CAACD,GAA8B;wBACrCC,QAAQD;wBACd;;4BAAO;gCACL0B,QAAQ;oCACN;wCACEpC,KAAKA,IAAIqC,IAAI;wCACbvC,UAAU;wCACVwC,MAAMC,KAAKC,SAAS,CAAC;4CAAE7B,OAAO8B,gBAAO9B,kBAAAA,4BAAAA,MAAOR,OAAO,yCAAIO;wCAAG;oCAC5D;;4BAEJ;;;;;;;;QAEJ;;IAEA,OAAO;QACLgC,MAAM;QACNlD,UAAAA;QACAI,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
/**
|
|
5
5
|
* Input schema for the categories-list tool
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
/**
|
|
5
5
|
* Input schema for the categories-list tool
|
|
@@ -17,8 +17,8 @@ _export(exports, {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
var _oauthmicrosoft = require("@mcp-z/oauth-microsoft");
|
|
20
|
+
var _server = require("@mcp-z/server");
|
|
20
21
|
var _microsoftgraphclient = require("@microsoft/microsoft-graph-client");
|
|
21
|
-
var _types = require("@modelcontextprotocol/sdk/types.js");
|
|
22
22
|
var _zod = require("zod");
|
|
23
23
|
var _indexts = require("../../schemas/index.js");
|
|
24
24
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -235,7 +235,7 @@ function handler(_, extra) {
|
|
|
235
235
|
logger.error('outlook.categories.list error', {
|
|
236
236
|
error: message
|
|
237
237
|
});
|
|
238
|
-
throw new
|
|
238
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error listing categories: ".concat(message), {
|
|
239
239
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
240
240
|
});
|
|
241
241
|
case 4:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/categories-list.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/categories-list.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport { type CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { Client } from '@microsoft/microsoft-graph-client';\nimport type * as MicrosoftGraph from '@microsoft/microsoft-graph-types';\nimport { z } from 'zod';\nimport { OutlookCategorySchema } from '../../schemas/index.ts';\n\n/**\n * Input schema for the categories-list tool\n *\n * Defines the validation schema for input parameters.\n */\nexport const inputSchema = z.object({});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n items: z.array(OutlookCategorySchema),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'List Outlook categories with colors and names.',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\n/**\n * Input type for the categories-list tool\n *\n * Represents the input parameters for listing Outlook categories.\n */\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler(_: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('outlook.categories.list called');\n\n try {\n const graph = Client.initWithMiddleware({ authProvider: extra.authContext.auth });\n const started = Date.now();\n\n // Call Microsoft Graph API to get master categories\n const response = await graph.api('/me/outlook/masterCategories').get();\n const categories = Array.isArray(response.value) ? response.value : [];\n\n const durationMs = Date.now() - started;\n logger.info('outlook.categories.list returning', { categoriesCount: categories.length });\n logger.info('outlook.categories.list metrics', { durationMs });\n\n const result: Output = {\n type: 'success' as const,\n items: categories.map((category: MicrosoftGraph.OutlookCategory) => ({\n id: category.id || undefined,\n displayName: category.displayName || undefined,\n color: category.color || undefined,\n })),\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('outlook.categories.list error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error listing categories: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'categories-list',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","inputSchema","AuthRequiredBranchSchema","schemas","z","object","successBranchSchema","type","literal","items","array","OutlookCategorySchema","outputSchema","discriminatedUnion","config","description","result","handler","_","extra","logger","graph","started","response","categories","durationMs","error","message","info","Client","initWithMiddleware","authProvider","authContext","auth","Date","now","api","get","Array","isArray","value","categoriesCount","length","map","category","id","undefined","displayName","color","content","text","JSON","stringify","structuredContent","Error","String","ProtocolError","ProtocolErrorCode","InternalError","stack","name"],"mappings":";;;;;;;;;;;QAwFA;eAAwBA;;QAvEXC;eAAAA;;;8BAhBW;sBAK8C;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,YAAAA;oBAAW;oBAEtDT,SAAiB;wBACrBT,MAAM;wBACNE,OAAOe,WAAWmB,GAAG,CAAC,SAACC;mCAA8C;gCACnEC,IAAID,SAASC,EAAE,IAAIC;gCACnBC,aAAaH,SAASG,WAAW,IAAID;gCACrCE,OAAOJ,SAASI,KAAK,IAAIF;4BAC3B;;oBACF;oBAEA;;wBAAO;4BACLG,OAAO;gCACL;oCACE1C,MAAM;oCACN2C,MAAMC,KAAKC,SAAS,CAACpC;gCACvB;;4BAEFqC,mBAAmB;gCAAErC,QAAAA;4BAAO;wBAC9B;;;oBACOU;oBACDC,UAAUD,AAAK,YAALA,OAAiB4B,SAAQ5B,MAAMC,OAAO,GAAG4B,OAAO7B;oBAChEN,OAAOM,KAAK,CAAC,iCAAiC;wBAAEA,OAAOC;oBAAQ;oBAE/D,MAAM,IAAI6B,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,6BAAoC,OAAR/B,UAAW;wBAC/FgC,OAAOjC,AAAK,YAALA,OAAiB4B,SAAQ5B,MAAMiC,KAAK,GAAGb;oBAChD;;;;;;;IAEJ;;AAEe,SAAS9C;IACtB,OAAO;QACL4D,MAAM;QACN9C,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodCoercedString<unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodCoercedString<unknown>;
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _oauthmicrosoft = require("@mcp-z/oauth-microsoft");
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
12
13
|
var _microsoftgraphclient = require("@microsoft/microsoft-graph-client");
|
|
13
|
-
var _types = require("@modelcontextprotocol/sdk/types.js");
|
|
14
14
|
var _zod = require("zod");
|
|
15
15
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16
16
|
try {
|
|
@@ -224,7 +224,7 @@ function handler(_0, _1) {
|
|
|
224
224
|
logger.error('outlook.label.add error', {
|
|
225
225
|
error: message
|
|
226
226
|
});
|
|
227
|
-
throw new
|
|
227
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error adding label: ".concat(message), {
|
|
228
228
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
229
229
|
});
|
|
230
230
|
case 4:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/label-add.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/label-add.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport { type CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { Client } from '@microsoft/microsoft-graph-client';\nimport { z } from 'zod';\n\nconst LabelResultSchema = z.object({\n id: z.string().describe('Message ID the categories were added to'),\n labels: z.array(z.string()).optional().describe('Categories that were applied'),\n});\n\nconst inputSchema = z.object({\n id: z.coerce.string().trim().min(1).describe('Outlook message ID to add categories to'),\n labels: z.array(z.coerce.string().trim()).min(1).describe('Category names to add (use outlook-categories-list to discover available categories)'),\n});\n\n// Success branch schema\nconst successBranchSchema = LabelResultSchema.extend({\n type: z.literal('success'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Add a label/category or move message to a folder in Outlook',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, labels }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('outlook.label.add called', { id, labels });\n\n try {\n const graph = Client.initWithMiddleware({ authProvider: extra.authContext.auth });\n await graph\n .api(`/me/messages/${encodeURIComponent(id)}`)\n .header('Content-Type', 'application/json')\n .patch({ categories: labels });\n\n const result: Output = {\n type: 'success' as const,\n id,\n labels,\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('outlook.label.add error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error adding label: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'label-add',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","LabelResultSchema","z","object","id","string","describe","labels","array","optional","inputSchema","coerce","trim","min","successBranchSchema","extend","type","literal","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","graph","error","message","info","Client","initWithMiddleware","authProvider","authContext","auth","api","encodeURIComponent","header","patch","categories","content","text","JSON","stringify","structuredContent","Error","String","ProtocolError","ProtocolErrorCode","InternalError","stack","undefined","name"],"mappings":";;;;+BA2EA;;;eAAwBA;;;8BA1EA;sBAK8C;oCAC/C;mBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AALlB,IAAM,AAAEC,2BAA6BC,uBAAO,CAApCD;AAOR,IAAME,oBAAoBC,MAAC,CAACC,MAAM,CAAC;IACjCC,IAAIF,MAAC,CAACG,MAAM,GAAGC,QAAQ,CAAC;IACxBC,QAAQL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACG,MAAM,IAAII,QAAQ,GAAGH,QAAQ,CAAC;AAClD;AAEA,IAAMI,cAAcR,MAAC,CAACC,MAAM,CAAC;IAC3BC,IAAIF,MAAC,CAACS,MAAM,CAACN,MAAM,GAAGO,IAAI,GAAGC,GAAG,CAAC,GAAGP,QAAQ,CAAC;IAC7CC,QAAQL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACS,MAAM,CAACN,MAAM,GAAGO,IAAI,IAAIC,GAAG,CAAC,GAAGP,QAAQ,CAAC;AAC5D;AAEA,wBAAwB;AACxB,IAAMQ,sBAAsBb,kBAAkBc,MAAM,CAAC;IACnDC,MAAMd,MAAC,CAACe,OAAO,CAAC;AAClB;AAEA,2CAA2C;AAC3C,IAAMC,eAAehB,MAAC,CAACiB,kBAAkB,CAAC,QAAQ;IAACL;IAAqBf;CAAyB;AAEjG,IAAMqB,SAAS;IACbC,aAAa;IACbX,aAAaA;IACbQ,cAAchB,MAAC,CAACC,MAAM,CAAC;QACrBmB,QAAQJ;IACV;AACF;AAKA,SAAeK;wCAAQ,KAAqB,EAAEC,KAAoB;YAAzCpB,IAAIG,QACrBkB,QAIEC,OAMAJ,QAeCK,OACDC;;;;oBA3BexB,KAAF,MAAEA,IAAIG,SAAN,MAAMA;oBACrBkB,SAASD,MAAMC,MAAM;oBAC3BA,OAAOI,IAAI,CAAC,4BAA4B;wBAAEzB,IAAAA;wBAAIG,QAAAA;oBAAO;;;;;;;;;oBAG7CmB,QAAQI,4BAAM,CAACC,kBAAkB,CAAC;wBAAEC,cAAcR,MAAMS,WAAW,CAACC,IAAI;oBAAC;oBAC/E;;wBAAMR,MACHS,GAAG,CAAC,AAAC,gBAAsC,OAAvBC,mBAAmBhC,MACvCiC,MAAM,CAAC,gBAAgB,oBACvBC,KAAK,CAAC;4BAAEC,YAAYhC;wBAAO;;;oBAH9B;oBAKMe,SAAiB;wBACrBN,MAAM;wBACNZ,IAAAA;wBACAG,QAAAA;oBACF;oBAEA;;wBAAO;4BACLiC,OAAO;gCACL;oCACExB,MAAM;oCACNyB,MAAMC,KAAKC,SAAS,CAACrB;gCACvB;;4BAEFsB,mBAAmB;gCAAEtB,QAAAA;4BAAO;wBAC9B;;;oBACOK;oBACDC,UAAUD,AAAK,YAALA,OAAiBkB,SAAQlB,MAAMC,OAAO,GAAGkB,OAAOnB;oBAChEF,OAAOE,KAAK,CAAC,2BAA2B;wBAAEA,OAAOC;oBAAQ;oBAEzD,MAAM,IAAImB,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,uBAA8B,OAARrB,UAAW;wBACzFsB,OAAOvB,AAAK,YAALA,OAAiBkB,SAAQlB,MAAMuB,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAASrD;IACtB,OAAO;QACLsD,MAAM;QACNhC,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
ids: z.ZodArray<z.ZodCoercedString<unknown>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
ids: z.ZodArray<z.ZodCoercedString<unknown>>;
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _oauthmicrosoft = require("@mcp-z/oauth-microsoft");
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
12
13
|
var _microsoftgraphclient = require("@microsoft/microsoft-graph-client");
|
|
13
|
-
var _types = require("@modelcontextprotocol/sdk/types.js");
|
|
14
14
|
var _zod = require("zod");
|
|
15
15
|
var _constantsts = require("../../constants.js");
|
|
16
16
|
function _array_like_to_array(arr, len) {
|
|
@@ -267,7 +267,7 @@ function handler(_0, _1) {
|
|
|
267
267
|
invalidIds: invalidIds,
|
|
268
268
|
count: invalidIds.length
|
|
269
269
|
});
|
|
270
|
-
throw new
|
|
270
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Found ".concat(invalidIds.length, " invalid IDs (contain invalid characters): ").concat(invalidIds.join(', ')));
|
|
271
271
|
}
|
|
272
272
|
_state.label = 1;
|
|
273
273
|
case 1:
|
|
@@ -480,7 +480,7 @@ function handler(_0, _1) {
|
|
|
480
480
|
logger.error('outlook-label-delete error', {
|
|
481
481
|
error: message
|
|
482
482
|
});
|
|
483
|
-
throw new
|
|
483
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error deleting categories: ".concat(message), {
|
|
484
484
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
485
485
|
});
|
|
486
486
|
case 7:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/label-delete.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport { Client } from '@microsoft/microsoft-graph-client';\nimport { type CallToolResult, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\nimport { CHUNK_SIZE, MAX_BATCH_SIZE } from '../../constants.ts';\n\nconst BatchResultSchema = z.object({\n totalRequested: z.number().describe('Total number of categories requested to delete'),\n successCount: z.number().describe('Number of categories successfully deleted'),\n failureCount: z.number().describe('Number of categories that failed to delete'),\n results: z\n .array(\n z.object({\n id: z.string().describe('Category ID'),\n success: z.boolean().describe('Whether the operation succeeded'),\n error: z.string().optional().describe('Error message if operation failed'),\n })\n )\n .describe('Individual results for each category'),\n});\n\nconst inputSchema = z.object({\n ids: z.array(z.coerce.string().trim().min(1)).min(1).max(MAX_BATCH_SIZE).describe('Outlook category IDs to delete'),\n});\n\n// Success branch schema\nconst successBranchSchema = BatchResultSchema.extend({\n type: z.literal('success'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Delete Outlook categories permanently (irreversible). Categories organize messages by color and name.',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ ids }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('outlook-label-delete called', { count: ids.length });\n\n // Validate IDs for Outlook-specific constraints\n // Note: Schema already validates non-empty, trimmed strings with min/max length\n // This check enforces business rule: Outlook category IDs cannot contain path separators or angle brackets\n const invalidIds: string[] = [];\n for (const id of ids) {\n if (id.includes('/') || id.includes('\\\\') || id.includes('<') || id.includes('>')) {\n invalidIds.push(id);\n }\n }\n\n if (invalidIds.length > 0) {\n logger.info('outlook-label-delete found invalid ids', { invalidIds, count: invalidIds.length });\n throw new McpError(ErrorCode.InvalidParams, `Found ${invalidIds.length} invalid IDs (contain invalid characters): ${invalidIds.join(', ')}`);\n }\n\n try {\n const graph = Client.initWithMiddleware({ authProvider: extra.authContext.auth });\n // Process deletions in chunks to prevent memory exhaustion\n const allResults: Array<{ id: string; success: boolean; error?: string }> = [];\n\n for (let i = 0; i < ids.length; i += CHUNK_SIZE) {\n const chunk = ids.slice(i, i + CHUNK_SIZE);\n logger.info('Processing chunk', { chunkIndex: i / CHUNK_SIZE + 1, chunkSize: chunk.length, totalChunks: Math.ceil(ids.length / CHUNK_SIZE) });\n\n // Delete categories sequentially to avoid API lock conflicts\n const chunkResults: Array<{ status: string; value?: unknown; reason?: unknown }> = [];\n for (const id of chunk) {\n try {\n await graph.api(`/me/outlook/masterCategories/${encodeURIComponent(id)}`).delete();\n chunkResults.push({ status: 'fulfilled', value: { id, success: true } });\n } catch (error) {\n chunkResults.push({ status: 'rejected', reason: error });\n }\n }\n\n // Process chunk results\n const processedChunkResults = chunkResults.map((result, chunkIndex) => {\n const id = chunk[chunkIndex];\n if (!id) {\n throw new Error(`Chunk index ${chunkIndex} is out of bounds for chunk of size ${chunk.length}`);\n }\n if (result.status === 'fulfilled') {\n return { id, success: true };\n }\n\n // Extract error message more robustly\n let errorMessage = 'Unknown error';\n if (result.reason) {\n if (typeof result.reason === 'string') {\n errorMessage = result.reason;\n } else if (result.reason instanceof Error) {\n errorMessage = result.reason.message;\n } else if (result.reason && typeof result.reason === 'object' && 'message' in result.reason) {\n errorMessage = String(result.reason.message);\n } else if (result.reason && typeof result.reason === 'object' && 'error' in result.reason) {\n errorMessage = String(result.reason.error);\n } else {\n errorMessage = String(result.reason);\n }\n }\n\n return { id, success: false, error: errorMessage };\n });\n\n allResults.push(...processedChunkResults);\n }\n\n const successCount = allResults.filter((r) => r.success).length;\n const failureCount = allResults.filter((r) => !r.success).length;\n\n const result: Output = {\n type: 'success' as const,\n totalRequested: ids.length,\n successCount,\n failureCount,\n results: allResults,\n };\n\n logger.info('outlook-label-delete completed', {\n totalRequested: ids.length,\n successCount,\n failureCount,\n chunksProcessed: Math.ceil(ids.length / CHUNK_SIZE),\n });\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('outlook-label-delete error', { error: message });\n\n throw new McpError(ErrorCode.InternalError, `Error deleting categories: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'label-delete',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","BatchResultSchema","z","object","totalRequested","number","describe","successCount","failureCount","results","array","id","string","success","boolean","error","optional","inputSchema","ids","coerce","trim","min","max","MAX_BATCH_SIZE","successBranchSchema","extend","type","literal","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","invalidIds","graph","allResults","i","message","info","count","length","includes","push","McpError","ErrorCode","InvalidParams","join","chunk","chunkResults","processedChunkResults","slice","CHUNK_SIZE","chunkIndex","chunkSize","totalChunks","Math","ceil","api","encodeURIComponent","delete","status","value","reason","map","Error","errorMessage","String","Client","initWithMiddleware","authProvider","authContext","auth","filter","r","chunksProcessed","content","text","JSON","stringify","structuredContent","InternalError","stack","undefined","name"],"mappings":";;;;+BA6JA;;;eAAwBA;;;8BA5JA;oCAKD;qBACkC;mBACvC;2BACyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AK,CAAC,8BAA8B;wBAAEA,OAAOyB;oBAAQ;oBAE5D,MAAM,IAAIM,eAAQ,CAACC,gBAAS,CAACoC,aAAa,EAAE,AAAC,8BAAqC,OAAR3C,UAAW;wBACnF4C,OAAOrE,AAAK,YAALA,OAAiBoD,SAAQpD,MAAMqE,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAASvF;IACtB,OAAO;QACLwF,MAAM;QACNxD,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/label-delete.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport { type CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { Client } from '@microsoft/microsoft-graph-client';\nimport { z } from 'zod';\nimport { CHUNK_SIZE, MAX_BATCH_SIZE } from '../../constants.ts';\n\nconst BatchResultSchema = z.object({\n totalRequested: z.number().describe('Total number of categories requested to delete'),\n successCount: z.number().describe('Number of categories successfully deleted'),\n failureCount: z.number().describe('Number of categories that failed to delete'),\n results: z\n .array(\n z.object({\n id: z.string().describe('Category ID'),\n success: z.boolean().describe('Whether the operation succeeded'),\n error: z.string().optional().describe('Error message if operation failed'),\n })\n )\n .describe('Individual results for each category'),\n});\n\nconst inputSchema = z.object({\n ids: z.array(z.coerce.string().trim().min(1)).min(1).max(MAX_BATCH_SIZE).describe('Outlook category IDs to delete'),\n});\n\n// Success branch schema\nconst successBranchSchema = BatchResultSchema.extend({\n type: z.literal('success'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Delete Outlook categories permanently (irreversible). Categories organize messages by color and name.',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ ids }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('outlook-label-delete called', { count: ids.length });\n\n // Validate IDs for Outlook-specific constraints\n // Note: Schema already validates non-empty, trimmed strings with min/max length\n // This check enforces business rule: Outlook category IDs cannot contain path separators or angle brackets\n const invalidIds: string[] = [];\n for (const id of ids) {\n if (id.includes('/') || id.includes('\\\\') || id.includes('<') || id.includes('>')) {\n invalidIds.push(id);\n }\n }\n\n if (invalidIds.length > 0) {\n logger.info('outlook-label-delete found invalid ids', { invalidIds, count: invalidIds.length });\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Found ${invalidIds.length} invalid IDs (contain invalid characters): ${invalidIds.join(', ')}`);\n }\n\n try {\n const graph = Client.initWithMiddleware({ authProvider: extra.authContext.auth });\n // Process deletions in chunks to prevent memory exhaustion\n const allResults: Array<{ id: string; success: boolean; error?: string }> = [];\n\n for (let i = 0; i < ids.length; i += CHUNK_SIZE) {\n const chunk = ids.slice(i, i + CHUNK_SIZE);\n logger.info('Processing chunk', { chunkIndex: i / CHUNK_SIZE + 1, chunkSize: chunk.length, totalChunks: Math.ceil(ids.length / CHUNK_SIZE) });\n\n // Delete categories sequentially to avoid API lock conflicts\n const chunkResults: Array<{ status: string; value?: unknown; reason?: unknown }> = [];\n for (const id of chunk) {\n try {\n await graph.api(`/me/outlook/masterCategories/${encodeURIComponent(id)}`).delete();\n chunkResults.push({ status: 'fulfilled', value: { id, success: true } });\n } catch (error) {\n chunkResults.push({ status: 'rejected', reason: error });\n }\n }\n\n // Process chunk results\n const processedChunkResults = chunkResults.map((result, chunkIndex) => {\n const id = chunk[chunkIndex];\n if (!id) {\n throw new Error(`Chunk index ${chunkIndex} is out of bounds for chunk of size ${chunk.length}`);\n }\n if (result.status === 'fulfilled') {\n return { id, success: true };\n }\n\n // Extract error message more robustly\n let errorMessage = 'Unknown error';\n if (result.reason) {\n if (typeof result.reason === 'string') {\n errorMessage = result.reason;\n } else if (result.reason instanceof Error) {\n errorMessage = result.reason.message;\n } else if (result.reason && typeof result.reason === 'object' && 'message' in result.reason) {\n errorMessage = String(result.reason.message);\n } else if (result.reason && typeof result.reason === 'object' && 'error' in result.reason) {\n errorMessage = String(result.reason.error);\n } else {\n errorMessage = String(result.reason);\n }\n }\n\n return { id, success: false, error: errorMessage };\n });\n\n allResults.push(...processedChunkResults);\n }\n\n const successCount = allResults.filter((r) => r.success).length;\n const failureCount = allResults.filter((r) => !r.success).length;\n\n const result: Output = {\n type: 'success' as const,\n totalRequested: ids.length,\n successCount,\n failureCount,\n results: allResults,\n };\n\n logger.info('outlook-label-delete completed', {\n totalRequested: ids.length,\n successCount,\n failureCount,\n chunksProcessed: Math.ceil(ids.length / CHUNK_SIZE),\n });\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('outlook-label-delete error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error deleting categories: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'label-delete',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","BatchResultSchema","z","object","totalRequested","number","describe","successCount","failureCount","results","array","id","string","success","boolean","error","optional","inputSchema","ids","coerce","trim","min","max","MAX_BATCH_SIZE","successBranchSchema","extend","type","literal","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","invalidIds","graph","allResults","i","message","info","count","length","includes","push","ProtocolError","ProtocolErrorCode","InvalidParams","join","chunk","chunkResults","processedChunkResults","slice","CHUNK_SIZE","chunkIndex","chunkSize","totalChunks","Math","ceil","api","encodeURIComponent","delete","status","value","reason","map","Error","errorMessage","String","Client","initWithMiddleware","authProvider","authContext","auth","filter","r","chunksProcessed","content","text","JSON","stringify","structuredContent","InternalError","stack","undefined","name"],"mappings":";;;;+BA6JA;;;eAAwBA;;;8BA5JA;sBAK8C;oCAC/C;mBACL;2BACyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAN3C,IAAM,AAAEC,2BAA6BC,uBAAO,CAApCD;AAQR,IAAME,oBAAoBC,MAAC,CAACC,MAAM,CAAC;IACjCC,gBAAgBF,MAAC,CAACG,MAAM,GAAGC,QAAQ,CAAC;IACpCC,cAAcL,MAAC,CAACG,MAAM,GAAGC,QAAQ,CAAC;IAClCE,cAAcN,MAAC,CAACG,MAAM,GAAGC,QAAQ,CAAC;IAClCG,SAASP,MAAC,CACPQ,KAAK,CACJR,MAAC,CAACC,MAAM,CAAC;QACPQ,IAAIT,MAAC,CAACU,MAAM,GAAGN,QAAQ,CAAC;QACxBO,SAASX,MAAC,CAACY,OAAO,GAAGR,QAAQ,CAAC;QAC9BS,OAAOb,MAAC,CAACU,MAAM,GAAGI,QAAQ,GAAGV,QAAQ,CAAC;IACxC,IAEDA,QAAQ,CAAC;AACd;AAEA,IAAMW,cAAcf,MAAC,CAACC,MAAM,CAAC;IAC3Be,KAAKhB,MAAC,CAACQ,KAAK,CAACR,MAAC,CAACiB,MAAM,CAACP,MAAM,GAAGQ,IAAI,GAAGC,GAAG,CAAC,IAAIA,GAAG,CAAC,GAAGC,GAAG,CAACC,2BAAc,EAAEjB,QAAQ,CAAC;AACpF;AAEA,wBAAwB;AACxB,IAAMkB,sBAAsBvB,kBAAkBwB,MAAM,CAAC;IACnDC,MAAMxB,MAAC,CAACyB,OAAO,CAAC;AAClB;AA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,MAAM;wBAC1BpC,cAAAA;wBACAC,cAAAA;wBACAqE,iBAAiBnB,KAAKC,IAAI,CAACzC,IAAIyB,MAAM,GAAGW,uBAAU;oBACpD;oBAEA;;wBAAO;4BACLwB,OAAO;gCACL;oCACEpD,MAAM;oCACNqD,MAAMC,KAAKC,SAAS,CAACjD;gCACvB;;4BAEFkD,mBAAmB;gCAAElD,QAAAA;4BAAO;wBAC9B;;;oBACOjB;oBACDyB,UAAUzB,AAAK,YAALA,OAAiBoD,SAAQpD,MAAMyB,OAAO,GAAG6B,OAAOtD;oBAChEoB,OAAOpB,KAAK,CAAC,8BAA8B;wBAAEA,OAAOyB;oBAAQ;oBAE5D,MAAM,IAAIM,qBAAa,CAACC,yBAAiB,CAACoC,aAAa,EAAE,AAAC,8BAAqC,OAAR3C,UAAW;wBAChG4C,OAAOrE,AAAK,YAALA,OAAiBoD,SAAQpD,MAAMqE,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAASvF;IACtB,OAAO;QACLwF,MAAM;QACNxD,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -17,8 +17,8 @@ _export(exports, {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
var _oauthmicrosoft = require("@mcp-z/oauth-microsoft");
|
|
20
|
+
var _server = require("@mcp-z/server");
|
|
20
21
|
var _microsoftgraphclient = require("@microsoft/microsoft-graph-client");
|
|
21
|
-
var _types = require("@modelcontextprotocol/sdk/types.js");
|
|
22
22
|
var _zod = require("zod");
|
|
23
23
|
var _indexts = require("../../schemas/index.js");
|
|
24
24
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -235,7 +235,7 @@ function handler(_, extra) {
|
|
|
235
235
|
logger.error('outlook.labels.list error', {
|
|
236
236
|
error: message
|
|
237
237
|
});
|
|
238
|
-
throw new
|
|
238
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error listing labels: ".concat(message), {
|
|
239
239
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
240
240
|
});
|
|
241
241
|
case 4:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/labels-list.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\nimport type { ToolModule } from '@mcp-z/server';\nimport {
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-outlook/src/mcp/tools/labels-list.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';\nimport { schemas } from '@mcp-z/oauth-microsoft';\nimport type { ToolModule } from '@mcp-z/server';\nimport { type CallToolResult, ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { Client } from '@microsoft/microsoft-graph-client';\nimport type * as MicrosoftGraph from '@microsoft/microsoft-graph-types';\nimport { z } from 'zod';\nimport { OutlookCategorySchema } from '../../schemas/index.ts';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\n/**\n * Input schema for the labels-list tool\n *\n * Defines the validation schema for input parameters.\n */\nexport const inputSchema = z.object({});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n items: z.array(OutlookCategorySchema),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'List Outlook categories for label: query syntax. Case-sensitive.',\n inputSchema: inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\n/**\n * Input type for the labels-list tool\n *\n * Represents the input parameters for listing Outlook labels.\n */\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler(_: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('outlook.labels.list called');\n\n try {\n const graph = Client.initWithMiddleware({ authProvider: extra.authContext.auth });\n const started = Date.now();\n\n // Call Microsoft Graph API to get master categories (same as categories tool)\n const response = await graph.api('/me/outlook/masterCategories').get();\n const categories = Array.isArray(response.value) ? response.value : [];\n\n const durationMs = Date.now() - started;\n logger.info('outlook.labels.list returning', { labelsCount: categories.length });\n logger.info('outlook.labels.list metrics', { durationMs });\n\n const result: Output = {\n type: 'success' as const,\n items: categories.map((category: MicrosoftGraph.OutlookCategory) => ({\n id: category.id || undefined,\n displayName: category.displayName || undefined,\n color: category.color || undefined,\n })),\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('outlook.labels.list error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error listing labels: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'labels-list',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","inputSchema","AuthRequiredBranchSchema","schemas","z","object","successBranchSchema","type","literal","items","array","OutlookCategorySchema","outputSchema","discriminatedUnion","config","description","result","handler","_","extra","logger","graph","started","response","categories","durationMs","error","message","info","Client","initWithMiddleware","authProvider","authContext","auth","Date","now","api","get","Array","isArray","value","labelsCount","length","map","category","id","undefined","displayName","color","content","text","JSON","stringify","structuredContent","Error","String","ProtocolError","ProtocolErrorCode","InternalError","stack","name"],"mappings":";;;;;;;;;;;QAuFA;eAAwBA;;QAvEXC;eAAAA;;;8BAfW;sBAE8C;oCAC/C;mBAEL;uBACoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,IAAM,AAAEC,2BAA6BC,uBAAO,CAApCD;AAOD,IAAMD,cAAcG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L;oCACE1C,MAAM;oCACN2C,MAAMC,KAAKC,SAAS,CAACpC;gCACvB;;4BAEFqC,mBAAmB;gCAAErC,QAAAA;4BAAO;wBAC9B;;;oBACOU;oBACDC,UAAUD,AAAK,YAALA,OAAiB4B,SAAQ5B,MAAMC,OAAO,GAAG4B,OAAO7B;oBAChEN,OAAOM,KAAK,CAAC,6BAA6B;wBAAEA,OAAOC;oBAAQ;oBAE3D,MAAM,IAAI6B,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,yBAAgC,OAAR/B,UAAW;wBAC3FgC,OAAOjC,AAAK,YAALA,OAAiB4B,SAAQ5B,MAAMiC,KAAK,GAAGb;oBAChD;;;;;;;IAEJ;;AAEe,SAAS9C;IACtB,OAAO;QACL4D,MAAM;QACN9C,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodCoercedString<unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-microsoft';
|
|
2
|
-
import { type CallToolResult } from '@
|
|
2
|
+
import { type CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodCoercedString<unknown>;
|
|
@@ -12,7 +12,6 @@ var _email = require("@mcp-z/email");
|
|
|
12
12
|
var _oauthmicrosoft = require("@mcp-z/oauth-microsoft");
|
|
13
13
|
var _server = require("@mcp-z/server");
|
|
14
14
|
var _microsoftgraphclient = require("@microsoft/microsoft-graph-client");
|
|
15
|
-
var _types = require("@modelcontextprotocol/sdk/types.js");
|
|
16
15
|
var _zod = require("zod");
|
|
17
16
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
18
17
|
try {
|
|
@@ -189,7 +188,7 @@ function handler(_0, _1) {
|
|
|
189
188
|
});
|
|
190
189
|
if (!id) {
|
|
191
190
|
logger.info('outlook.message.get missing id');
|
|
192
|
-
throw new
|
|
191
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, 'Missing id');
|
|
193
192
|
}
|
|
194
193
|
_state.label = 1;
|
|
195
194
|
case 1:
|
|
@@ -264,7 +263,7 @@ function handler(_0, _1) {
|
|
|
264
263
|
logger.error('outlook.message.get error', {
|
|
265
264
|
error: message1
|
|
266
265
|
});
|
|
267
|
-
throw new
|
|
266
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error getting message: ".concat(message1), {
|
|
268
267
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
269
268
|
});
|
|
270
269
|
case 4:
|