mcp-google-tasks 0.1.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/LICENSE +21 -0
- package/README.md +301 -0
- package/README.ru.md +301 -0
- package/dist/client.js +333 -0
- package/dist/config.js +83 -0
- package/dist/index.js +119 -0
- package/dist/telemetry.js +120 -0
- package/dist/tools/completion.js +48 -0
- package/dist/tools/raw.js +33 -0
- package/dist/tools/tasklists.js +83 -0
- package/dist/tools/tasks.js +184 -0
- package/dist/tools/util.js +74 -0
- package/dist/types.js +44 -0
- package/package.json +60 -0
- package/test/dist-smoke.test.js +175 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DESTRUCTIVE, fail, ok, taskIdSchema, tasklistIdSchema, UPDATE } from "./util.js";
|
|
2
|
+
/**
|
|
3
|
+
* Completion is deliberately separated from deletion: completing a task is
|
|
4
|
+
* reversible (reopen_task restores it), deleting is not. The two reversible
|
|
5
|
+
* transitions are UPDATE; clear_completed_tasks hides many tasks at once and
|
|
6
|
+
* cannot be undone in bulk, so it carries the destructive hints.
|
|
7
|
+
*/
|
|
8
|
+
export function registerCompletionTools(server, client) {
|
|
9
|
+
server.registerTool("complete_task", {
|
|
10
|
+
title: "Complete a task",
|
|
11
|
+
annotations: UPDATE,
|
|
12
|
+
description: "Marks a task completed (status=completed; the API stamps the completed timestamp). This is REVERSIBLE — reopen_task undoes it — and is the right call for \"done\", unlike delete_task which erases the task. The API call touches only the addressed task: completing a parent does NOT cascade to its subtasks — complete them individually if the whole tree is done. A completed task stays listed until cleared: list_tasks still returns it with show_completed=true (+ show_hidden=true after a clear). Returns the updated task with status and completed.",
|
|
13
|
+
inputSchema: { tasklist_id: tasklistIdSchema(), task_id: taskIdSchema() },
|
|
14
|
+
}, async ({ tasklist_id, task_id }) => {
|
|
15
|
+
try {
|
|
16
|
+
return ok(await client.setTaskStatus(tasklist_id, task_id, true));
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
return fail(e);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
server.registerTool("reopen_task", {
|
|
23
|
+
title: "Reopen a task",
|
|
24
|
+
annotations: UPDATE,
|
|
25
|
+
description: "Reverts a completed task to needsAction and clears its completed timestamp — the undo for complete_task. Works on hidden tasks too (tasks cleared with clear_completed_tasks): reopening un-hides them. Cannot resurrect a deleted task — deletion is permanent. Returns the updated task.",
|
|
26
|
+
inputSchema: { tasklist_id: tasklistIdSchema(), task_id: taskIdSchema() },
|
|
27
|
+
}, async ({ tasklist_id, task_id }) => {
|
|
28
|
+
try {
|
|
29
|
+
return ok(await client.setTaskStatus(tasklist_id, task_id, false));
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
return fail(e);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
server.registerTool("clear_completed_tasks", {
|
|
36
|
+
title: "Clear completed tasks",
|
|
37
|
+
annotations: DESTRUCTIVE,
|
|
38
|
+
description: "Clears ALL completed tasks from one list in a single call: they are flagged hidden and vanish from default listings (the Google Tasks UI does this as \"Delete all completed\"). The tasks are not deleted — list_tasks with show_completed=true and show_hidden=true still returns them, and reopen_task can restore any of them individually — but there is no single call to un-clear a whole list, so treat it as destructive. Open (needsAction) tasks are untouched. Returns {cleared:true} with the tasklist_id echoed.",
|
|
39
|
+
inputSchema: { tasklist_id: tasklistIdSchema() },
|
|
40
|
+
}, async ({ tasklist_id }) => {
|
|
41
|
+
try {
|
|
42
|
+
return ok(await client.clearCompletedTasks(tasklist_id));
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
return fail(e);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DESTRUCTIVE, fail, ok } from "./util.js";
|
|
3
|
+
export function registerRawTool(server, client) {
|
|
4
|
+
server.registerTool("raw_request", {
|
|
5
|
+
title: "Raw Google Tasks API call",
|
|
6
|
+
// Full API surface incl. deletes and clears — annotate for the worst case
|
|
7
|
+
// a call can do, not the average.
|
|
8
|
+
annotations: DESTRUCTIVE,
|
|
9
|
+
description: 'Escape hatch to call any Google Tasks API v1 path directly, for requests the typed tools don\'t cover — e.g. a full-resource PUT ("tasks/v1/lists/<listId>/tasks/<taskId>", method PUT, body with the complete task), or a query combination the typed filters don\'t expose. The path is relative to https://tasks.googleapis.com and may carry a query string (e.g. "tasks/v1/lists/<listId>/tasks?showDeleted=true"). The Bearer token is added automatically; the method defaults to GET. PATCH/PUT/POST/DELETE hit live data with no confirmation — prefer the typed tools when one fits.',
|
|
10
|
+
inputSchema: {
|
|
11
|
+
path: z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1)
|
|
14
|
+
.describe('API path relative to https://tasks.googleapis.com, e.g. "tasks/v1/users/@me/lists".'),
|
|
15
|
+
method: z
|
|
16
|
+
.enum(["GET", "POST", "PATCH", "PUT", "DELETE"])
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("HTTP method. Defaults to GET."),
|
|
19
|
+
body: z
|
|
20
|
+
.record(z.any())
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("JSON request body — sent for POST/PATCH/PUT/DELETE, ignored for GET."),
|
|
23
|
+
},
|
|
24
|
+
}, async ({ path, method, body }) => {
|
|
25
|
+
try {
|
|
26
|
+
const m = (method ?? "GET");
|
|
27
|
+
return ok(await client.request(m, path, body));
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
return fail(e);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DESTRUCTIVE, fail, ok, READ_ONLY, tasklistIdSchema, UPDATE, WRITE } from "./util.js";
|
|
3
|
+
export function registerTaskListTools(server, client) {
|
|
4
|
+
server.registerTool("list_tasklists", {
|
|
5
|
+
title: "List task lists",
|
|
6
|
+
annotations: READ_ONLY,
|
|
7
|
+
description: "Lists the user's task lists: id, title, updated (RFC3339). Every task lives in exactly one list, so this is the entry point — task tools need a tasklist_id from here (or the \"@default\" alias for the default list). Paginate with page_token from nextPageToken; page_size caps a page at 1000 and the API's default is already 1000, so one call usually returns everything. The API has no search or ordering — filter client-side.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
page_size: z
|
|
10
|
+
.number()
|
|
11
|
+
.int()
|
|
12
|
+
.min(1)
|
|
13
|
+
.max(1000)
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Max task lists per page (1..1000; the API's default is 1000)."),
|
|
16
|
+
page_token: z.string().optional().describe("nextPageToken from the previous page."),
|
|
17
|
+
},
|
|
18
|
+
}, async ({ page_size, page_token }) => {
|
|
19
|
+
try {
|
|
20
|
+
return ok(await client.listTaskLists({ pageSize: page_size, pageToken: page_token }));
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
return fail(e);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
server.registerTool("get_tasklist", {
|
|
27
|
+
title: "Get a task list",
|
|
28
|
+
annotations: READ_ONLY,
|
|
29
|
+
description: 'Fetches one task list by id: id, title, updated, selfLink. Accepts "@default" for the user\'s default list — useful to resolve its real id. The list resource carries only metadata; the tasks themselves come from list_tasks.',
|
|
30
|
+
inputSchema: { tasklist_id: tasklistIdSchema() },
|
|
31
|
+
}, async ({ tasklist_id }) => {
|
|
32
|
+
try {
|
|
33
|
+
return ok(await client.getTaskList(tasklist_id));
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
return fail(e);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
server.registerTool("create_tasklist", {
|
|
40
|
+
title: "Create a task list",
|
|
41
|
+
annotations: WRITE,
|
|
42
|
+
description: "Creates a new task list and returns it (id, title, updated). The API accepts only a title — there are no other list-level settings. The returned id is the tasklist_id every task tool needs. Google caps the number of lists per account; a quota failure surfaces as an HTTP error, not silence.",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
title: z.string().min(1).max(1024).describe("The list title shown in Google Tasks (max 1024 chars)."),
|
|
45
|
+
},
|
|
46
|
+
}, async ({ title }) => {
|
|
47
|
+
try {
|
|
48
|
+
return ok(await client.createTaskList(title));
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
return fail(e);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
server.registerTool("update_tasklist", {
|
|
55
|
+
title: "Rename a task list",
|
|
56
|
+
annotations: UPDATE,
|
|
57
|
+
description: "Renames a task list (PATCH — the title is the only field the API lets you change). Tasks, their order and their completion state are untouched. Returns the updated list resource.",
|
|
58
|
+
inputSchema: {
|
|
59
|
+
tasklist_id: tasklistIdSchema(),
|
|
60
|
+
title: z.string().min(1).max(1024).describe("The new list title (max 1024 chars)."),
|
|
61
|
+
},
|
|
62
|
+
}, async ({ tasklist_id, title }) => {
|
|
63
|
+
try {
|
|
64
|
+
return ok(await client.updateTaskList(tasklist_id, title));
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return fail(e);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
server.registerTool("delete_tasklist", {
|
|
71
|
+
title: "Delete a task list",
|
|
72
|
+
annotations: DESTRUCTIVE,
|
|
73
|
+
description: "Deletes a task list AND every task in it, permanently — there is no undo and no trash. The user's default task list cannot be deleted (the API rejects it). To empty a list but keep it, use clear_completed_tasks or delete tasks one by one instead. Returns {deleted:true} with the tasklist_id echoed.",
|
|
74
|
+
inputSchema: { tasklist_id: tasklistIdSchema() },
|
|
75
|
+
}, async ({ tasklist_id }) => {
|
|
76
|
+
try {
|
|
77
|
+
return ok(await client.deleteTaskList(tasklist_id));
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
return fail(e);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DESTRUCTIVE, dueDateSchema, fail, ok, READ_ONLY, rfc3339Timestamp, taskIdSchema, tasklistIdSchema, UPDATE, WRITE, } from "./util.js";
|
|
3
|
+
export function registerTaskTools(server, client) {
|
|
4
|
+
server.registerTool("list_tasks", {
|
|
5
|
+
title: "List tasks",
|
|
6
|
+
annotations: READ_ONLY,
|
|
7
|
+
description: "Lists tasks in one list: id, title, notes, status (needsAction|completed), due (date only — the API never stores a time of day), completed timestamp, parent (subtask's parent id), position (opaque sort key within siblings — sort by it client-side; change it only via move_task), updated, deleted/hidden flags, webViewLink. IMPORTANT: tasks completed in Google's own apps are also flagged hidden — pass show_completed=true AND show_hidden=true to reliably see all completed tasks. For incremental sync poll with updated_min plus show_deleted=true and show_hidden=true, so deletions and clears are not missed (the API has no push notifications). due_min/due_max bound the due date; completed_min/completed_max the completion time. Paginate with page_token; page_size caps at 100 (API default 20). Filtering by due/completed dates implies those fields exist — tasks without a due date never match due bounds.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
tasklist_id: tasklistIdSchema(),
|
|
10
|
+
updated_min: rfc3339Timestamp()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Only tasks modified after this RFC3339 UTC timestamp (updatedMin) — the sync filter."),
|
|
13
|
+
due_min: rfc3339Timestamp().optional().describe("Lower bound on the due date (RFC3339)."),
|
|
14
|
+
due_max: rfc3339Timestamp().optional().describe("Upper bound on the due date (RFC3339)."),
|
|
15
|
+
completed_min: rfc3339Timestamp()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Lower bound on the completion date (RFC3339)."),
|
|
18
|
+
completed_max: rfc3339Timestamp()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Upper bound on the completion date (RFC3339)."),
|
|
21
|
+
show_completed: z
|
|
22
|
+
.boolean()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Include completed tasks (API default true; needs show_hidden=true to catch tasks completed in Google's UI)."),
|
|
25
|
+
show_hidden: z.boolean().optional().describe("Include hidden tasks (API default false)."),
|
|
26
|
+
show_deleted: z.boolean().optional().describe("Include deleted tasks (API default false; for sync)."),
|
|
27
|
+
show_assigned: z
|
|
28
|
+
.boolean()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Include tasks assigned to the user from Google Docs / Chat spaces (API default false)."),
|
|
31
|
+
page_size: z
|
|
32
|
+
.number()
|
|
33
|
+
.int()
|
|
34
|
+
.min(1)
|
|
35
|
+
.max(100)
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("Max tasks per page (1..100; the API's default is 20)."),
|
|
38
|
+
page_token: z.string().optional().describe("nextPageToken from the previous page."),
|
|
39
|
+
},
|
|
40
|
+
}, async (args) => {
|
|
41
|
+
try {
|
|
42
|
+
return ok(await client.listTasks({
|
|
43
|
+
taskListId: args.tasklist_id,
|
|
44
|
+
updatedMin: args.updated_min,
|
|
45
|
+
dueMin: args.due_min,
|
|
46
|
+
dueMax: args.due_max,
|
|
47
|
+
completedMin: args.completed_min,
|
|
48
|
+
completedMax: args.completed_max,
|
|
49
|
+
showCompleted: args.show_completed,
|
|
50
|
+
showHidden: args.show_hidden,
|
|
51
|
+
showDeleted: args.show_deleted,
|
|
52
|
+
showAssigned: args.show_assigned,
|
|
53
|
+
pageSize: args.page_size,
|
|
54
|
+
pageToken: args.page_token,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
return fail(e);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
server.registerTool("get_task", {
|
|
62
|
+
title: "Get a task",
|
|
63
|
+
annotations: READ_ONLY,
|
|
64
|
+
description: "Fetches one task by id: title, notes, status, due (date only), completed timestamp, parent, position, updated, deleted/hidden flags, links and webViewLink. Also the safe way to verify state after an ambiguous write failure — writes are never retried automatically.",
|
|
65
|
+
inputSchema: { tasklist_id: tasklistIdSchema(), task_id: taskIdSchema() },
|
|
66
|
+
}, async ({ tasklist_id, task_id }) => {
|
|
67
|
+
try {
|
|
68
|
+
return ok(await client.getTask(tasklist_id, task_id));
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
return fail(e);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
server.registerTool("create_task", {
|
|
75
|
+
title: "Create a task",
|
|
76
|
+
annotations: WRITE,
|
|
77
|
+
description: "Creates a task in a list and returns it (id, title, position, webViewLink, ...). due accepts YYYY-MM-DD or an RFC3339 timestamp, but Google Tasks stores only the DATE — any time of day is discarded and never returned. notes is plain text (max 8192 chars); title max 1024 chars. Hierarchy and order are set at creation via parent (the id of an existing task in the same list — the new task becomes its subtask; Google Tasks supports one level of nesting reliably) and previous (the sibling to insert after; omit both to land at the top of the list). New tasks start as needsAction — use complete_task to complete. Recurrence cannot be created or read through the API.",
|
|
78
|
+
inputSchema: {
|
|
79
|
+
tasklist_id: tasklistIdSchema(),
|
|
80
|
+
title: z.string().min(1).max(1024).describe("The task title (max 1024 chars)."),
|
|
81
|
+
notes: z.string().max(8192).optional().describe("Free-text notes shown under the title (max 8192 chars)."),
|
|
82
|
+
due: dueDateSchema()
|
|
83
|
+
.optional()
|
|
84
|
+
.describe("Due date: YYYY-MM-DD or RFC3339. Only the date is stored — the time part is discarded."),
|
|
85
|
+
parent: taskIdSchema()
|
|
86
|
+
.optional()
|
|
87
|
+
.describe("Parent task id in the same list — makes the new task a subtask."),
|
|
88
|
+
previous: taskIdSchema()
|
|
89
|
+
.optional()
|
|
90
|
+
.describe("Sibling task id to insert after (same parent). Omit to insert at the first position."),
|
|
91
|
+
},
|
|
92
|
+
}, async ({ tasklist_id, title, notes, due, parent, previous }) => {
|
|
93
|
+
try {
|
|
94
|
+
return ok(await client.createTask({ taskListId: tasklist_id, title, notes, due, parent, previous }));
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
return fail(e);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
server.registerTool("update_task", {
|
|
101
|
+
title: "Update a task",
|
|
102
|
+
annotations: UPDATE,
|
|
103
|
+
description: "Changes a task's title, notes and/or due date (PATCH — only the provided fields change, at least one is required). clear_due=true / clear_notes=true erase the field entirely (you cannot clear by sending an empty string a Google API would keep). This tool does NOT change completion status (use complete_task / reopen_task), and cannot re-parent or reorder (use move_task) — parent and position are read-only in the task resource. Returns the updated task.",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
tasklist_id: tasklistIdSchema(),
|
|
106
|
+
task_id: taskIdSchema(),
|
|
107
|
+
title: z.string().min(1).max(1024).optional().describe("New task title (max 1024 chars)."),
|
|
108
|
+
notes: z.string().max(8192).optional().describe("New notes text (max 8192 chars; replaces the old notes)."),
|
|
109
|
+
due: dueDateSchema()
|
|
110
|
+
.optional()
|
|
111
|
+
.describe("New due date: YYYY-MM-DD or RFC3339 (only the date is stored)."),
|
|
112
|
+
clear_due: z.boolean().optional().describe("true removes the due date entirely (do not combine with due)."),
|
|
113
|
+
clear_notes: z
|
|
114
|
+
.boolean()
|
|
115
|
+
.optional()
|
|
116
|
+
.describe("true removes the notes entirely (do not combine with notes)."),
|
|
117
|
+
},
|
|
118
|
+
}, async ({ tasklist_id, task_id, title, notes, due, clear_due, clear_notes }) => {
|
|
119
|
+
try {
|
|
120
|
+
if (clear_due && due !== undefined) {
|
|
121
|
+
return fail(new Error("due and clear_due are mutually exclusive — pass one of them."));
|
|
122
|
+
}
|
|
123
|
+
if (clear_notes && notes !== undefined) {
|
|
124
|
+
return fail(new Error("notes and clear_notes are mutually exclusive — pass one of them."));
|
|
125
|
+
}
|
|
126
|
+
return ok(await client.updateTask({
|
|
127
|
+
taskListId: tasklist_id,
|
|
128
|
+
taskId: task_id,
|
|
129
|
+
title,
|
|
130
|
+
notes,
|
|
131
|
+
due,
|
|
132
|
+
clearDue: clear_due,
|
|
133
|
+
clearNotes: clear_notes,
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
return fail(e);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
server.registerTool("move_task", {
|
|
141
|
+
title: "Move a task",
|
|
142
|
+
annotations: WRITE,
|
|
143
|
+
description: "Moves a task: under a parent (subtask), after a sibling (previous), and/or into another list (destination_tasklist). Omitting parent puts it at the top level; omitting previous puts it first among its siblings — so calling with neither moves the task to the very top of its list. This is the ONLY way to change hierarchy or order (parent/position are read-only fields; positions are opaque strings maintained by the API). Constraints: parent and previous must be in the task's (destination) list; assigned tasks and recurrent tasks cannot be moved between lists. Returns the task with its new position.",
|
|
144
|
+
inputSchema: {
|
|
145
|
+
tasklist_id: tasklistIdSchema(),
|
|
146
|
+
task_id: taskIdSchema(),
|
|
147
|
+
parent: taskIdSchema()
|
|
148
|
+
.optional()
|
|
149
|
+
.describe("New parent task id — the task becomes its subtask. Omit for the top level."),
|
|
150
|
+
previous: taskIdSchema()
|
|
151
|
+
.optional()
|
|
152
|
+
.describe("Sibling task id to place the task after (same parent). Omit for the first position."),
|
|
153
|
+
destination_tasklist: tasklistIdSchema()
|
|
154
|
+
.optional()
|
|
155
|
+
.describe("Move the task into this other task list."),
|
|
156
|
+
},
|
|
157
|
+
}, async ({ tasklist_id, task_id, parent, previous, destination_tasklist }) => {
|
|
158
|
+
try {
|
|
159
|
+
return ok(await client.moveTask({
|
|
160
|
+
taskListId: tasklist_id,
|
|
161
|
+
taskId: task_id,
|
|
162
|
+
parent,
|
|
163
|
+
previous,
|
|
164
|
+
destinationTasklist: destination_tasklist,
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
return fail(e);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
server.registerTool("delete_task", {
|
|
172
|
+
title: "Delete a task",
|
|
173
|
+
annotations: DESTRUCTIVE,
|
|
174
|
+
description: "Deletes a task permanently — this is NOT the same as completing it. To mark work done (reversibly), use complete_task instead. A deleted task disappears from default listings immediately; for a while it remains visible to list_tasks with show_deleted=true (deleted:true) so sync clients can observe the deletion, then it is gone for good. Deleting a parent task also deletes its subtasks. Returns {deleted:true} with the ids echoed.",
|
|
175
|
+
inputSchema: { tasklist_id: tasklistIdSchema(), task_id: taskIdSchema() },
|
|
176
|
+
}, async ({ tasklist_id, task_id }) => {
|
|
177
|
+
try {
|
|
178
|
+
return ok(await client.deleteTask(tasklist_id, task_id));
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
return fail(e);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema factories, not shared consts: reusing one zod object across two fields
|
|
4
|
+
* makes zod-to-json-schema dedupe them into a `$ref`, which some tool-schema
|
|
5
|
+
* consumers (OpenAI Apps review) don't dereference and flag as `any`. A fresh
|
|
6
|
+
* object per field keeps each one inlined with its type + pattern.
|
|
7
|
+
*/
|
|
8
|
+
export const tasklistIdSchema = () => z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.describe('The task list id — from list_tasklists or create_tasklist output. "@default" addresses the user\'s default list.');
|
|
12
|
+
/** A task id — always paired with the list it lives in. */
|
|
13
|
+
export const taskIdSchema = () => z.string().min(1).describe("The task id — from list_tasks, get_task or create_task output.");
|
|
14
|
+
/** An RFC3339 UTC timestamp, e.g. 2026-08-01T00:00:00Z — the shape the list filters accept. */
|
|
15
|
+
export const rfc3339Timestamp = () => z
|
|
16
|
+
.string()
|
|
17
|
+
.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/, "Must be an RFC3339 timestamp, e.g. 2026-08-01T00:00:00Z");
|
|
18
|
+
/**
|
|
19
|
+
* A due date: a bare YYYY-MM-DD or a full RFC3339 timestamp. The API keeps only
|
|
20
|
+
* the date part — the time of day is discarded on write and never returned.
|
|
21
|
+
*/
|
|
22
|
+
export const dueDateSchema = () => z
|
|
23
|
+
.string()
|
|
24
|
+
.regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2}))?$/, "Must be YYYY-MM-DD or an RFC3339 timestamp, e.g. 2026-09-01 or 2026-09-01T00:00:00Z");
|
|
25
|
+
/** Wraps a value as a compact-JSON tool result (compact: the consumer is an LLM). */
|
|
26
|
+
export function ok(data) {
|
|
27
|
+
const text = typeof data === "string" ? data : JSON.stringify(data);
|
|
28
|
+
return { content: [{ type: "text", text: text ?? "null" }] };
|
|
29
|
+
}
|
|
30
|
+
export function fail(err) {
|
|
31
|
+
let message = err instanceof Error ? err.message : String(err);
|
|
32
|
+
// Surface the underlying cause (e.g. the network error behind a timeout) — no
|
|
33
|
+
// secrets live in cause, and it makes failures far easier to diagnose.
|
|
34
|
+
if (err instanceof Error && err.cause instanceof Error)
|
|
35
|
+
message += ` (${err.cause.message})`;
|
|
36
|
+
return { content: [{ type: "text", text: `Error: ${message}` }], isError: true };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* MCP tool annotations — hints the consuming client can use to gate or label a
|
|
40
|
+
* tool. All four hints are set explicitly on every tool: some clients (OpenAI
|
|
41
|
+
* Apps review) require readOnlyHint, destructiveHint and openWorldHint on each.
|
|
42
|
+
*
|
|
43
|
+
* The Tasks API mixes reads and writes, so each tool picks one of four presets:
|
|
44
|
+
* READ_ONLY (pure reads), WRITE (creates new state; replaying duplicates it),
|
|
45
|
+
* UPDATE (overwrites existing fields; replaying the same update converges) and
|
|
46
|
+
* DESTRUCTIVE (removes existing state; replaying hits different targets).
|
|
47
|
+
* Completion is deliberately UPDATE, not DESTRUCTIVE: completing a task is
|
|
48
|
+
* reversible (reopen_task undoes it), while delete_task and delete_tasklist
|
|
49
|
+
* are not.
|
|
50
|
+
*/
|
|
51
|
+
export const READ_ONLY = {
|
|
52
|
+
readOnlyHint: true,
|
|
53
|
+
destructiveHint: false,
|
|
54
|
+
idempotentHint: true,
|
|
55
|
+
openWorldHint: true,
|
|
56
|
+
};
|
|
57
|
+
export const WRITE = {
|
|
58
|
+
readOnlyHint: false,
|
|
59
|
+
destructiveHint: false,
|
|
60
|
+
idempotentHint: false,
|
|
61
|
+
openWorldHint: true,
|
|
62
|
+
};
|
|
63
|
+
export const UPDATE = {
|
|
64
|
+
readOnlyHint: false,
|
|
65
|
+
destructiveHint: true,
|
|
66
|
+
idempotentHint: true,
|
|
67
|
+
openWorldHint: true,
|
|
68
|
+
};
|
|
69
|
+
export const DESTRUCTIVE = {
|
|
70
|
+
readOnlyHint: false,
|
|
71
|
+
destructiveHint: true,
|
|
72
|
+
idempotentHint: false,
|
|
73
|
+
openWorldHint: true,
|
|
74
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server talks to the Google Tasks API v1 (https://tasks.googleapis.com,
|
|
3
|
+
* REST over JSON). Auth is Google OAuth 2.0: a Bearer access token, minted
|
|
4
|
+
* on demand from a refresh token via https://oauth2.googleapis.com/token
|
|
5
|
+
* (or a static short-lived access token, mostly for testing).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Google APIs report failures as a non-2xx HTTP status with a JSON envelope
|
|
9
|
+
* ({ error: { code, message, status, details } }); the OAuth token endpoint
|
|
10
|
+
* uses { error, error_description }. The parsed body is kept alongside the
|
|
11
|
+
* status and a short readable message is derived.
|
|
12
|
+
*/
|
|
13
|
+
export class GoogleTasksError extends Error {
|
|
14
|
+
status;
|
|
15
|
+
body;
|
|
16
|
+
constructor(status, body) {
|
|
17
|
+
super(`HTTP ${status}: ${formatErrorBody(body)}`);
|
|
18
|
+
this.name = "GoogleTasksError";
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.body = body;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Turns a parsed Google API error body into a short, readable message. */
|
|
24
|
+
function formatErrorBody(body) {
|
|
25
|
+
if (body == null)
|
|
26
|
+
return "(no body)";
|
|
27
|
+
if (typeof body === "string")
|
|
28
|
+
return body.slice(0, 500);
|
|
29
|
+
if (typeof body !== "object")
|
|
30
|
+
return String(body);
|
|
31
|
+
const obj = body;
|
|
32
|
+
// OAuth token endpoint style: { error: "invalid_grant", error_description: "..." }
|
|
33
|
+
if (typeof obj.error === "string") {
|
|
34
|
+
const description = typeof obj.error_description === "string" ? `: ${obj.error_description}` : "";
|
|
35
|
+
return `${obj.error}${description}`.slice(0, 500);
|
|
36
|
+
}
|
|
37
|
+
// Google API envelope: { error: { code, message, status, details } }
|
|
38
|
+
const err = (typeof obj.error === "object" && obj.error !== null ? obj.error : obj);
|
|
39
|
+
if (typeof err.message === "string") {
|
|
40
|
+
const status = typeof err.status === "string" ? `[${err.status}] ` : "";
|
|
41
|
+
return `${status}${err.message}`.slice(0, 500);
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify(obj).slice(0, 500);
|
|
44
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-google-tasks",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for the Google Tasks API — manage task lists, create and organize tasks with due dates, notes and subtasks, track completion and sync changes. For Claude, Cursor, Codex and other AI clients.",
|
|
5
|
+
"mcpName": "io.github.A1-x-Tech/mcp-google-tasks",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-google-tasks": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"test"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rm -rf dist && tsc",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"dev": "tsx watch src/index.ts",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.check.json",
|
|
22
|
+
"smoke": "node --import tsx src/smoke.ts",
|
|
23
|
+
"test": "npm run test:src && npm run test:dist",
|
|
24
|
+
"test:src": "node --import tsx --test $(find src -name '*.test.ts')",
|
|
25
|
+
"test:dist": "npm run build && node --test test/dist-smoke.test.js",
|
|
26
|
+
"prepare": "npm run build",
|
|
27
|
+
"prepublishOnly": "npm run typecheck && npm test"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"mcp",
|
|
31
|
+
"model-context-protocol",
|
|
32
|
+
"google",
|
|
33
|
+
"google-tasks",
|
|
34
|
+
"tasks",
|
|
35
|
+
"todo",
|
|
36
|
+
"productivity",
|
|
37
|
+
"claude",
|
|
38
|
+
"cursor",
|
|
39
|
+
"codex"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"author": "gistrec <gistrec@gmail.com>",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/A1-x-Tech/mcp-google-tasks.git"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/A1-x-Tech/mcp-google-tasks#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/A1-x-Tech/mcp-google-tasks/issues"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
53
|
+
"zod": "^3.25.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^25.9.3",
|
|
57
|
+
"tsx": "^4.22.4",
|
|
58
|
+
"typescript": "^5.7.0"
|
|
59
|
+
}
|
|
60
|
+
}
|