@kbzowski/mcp-inbox 0.5.1 → 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.
@@ -0,0 +1,383 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "id": "e16b77cc-38e7-43f6-b5fe-2225258a2003",
5
+ "prevIds": [
6
+ "a62d5cf7-0616-477c-818a-4896f264206d"
7
+ ],
8
+ "ddl": [
9
+ {
10
+ "name": "emails",
11
+ "entityType": "tables"
12
+ },
13
+ {
14
+ "name": "folders",
15
+ "entityType": "tables"
16
+ },
17
+ {
18
+ "name": "vec_index_state",
19
+ "entityType": "tables"
20
+ },
21
+ {
22
+ "type": "text",
23
+ "notNull": true,
24
+ "autoincrement": false,
25
+ "default": null,
26
+ "generated": null,
27
+ "name": "folder",
28
+ "entityType": "columns",
29
+ "table": "emails"
30
+ },
31
+ {
32
+ "type": "integer",
33
+ "notNull": true,
34
+ "autoincrement": false,
35
+ "default": null,
36
+ "generated": null,
37
+ "name": "uid",
38
+ "entityType": "columns",
39
+ "table": "emails"
40
+ },
41
+ {
42
+ "type": "text",
43
+ "notNull": false,
44
+ "autoincrement": false,
45
+ "default": null,
46
+ "generated": null,
47
+ "name": "message_id",
48
+ "entityType": "columns",
49
+ "table": "emails"
50
+ },
51
+ {
52
+ "type": "text",
53
+ "notNull": false,
54
+ "autoincrement": false,
55
+ "default": null,
56
+ "generated": null,
57
+ "name": "subject",
58
+ "entityType": "columns",
59
+ "table": "emails"
60
+ },
61
+ {
62
+ "type": "text",
63
+ "notNull": false,
64
+ "autoincrement": false,
65
+ "default": null,
66
+ "generated": null,
67
+ "name": "from_addr",
68
+ "entityType": "columns",
69
+ "table": "emails"
70
+ },
71
+ {
72
+ "type": "text",
73
+ "notNull": false,
74
+ "autoincrement": false,
75
+ "default": null,
76
+ "generated": null,
77
+ "name": "to_addrs",
78
+ "entityType": "columns",
79
+ "table": "emails"
80
+ },
81
+ {
82
+ "type": "text",
83
+ "notNull": false,
84
+ "autoincrement": false,
85
+ "default": null,
86
+ "generated": null,
87
+ "name": "cc_addrs",
88
+ "entityType": "columns",
89
+ "table": "emails"
90
+ },
91
+ {
92
+ "type": "integer",
93
+ "notNull": false,
94
+ "autoincrement": false,
95
+ "default": null,
96
+ "generated": null,
97
+ "name": "date",
98
+ "entityType": "columns",
99
+ "table": "emails"
100
+ },
101
+ {
102
+ "type": "text",
103
+ "notNull": true,
104
+ "autoincrement": false,
105
+ "default": null,
106
+ "generated": null,
107
+ "name": "flags",
108
+ "entityType": "columns",
109
+ "table": "emails"
110
+ },
111
+ {
112
+ "type": "integer",
113
+ "notNull": true,
114
+ "autoincrement": false,
115
+ "default": "false",
116
+ "generated": null,
117
+ "name": "has_attachments",
118
+ "entityType": "columns",
119
+ "table": "emails"
120
+ },
121
+ {
122
+ "type": "text",
123
+ "notNull": true,
124
+ "autoincrement": false,
125
+ "default": null,
126
+ "generated": null,
127
+ "name": "envelope_json",
128
+ "entityType": "columns",
129
+ "table": "emails"
130
+ },
131
+ {
132
+ "type": "text",
133
+ "notNull": false,
134
+ "autoincrement": false,
135
+ "default": null,
136
+ "generated": null,
137
+ "name": "body_text",
138
+ "entityType": "columns",
139
+ "table": "emails"
140
+ },
141
+ {
142
+ "type": "text",
143
+ "notNull": false,
144
+ "autoincrement": false,
145
+ "default": null,
146
+ "generated": null,
147
+ "name": "body_html",
148
+ "entityType": "columns",
149
+ "table": "emails"
150
+ },
151
+ {
152
+ "type": "text",
153
+ "notNull": false,
154
+ "autoincrement": false,
155
+ "default": null,
156
+ "generated": null,
157
+ "name": "attachments_json",
158
+ "entityType": "columns",
159
+ "table": "emails"
160
+ },
161
+ {
162
+ "type": "integer",
163
+ "notNull": false,
164
+ "autoincrement": false,
165
+ "default": null,
166
+ "generated": null,
167
+ "name": "modseq",
168
+ "entityType": "columns",
169
+ "table": "emails"
170
+ },
171
+ {
172
+ "type": "integer",
173
+ "notNull": true,
174
+ "autoincrement": false,
175
+ "default": null,
176
+ "generated": null,
177
+ "name": "cached_at",
178
+ "entityType": "columns",
179
+ "table": "emails"
180
+ },
181
+ {
182
+ "type": "integer",
183
+ "notNull": false,
184
+ "autoincrement": false,
185
+ "default": null,
186
+ "generated": null,
187
+ "name": "body_cached_at",
188
+ "entityType": "columns",
189
+ "table": "emails"
190
+ },
191
+ {
192
+ "type": "text",
193
+ "notNull": false,
194
+ "autoincrement": false,
195
+ "default": null,
196
+ "generated": null,
197
+ "name": "name",
198
+ "entityType": "columns",
199
+ "table": "folders"
200
+ },
201
+ {
202
+ "type": "text",
203
+ "notNull": true,
204
+ "autoincrement": false,
205
+ "default": null,
206
+ "generated": null,
207
+ "name": "delimiter",
208
+ "entityType": "columns",
209
+ "table": "folders"
210
+ },
211
+ {
212
+ "type": "text",
213
+ "notNull": false,
214
+ "autoincrement": false,
215
+ "default": null,
216
+ "generated": null,
217
+ "name": "special_use",
218
+ "entityType": "columns",
219
+ "table": "folders"
220
+ },
221
+ {
222
+ "type": "integer",
223
+ "notNull": true,
224
+ "autoincrement": false,
225
+ "default": null,
226
+ "generated": null,
227
+ "name": "uid_validity",
228
+ "entityType": "columns",
229
+ "table": "folders"
230
+ },
231
+ {
232
+ "type": "integer",
233
+ "notNull": false,
234
+ "autoincrement": false,
235
+ "default": null,
236
+ "generated": null,
237
+ "name": "uid_next",
238
+ "entityType": "columns",
239
+ "table": "folders"
240
+ },
241
+ {
242
+ "type": "integer",
243
+ "notNull": false,
244
+ "autoincrement": false,
245
+ "default": null,
246
+ "generated": null,
247
+ "name": "highest_modseq",
248
+ "entityType": "columns",
249
+ "table": "folders"
250
+ },
251
+ {
252
+ "type": "integer",
253
+ "notNull": true,
254
+ "autoincrement": false,
255
+ "default": null,
256
+ "generated": null,
257
+ "name": "last_synced_at",
258
+ "entityType": "columns",
259
+ "table": "folders"
260
+ },
261
+ {
262
+ "type": "text",
263
+ "notNull": false,
264
+ "autoincrement": false,
265
+ "default": null,
266
+ "generated": null,
267
+ "name": "folder",
268
+ "entityType": "columns",
269
+ "table": "vec_index_state"
270
+ },
271
+ {
272
+ "type": "text",
273
+ "notNull": true,
274
+ "autoincrement": false,
275
+ "default": null,
276
+ "generated": null,
277
+ "name": "model",
278
+ "entityType": "columns",
279
+ "table": "vec_index_state"
280
+ },
281
+ {
282
+ "type": "integer",
283
+ "notNull": true,
284
+ "autoincrement": false,
285
+ "default": null,
286
+ "generated": null,
287
+ "name": "dims",
288
+ "entityType": "columns",
289
+ "table": "vec_index_state"
290
+ },
291
+ {
292
+ "type": "integer",
293
+ "notNull": true,
294
+ "autoincrement": false,
295
+ "default": null,
296
+ "generated": null,
297
+ "name": "from_uid",
298
+ "entityType": "columns",
299
+ "table": "vec_index_state"
300
+ },
301
+ {
302
+ "type": "integer",
303
+ "notNull": true,
304
+ "autoincrement": false,
305
+ "default": null,
306
+ "generated": null,
307
+ "name": "to_uid",
308
+ "entityType": "columns",
309
+ "table": "vec_index_state"
310
+ },
311
+ {
312
+ "type": "integer",
313
+ "notNull": true,
314
+ "autoincrement": false,
315
+ "default": null,
316
+ "generated": null,
317
+ "name": "indexed_at",
318
+ "entityType": "columns",
319
+ "table": "vec_index_state"
320
+ },
321
+ {
322
+ "columns": [
323
+ "folder",
324
+ "uid"
325
+ ],
326
+ "nameExplicit": false,
327
+ "name": "emails_pk",
328
+ "entityType": "pks",
329
+ "table": "emails"
330
+ },
331
+ {
332
+ "columns": [
333
+ "name"
334
+ ],
335
+ "nameExplicit": false,
336
+ "name": "folders_pk",
337
+ "table": "folders",
338
+ "entityType": "pks"
339
+ },
340
+ {
341
+ "columns": [
342
+ "folder"
343
+ ],
344
+ "nameExplicit": false,
345
+ "name": "vec_index_state_pk",
346
+ "table": "vec_index_state",
347
+ "entityType": "pks"
348
+ },
349
+ {
350
+ "columns": [
351
+ {
352
+ "value": "folder",
353
+ "isExpression": false
354
+ },
355
+ {
356
+ "value": "date",
357
+ "isExpression": false
358
+ }
359
+ ],
360
+ "isUnique": false,
361
+ "where": null,
362
+ "origin": "manual",
363
+ "name": "idx_emails_date",
364
+ "entityType": "indexes",
365
+ "table": "emails"
366
+ },
367
+ {
368
+ "columns": [
369
+ {
370
+ "value": "message_id",
371
+ "isExpression": false
372
+ }
373
+ ],
374
+ "isUnique": false,
375
+ "where": null,
376
+ "origin": "manual",
377
+ "name": "idx_emails_message_id",
378
+ "entityType": "indexes",
379
+ "table": "emails"
380
+ }
381
+ ],
382
+ "renames": []
383
+ }
@@ -14,6 +14,10 @@ export interface ToolContext {
14
14
  imap: ImapClient;
15
15
  smtp: SmtpClient;
16
16
  cacheConfig: AppConfig['cache'];
17
+ /** Null when IMAP_EMBEDDINGS_BASE_URL is unset - semantic tools refuse to run. */
18
+ embeddings: AppConfig['embeddings'];
19
+ /** False when sqlite-vec has no build for this platform. */
20
+ vectorsAvailable: boolean;
17
21
  /** Default sender + smtp config for tools that compose messages. */
18
22
  defaults: {
19
23
  fromAddress: string;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export declare const indexFolderTool: import("../define-tool").ToolDefinition<z.ZodObject<{
3
+ folders: z.ZodDefault<z.ZodArray<z.ZodString>>;
4
+ max_messages: z.ZodDefault<z.ZodNumber>;
5
+ max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
6
+ response_format: z.ZodDefault<z.ZodEnum<{
7
+ json: "json";
8
+ markdown: "markdown";
9
+ }>>;
10
+ }, z.core.$strip>>;
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export declare const semanticSearchTool: import("../define-tool").ToolDefinition<z.ZodObject<{
3
+ query: z.ZodString;
4
+ folder: z.ZodOptional<z.ZodString>;
5
+ limit: z.ZodDefault<z.ZodNumber>;
6
+ since_date: z.ZodOptional<z.ZodString>;
7
+ before_date: z.ZodOptional<z.ZodString>;
8
+ max_staleness_seconds: z.ZodOptional<z.ZodNumber>;
9
+ response_format: z.ZodDefault<z.ZodEnum<{
10
+ json: "json";
11
+ markdown: "markdown";
12
+ }>>;
13
+ }, z.core.$strip>>;
@@ -1,7 +1,15 @@
1
+ import type { ImapFlow } from 'imapflow';
1
2
  import type { ToolContext } from '../define-tool';
3
+ import type { EmbeddingsConfig } from '../../config/env';
2
4
  import { type ListEmailsOptions } from '../../cache/queries';
3
5
  import type { AttachmentInfo, Email } from '../../cache/schema';
4
6
  import { type SpecialUseAttr } from '../../imap/folders';
7
+ /**
8
+ * ImapFlow's `messageDelete` reports a server refusal by returning false, not
9
+ * by throwing, so a bare await reads a failed delete as a success. The caller
10
+ * must hold the mailbox lock.
11
+ */
12
+ export declare function deleteOrThrow(imap: Pick<ImapFlow, 'messageDelete'>, folder: string, uids: string | number[]): Promise<void>;
5
13
  /**
6
14
  * Sync a folder if its cache is older than `maxStalenessSec`, which falls
7
15
  * back to IMAP_CACHE_DEFAULT_STALENESS_SEC when the caller omits it.
@@ -9,6 +17,12 @@ import { type SpecialUseAttr } from '../../imap/folders';
9
17
  * response with `served_from: "cache" | "sync"`.
10
18
  */
11
19
  export declare function syncIfStale(ctx: ToolContext, folder: string, maxStalenessSec?: number): Promise<boolean>;
20
+ /**
21
+ * Guards for the two semantic-search tools. Both messages name
22
+ * imap_search_emails because they are what the model reads when it has to
23
+ * pick a different tool - `server.ts` surfaces `userMessage` verbatim.
24
+ */
25
+ export declare function requireEmbeddings(ctx: ToolContext): EmbeddingsConfig;
12
26
  /**
13
27
  * Read envelopes from the cache with pagination. `syncIfStale` should
14
28
  * be called first if the caller wants fresh data.
@@ -14,11 +14,14 @@
14
14
  * contexts to avoid cross-test leakage.
15
15
  */
16
16
  type Level = 'debug' | 'info' | 'warn' | 'error';
17
+ type Meta = Record<string, unknown> & {
18
+ msg?: never;
19
+ };
17
20
  export interface Logger {
18
- debug: (msg: string, meta?: Record<string, unknown>) => void;
19
- info: (msg: string, meta?: Record<string, unknown>) => void;
20
- warn: (msg: string, meta?: Record<string, unknown>) => void;
21
- error: (msg: string, meta?: Record<string, unknown>) => void;
21
+ debug: (msg: string, meta?: Meta) => void;
22
+ info: (msg: string, meta?: Meta) => void;
23
+ warn: (msg: string, meta?: Meta) => void;
24
+ error: (msg: string, meta?: Meta) => void;
22
25
  child: (subNamespace: string) => Logger;
23
26
  }
24
27
  export declare class LoggerContext {
@@ -28,7 +31,7 @@ export declare class LoggerContext {
28
31
  level?: Level;
29
32
  }): void;
30
33
  shouldEmit(level: Level, namespace: string): boolean;
31
- emit(level: Level, namespace: string, msg: string, meta?: Record<string, unknown>): void;
34
+ emit(level: Level, namespace: string, msg: string, meta?: Meta): void;
32
35
  logger(namespace: string): Logger;
33
36
  }
34
37
  export declare function configureLogger(opts: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbzowski/mcp-inbox",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
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",
@@ -64,27 +64,27 @@
64
64
  "release": "changeset publish"
65
65
  },
66
66
  "dependencies": {
67
- "@modelcontextprotocol/sdk": "^1.20.0",
68
- "drizzle-orm": "1.0.0-beta.22",
69
- "imapflow": "^1.3.2",
70
- "mailparser": "^3.7.2",
71
- "nodemailer": "^9.0.4",
72
- "zod": "^4.0.0"
67
+ "@modelcontextprotocol/sdk": "^1.32.2",
68
+ "drizzle-orm": "1.0.0-rc.6",
69
+ "imapflow": "^2.12.2",
70
+ "mailparser": "^3.15.0",
71
+ "nodemailer": "^10.6.1",
72
+ "sqlite-vec": "0.1.9",
73
+ "zod": "^4.6.7"
73
74
  },
74
75
  "devDependencies": {
75
- "@changesets/cli": "^2.27.10",
76
- "@types/mailparser": "^3.4.5",
77
- "@types/node": "^26.1.2",
78
- "@types/nodemailer": "^8.0.0",
79
- "drizzle-kit": "1.0.0-beta.22",
80
- "esbuild": "^0.28.0",
81
- "lefthook": "^2.1.6",
82
- "oxfmt": "^0.62.0",
83
- "oxlint": "^1.77.0",
84
- "oxlint-tsgolint": "^7.0.2001",
85
- "testcontainers": "^12.1.0",
86
- "tsx": "^4.19.0",
76
+ "@changesets/cli": "^3.0.3",
77
+ "@types/mailparser": "^3.9.0",
78
+ "@types/node": "^26.6.6",
79
+ "drizzle-kit": "1.0.0-rc.6",
80
+ "esbuild": "^0.28.2",
81
+ "lefthook": "^2.2.2",
82
+ "oxfmt": "^0.79.0",
83
+ "oxlint": "^1.94.0",
84
+ "oxlint-tsgolint": "^7.0.2008",
85
+ "testcontainers": "^12.2.2",
86
+ "tsx": "^4.23.15",
87
87
  "typescript": "^7.0.2",
88
- "vitest": "^4.0.0"
88
+ "vitest": "^5.1.1"
89
89
  }
90
90
  }