@todoist/mcp 17.3.15 → 17.3.17

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.
@@ -27,8 +27,9 @@ type RequireValidTodoistTokenOptions = TokenSource & {
27
27
  * Express middleware that validates the Todoist API token before MCP processing.
28
28
  *
29
29
  * Returns HTTP 401 with an `invalid_token` challenge if the token is refused,
30
- * allowing MCP clients to trigger OAuth token refresh, and 403 with an
31
- * `insufficient_scope` challenge if it lacks a scope the tools need.
30
+ * allowing MCP clients to trigger OAuth token refresh, 403 with an
31
+ * `insufficient_scope` challenge if it lacks a scope the tools need, and 429
32
+ * with `Retry-After` if the Todoist API is rate-limiting the token's user.
32
33
  */
33
34
  declare function requireValidTodoistToken(options: RequireValidTodoistTokenOptions): RequestHandler;
34
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"require-valid-todoist-token.d.ts","sourceRoot":"","sources":["../../src/middleware/require-valid-todoist-token.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAgB,OAAO,EAAE,cAAc,EAAY,MAAM,SAAS,CAAA;AAI9E,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,kBAAkB,GAAG;IACtB,IAAI,EAAE,SAAS,CAAA;IACf,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAA;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAEzD,KAAK,+BAA+B,GAAG,WAAW,GAAG;IACjD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC/B,CAAA;AAoFD;;;;;;GAMG;AACH,iBAAS,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,cAAc,CAgC1F;AAED;;GAEG;AACH,iBAAS,yBAAyB,IAAI,IAAI,CAEzC;AAED,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,KAAK,+BAA+B,EAAE,CAAA"}
1
+ {"version":3,"file":"require-valid-todoist-token.d.ts","sourceRoot":"","sources":["../../src/middleware/require-valid-todoist-token.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAgB,OAAO,EAAE,cAAc,EAAY,MAAM,SAAS,CAAA;AAI9E,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,kBAAkB,GAAG;IACtB,IAAI,EAAE,SAAS,CAAA;IACf,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAA;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAEzD,KAAK,+BAA+B,GAAG,WAAW,GAAG;IACjD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC/B,CAAA;AAgGD;;;;;;;GAOG;AACH,iBAAS,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,cAAc,CAyC1F;AAED;;GAEG;AACH,iBAAS,yBAAyB,IAAI,IAAI,CAEzC;AAED,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,KAAK,+BAA+B,EAAE,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { GetPromptResult } from '@modelcontextprotocol/server';
2
+ import { TodoistApi } from '@todoist/sdk';
2
3
  import { z } from 'zod';
3
4
  declare const argsSchema: z.ZodObject<{
4
5
  period: z.ZodDefault<z.ZodEnum<{
@@ -21,15 +22,18 @@ declare const argsSchema: z.ZodObject<{
21
22
  type PromptArgs = z.infer<typeof argsSchema>;
22
23
  /**
23
24
  * Compute the date range (since/until as YYYY-MM-DD) for a given period.
24
- * Uses UTC since the prompt instructs the LLM to call user-info for timezone.
25
+ * "Today" is the date at `offsetMinutes` from UTC, which the prompt callback sets to
26
+ * the user's Todoist timezone, so the range follows the user's calendar rather than
27
+ * the server's. The arithmetic runs on UTC calendar dates, so the server's own
28
+ * timezone and daylight-saving changes cannot move a day.
25
29
  */
26
- declare function computeDateRange(period: PromptArgs['period'], now?: Date): {
30
+ declare function computeDateRange(period: PromptArgs['period'], now?: Date, offsetMinutes?: number): {
27
31
  since: string;
28
32
  until: string;
29
33
  periodDescription: string;
30
34
  };
31
- declare function buildPromptText(args: PromptArgs): string;
32
- declare function callback(args: PromptArgs): GetPromptResult;
35
+ declare function buildPromptText(args: PromptArgs, range?: ReturnType<typeof computeDateRange>): string;
36
+ declare function callback(args: PromptArgs, client: TodoistApi): Promise<GetPromptResult>;
33
37
  declare const productivityAnalysis: {
34
38
  name: string;
35
39
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"productivity-analysis.d.ts","sourceRoot":"","sources":["../../src/prompts/productivity-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;iBAiBd,CAAA;AAEF,KAAK,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AAE5C;;;GAGG;AACH,iBAAS,gBAAgB,CACrB,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC5B,GAAG,GAAE,IAAiB,GACvB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM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B,EAAE,CAAA"}
@@ -0,0 +1,82 @@
1
+ import { validateBearerToken as A, getValidationRateLimit as v, createTokenVerdictCache as k, buildBearerChallenge as f } from "@todoist/mcp-core/host";
2
+ import { a2 as p, a3 as g } from "./mcp-server-CJPiZqMc.js";
3
+ const m = "https://api.todoist.com", E = (e, t) => A({
4
+ // Resolved the way the SDK resolves its own requests against a custom base URL. An empty
5
+ // base (`TODOIST_BASE_URL=`) means the default, as it does for the SDK client.
6
+ url: new URL("/api/v1/user", t || m),
7
+ token: e,
8
+ headers: g({ label: "auth:validate-token" }),
9
+ fetch: p
10
+ }), L = 3e5, S = 12e4, U = 1e4, y = 60, u = /* @__PURE__ */ new Map();
11
+ function b(e) {
12
+ let t = u.get(e);
13
+ return t || (t = k({
14
+ ttlMs: e,
15
+ maxEntries: U,
16
+ now: () => Date.now()
17
+ }), u.set(e, t)), t;
18
+ }
19
+ function h(e, { tokenSent: t, resourceMetadataUrl: r }) {
20
+ e.status(401).set(
21
+ "WWW-Authenticate",
22
+ f({
23
+ error: t ? "invalid_token" : void 0,
24
+ resourceMetadataUrl: r
25
+ })
26
+ ).json(
27
+ t ? {
28
+ error: "invalid_token",
29
+ error_description: "Todoist API token is invalid or expired"
30
+ } : { error_description: "Todoist API token is missing" }
31
+ );
32
+ }
33
+ function w(e, t) {
34
+ e.status(403).set(
35
+ "WWW-Authenticate",
36
+ f({ error: "insufficient_scope", resourceMetadataUrl: t })
37
+ ).json({
38
+ error: "insufficient_scope",
39
+ error_description: "Todoist API token does not have the required scopes"
40
+ });
41
+ }
42
+ function I(e, t) {
43
+ e.status(429).set("Retry-After", String(t)).json({ error_description: "Todoist API rate limit reached, retry later" });
44
+ }
45
+ function T(e, t, r, i) {
46
+ e === "valid" ? r() : e === "forbidden" ? w(t, i) : h(t, { tokenSent: !0, resourceMetadataUrl: i });
47
+ }
48
+ function D(e) {
49
+ const t = e.type === "static" ? L : S, r = b(e.cacheTtlMs ?? t), { resourceMetadataUrl: i } = e;
50
+ return async (_, n, a) => {
51
+ const o = e.type === "static" ? e.apiKey : e.getApiKey(_);
52
+ if (!o) {
53
+ h(n, { tokenSent: !1, resourceMetadataUrl: i });
54
+ return;
55
+ }
56
+ const d = r.get(o, e.baseUrl);
57
+ if (d !== void 0) {
58
+ T(d, n, a, i);
59
+ return;
60
+ }
61
+ let s;
62
+ try {
63
+ s = await E(o, e.baseUrl);
64
+ } catch (c) {
65
+ const l = v(c);
66
+ if (l) {
67
+ console.warn(
68
+ "[Token validation] Todoist API rate limit reached, answering 429:",
69
+ c
70
+ ), I(n, l.retryAfterSeconds ?? y);
71
+ return;
72
+ }
73
+ console.warn("[Token validation] Validation failed, proceeding:", c), a();
74
+ return;
75
+ }
76
+ r.set(o, e.baseUrl, s), T(s, n, a, i);
77
+ };
78
+ }
79
+ export {
80
+ D as r,
81
+ E as v
82
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"find-tasks-by-date.d.ts","sourceRoot":"","sources":["../../src/tools/find-tasks-by-date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAwDvB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;CAiDtB,CAAA;AAUD,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkG0C,CAAA;AAqF/D,OAAO,EAAE,eAAe,EAAE,CAAA"}
1
+ {"version":3,"file":"find-tasks-by-date.d.ts","sourceRoot":"","sources":["../../src/tools/find-tasks-by-date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAyDvB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;CAiDtB,CAAA;AAUD,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkG0C,CAAA;AA0F/D,OAAO,EAAE,eAAe,EAAE,CAAA"}
@@ -21,6 +21,11 @@ export declare function shiftDateStringByDays(dateString: string, days: number):
21
21
  * the last day named is `daysCount - 1` days after the start.
22
22
  */
23
23
  export declare function describeDateRange(startDate: string, daysCount: number): string;
24
+ /**
25
+ * The days a search of `daysCount` days from today covers: "Today", "Today and
26
+ * Tomorrow", or "Today and the next N days".
27
+ */
28
+ export declare function describeDaysFromToday(daysCount: number): string;
24
29
  /**
25
30
  * The first moment of a YYYY-MM-DD date in `timeZone`, as `YYYY-MM-DDT00:00:00` with the
26
31
  * offset that names it. A fixed offset such as the user's current `gmtString` is wrong
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKhD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CASjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAa9E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAI9E;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,cAAc,GACjB,EAAE;IACC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACnC,cAAc,EAAE,MAAM,CAAA;CACzB,GAAG,MAAM,CAmBT"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKhD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CASjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAa9E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAI/D;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,cAAc,GACjB,EAAE;IACC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACnC,cAAc,EAAE,MAAM,CAAA;CACzB,GAAG,MAAM,CAmBT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoist/mcp",
3
- "version": "17.3.15",
3
+ "version": "17.3.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@modelcontextprotocol/ext-apps": "2.0.4",
70
- "@todoist/mcp-core": "1.2.0",
70
+ "@todoist/mcp-core": "1.3.0",
71
71
  "@todoist/sdk": "24.1.0",
72
72
  "date-fns": "4.1.0",
73
73
  "dompurify": "3.4.18",
@@ -1,71 +0,0 @@
1
- import { validateBearerToken as _, createTokenVerdictCache as v, buildBearerChallenge as u } from "@todoist/mcp-core/host";
2
- import { a2 as k, a3 as p } from "./mcp-server-KgV8_prN.js";
3
- const A = "https://api.todoist.com", U = (e, t) => _({
4
- // Resolved the way the SDK resolves its own requests against a custom base URL. An empty
5
- // base (`TODOIST_BASE_URL=`) means the default, as it does for the SDK client.
6
- url: new URL("/api/v1/user", t || A),
7
- token: e,
8
- headers: p({ label: "auth:validate-token" }),
9
- fetch: k
10
- }), g = 3e5, b = 12e4, m = 1e4, d = /* @__PURE__ */ new Map();
11
- function y(e) {
12
- let t = d.get(e);
13
- return t || (t = v({
14
- ttlMs: e,
15
- maxEntries: m,
16
- now: () => Date.now()
17
- }), d.set(e, t)), t;
18
- }
19
- function T(e, { tokenSent: t, resourceMetadataUrl: r }) {
20
- e.status(401).set(
21
- "WWW-Authenticate",
22
- u({
23
- error: t ? "invalid_token" : void 0,
24
- resourceMetadataUrl: r
25
- })
26
- ).json(
27
- t ? {
28
- error: "invalid_token",
29
- error_description: "Todoist API token is invalid or expired"
30
- } : { error_description: "Todoist API token is missing" }
31
- );
32
- }
33
- function E(e, t) {
34
- e.status(403).set(
35
- "WWW-Authenticate",
36
- u({ error: "insufficient_scope", resourceMetadataUrl: t })
37
- ).json({
38
- error: "insufficient_scope",
39
- error_description: "Todoist API token does not have the required scopes"
40
- });
41
- }
42
- function l(e, t, r, i) {
43
- e === "valid" ? r() : e === "forbidden" ? E(t, i) : T(t, { tokenSent: !0, resourceMetadataUrl: i });
44
- }
45
- function w(e) {
46
- const t = e.type === "static" ? g : b, r = y(e.cacheTtlMs ?? t), { resourceMetadataUrl: i } = e;
47
- return async (f, o, a) => {
48
- const n = e.type === "static" ? e.apiKey : e.getApiKey(f);
49
- if (!n) {
50
- T(o, { tokenSent: !1, resourceMetadataUrl: i });
51
- return;
52
- }
53
- const c = r.get(n, e.baseUrl);
54
- if (c !== void 0) {
55
- l(c, o, a, i);
56
- return;
57
- }
58
- let s;
59
- try {
60
- s = await U(n, e.baseUrl);
61
- } catch (h) {
62
- console.warn("[Token validation] Validation failed, proceeding:", h), a();
63
- return;
64
- }
65
- r.set(n, e.baseUrl, s), l(s, o, a, i);
66
- };
67
- }
68
- export {
69
- w as r,
70
- U as v
71
- };