@remit/mcp-server 0.5.2 → 0.6.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/dist/deps.d.ts CHANGED
@@ -20,7 +20,7 @@ export interface McpDeps {
20
20
  message: Pick<IMessageRepository, "get" | "describe">;
21
21
  threadMessage: Pick<IThreadMessageRepository, "listByMailbox" | "listByThread" | "searchByDate">;
22
22
  filter: Pick<IFilterRepository, "listPageByAccountConfig" | "refreshExpiry" | "create" | "get" | "update">;
23
- organizeJobRequest: Pick<IOrganizeJobRequestRepository, "create">;
23
+ organizeJobRequest: Pick<IOrganizeJobRequestRepository, "create" | "get">;
24
24
  storage: Pick<StorageService, "retrieveBodyPart">;
25
25
  bodySync: BodyPartMaterializer;
26
26
  bodySyncQueue: BodySyncCue;
@@ -1,10 +1,10 @@
1
- import { FILTER_NO_ACTION } from "@remit/data-ports";
1
+ import { FILTER_NO_ACTION, } from "@remit/data-ports";
2
2
  import { isNotFoundError } from "@remit/data-ports/errors";
3
3
  import { deriveAccountConfigId } from "@remit/data-ports/id";
4
4
  import { FilterClauseField, FilterMatchOperator, FilterScope, FilterState, } from "@remit/domain-enums";
5
5
  import { createFilter, listFilters, queueOrganizeJob, refuse, updateFilter, } from "@remit/mailbox-service";
6
6
  import { z } from "zod";
7
- import { asJson, refused } from "./tool-result.js";
7
+ import { asJson, refused, toolError } from "./tool-result.js";
8
8
  const FILTER_WRITE = {
9
9
  readOnlyHint: false,
10
10
  destructiveHint: false,
@@ -26,6 +26,22 @@ const toFilter = (item) => ({
26
26
  createdAt: item.createdAt,
27
27
  updatedAt: item.updatedAt,
28
28
  });
29
+ const toOrganizeJob = (job) => ({
30
+ organizeJobId: job.organizeJobId,
31
+ state: job.state,
32
+ filterId: job.filterId,
33
+ matchedCount: job.matchedCount,
34
+ appliedCount: job.appliedCount,
35
+ failedCount: job.failedCount,
36
+ errorMessage: job.errorMessage,
37
+ createdAt: job.createdAt,
38
+ updatedAt: job.updatedAt,
39
+ });
40
+ const absentJob = (error) => {
41
+ if (!isNotFoundError(error))
42
+ throw error;
43
+ return null;
44
+ };
29
45
  const notFound = (error) => {
30
46
  if (!isNotFoundError(error))
31
47
  throw error;
@@ -152,4 +168,22 @@ export const registerFilterTools = (server, deps, userId) => {
152
168
  });
153
169
  return asJson({ filter, organizeJobId: job.organizeJobId });
154
170
  });
171
+ server.registerTool("get_organize_job", {
172
+ description: "Read an organize job that applies a filter to existing mail: its state (Pending, Running, Complete, Failed), how many messages it matched, applied and failed, and the error when it failed.",
173
+ inputSchema: {
174
+ organizeJobId: z
175
+ .string()
176
+ .min(1)
177
+ .describe("organizeJobId from create_filter or update_filter"),
178
+ },
179
+ annotations: { readOnlyHint: true, openWorldHint: false },
180
+ }, async ({ organizeJobId }) => {
181
+ const job = await deps.organizeJobRequest
182
+ .get(organizeJobId)
183
+ .catch(absentJob);
184
+ if (!job || job.accountConfigId !== accountConfigId) {
185
+ return toolError(`Organize job not found: ${organizeJobId}. Use the organizeJobId create_filter or update_filter returned.`);
186
+ }
187
+ return asJson(toOrganizeJob(job));
188
+ });
155
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/mcp-server",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "The remit MCP server: mail tools over streamable HTTP and the OAuth authorization server that guards them.",
5
5
  "type": "module",
6
6
  "exports": {