@doist/todoist-ai 7.2.0 → 7.3.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/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as s, s as a, m as e, a as t, u as o, d, b as n, c as i, e as r, h as c, i as m, j as f, k as p, l as k, n as l, o as j, p as u, q as T, r as g, t as v, v as C, w as P, x as S } from "./mcp-server-
|
|
2
|
-
import { g as y } from "./mcp-server-
|
|
1
|
+
import { f as s, s as a, m as e, a as t, u as o, d, b as n, c as i, e as r, h as c, i as m, j as f, k as p, l as k, n as l, o as j, p as u, q as T, r as g, t as v, v as C, w as P, x as S } from "./mcp-server-DYc-KMKy.js";
|
|
2
|
+
import { g as y } from "./mcp-server-DYc-KMKy.js";
|
|
3
3
|
const h = {
|
|
4
4
|
// Task management tools
|
|
5
5
|
addTasks: S,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-http.d.ts","sourceRoot":"","sources":["../src/main-http.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { randomUUID as T } from "node:crypto";
|
|
3
|
+
import { StreamableHTTPServerTransport as f } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
4
|
+
import { isInitializeRequest as h } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import S from "dotenv";
|
|
6
|
+
import m from "express";
|
|
7
|
+
import { g as v } from "./mcp-server-DYc-KMKy.js";
|
|
8
|
+
S.config();
|
|
9
|
+
const d = Number.parseInt(process.env.PORT || "3000", 10), l = Number.parseInt(process.env.SESSION_TIMEOUT_MS || "1800000", 10), t = /* @__PURE__ */ new Map();
|
|
10
|
+
function u(i) {
|
|
11
|
+
const r = t.get(i);
|
|
12
|
+
r && (clearTimeout(r.timeoutId), r.transport.close(), t.delete(i), console.error(`[Session] Cleaned up session ${i} due to inactivity`));
|
|
13
|
+
}
|
|
14
|
+
function p(i) {
|
|
15
|
+
const r = t.get(i);
|
|
16
|
+
r && (clearTimeout(r.timeoutId), r.lastActivity = Date.now(), r.timeoutId = setTimeout(() => u(i), l));
|
|
17
|
+
}
|
|
18
|
+
function g() {
|
|
19
|
+
const i = process.env.TODOIST_BASE_URL, r = process.env.TODOIST_API_KEY;
|
|
20
|
+
r || (console.error("Error: TODOIST_API_KEY environment variable is required"), process.exit(1));
|
|
21
|
+
const a = m();
|
|
22
|
+
a.use(m.json()), a.get("/health", (o, n) => {
|
|
23
|
+
n.json({
|
|
24
|
+
status: "ok",
|
|
25
|
+
activeSessions: t.size,
|
|
26
|
+
sessionTimeoutMs: l
|
|
27
|
+
});
|
|
28
|
+
}), a.post("/mcp", async (o, n) => {
|
|
29
|
+
const s = o.headers["mcp-session-id"];
|
|
30
|
+
try {
|
|
31
|
+
if (s && t.has(s)) {
|
|
32
|
+
const e = t.get(s);
|
|
33
|
+
e && (p(s), await e.transport.handleRequest(o, n, o.body));
|
|
34
|
+
} else if (!s && h(o.body)) {
|
|
35
|
+
const e = new f({
|
|
36
|
+
sessionIdGenerator: () => T(),
|
|
37
|
+
onsessioninitialized: (c) => {
|
|
38
|
+
const I = setTimeout(() => u(c), l);
|
|
39
|
+
t.set(c, {
|
|
40
|
+
transport: e,
|
|
41
|
+
lastActivity: Date.now(),
|
|
42
|
+
timeoutId: I
|
|
43
|
+
}), console.error(`[Session] New session initialized: ${c}`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
e.onclose = () => {
|
|
47
|
+
if (e.sessionId) {
|
|
48
|
+
const c = t.get(e.sessionId);
|
|
49
|
+
c && (clearTimeout(c.timeoutId), t.delete(e.sessionId), console.error(`[Session] Session closed: ${e.sessionId}`));
|
|
50
|
+
}
|
|
51
|
+
}, await v({ todoistApiKey: r, baseUrl: i }).connect(e), await e.handleRequest(o, n, o.body);
|
|
52
|
+
} else
|
|
53
|
+
n.status(400).json({
|
|
54
|
+
jsonrpc: "2.0",
|
|
55
|
+
error: {
|
|
56
|
+
code: -32001,
|
|
57
|
+
message: "Invalid session. Please reconnect to establish a new session."
|
|
58
|
+
},
|
|
59
|
+
id: null
|
|
60
|
+
});
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error("[Error] Request handling failed:", e), n.status(500).json({
|
|
63
|
+
jsonrpc: "2.0",
|
|
64
|
+
error: {
|
|
65
|
+
code: -32603,
|
|
66
|
+
message: "Internal server error"
|
|
67
|
+
},
|
|
68
|
+
id: null
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}), a.get("/mcp", async (o, n) => {
|
|
72
|
+
const s = o.headers["mcp-session-id"];
|
|
73
|
+
if (!s || !t.has(s)) {
|
|
74
|
+
n.status(400).json({
|
|
75
|
+
jsonrpc: "2.0",
|
|
76
|
+
error: {
|
|
77
|
+
code: -32001,
|
|
78
|
+
message: "Invalid or expired session. Please reconnect."
|
|
79
|
+
},
|
|
80
|
+
id: null
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const e = t.get(s);
|
|
85
|
+
e && (p(s), await e.transport.handleRequest(o, n));
|
|
86
|
+
}), a.delete("/mcp", async (o, n) => {
|
|
87
|
+
const s = o.headers["mcp-session-id"];
|
|
88
|
+
if (!s || !t.has(s)) {
|
|
89
|
+
n.status(400).json({
|
|
90
|
+
jsonrpc: "2.0",
|
|
91
|
+
error: {
|
|
92
|
+
code: -32001,
|
|
93
|
+
message: "Invalid session"
|
|
94
|
+
},
|
|
95
|
+
id: null
|
|
96
|
+
});
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const e = t.get(s);
|
|
100
|
+
e && await e.transport.handleRequest(o, n);
|
|
101
|
+
}), a.listen(d, () => {
|
|
102
|
+
console.error(`Todoist MCP HTTP Server started on port ${d}`), console.error(
|
|
103
|
+
`Session timeout: ${l}ms (${l / 6e4} minutes)`
|
|
104
|
+
), console.error(`MCP endpoint: http://localhost:${d}/mcp`), console.error(`Health check: http://localhost:${d}/health`);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
g();
|
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { StdioServerTransport as s } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import c from "dotenv";
|
|
4
|
-
import { g as i } from "./mcp-server-
|
|
4
|
+
import { g as i } from "./mcp-server-DYc-KMKy.js";
|
|
5
5
|
function p() {
|
|
6
6
|
const o = process.env.TODOIST_BASE_URL, r = process.env.TODOIST_API_KEY;
|
|
7
7
|
if (!r)
|