@kbzowski/mcp-inbox 0.4.0 → 0.5.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 +25 -214
- package/dist/app.js +774 -398
- package/dist/cache/queries.d.ts +25 -3
- package/dist/cache/schema.d.ts +24 -2
- package/dist/cache/sync.d.ts +16 -6
- package/dist/config/env.d.ts +15 -27
- package/dist/imap/client.d.ts +9 -1
- package/dist/imap/mime-builder.d.ts +12 -0
- package/dist/imap/search.d.ts +6 -0
- package/dist/index.js +0 -1
- package/dist/migrations/20260804112339_fantastic_miss_america/migration.sql +1 -0
- package/dist/migrations/20260804112339_fantastic_miss_america/snapshot.json +310 -0
- package/dist/tools/compose-schema.d.ts +14 -0
- package/dist/tools/drafts/create-draft.d.ts +5 -0
- package/dist/tools/drafts/get-draft.d.ts +1 -1
- package/dist/tools/drafts/list-drafts.d.ts +1 -1
- package/dist/tools/drafts/update-draft.d.ts +5 -0
- package/dist/tools/emails/flags.d.ts +15 -0
- package/dist/tools/emails/get-email.d.ts +1 -1
- package/dist/tools/emails/list-emails.d.ts +1 -1
- package/dist/tools/emails/search-emails.d.ts +3 -1
- package/dist/tools/emails/set-flags.d.ts +13 -0
- package/dist/tools/emails/shared.d.ts +25 -27
- package/dist/tools/send/forward.d.ts +7 -1
- package/dist/tools/send/reply.d.ts +14 -1
- package/dist/tools/send/send-email.d.ts +5 -0
- package/package.json +12 -13
- package/dist/app.js.map +0 -7
- package/dist/index.js.map +0 -7
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
export declare const getEmailTool: import("../define-tool").ToolDefinition<z.ZodObject<{
|
|
3
3
|
folder: z.ZodString;
|
|
4
4
|
uid: z.ZodNumber;
|
|
5
|
-
max_staleness_seconds: z.
|
|
5
|
+
max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
|
|
6
6
|
response_format: z.ZodDefault<z.ZodEnum<{
|
|
7
7
|
json: "json";
|
|
8
8
|
markdown: "markdown";
|
|
@@ -6,7 +6,7 @@ export declare const listEmailsTool: import("../define-tool").ToolDefinition<z.Z
|
|
|
6
6
|
unseen_only: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
since_date: z.ZodOptional<z.ZodString>;
|
|
8
8
|
before_date: z.ZodOptional<z.ZodString>;
|
|
9
|
-
max_staleness_seconds: z.
|
|
9
|
+
max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
|
|
10
10
|
response_format: z.ZodDefault<z.ZodEnum<{
|
|
11
11
|
json: "json";
|
|
12
12
|
markdown: "markdown";
|
|
@@ -7,6 +7,8 @@ export declare const searchEmailsTool: import("../define-tool").ToolDefinition<z
|
|
|
7
7
|
to: z.ZodOptional<z.ZodString>;
|
|
8
8
|
body: z.ZodOptional<z.ZodString>;
|
|
9
9
|
unseen: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
flagged: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
answered: z.ZodOptional<z.ZodBoolean>;
|
|
10
12
|
since_date: z.ZodOptional<z.ZodString>;
|
|
11
13
|
before_date: z.ZodOptional<z.ZodString>;
|
|
12
14
|
larger_than_bytes: z.ZodOptional<z.ZodNumber>;
|
|
@@ -14,7 +16,7 @@ export declare const searchEmailsTool: import("../define-tool").ToolDefinition<z
|
|
|
14
16
|
or: z.ZodOptional<z.ZodArray<z.ZodType<EmailSearchCriteria, unknown, z.core.$ZodTypeInternals<EmailSearchCriteria, unknown>>>>;
|
|
15
17
|
not: z.ZodOptional<z.ZodType<EmailSearchCriteria, unknown, z.core.$ZodTypeInternals<EmailSearchCriteria, unknown>>>;
|
|
16
18
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
17
|
-
max_staleness_seconds: z.
|
|
19
|
+
max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
|
|
18
20
|
response_format: z.ZodDefault<z.ZodEnum<{
|
|
19
21
|
json: "json";
|
|
20
22
|
markdown: "markdown";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const setFlagsTool: import("../define-tool").ToolDefinition<z.ZodObject<{
|
|
3
|
+
folder: z.ZodString;
|
|
4
|
+
uids: z.ZodArray<z.ZodNumber>;
|
|
5
|
+
add: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
6
|
+
"\\Answered": "\\Answered";
|
|
7
|
+
"\\Flagged": "\\Flagged";
|
|
8
|
+
}>>>;
|
|
9
|
+
remove: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
10
|
+
"\\Answered": "\\Answered";
|
|
11
|
+
"\\Flagged": "\\Flagged";
|
|
12
|
+
}>>>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ToolContext } from '../define-tool';
|
|
2
2
|
import { type ListEmailsOptions } from '../../cache/queries';
|
|
3
|
-
import type { Email } from '../../cache/schema';
|
|
3
|
+
import type { AttachmentInfo, Email } from '../../cache/schema';
|
|
4
4
|
import { type SpecialUseAttr } from '../../imap/folders';
|
|
5
5
|
/**
|
|
6
|
-
* Sync a folder if its cache is older than `maxStalenessSec
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Sync a folder if its cache is older than `maxStalenessSec`, which falls
|
|
7
|
+
* back to IMAP_CACHE_DEFAULT_STALENESS_SEC when the caller omits it.
|
|
8
|
+
* Returns true iff a sync actually ran, so callers can decorate their
|
|
9
|
+
* response with `served_from: "cache" | "sync"`.
|
|
9
10
|
*/
|
|
10
|
-
export declare function syncIfStale(ctx: ToolContext, folder: string, maxStalenessSec
|
|
11
|
+
export declare function syncIfStale(ctx: ToolContext, folder: string, maxStalenessSec?: number): Promise<boolean>;
|
|
11
12
|
/**
|
|
12
13
|
* Read envelopes from the cache with pagination. `syncIfStale` should
|
|
13
14
|
* be called first if the caller wants fresh data.
|
|
@@ -23,38 +24,35 @@ export declare function readEnvelopes(ctx: ToolContext, folder: string, opts: Li
|
|
|
23
24
|
* explicit override when the server lacks RFC 6154 SPECIAL-USE.
|
|
24
25
|
*/
|
|
25
26
|
export declare function resolveSpecialFolder(ctx: ToolContext, attr: SpecialUseAttr, explicitOverride?: string): Promise<string>;
|
|
27
|
+
export type { AttachmentInfo };
|
|
28
|
+
export interface CachedBodyResult {
|
|
29
|
+
bodyText: string | null;
|
|
30
|
+
bodyHtml: string | null;
|
|
31
|
+
attachments: AttachmentInfo[];
|
|
32
|
+
}
|
|
33
|
+
/** Fetch a message's raw RFC 2822 source. Always hits the network. */
|
|
34
|
+
export declare function fetchRawSource(ctx: ToolContext, folder: string, uid: number): Promise<Buffer>;
|
|
26
35
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* client. If the user wants the file, they open their mail client.
|
|
36
|
+
* Fetch a message's body and attachment metadata, caching both on first
|
|
37
|
+
* access. Message bodies are immutable, so a cached entry is served
|
|
38
|
+
* without touching the network - no staleness window applies.
|
|
31
39
|
*/
|
|
32
|
-
export
|
|
33
|
-
filename: string | null;
|
|
34
|
-
content_type: string;
|
|
35
|
-
size_bytes: number;
|
|
36
|
-
}
|
|
40
|
+
export declare function ensureBodyCached(ctx: ToolContext, folder: string, uid: number): Promise<CachedBodyResult>;
|
|
37
41
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* Also returns attachment metadata (filename + content-type + size) so
|
|
43
|
-
* tools can describe what's attached without downloading bytes. The
|
|
44
|
-
* metadata itself is re-derived on each call since it's small and the
|
|
45
|
-
* canonical source is the live message.
|
|
42
|
+
* Like `ensureBodyCached`, but also returns the raw source. Callers that
|
|
43
|
+
* need the bytes (forwarding the original verbatim) get them in the same
|
|
44
|
+
* single fetch instead of paying a second round-trip.
|
|
46
45
|
*/
|
|
47
|
-
export declare function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
attachments: AttachmentInfo[];
|
|
46
|
+
export declare function ensureBodyAndSource(ctx: ToolContext, folder: string, uid: number): Promise<{
|
|
47
|
+
body: CachedBodyResult;
|
|
48
|
+
source: Buffer;
|
|
51
49
|
}>;
|
|
52
50
|
/**
|
|
53
51
|
* Ensure an envelope is cached for (folder, uid). If missing - or if
|
|
54
52
|
* the folder cache is stale per `maxStalenessSec` - triggers a sync
|
|
55
53
|
* first. Returns the cached Email or throws IMAP_MESSAGE_NOT_FOUND.
|
|
56
54
|
*/
|
|
57
|
-
export declare function ensureEnvelopeCached(ctx: ToolContext, folder: string, uid: number, maxStalenessSec
|
|
55
|
+
export declare function ensureEnvelopeCached(ctx: ToolContext, folder: string, uid: number, maxStalenessSec?: number): Promise<Email>;
|
|
58
56
|
/**
|
|
59
57
|
* Project an Email row to the public tool response shape.
|
|
60
58
|
* Hides internal fields (envelope_json blob, modseq, cache timestamps).
|
|
@@ -7,5 +7,11 @@ export declare const forwardTool: import("../define-tool").ToolDefinition<z.ZodO
|
|
|
7
7
|
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
8
8
|
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
9
9
|
from: z.ZodOptional<z.ZodString>;
|
|
10
|
-
max_staleness_seconds: z.
|
|
10
|
+
max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
12
|
+
filename: z.ZodString;
|
|
13
|
+
content_base64: z.ZodBase64;
|
|
14
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>>>;
|
|
11
16
|
}, z.core.$strip>>;
|
|
17
|
+
export declare function emlFilename(subject: string | null): string;
|
|
@@ -8,5 +8,18 @@ export declare const replyTool: import("../define-tool").ToolDefinition<z.ZodObj
|
|
|
8
8
|
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
9
9
|
reply_all: z.ZodDefault<z.ZodBoolean>;
|
|
10
10
|
from: z.ZodOptional<z.ZodString>;
|
|
11
|
-
max_staleness_seconds: z.
|
|
11
|
+
max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
13
|
+
filename: z.ZodString;
|
|
14
|
+
content_base64: z.ZodBase64;
|
|
15
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>>>;
|
|
17
|
+
mark_answered: z.ZodDefault<z.ZodBoolean>;
|
|
12
18
|
}, z.core.$strip>>;
|
|
19
|
+
/**
|
|
20
|
+
* Build the References chain for a reply: the parent's own chain plus the
|
|
21
|
+
* parent's Message-ID last, per RFC 5322 §3.6.4. Over the cap, the root is
|
|
22
|
+
* kept and the most recent entries trimmed to it - the root is what clients
|
|
23
|
+
* thread on, the middle is what they can afford to lose.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mergeReferences(headerValue: string | null, parentMessageId: string | undefined, cap?: number): string[];
|
|
@@ -7,4 +7,9 @@ export declare const sendEmailTool: import("../define-tool").ToolDefinition<z.Zo
|
|
|
7
7
|
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
8
8
|
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
9
9
|
from: z.ZodOptional<z.ZodString>;
|
|
10
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
|
+
filename: z.ZodString;
|
|
12
|
+
content_base64: z.ZodBase64;
|
|
13
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>>;
|
|
10
15
|
}, z.core.$strip>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbzowski/mcp-inbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "MCP server exposing IMAP/SMTP email over a fast local cache. Read, search, compose, and manage email from any IMAP provider with near-instant response times via background sync and IDLE push.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"test:watch": "vitest",
|
|
55
55
|
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
56
56
|
"typecheck": "tsc --noEmit",
|
|
57
|
-
"lint": "
|
|
58
|
-
"lint:fix": "
|
|
59
|
-
"format": "
|
|
60
|
-
"format:check": "
|
|
57
|
+
"lint": "oxlint src tests --type-aware",
|
|
58
|
+
"lint:fix": "oxlint src tests --type-aware --fix",
|
|
59
|
+
"format": "oxfmt .",
|
|
60
|
+
"format:check": "oxfmt --check .",
|
|
61
61
|
"db:generate": "drizzle-kit generate",
|
|
62
62
|
"prepare": "lefthook install",
|
|
63
63
|
"prepublishOnly": "npm run typecheck && npm run lint && npm run test && npm run build",
|
|
@@ -68,24 +68,23 @@
|
|
|
68
68
|
"drizzle-orm": "1.0.0-beta.22",
|
|
69
69
|
"imapflow": "^1.3.2",
|
|
70
70
|
"mailparser": "^3.7.2",
|
|
71
|
-
"nodemailer": "^
|
|
71
|
+
"nodemailer": "^9.0.4",
|
|
72
72
|
"zod": "^4.0.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@changesets/cli": "^2.27.10",
|
|
76
76
|
"@types/mailparser": "^3.4.5",
|
|
77
|
-
"@types/node": "^
|
|
77
|
+
"@types/node": "^26.1.2",
|
|
78
78
|
"@types/nodemailer": "^8.0.0",
|
|
79
79
|
"drizzle-kit": "1.0.0-beta.22",
|
|
80
80
|
"esbuild": "^0.28.0",
|
|
81
|
-
"eslint": "^10.0.0",
|
|
82
|
-
"eslint-config-prettier": "^10.0.0",
|
|
83
81
|
"lefthook": "^2.1.6",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
82
|
+
"oxfmt": "^0.62.0",
|
|
83
|
+
"oxlint": "^1.77.0",
|
|
84
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
85
|
+
"testcontainers": "^12.1.0",
|
|
86
86
|
"tsx": "^4.19.0",
|
|
87
|
-
"typescript": "^
|
|
88
|
-
"typescript-eslint": "^8.20.0",
|
|
87
|
+
"typescript": "^7.0.2",
|
|
89
88
|
"vitest": "^4.0.0"
|
|
90
89
|
}
|
|
91
90
|
}
|