@doist/todoist-ai 0.1.0 → 0.1.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.
Files changed (259) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index.d.ts +477 -0
  3. package/dist/cjs/index.d.ts.map +1 -0
  4. package/dist/cjs/index.js +49 -0
  5. package/dist/cjs/main.d.ts.map +1 -0
  6. package/dist/cjs/mcp-helpers.d.ts.map +1 -0
  7. package/dist/cjs/mcp-server.d.ts.map +1 -0
  8. package/dist/cjs/todoist-tool.d.ts.map +1 -0
  9. package/dist/cjs/tools/account-overview.d.ts.map +1 -0
  10. package/dist/cjs/tools/project-overview.d.ts.map +1 -0
  11. package/dist/cjs/tools/projects-add-one.d.ts.map +1 -0
  12. package/dist/cjs/tools/projects-delete-one.d.ts.map +1 -0
  13. package/dist/cjs/tools/projects-list.d.ts.map +1 -0
  14. package/dist/cjs/tools/projects-search.d.ts.map +1 -0
  15. package/dist/cjs/tools/projects-update-one.d.ts.map +1 -0
  16. package/dist/cjs/tools/sections-add-one.d.ts.map +1 -0
  17. package/dist/cjs/tools/sections-delete-one.d.ts.map +1 -0
  18. package/dist/cjs/tools/sections-search.d.ts.map +1 -0
  19. package/dist/cjs/tools/sections-update-one.d.ts.map +1 -0
  20. package/dist/cjs/tools/shared.d.ts.map +1 -0
  21. package/dist/cjs/tools/subtasks-list-for-parent-task.d.ts.map +1 -0
  22. package/dist/cjs/tools/tasks-add-multiple.d.ts.map +1 -0
  23. package/dist/cjs/tools/tasks-by-date-range.d.ts.map +1 -0
  24. package/dist/cjs/tools/tasks-by-project.d.ts.map +1 -0
  25. package/dist/cjs/tools/tasks-complete-multiple.d.ts.map +1 -0
  26. package/dist/cjs/tools/tasks-delete-one.d.ts.map +1 -0
  27. package/dist/cjs/tools/tasks-list-for-section.d.ts.map +1 -0
  28. package/dist/cjs/tools/tasks-list-overdue.d.ts.map +1 -0
  29. package/dist/cjs/tools/tasks-organize-multiple.d.ts.map +1 -0
  30. package/dist/cjs/tools/tasks-search.d.ts.map +1 -0
  31. package/dist/cjs/tools/tasks-update-one.d.ts.map +1 -0
  32. package/dist/esm/index.d.ts +477 -0
  33. package/dist/esm/index.d.ts.map +1 -0
  34. package/dist/esm/index.js +49 -0
  35. package/dist/esm/main.d.ts +2 -0
  36. package/dist/esm/main.d.ts.map +1 -0
  37. package/dist/esm/main.js +23 -0
  38. package/dist/esm/mcp-helpers.d.ts +13 -0
  39. package/dist/esm/mcp-helpers.d.ts.map +1 -0
  40. package/dist/esm/mcp-helpers.js +52 -0
  41. package/dist/esm/mcp-server.d.ts +11 -0
  42. package/dist/esm/mcp-server.d.ts.map +1 -0
  43. package/{src/mcp-server.ts → dist/esm/mcp-server.js} +31 -44
  44. package/dist/esm/todoist-tool.d.ts +35 -0
  45. package/dist/esm/todoist-tool.d.ts.map +1 -0
  46. package/dist/esm/todoist-tool.js +1 -0
  47. package/dist/esm/tools/account-overview.d.ts +9 -0
  48. package/dist/esm/tools/account-overview.d.ts.map +1 -0
  49. package/dist/esm/tools/account-overview.js +94 -0
  50. package/dist/esm/tools/project-overview.d.ts +14 -0
  51. package/dist/esm/tools/project-overview.d.ts.map +1 -0
  52. package/dist/esm/tools/project-overview.js +107 -0
  53. package/dist/esm/tools/projects-add-one.d.ts +22 -0
  54. package/dist/esm/tools/projects-add-one.d.ts.map +1 -0
  55. package/dist/esm/tools/projects-add-one.js +15 -0
  56. package/dist/esm/tools/projects-delete-one.d.ts +15 -0
  57. package/dist/esm/tools/projects-delete-one.d.ts.map +1 -0
  58. package/dist/esm/tools/projects-delete-one.js +14 -0
  59. package/dist/esm/tools/projects-list.d.ts +18 -0
  60. package/dist/esm/tools/projects-list.d.ts.map +1 -0
  61. package/dist/esm/tools/projects-list.js +30 -0
  62. package/dist/esm/tools/projects-search.d.ts +29 -0
  63. package/dist/esm/tools/projects-search.d.ts.map +1 -0
  64. package/dist/esm/tools/projects-search.js +39 -0
  65. package/dist/esm/tools/projects-update-one.d.ts +15 -0
  66. package/dist/esm/tools/projects-update-one.d.ts.map +1 -0
  67. package/dist/esm/tools/projects-update-one.js +16 -0
  68. package/dist/esm/tools/sections-add-one.d.ts +15 -0
  69. package/dist/esm/tools/sections-add-one.d.ts.map +1 -0
  70. package/dist/esm/tools/sections-add-one.js +21 -0
  71. package/dist/esm/tools/sections-delete-one.d.ts +15 -0
  72. package/dist/esm/tools/sections-delete-one.d.ts.map +1 -0
  73. package/dist/esm/tools/sections-delete-one.js +14 -0
  74. package/dist/esm/tools/sections-search.d.ts +18 -0
  75. package/dist/esm/tools/sections-search.d.ts.map +1 -0
  76. package/dist/esm/tools/sections-search.js +30 -0
  77. package/dist/esm/tools/sections-update-one.d.ts +15 -0
  78. package/dist/esm/tools/sections-update-one.d.ts.map +1 -0
  79. package/dist/esm/tools/sections-update-one.js +16 -0
  80. package/dist/esm/tools/shared.d.ts +55 -0
  81. package/dist/esm/tools/shared.d.ts.map +1 -0
  82. package/dist/esm/tools/shared.js +71 -0
  83. package/dist/esm/tools/subtasks-list-for-parent-task.d.ts +31 -0
  84. package/dist/esm/tools/subtasks-list-for-parent-task.d.ts.map +1 -0
  85. package/dist/esm/tools/subtasks-list-for-parent-task.js +37 -0
  86. package/dist/esm/tools/tasks-add-multiple.d.ts +50 -0
  87. package/dist/esm/tools/tasks-add-multiple.d.ts.map +1 -0
  88. package/dist/esm/tools/tasks-add-multiple.js +47 -0
  89. package/dist/esm/tools/tasks-by-date-range.d.ts +33 -0
  90. package/dist/esm/tools/tasks-by-date-range.d.ts.map +1 -0
  91. package/dist/esm/tools/tasks-by-date-range.js +47 -0
  92. package/dist/esm/tools/tasks-by-project.d.ts +31 -0
  93. package/dist/esm/tools/tasks-by-project.d.ts.map +1 -0
  94. package/dist/esm/tools/tasks-by-project.js +37 -0
  95. package/dist/esm/tools/tasks-complete-multiple.d.ts +16 -0
  96. package/dist/esm/tools/tasks-complete-multiple.d.ts.map +1 -0
  97. package/dist/esm/tools/tasks-complete-multiple.js +26 -0
  98. package/dist/esm/tools/tasks-delete-one.d.ts +15 -0
  99. package/dist/esm/tools/tasks-delete-one.d.ts.map +1 -0
  100. package/dist/esm/tools/tasks-delete-one.js +14 -0
  101. package/dist/esm/tools/tasks-list-for-section.d.ts +31 -0
  102. package/dist/esm/tools/tasks-list-for-section.d.ts.map +1 -0
  103. package/dist/esm/tools/tasks-list-for-section.js +37 -0
  104. package/dist/esm/tools/tasks-list-overdue.d.ts +29 -0
  105. package/dist/esm/tools/tasks-list-overdue.d.ts.map +1 -0
  106. package/dist/esm/tools/tasks-list-overdue.js +29 -0
  107. package/dist/esm/tools/tasks-organize-multiple.d.ts +37 -0
  108. package/dist/esm/tools/tasks-organize-multiple.d.ts.map +1 -0
  109. package/dist/esm/tools/tasks-organize-multiple.js +40 -0
  110. package/dist/esm/tools/tasks-search.d.ts +31 -0
  111. package/dist/esm/tools/tasks-search.d.ts.map +1 -0
  112. package/dist/esm/tools/tasks-search.js +30 -0
  113. package/dist/esm/tools/tasks-update-one.d.ts +27 -0
  114. package/dist/esm/tools/tasks-update-one.d.ts.map +1 -0
  115. package/dist/esm/tools/tasks-update-one.js +42 -0
  116. package/dist/types/index.d.ts +476 -0
  117. package/dist/types/main.d.ts +1 -0
  118. package/dist/types/mcp-helpers.d.ts +12 -0
  119. package/dist/types/mcp-server.d.ts +10 -0
  120. package/dist/types/todoist-tool.d.ts +34 -0
  121. package/dist/types/tools/account-overview.d.ts +8 -0
  122. package/dist/types/tools/project-overview.d.ts +13 -0
  123. package/dist/types/tools/projects-add-one.d.ts +21 -0
  124. package/dist/types/tools/projects-delete-one.d.ts +14 -0
  125. package/dist/types/tools/projects-list.d.ts +17 -0
  126. package/dist/types/tools/projects-search.d.ts +28 -0
  127. package/dist/types/tools/projects-update-one.d.ts +14 -0
  128. package/dist/types/tools/sections-add-one.d.ts +14 -0
  129. package/dist/types/tools/sections-delete-one.d.ts +14 -0
  130. package/dist/types/tools/sections-search.d.ts +17 -0
  131. package/dist/types/tools/sections-update-one.d.ts +14 -0
  132. package/dist/types/tools/shared.d.ts +54 -0
  133. package/dist/types/tools/subtasks-list-for-parent-task.d.ts +30 -0
  134. package/dist/types/tools/tasks-add-multiple.d.ts +49 -0
  135. package/dist/types/tools/tasks-by-date-range.d.ts +32 -0
  136. package/dist/types/tools/tasks-by-project.d.ts +30 -0
  137. package/dist/types/tools/tasks-complete-multiple.d.ts +15 -0
  138. package/dist/types/tools/tasks-delete-one.d.ts +14 -0
  139. package/dist/types/tools/tasks-list-for-section.d.ts +30 -0
  140. package/dist/types/tools/tasks-list-overdue.d.ts +28 -0
  141. package/dist/types/tools/tasks-organize-multiple.d.ts +36 -0
  142. package/dist/types/tools/tasks-search.d.ts +30 -0
  143. package/dist/types/tools/tasks-update-one.d.ts +26 -0
  144. package/package.json +20 -7
  145. package/dist/index.d.ts +0 -2
  146. package/dist/index.d.ts.map +0 -1
  147. package/dist/index.js +0 -1
  148. package/dist/main.d.ts.map +0 -1
  149. package/dist/mcp-helpers.d.ts.map +0 -1
  150. package/dist/mcp-server.d.ts.map +0 -1
  151. package/dist/todoist-tool.d.ts.map +0 -1
  152. package/dist/tools/account-overview.d.ts.map +0 -1
  153. package/dist/tools/index.d.ts +0 -23
  154. package/dist/tools/index.d.ts.map +0 -1
  155. package/dist/tools/index.js +0 -22
  156. package/dist/tools/project-overview.d.ts.map +0 -1
  157. package/dist/tools/projects-add-one.d.ts.map +0 -1
  158. package/dist/tools/projects-delete-one.d.ts.map +0 -1
  159. package/dist/tools/projects-list.d.ts.map +0 -1
  160. package/dist/tools/projects-search.d.ts.map +0 -1
  161. package/dist/tools/projects-update-one.d.ts.map +0 -1
  162. package/dist/tools/sections-add-one.d.ts.map +0 -1
  163. package/dist/tools/sections-delete-one.d.ts.map +0 -1
  164. package/dist/tools/sections-search.d.ts.map +0 -1
  165. package/dist/tools/sections-update-one.d.ts.map +0 -1
  166. package/dist/tools/shared.d.ts.map +0 -1
  167. package/dist/tools/subtasks-list-for-parent-task.d.ts.map +0 -1
  168. package/dist/tools/tasks-add-multiple.d.ts.map +0 -1
  169. package/dist/tools/tasks-by-date-range.d.ts.map +0 -1
  170. package/dist/tools/tasks-by-project.d.ts.map +0 -1
  171. package/dist/tools/tasks-complete-multiple.d.ts.map +0 -1
  172. package/dist/tools/tasks-delete-one.d.ts.map +0 -1
  173. package/dist/tools/tasks-list-for-section.d.ts.map +0 -1
  174. package/dist/tools/tasks-list-overdue.d.ts.map +0 -1
  175. package/dist/tools/tasks-organize-multiple.d.ts.map +0 -1
  176. package/dist/tools/tasks-search.d.ts.map +0 -1
  177. package/dist/tools/tasks-update-one.d.ts.map +0 -1
  178. package/src/index.ts +0 -1
  179. package/src/main.ts +0 -26
  180. package/src/mcp-helpers.ts +0 -76
  181. package/src/todoist-tool.ts +0 -42
  182. package/src/tools/account-overview.ts +0 -130
  183. package/src/tools/index.ts +0 -26
  184. package/src/tools/project-overview.ts +0 -130
  185. package/src/tools/projects-add-one.ts +0 -19
  186. package/src/tools/projects-delete-one.ts +0 -18
  187. package/src/tools/projects-list.ts +0 -36
  188. package/src/tools/projects-search.ts +0 -49
  189. package/src/tools/projects-update-one.ts +0 -20
  190. package/src/tools/sections-add-one.ts +0 -25
  191. package/src/tools/sections-delete-one.ts +0 -18
  192. package/src/tools/sections-search.ts +0 -39
  193. package/src/tools/sections-update-one.ts +0 -20
  194. package/src/tools/shared.ts +0 -94
  195. package/src/tools/subtasks-list-for-parent-task.ts +0 -43
  196. package/src/tools/tasks-add-multiple.ts +0 -53
  197. package/src/tools/tasks-by-date-range.ts +0 -58
  198. package/src/tools/tasks-by-project.ts +0 -43
  199. package/src/tools/tasks-complete-multiple.ts +0 -29
  200. package/src/tools/tasks-delete-one.ts +0 -18
  201. package/src/tools/tasks-list-for-section.ts +0 -43
  202. package/src/tools/tasks-list-overdue.ts +0 -35
  203. package/src/tools/tasks-organize-multiple.ts +0 -45
  204. package/src/tools/tasks-search.ts +0 -36
  205. package/src/tools/tasks-update-one.ts +0 -48
  206. /package/dist/{main.d.ts → cjs/main.d.ts} +0 -0
  207. /package/dist/{main.js → cjs/main.js} +0 -0
  208. /package/dist/{mcp-helpers.d.ts → cjs/mcp-helpers.d.ts} +0 -0
  209. /package/dist/{mcp-helpers.js → cjs/mcp-helpers.js} +0 -0
  210. /package/dist/{mcp-server.d.ts → cjs/mcp-server.d.ts} +0 -0
  211. /package/dist/{mcp-server.js → cjs/mcp-server.js} +0 -0
  212. /package/dist/{todoist-tool.d.ts → cjs/todoist-tool.d.ts} +0 -0
  213. /package/dist/{todoist-tool.js → cjs/todoist-tool.js} +0 -0
  214. /package/dist/{tools → cjs/tools}/account-overview.d.ts +0 -0
  215. /package/dist/{tools → cjs/tools}/account-overview.js +0 -0
  216. /package/dist/{tools → cjs/tools}/project-overview.d.ts +0 -0
  217. /package/dist/{tools → cjs/tools}/project-overview.js +0 -0
  218. /package/dist/{tools → cjs/tools}/projects-add-one.d.ts +0 -0
  219. /package/dist/{tools → cjs/tools}/projects-add-one.js +0 -0
  220. /package/dist/{tools → cjs/tools}/projects-delete-one.d.ts +0 -0
  221. /package/dist/{tools → cjs/tools}/projects-delete-one.js +0 -0
  222. /package/dist/{tools → cjs/tools}/projects-list.d.ts +0 -0
  223. /package/dist/{tools → cjs/tools}/projects-list.js +0 -0
  224. /package/dist/{tools → cjs/tools}/projects-search.d.ts +0 -0
  225. /package/dist/{tools → cjs/tools}/projects-search.js +0 -0
  226. /package/dist/{tools → cjs/tools}/projects-update-one.d.ts +0 -0
  227. /package/dist/{tools → cjs/tools}/projects-update-one.js +0 -0
  228. /package/dist/{tools → cjs/tools}/sections-add-one.d.ts +0 -0
  229. /package/dist/{tools → cjs/tools}/sections-add-one.js +0 -0
  230. /package/dist/{tools → cjs/tools}/sections-delete-one.d.ts +0 -0
  231. /package/dist/{tools → cjs/tools}/sections-delete-one.js +0 -0
  232. /package/dist/{tools → cjs/tools}/sections-search.d.ts +0 -0
  233. /package/dist/{tools → cjs/tools}/sections-search.js +0 -0
  234. /package/dist/{tools → cjs/tools}/sections-update-one.d.ts +0 -0
  235. /package/dist/{tools → cjs/tools}/sections-update-one.js +0 -0
  236. /package/dist/{tools → cjs/tools}/shared.d.ts +0 -0
  237. /package/dist/{tools → cjs/tools}/shared.js +0 -0
  238. /package/dist/{tools → cjs/tools}/subtasks-list-for-parent-task.d.ts +0 -0
  239. /package/dist/{tools → cjs/tools}/subtasks-list-for-parent-task.js +0 -0
  240. /package/dist/{tools → cjs/tools}/tasks-add-multiple.d.ts +0 -0
  241. /package/dist/{tools → cjs/tools}/tasks-add-multiple.js +0 -0
  242. /package/dist/{tools → cjs/tools}/tasks-by-date-range.d.ts +0 -0
  243. /package/dist/{tools → cjs/tools}/tasks-by-date-range.js +0 -0
  244. /package/dist/{tools → cjs/tools}/tasks-by-project.d.ts +0 -0
  245. /package/dist/{tools → cjs/tools}/tasks-by-project.js +0 -0
  246. /package/dist/{tools → cjs/tools}/tasks-complete-multiple.d.ts +0 -0
  247. /package/dist/{tools → cjs/tools}/tasks-complete-multiple.js +0 -0
  248. /package/dist/{tools → cjs/tools}/tasks-delete-one.d.ts +0 -0
  249. /package/dist/{tools → cjs/tools}/tasks-delete-one.js +0 -0
  250. /package/dist/{tools → cjs/tools}/tasks-list-for-section.d.ts +0 -0
  251. /package/dist/{tools → cjs/tools}/tasks-list-for-section.js +0 -0
  252. /package/dist/{tools → cjs/tools}/tasks-list-overdue.d.ts +0 -0
  253. /package/dist/{tools → cjs/tools}/tasks-list-overdue.js +0 -0
  254. /package/dist/{tools → cjs/tools}/tasks-organize-multiple.d.ts +0 -0
  255. /package/dist/{tools → cjs/tools}/tasks-organize-multiple.js +0 -0
  256. /package/dist/{tools → cjs/tools}/tasks-search.d.ts +0 -0
  257. /package/dist/{tools → cjs/tools}/tasks-search.js +0 -0
  258. /package/dist/{tools → cjs/tools}/tasks-update-one.d.ts +0 -0
  259. /package/dist/{tools → cjs/tools}/tasks-update-one.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"tasks-search.d.ts","sourceRoot":"","sources":["../../src/tools/tasks-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYyB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tasks-update-one.d.ts","sourceRoot":"","sources":["../../src/tools/tasks-update-one.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqCxB,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;CAQsB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,CAAC"}
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { getMcpServer } from "./mcp-server.js";
package/src/main.ts DELETED
@@ -1,26 +0,0 @@
1
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
2
- import dotenv from "dotenv";
3
- import { getMcpServer } from "./mcp-server.js";
4
-
5
- function main() {
6
- const todoistApiKey = process.env.TODOIST_API_KEY;
7
- if (!todoistApiKey) {
8
- throw new Error("TODOIST_API_KEY is not set");
9
- }
10
-
11
- const server = getMcpServer({ todoistApiKey });
12
- const transport = new StdioServerTransport();
13
- server
14
- .connect(transport)
15
- .then(() => {
16
- // We use console.error because standard I/O is being used for the MCP server communication.
17
- console.error("Server started");
18
- })
19
- .catch((error) => {
20
- console.error("Error starting the Todoist MCP server:", error);
21
- process.exit(1);
22
- });
23
- }
24
-
25
- dotenv.config();
26
- main();
@@ -1,76 +0,0 @@
1
- import type { TodoistApi } from "@doist/todoist-api-typescript";
2
- import type {
3
- McpServer,
4
- ToolCallback,
5
- } from "@modelcontextprotocol/sdk/server/mcp.js";
6
- import type { ZodTypeAny, z } from "zod";
7
- import type { TodoistTool } from "./todoist-tool.js";
8
-
9
- function textContent(text: string) {
10
- return {
11
- content: [{ type: "text" as const, text }],
12
- };
13
- }
14
-
15
- function jsonContent(data: unknown) {
16
- return {
17
- content: [
18
- {
19
- type: "text" as const,
20
- mimeType: "application/json",
21
- text: JSON.stringify(data, null, 2),
22
- },
23
- ],
24
- };
25
- }
26
-
27
- function textOrJsonContent(data: unknown) {
28
- return typeof data === "string" ? textContent(data) : jsonContent(data);
29
- }
30
-
31
- function errorContent(error: string) {
32
- return {
33
- ...textContent(error),
34
- isError: true,
35
- };
36
- }
37
-
38
- /**
39
- * Register a Todoist tool in an MCP server.
40
- * @param tool - The tool to register.
41
- * @param server - The server to register the tool on.
42
- * @param client - The Todoist API client to use to execute the tool.
43
- */
44
- function registerTool<Params extends z.ZodRawShape>(
45
- tool: TodoistTool<Params>,
46
- server: McpServer,
47
- client: TodoistApi,
48
- ) {
49
- // @ts-ignore I give up
50
- const cb: ToolCallback<Params> = async (
51
- args: z.objectOutputType<Params, ZodTypeAny>,
52
- _context,
53
- ) => {
54
- try {
55
- const result = await tool.execute(
56
- args as z.infer<z.ZodObject<Params>>,
57
- client,
58
- );
59
- return textOrJsonContent(result);
60
- } catch (error) {
61
- console.error(`Error executing tool ${tool.name}:`, {
62
- args,
63
- error,
64
- });
65
- const message =
66
- error instanceof Error
67
- ? error.message
68
- : "An unknown error occurred";
69
- return errorContent(message);
70
- }
71
- };
72
-
73
- server.tool(tool.name, tool.description, tool.parameters, cb);
74
- }
75
-
76
- export { registerTool };
@@ -1,42 +0,0 @@
1
- import type { TodoistApi } from "@doist/todoist-api-typescript";
2
- import type { z } from "zod";
3
-
4
- /**
5
- * A Todoist tool that can be used in an MCP server or other conversational AI interfaces.
6
- */
7
- type TodoistTool<Params extends z.ZodRawShape> = {
8
- /**
9
- * The name of the tool.
10
- */
11
- name: string;
12
-
13
- /**
14
- * The description of the tool. This is important for the LLM to understand what the tool does,
15
- * and how to use it.
16
- */
17
- description: string;
18
-
19
- /**
20
- * The schema of the parameters of the tool.
21
- *
22
- * This is used to validate the parameters of the tool, as well as to let the LLM know what the
23
- * parameters are.
24
- */
25
- parameters: Params;
26
-
27
- /**
28
- * The function that executes the tool.
29
- *
30
- * This is the main function that will be called when the tool is used.
31
- *
32
- * @param args - The arguments of the tool.
33
- * @param client - The Todoist API client used to make requests to the Todoist API.
34
- * @returns The result of the tool.
35
- */
36
- execute: (
37
- args: z.infer<z.ZodObject<Params>>,
38
- client: TodoistApi,
39
- ) => Promise<unknown>;
40
- };
41
-
42
- export type { TodoistTool };
@@ -1,130 +0,0 @@
1
- import type {
2
- Project,
3
- Section,
4
- TodoistApi,
5
- } from "@doist/todoist-api-typescript";
6
- import type { TodoistTool } from "../todoist-tool.js";
7
-
8
- const ArgsSchema = {};
9
-
10
- type ProjectWithChildren = Project & {
11
- children: ProjectWithChildren[];
12
- childOrder: number;
13
- };
14
-
15
- function buildProjectTree(projects: Project[]): Project[] {
16
- // Sort projects by childOrder, then build a tree
17
- const byId: Record<string, ProjectWithChildren> = {};
18
- for (const p of projects) {
19
- byId[p.id] = {
20
- ...p,
21
- children: [],
22
- childOrder: (p as { childOrder?: number }).childOrder ?? 0,
23
- };
24
- }
25
- const roots: ProjectWithChildren[] = [];
26
- for (const p of projects) {
27
- const current = byId[p.id];
28
- if (!current) continue;
29
- if (p.parentId) {
30
- const parent = byId[p.parentId];
31
- if (parent) {
32
- parent.children.push(current);
33
- } else {
34
- roots.push(current);
35
- }
36
- } else {
37
- roots.push(current);
38
- }
39
- }
40
- function sortTree(nodes: ProjectWithChildren[]) {
41
- nodes.sort((a, b) => a.childOrder - b.childOrder);
42
- for (const n of nodes) {
43
- sortTree(n.children);
44
- }
45
- }
46
- sortTree(roots);
47
- return roots;
48
- }
49
-
50
- async function getSectionsByProject(
51
- client: TodoistApi,
52
- projectIds: string[],
53
- ): Promise<Record<string, Section[]>> {
54
- const result: Record<string, Section[]> = {};
55
- await Promise.all(
56
- projectIds.map(async (projectId) => {
57
- const { results } = await client.getSections({ projectId });
58
- result[projectId] = results;
59
- }),
60
- );
61
- return result;
62
- }
63
-
64
- function renderProjectMarkdown(
65
- project: ProjectWithChildren,
66
- sectionsByProject: Record<string, Section[]>,
67
- indent = "",
68
- ): string[] {
69
- const lines: string[] = [];
70
- lines.push(`${indent}- Project: ${project.name} (id=${project.id})`);
71
- const sections = sectionsByProject[project.id] || [];
72
- for (const section of sections) {
73
- lines.push(`${indent} - Section: ${section.name} (id=${section.id})`);
74
- }
75
- for (const child of project.children) {
76
- lines.push(
77
- ...renderProjectMarkdown(child, sectionsByProject, `${indent} `),
78
- );
79
- }
80
- return lines;
81
- }
82
-
83
- const accountOverview = {
84
- name: "account-overview",
85
- description:
86
- "Get a Markdown overview of all projects (with hierarchy and sections) and the inbox project. Useful in almost any context before engaging with Todoist further.",
87
- parameters: ArgsSchema,
88
- async execute(_args, client) {
89
- const { results: projects } = await client.getProjects({});
90
- const inbox = projects.find((p) => p.isInboxProject === true);
91
- const nonInbox = projects.filter((p) => p.isInboxProject !== true);
92
- const tree = buildProjectTree(nonInbox);
93
- const allProjectIds = projects.map((p) => p.id);
94
- const sectionsByProject = await getSectionsByProject(
95
- client,
96
- allProjectIds,
97
- );
98
-
99
- const lines: string[] = ["# Personal Projects", ""];
100
- if (inbox) {
101
- lines.push(`- Inbox Project: ${inbox.name} (id=${inbox.id})`);
102
- for (const section of sectionsByProject[inbox.id] || []) {
103
- lines.push(` - Section: ${section.name} (id=${section.id})`);
104
- }
105
- }
106
- if (tree.length) {
107
- for (const project of tree as ProjectWithChildren[]) {
108
- lines.push(
109
- ...renderProjectMarkdown(project, sectionsByProject),
110
- );
111
- }
112
- } else {
113
- lines.push("_No projects found._");
114
- }
115
- lines.push("");
116
- // Add explanation about nesting if there are nested projects
117
- const hasNested = (tree as ProjectWithChildren[]).some(
118
- (p) => p.children.length > 0,
119
- );
120
- if (hasNested) {
121
- lines.push(
122
- "_Note: Indentation indicates that a project is a sub-project of the one above it. This allows for organizing projects hierarchically, with parent projects containing related sub-projects._",
123
- "",
124
- );
125
- }
126
- return lines.join("\n");
127
- },
128
- } satisfies TodoistTool<typeof ArgsSchema>;
129
-
130
- export { accountOverview };
@@ -1,26 +0,0 @@
1
- export { projectsList } from "./projects-list.js";
2
- export { projectsSearch } from "./projects-search.js";
3
- export { projectsAddOne } from "./projects-add-one.js";
4
- export { projectsUpdateOne } from "./projects-update-one.js";
5
- export { projectsDeleteOne } from "./projects-delete-one.js";
6
-
7
- export { sectionsSearch } from "./sections-search.js";
8
- export { sectionsAddOne } from "./sections-add-one.js";
9
- export { sectionsUpdateOne } from "./sections-update-one.js";
10
- export { sectionsDeleteOne } from "./sections-delete-one.js";
11
-
12
- export { tasksListByDate } from "./tasks-by-date-range.js";
13
- export { tasksDeleteOne } from "./tasks-delete-one.js";
14
- export { tasksCompleteMultiple } from "./tasks-complete-multiple.js";
15
- export { tasksListForProject } from "./tasks-by-project.js";
16
- export { tasksListOverdue } from "./tasks-list-overdue.js";
17
- export { tasksSearch } from "./tasks-search.js";
18
- export { tasksAddMultiple } from "./tasks-add-multiple.js";
19
- export { tasksUpdateOne } from "./tasks-update-one.js";
20
- export { tasksOrganizeMultiple } from "./tasks-organize-multiple.js";
21
- export { tasksListForSection } from "./tasks-list-for-section.js";
22
-
23
- export { subtasksListForParentTask } from "./subtasks-list-for-parent-task.js";
24
-
25
- export { accountOverview } from "./account-overview.js";
26
- export { projectOverview } from "./project-overview.js";
@@ -1,130 +0,0 @@
1
- import type {
2
- Project,
3
- Section,
4
- TodoistApi,
5
- } from "@doist/todoist-api-typescript";
6
- import { z } from "zod";
7
- import type { TodoistTool } from "../todoist-tool.js";
8
- import { mapTask } from "./shared.js";
9
-
10
- const ArgsSchema = {
11
- projectId: z
12
- .string()
13
- .min(1)
14
- .describe("The ID of the project to get an overview for."),
15
- };
16
-
17
- type MappedTask = ReturnType<typeof mapTask>;
18
-
19
- type TaskTreeNode = MappedTask & { children: TaskTreeNode[] };
20
-
21
- function buildTaskTree(tasks: MappedTask[]): TaskTreeNode[] {
22
- const byId: Record<string, TaskTreeNode> = {};
23
- for (const task of tasks) {
24
- byId[task.id] = { ...task, children: [] };
25
- }
26
- const roots: TaskTreeNode[] = [];
27
- for (const task of tasks) {
28
- const node = byId[task.id];
29
- if (!node) continue;
30
- if (!task.parentId) {
31
- roots.push(node);
32
- continue;
33
- }
34
- const parent = byId[task.parentId];
35
- if (parent) {
36
- parent.children.push(node);
37
- } else {
38
- roots.push(node);
39
- }
40
- }
41
- return roots;
42
- }
43
-
44
- function renderTaskTreeMarkdown(tasks: TaskTreeNode[], indent = ""): string[] {
45
- const lines: string[] = [];
46
- for (const task of tasks) {
47
- const idPart = `id=${task.id}`;
48
- const duePart = task.dueDate ? `; due=${task.dueDate}` : "";
49
- const contentPart = `; content=${task.content}`;
50
- lines.push(`${indent}- ${idPart}${duePart}${contentPart}`);
51
- if (task.children.length > 0) {
52
- lines.push(...renderTaskTreeMarkdown(task.children, `${indent} `));
53
- }
54
- }
55
- return lines;
56
- }
57
-
58
- async function getAllTasksForProject(
59
- client: TodoistApi,
60
- projectId: string,
61
- ): Promise<MappedTask[]> {
62
- let allTasks: MappedTask[] = [];
63
- let cursor: string | undefined = undefined;
64
- do {
65
- const { results, nextCursor } = await client.getTasks({
66
- projectId,
67
- limit: 50,
68
- cursor: cursor ?? undefined,
69
- });
70
- allTasks = allTasks.concat(results.map(mapTask));
71
- cursor = nextCursor ?? undefined;
72
- } while (cursor);
73
- return allTasks;
74
- }
75
-
76
- async function getProjectSections(
77
- client: TodoistApi,
78
- projectId: string,
79
- ): Promise<Section[]> {
80
- const { results } = await client.getSections({ projectId });
81
- return results;
82
- }
83
-
84
- const projectOverview = {
85
- name: "project-overview",
86
- description:
87
- "Get a Markdown overview of a single project, including its sections and all tasks. Tasks are grouped by section, with tasks not in any section listed first. Each task is listed as '- id=TASKID; due=YYYY-MM-DD; content=TASK CONTENT' (omit due if not present). Subtasks are nested as indented list items.",
88
- parameters: ArgsSchema,
89
- async execute(args, client) {
90
- const { projectId } = args;
91
- const project: Project = await client.getProject(projectId);
92
- const sections = await getProjectSections(client, projectId);
93
- const allTasks = await getAllTasksForProject(client, projectId);
94
-
95
- // Group tasks by sectionId
96
- const tasksBySection: Record<string, MappedTask[]> = {};
97
- for (const section of sections) {
98
- tasksBySection[section.id] = [];
99
- }
100
- const tasksWithoutSection: MappedTask[] = [];
101
- for (const task of allTasks) {
102
- if (task.sectionId && tasksBySection[task.sectionId]) {
103
- // biome-ignore lint/style/noNonNullAssertion: the "if" above ensures that it is defined
104
- tasksBySection[task.sectionId]!.push(task);
105
- } else {
106
- tasksWithoutSection.push(task);
107
- }
108
- }
109
-
110
- const lines: string[] = [`# ${project.name}`];
111
- if (tasksWithoutSection.length > 0) {
112
- lines.push("");
113
- const tree = buildTaskTree(tasksWithoutSection);
114
- lines.push(...renderTaskTreeMarkdown(tree));
115
- }
116
- for (const section of sections) {
117
- lines.push("");
118
- lines.push(`## ${section.name}`);
119
- const sectionTasks = tasksBySection[section.id];
120
- if (!sectionTasks?.length) {
121
- continue;
122
- }
123
- const tree = buildTaskTree(sectionTasks);
124
- lines.push(...renderTaskTreeMarkdown(tree));
125
- }
126
- return lines.join("\n");
127
- },
128
- } satisfies TodoistTool<typeof ArgsSchema>;
129
-
130
- export { projectOverview };
@@ -1,19 +0,0 @@
1
- import { z } from "zod";
2
- import type { TodoistTool } from "../todoist-tool.js";
3
- import { mapProject } from "./shared.js";
4
-
5
- const ArgsSchema = {
6
- name: z.string().min(1).describe("The name of the project to add."),
7
- };
8
-
9
- const projectsAddOne = {
10
- name: "projects-add-one",
11
- description: "Add a new project.",
12
- parameters: ArgsSchema,
13
- async execute(args, client) {
14
- const project = await client.addProject({ name: args.name });
15
- return mapProject(project);
16
- },
17
- } satisfies TodoistTool<typeof ArgsSchema>;
18
-
19
- export { projectsAddOne };
@@ -1,18 +0,0 @@
1
- import { z } from "zod";
2
- import type { TodoistTool } from "../todoist-tool.js";
3
-
4
- const ArgsSchema = {
5
- id: z.string().min(1).describe("The ID of the project to delete."),
6
- };
7
-
8
- const projectsDeleteOne = {
9
- name: "projects-delete-one",
10
- description: "Delete a project by its ID.",
11
- parameters: ArgsSchema,
12
- async execute(args, client) {
13
- await client.deleteProject(args.id);
14
- return { success: true };
15
- },
16
- } satisfies TodoistTool<typeof ArgsSchema>;
17
-
18
- export { projectsDeleteOne };
@@ -1,36 +0,0 @@
1
- import { z } from "zod";
2
- import type { TodoistTool } from "../todoist-tool.js";
3
-
4
- const ArgsSchema = {
5
- limit: z
6
- .number()
7
- .int()
8
- .min(1)
9
- .max(100)
10
- .default(50)
11
- .describe("The maximum number of projects to return."),
12
- cursor: z
13
- .string()
14
- .optional()
15
- .describe(
16
- "The cursor to get the next page of projects (cursor is obtained from the previous call to this tool, with the same parameters).",
17
- ),
18
- };
19
-
20
- const projectsList = {
21
- name: "projects-list",
22
- description: "List all projects for the user.",
23
- parameters: ArgsSchema,
24
- async execute(args, client) {
25
- const { results, nextCursor } = await client.getProjects({
26
- limit: args.limit,
27
- cursor: args.cursor ?? null,
28
- });
29
- return {
30
- projects: results,
31
- nextCursor,
32
- };
33
- },
34
- } satisfies TodoistTool<typeof ArgsSchema>;
35
-
36
- export { projectsList };
@@ -1,49 +0,0 @@
1
- import { z } from "zod";
2
- import type { TodoistTool } from "../todoist-tool.js";
3
- import { mapProject } from "./shared.js";
4
-
5
- const ArgsSchema = {
6
- search: z
7
- .string()
8
- .optional()
9
- .describe(
10
- "Search for a project by name (partial and case insensitive match). If omitted, all projects are returned.",
11
- ),
12
- limit: z
13
- .number()
14
- .int()
15
- .min(1)
16
- .max(100)
17
- .default(50)
18
- .describe("The maximum number of projects to return."),
19
- cursor: z
20
- .string()
21
- .optional()
22
- .describe(
23
- "The cursor to get the next page of projects (cursor is obtained from the previous call to this tool, with the same parameters).",
24
- ),
25
- };
26
-
27
- const projectsSearch = {
28
- name: "projects-search",
29
- description: "Search for projects by name or other criteria.",
30
- parameters: ArgsSchema,
31
- async execute(args, client) {
32
- const { results, nextCursor } = await client.getProjects({
33
- limit: args.limit,
34
- cursor: args.cursor ?? null,
35
- });
36
- const searchLower = args.search ? args.search.toLowerCase() : undefined;
37
- const filtered = searchLower
38
- ? results.filter((project) =>
39
- project.name.toLowerCase().includes(searchLower),
40
- )
41
- : results;
42
- return {
43
- projects: filtered.map(mapProject),
44
- nextCursor,
45
- };
46
- },
47
- } satisfies TodoistTool<typeof ArgsSchema>;
48
-
49
- export { projectsSearch };
@@ -1,20 +0,0 @@
1
- import { z } from "zod";
2
- import type { TodoistTool } from "../todoist-tool.js";
3
-
4
- const ArgsSchema = {
5
- id: z.string().min(1).describe("The ID of the project to update."),
6
- name: z.string().min(1).describe("The new name for the project."),
7
- };
8
-
9
- const projectsUpdateOne = {
10
- name: "projects-update-one",
11
- description: "Update a project's name by its ID.",
12
- parameters: ArgsSchema,
13
- async execute(args, client) {
14
- const { id, name } = args;
15
- const project = await client.updateProject(id, { name });
16
- return project;
17
- },
18
- } satisfies TodoistTool<typeof ArgsSchema>;
19
-
20
- export { projectsUpdateOne };
@@ -1,25 +0,0 @@
1
- import { z } from "zod";
2
- import type { TodoistTool } from "../todoist-tool.js";
3
-
4
- const ArgsSchema = {
5
- name: z.string().min(1).describe("The name of the section to add."),
6
- projectId: z
7
- .string()
8
- .min(1)
9
- .describe("The ID of the project to add the section to."),
10
- };
11
-
12
- const sectionsAddOne = {
13
- name: "sections-add-one",
14
- description: "Add a new section to a project.",
15
- parameters: ArgsSchema,
16
- async execute(args, client) {
17
- const section = await client.addSection({
18
- name: args.name,
19
- projectId: args.projectId,
20
- });
21
- return section;
22
- },
23
- } satisfies TodoistTool<typeof ArgsSchema>;
24
-
25
- export { sectionsAddOne };
@@ -1,18 +0,0 @@
1
- import { z } from "zod";
2
- import type { TodoistTool } from "../todoist-tool.js";
3
-
4
- const ArgsSchema = {
5
- id: z.string().min(1).describe("The ID of the section to delete."),
6
- };
7
-
8
- const sectionsDeleteOne = {
9
- name: "sections-delete-one",
10
- description: "Delete a section by its ID.",
11
- parameters: ArgsSchema,
12
- async execute(args, client) {
13
- await client.deleteSection(args.id);
14
- return { success: true };
15
- },
16
- } satisfies TodoistTool<typeof ArgsSchema>;
17
-
18
- export { sectionsDeleteOne };
@@ -1,39 +0,0 @@
1
- import type { Section } from "@doist/todoist-api-typescript";
2
- import { z } from "zod";
3
- import type { TodoistTool } from "../todoist-tool.js";
4
-
5
- const ArgsSchema = {
6
- projectId: z
7
- .string()
8
- .min(1)
9
- .describe("The ID of the project to search sections in."),
10
- search: z
11
- .string()
12
- .optional()
13
- .describe(
14
- "Search for a section by name (partial and case insensitive match). If omitted, all sections in the project are returned.",
15
- ),
16
- };
17
-
18
- const sectionsSearch = {
19
- name: "sections-search",
20
- description: "Search for sections by name or other criteria in a project.",
21
- parameters: ArgsSchema,
22
- async execute(args, client) {
23
- const { results } = await client.getSections({
24
- projectId: args.projectId,
25
- });
26
- const searchLower = args.search ? args.search.toLowerCase() : undefined;
27
- const filtered = searchLower
28
- ? results.filter((section: Section) =>
29
- section.name.toLowerCase().includes(searchLower),
30
- )
31
- : results;
32
- return filtered.map((section: Section) => ({
33
- id: section.id,
34
- name: section.name,
35
- }));
36
- },
37
- } satisfies TodoistTool<typeof ArgsSchema>;
38
-
39
- export { sectionsSearch };