@taazkareem/clickup-mcp-server 0.4.31 → 0.4.40
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/README.md +0 -2
- package/build/config.js +4 -14
- package/build/handlers/prompts.js +0 -53
- package/build/handlers/tools.js +30 -303
- package/build/index.js +646 -184
- package/build/services/clickup.js +5 -171
- package/build/types/clickup.js +0 -7
- package/build/utils/logger.js +39 -45
- package/build/utils/resolvers.js +0 -50
- package/package.json +5 -7
- package/LICENSE +0 -21
package/build/index.js
CHANGED
|
@@ -1,234 +1,696 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
* ClickUp MCP Server
|
|
4
|
-
* A Model Context Protocol server implementation for ClickUp integration.
|
|
5
|
-
* Provides tools and resources for AI agents to interact with ClickUp tasks,
|
|
6
|
-
* spaces, lists, and folders through a standardized protocol.
|
|
7
|
-
*
|
|
8
|
-
* @module clickup-mcp-server
|
|
9
|
-
*/
|
|
10
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
11
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
12
5
|
import { ClickUpService } from "./services/clickup.js";
|
|
13
6
|
import config from "./config.js";
|
|
14
|
-
import { handleWorkspaceHierarchy, handleCreateTask
|
|
7
|
+
import { handleWorkspaceHierarchy, handleCreateTask } from "./handlers/tools.js";
|
|
15
8
|
import { handleSummarizeTasks, handleAnalyzeTaskPriorities } from "./handlers/prompts.js";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
process.on('uncaughtException', (error) => {
|
|
20
|
-
logError('server.uncaught', error);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
});
|
|
23
|
-
process.on('unhandledRejection', (reason) => {
|
|
24
|
-
logError('server.unhandled_rejection', reason);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
});
|
|
27
|
-
logInfo('server', { status: 'starting' });
|
|
28
|
-
logInfo('config', {
|
|
9
|
+
import { getAllTasks } from "./utils/resolvers.js";
|
|
10
|
+
console.log('Server starting up...');
|
|
11
|
+
console.log('Config loaded:', {
|
|
29
12
|
clickupApiKey: config.clickupApiKey ? '***' : 'missing',
|
|
30
13
|
teamId: config.teamId || 'missing'
|
|
31
14
|
});
|
|
32
|
-
// Initialize ClickUp service
|
|
15
|
+
// Initialize ClickUp service
|
|
33
16
|
let clickup;
|
|
34
17
|
try {
|
|
35
|
-
|
|
18
|
+
console.log('Initializing ClickUp service...');
|
|
36
19
|
clickup = ClickUpService.initialize(config.clickupApiKey);
|
|
37
|
-
|
|
20
|
+
console.log('ClickUp service initialized successfully');
|
|
38
21
|
}
|
|
39
22
|
catch (error) {
|
|
40
|
-
|
|
23
|
+
console.error("Failed to initialize ClickUp service:", error);
|
|
41
24
|
process.exit(1);
|
|
42
25
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
type: "text",
|
|
54
|
-
text: "pong"
|
|
55
|
-
}]
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
// Tool schemas as raw shapes
|
|
59
|
-
const workspaceHierarchySchema = {
|
|
60
|
-
teamId: z.string().optional()
|
|
61
|
-
};
|
|
62
|
-
const taskSchema = {
|
|
63
|
-
name: z.string(),
|
|
64
|
-
description: z.string().optional(),
|
|
65
|
-
status: z.string().optional(),
|
|
66
|
-
priority: z.number().optional(),
|
|
67
|
-
dueDate: z.string().optional(),
|
|
68
|
-
listId: z.string().optional(),
|
|
69
|
-
listName: z.string().optional()
|
|
70
|
-
};
|
|
71
|
-
const bulkTasksSchema = {
|
|
72
|
-
tasks: z.array(z.object(taskSchema)),
|
|
73
|
-
listId: z.string().optional(),
|
|
74
|
-
listName: z.string().optional()
|
|
75
|
-
};
|
|
76
|
-
const listSchema = {
|
|
77
|
-
name: z.string(),
|
|
78
|
-
spaceId: z.string().optional(),
|
|
79
|
-
spaceName: z.string().optional(),
|
|
80
|
-
content: z.string().optional()
|
|
81
|
-
};
|
|
82
|
-
const folderSchema = {
|
|
83
|
-
name: z.string(),
|
|
84
|
-
spaceId: z.string().optional(),
|
|
85
|
-
spaceName: z.string().optional(),
|
|
86
|
-
override_statuses: z.boolean().optional()
|
|
87
|
-
};
|
|
88
|
-
const listInFolderSchema = {
|
|
89
|
-
name: z.string(),
|
|
90
|
-
folderId: z.string().optional(),
|
|
91
|
-
folderName: z.string().optional(),
|
|
92
|
-
spaceId: z.string().optional(),
|
|
93
|
-
spaceName: z.string().optional(),
|
|
94
|
-
content: z.string().optional()
|
|
95
|
-
};
|
|
96
|
-
// Register tools with proper schemas
|
|
97
|
-
mcpServer.tool('workspace_hierarchy', 'List complete hierarchy of the ClickUp workspace', workspaceHierarchySchema, async (args) => {
|
|
98
|
-
const result = await handleWorkspaceHierarchy(clickup, config.teamId);
|
|
99
|
-
return {
|
|
100
|
-
content: [{
|
|
101
|
-
type: "text",
|
|
102
|
-
text: JSON.stringify(result, null, 2)
|
|
103
|
-
}]
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
mcpServer.tool('create_task', 'Create a new task in ClickUp', taskSchema, async (args) => {
|
|
107
|
-
const result = await handleCreateTask(clickup, config.teamId, args);
|
|
108
|
-
return {
|
|
109
|
-
content: [{
|
|
110
|
-
type: "text",
|
|
111
|
-
text: JSON.stringify(result, null, 2)
|
|
112
|
-
}]
|
|
113
|
-
};
|
|
26
|
+
console.log('Creating MCP server...');
|
|
27
|
+
const server = new Server({
|
|
28
|
+
name: "clickup",
|
|
29
|
+
version: "0.1.0",
|
|
30
|
+
}, {
|
|
31
|
+
capabilities: {
|
|
32
|
+
resources: {},
|
|
33
|
+
tools: {},
|
|
34
|
+
prompts: {},
|
|
35
|
+
},
|
|
114
36
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
37
|
+
console.log('MCP server created');
|
|
38
|
+
/**
|
|
39
|
+
* Handler for listing available ClickUp tasks as resources.
|
|
40
|
+
*/
|
|
41
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
42
|
+
console.log('Handling ListResources request');
|
|
43
|
+
try {
|
|
44
|
+
const { tasks, spaces } = await getAllTasks(clickup, config.teamId);
|
|
45
|
+
return {
|
|
46
|
+
resources: tasks.map(task => ({
|
|
47
|
+
uri: `clickup://task/${task.id}`,
|
|
48
|
+
mimeType: "application/json",
|
|
49
|
+
name: task.name,
|
|
50
|
+
description: task.description || `Task in ${task.list.name} (${task.space.name})`,
|
|
51
|
+
tags: []
|
|
52
|
+
}))
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error('Error in ListResources:', error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
132
59
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Handler for reading the contents of a specific ClickUp task.
|
|
62
|
+
*/
|
|
63
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
64
|
+
try {
|
|
65
|
+
const url = new URL(request.params.uri);
|
|
66
|
+
const taskId = url.pathname.replace(/^\/task\//, '');
|
|
67
|
+
const task = await clickup.getTask(taskId);
|
|
68
|
+
return {
|
|
69
|
+
contents: [{
|
|
70
|
+
uri: request.params.uri,
|
|
71
|
+
mimeType: "application/json",
|
|
72
|
+
text: JSON.stringify(task, null, 2),
|
|
73
|
+
tags: []
|
|
74
|
+
}]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error('Error reading resource:', error);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
141
81
|
});
|
|
142
|
-
|
|
143
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Handler for listing available tools.
|
|
84
|
+
*/
|
|
85
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
86
|
+
console.log('Handling ListTools request');
|
|
144
87
|
return {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
88
|
+
tools: [
|
|
89
|
+
{
|
|
90
|
+
name: "workspace_hierarchy",
|
|
91
|
+
description: "List complete hierarchy of the ClickUp workspace",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {},
|
|
95
|
+
required: []
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "create_task",
|
|
100
|
+
description: "Create a new task in ClickUp",
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: {
|
|
104
|
+
listId: {
|
|
105
|
+
type: "string",
|
|
106
|
+
description: "ID of the list to create the task in (optional if listName is provided)"
|
|
107
|
+
},
|
|
108
|
+
listName: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "Name of the list to create the task in (optional if listId is provided)"
|
|
111
|
+
},
|
|
112
|
+
name: {
|
|
113
|
+
type: "string",
|
|
114
|
+
description: "Name of the task"
|
|
115
|
+
},
|
|
116
|
+
description: {
|
|
117
|
+
type: "string",
|
|
118
|
+
description: "Description of the task"
|
|
119
|
+
},
|
|
120
|
+
status: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "Status of the task"
|
|
123
|
+
},
|
|
124
|
+
priority: {
|
|
125
|
+
type: "number",
|
|
126
|
+
description: "Priority of the task (1-4)"
|
|
127
|
+
},
|
|
128
|
+
dueDate: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "Due date of the task (ISO string)"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
required: ["name"]
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "create_bulk_tasks",
|
|
138
|
+
description: "Create multiple tasks in a ClickUp list",
|
|
139
|
+
inputSchema: {
|
|
140
|
+
type: "object",
|
|
141
|
+
properties: {
|
|
142
|
+
listId: {
|
|
143
|
+
type: "string",
|
|
144
|
+
description: "ID of the list to create the tasks in (optional if listName is provided)"
|
|
145
|
+
},
|
|
146
|
+
listName: {
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "Name of the list to create the tasks in (optional if listId is provided)"
|
|
149
|
+
},
|
|
150
|
+
tasks: {
|
|
151
|
+
type: "array",
|
|
152
|
+
description: "Array of tasks to create",
|
|
153
|
+
items: {
|
|
154
|
+
type: "object",
|
|
155
|
+
properties: {
|
|
156
|
+
name: {
|
|
157
|
+
type: "string",
|
|
158
|
+
description: "Name of the task"
|
|
159
|
+
},
|
|
160
|
+
description: {
|
|
161
|
+
type: "string",
|
|
162
|
+
description: "Description of the task"
|
|
163
|
+
},
|
|
164
|
+
status: {
|
|
165
|
+
type: "string",
|
|
166
|
+
description: "Status of the task"
|
|
167
|
+
},
|
|
168
|
+
priority: {
|
|
169
|
+
type: "number",
|
|
170
|
+
description: "Priority level (1-4)"
|
|
171
|
+
},
|
|
172
|
+
dueDate: {
|
|
173
|
+
type: "string",
|
|
174
|
+
description: "Due date (ISO string)"
|
|
175
|
+
},
|
|
176
|
+
assignees: {
|
|
177
|
+
type: "array",
|
|
178
|
+
items: {
|
|
179
|
+
type: "number"
|
|
180
|
+
},
|
|
181
|
+
description: "Array of user IDs to assign to the task"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
required: ["name"]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
required: ["tasks"]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "create_list",
|
|
193
|
+
description: "Create a new list in a ClickUp space",
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: "object",
|
|
196
|
+
properties: {
|
|
197
|
+
spaceId: {
|
|
198
|
+
type: "string",
|
|
199
|
+
description: "ID of the space to create the list in (optional if spaceName is provided)"
|
|
200
|
+
},
|
|
201
|
+
spaceName: {
|
|
202
|
+
type: "string",
|
|
203
|
+
description: "Name of the space to create the list in (optional if spaceId is provided)"
|
|
204
|
+
},
|
|
205
|
+
name: {
|
|
206
|
+
type: "string",
|
|
207
|
+
description: "Name of the list"
|
|
208
|
+
},
|
|
209
|
+
content: {
|
|
210
|
+
type: "string",
|
|
211
|
+
description: "Description or content of the list"
|
|
212
|
+
},
|
|
213
|
+
dueDate: {
|
|
214
|
+
type: "string",
|
|
215
|
+
description: "Due date for the list (ISO string)"
|
|
216
|
+
},
|
|
217
|
+
priority: {
|
|
218
|
+
type: "number",
|
|
219
|
+
description: "Priority of the list (1-4)"
|
|
220
|
+
},
|
|
221
|
+
assignee: {
|
|
222
|
+
type: "number",
|
|
223
|
+
description: "User ID to assign the list to"
|
|
224
|
+
},
|
|
225
|
+
status: {
|
|
226
|
+
type: "string",
|
|
227
|
+
description: "Status of the list"
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
required: ["name"]
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "create_folder",
|
|
235
|
+
description: "Create a new folder in a ClickUp space",
|
|
236
|
+
inputSchema: {
|
|
237
|
+
type: "object",
|
|
238
|
+
properties: {
|
|
239
|
+
spaceId: {
|
|
240
|
+
type: "string",
|
|
241
|
+
description: "ID of the space to create the folder in (optional if spaceName is provided)"
|
|
242
|
+
},
|
|
243
|
+
spaceName: {
|
|
244
|
+
type: "string",
|
|
245
|
+
description: "Name of the space to create the folder in (optional if spaceId is provided)"
|
|
246
|
+
},
|
|
247
|
+
name: {
|
|
248
|
+
type: "string",
|
|
249
|
+
description: "Name of the folder"
|
|
250
|
+
},
|
|
251
|
+
override_statuses: {
|
|
252
|
+
type: "boolean",
|
|
253
|
+
description: "Whether to override space statuses"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
required: ["name"]
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "create_list_in_folder",
|
|
261
|
+
description: "Create a new list in a ClickUp folder",
|
|
262
|
+
inputSchema: {
|
|
263
|
+
type: "object",
|
|
264
|
+
properties: {
|
|
265
|
+
folderId: {
|
|
266
|
+
type: "string",
|
|
267
|
+
description: "ID of the folder to create the list in (optional if folderName and spaceId/spaceName are provided)"
|
|
268
|
+
},
|
|
269
|
+
folderName: {
|
|
270
|
+
type: "string",
|
|
271
|
+
description: "Name of the folder to create the list in"
|
|
272
|
+
},
|
|
273
|
+
spaceId: {
|
|
274
|
+
type: "string",
|
|
275
|
+
description: "ID of the space containing the folder (required if using folderName)"
|
|
276
|
+
},
|
|
277
|
+
spaceName: {
|
|
278
|
+
type: "string",
|
|
279
|
+
description: "Name of the space containing the folder (alternative to spaceId)"
|
|
280
|
+
},
|
|
281
|
+
name: {
|
|
282
|
+
type: "string",
|
|
283
|
+
description: "Name of the list"
|
|
284
|
+
},
|
|
285
|
+
content: {
|
|
286
|
+
type: "string",
|
|
287
|
+
description: "Description or content of the list"
|
|
288
|
+
},
|
|
289
|
+
status: {
|
|
290
|
+
type: "string",
|
|
291
|
+
description: "Status of the list"
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
required: ["name"]
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "move_task",
|
|
299
|
+
description: "Move a task to a different list",
|
|
300
|
+
inputSchema: {
|
|
301
|
+
type: "object",
|
|
302
|
+
properties: {
|
|
303
|
+
taskId: {
|
|
304
|
+
type: "string",
|
|
305
|
+
description: "ID of the task to move"
|
|
306
|
+
},
|
|
307
|
+
listId: {
|
|
308
|
+
type: "string",
|
|
309
|
+
description: "ID of the destination list (optional if listName is provided)"
|
|
310
|
+
},
|
|
311
|
+
listName: {
|
|
312
|
+
type: "string",
|
|
313
|
+
description: "Name of the destination list (optional if listId is provided)"
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
required: ["taskId"]
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "duplicate_task",
|
|
321
|
+
description: "Duplicate a task to a list",
|
|
322
|
+
inputSchema: {
|
|
323
|
+
type: "object",
|
|
324
|
+
properties: {
|
|
325
|
+
taskId: {
|
|
326
|
+
type: "string",
|
|
327
|
+
description: "ID of the task to duplicate"
|
|
328
|
+
},
|
|
329
|
+
listId: {
|
|
330
|
+
type: "string",
|
|
331
|
+
description: "ID of the destination list (optional if listName is provided)"
|
|
332
|
+
},
|
|
333
|
+
listName: {
|
|
334
|
+
type: "string",
|
|
335
|
+
description: "Name of the destination list (optional if listId is provided)"
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
required: ["taskId"]
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
name: "update_task",
|
|
343
|
+
description: "Update an existing task in ClickUp",
|
|
344
|
+
inputSchema: {
|
|
345
|
+
type: "object",
|
|
346
|
+
properties: {
|
|
347
|
+
taskId: {
|
|
348
|
+
type: "string",
|
|
349
|
+
description: "ID of the task to update"
|
|
350
|
+
},
|
|
351
|
+
name: {
|
|
352
|
+
type: "string",
|
|
353
|
+
description: "New name of the task"
|
|
354
|
+
},
|
|
355
|
+
description: {
|
|
356
|
+
type: "string",
|
|
357
|
+
description: "New description of the task"
|
|
358
|
+
},
|
|
359
|
+
status: {
|
|
360
|
+
type: "string",
|
|
361
|
+
description: "New status of the task"
|
|
362
|
+
},
|
|
363
|
+
priority: {
|
|
364
|
+
type: "number",
|
|
365
|
+
description: "New priority of the task (1-4)"
|
|
366
|
+
},
|
|
367
|
+
dueDate: {
|
|
368
|
+
type: "string",
|
|
369
|
+
description: "New due date of the task (ISO string)"
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
required: ["taskId"]
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
]
|
|
149
376
|
};
|
|
150
377
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
378
|
+
/**
|
|
379
|
+
* Handler for executing tools.
|
|
380
|
+
*/
|
|
381
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
382
|
+
try {
|
|
383
|
+
switch (request.params.name) {
|
|
384
|
+
case "workspace_hierarchy": {
|
|
385
|
+
const output = await handleWorkspaceHierarchy(clickup, config.teamId);
|
|
386
|
+
return {
|
|
387
|
+
content: [{
|
|
388
|
+
type: "text",
|
|
389
|
+
text: output
|
|
390
|
+
}]
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
case "create_task": {
|
|
394
|
+
const args = request.params.arguments;
|
|
395
|
+
const task = await handleCreateTask(clickup, config.teamId, args);
|
|
396
|
+
return {
|
|
397
|
+
content: [{
|
|
398
|
+
type: "text",
|
|
399
|
+
text: `Created task ${task.id}: ${task.name}`
|
|
400
|
+
}]
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
case "create_bulk_tasks": {
|
|
404
|
+
const args = request.params.arguments;
|
|
405
|
+
let listId = args.listId;
|
|
406
|
+
if (!listId && args.listName) {
|
|
407
|
+
const result = await clickup.findListByNameGlobally(config.teamId, args.listName);
|
|
408
|
+
if (!result) {
|
|
409
|
+
throw new Error(`List with name "${args.listName}" not found`);
|
|
410
|
+
}
|
|
411
|
+
listId = result.list.id;
|
|
412
|
+
}
|
|
413
|
+
if (!listId) {
|
|
414
|
+
throw new Error("Either listId or listName is required");
|
|
415
|
+
}
|
|
416
|
+
if (!args.tasks || !args.tasks.length) {
|
|
417
|
+
throw new Error("At least one task is required");
|
|
418
|
+
}
|
|
419
|
+
const { listId: _, listName: __, tasks } = args;
|
|
420
|
+
const createdTasks = await clickup.createBulkTasks(listId, { tasks });
|
|
421
|
+
return {
|
|
422
|
+
content: [{
|
|
423
|
+
type: "text",
|
|
424
|
+
text: `Created ${createdTasks.length} tasks:\n${createdTasks.map(task => `- ${task.id}: ${task.name}`).join('\n')}`
|
|
425
|
+
}]
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
case "create_list": {
|
|
429
|
+
const args = request.params.arguments;
|
|
430
|
+
if (!args.name) {
|
|
431
|
+
throw new Error("name is required");
|
|
432
|
+
}
|
|
433
|
+
// If folder is specified, create list in folder
|
|
434
|
+
if (args.folderName || args.folderId) {
|
|
435
|
+
let folderId = args.folderId;
|
|
436
|
+
if (!folderId && args.folderName) {
|
|
437
|
+
const result = await clickup.findFolderByNameGlobally(config.teamId, args.folderName);
|
|
438
|
+
if (!result) {
|
|
439
|
+
throw new Error(`Folder with name "${args.folderName}" not found`);
|
|
440
|
+
}
|
|
441
|
+
folderId = result.folder.id;
|
|
442
|
+
}
|
|
443
|
+
if (!folderId) {
|
|
444
|
+
throw new Error("Either folderId or folderName must be provided");
|
|
445
|
+
}
|
|
446
|
+
const { spaceId: _, spaceName: __, folderName: ___, folderId: ____, ...listData } = args;
|
|
447
|
+
const list = await clickup.createListInFolder(folderId, listData);
|
|
448
|
+
return {
|
|
449
|
+
content: [{
|
|
450
|
+
type: "text",
|
|
451
|
+
text: `Created list ${list.id}: ${list.name} in folder`
|
|
452
|
+
}]
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
// Otherwise, create list in space
|
|
456
|
+
let spaceId = args.spaceId;
|
|
457
|
+
if (!spaceId && args.spaceName) {
|
|
458
|
+
const space = await clickup.findSpaceByName(config.teamId, args.spaceName);
|
|
459
|
+
if (!space) {
|
|
460
|
+
throw new Error(`Space with name "${args.spaceName}" not found`);
|
|
461
|
+
}
|
|
462
|
+
spaceId = space.id;
|
|
463
|
+
}
|
|
464
|
+
if (!spaceId) {
|
|
465
|
+
throw new Error("Either spaceId or spaceName must be provided");
|
|
466
|
+
}
|
|
467
|
+
const { spaceId: _, spaceName: __, folderName: ___, folderId: ____, ...listData } = args;
|
|
468
|
+
const list = await clickup.createList(spaceId, listData);
|
|
469
|
+
return {
|
|
470
|
+
content: [{
|
|
471
|
+
type: "text",
|
|
472
|
+
text: `Created list ${list.id}: ${list.name}`
|
|
473
|
+
}]
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
case "create_folder": {
|
|
477
|
+
const args = request.params.arguments;
|
|
478
|
+
if (!args.name) {
|
|
479
|
+
throw new Error("name is required");
|
|
480
|
+
}
|
|
481
|
+
let spaceId = args.spaceId;
|
|
482
|
+
if (!spaceId && args.spaceName) {
|
|
483
|
+
const space = await clickup.findSpaceByName(config.teamId, args.spaceName);
|
|
484
|
+
if (!space) {
|
|
485
|
+
throw new Error(`Space with name "${args.spaceName}" not found`);
|
|
486
|
+
}
|
|
487
|
+
spaceId = space.id;
|
|
488
|
+
}
|
|
489
|
+
if (!spaceId) {
|
|
490
|
+
throw new Error("Either spaceId or spaceName must be provided");
|
|
491
|
+
}
|
|
492
|
+
const { spaceId: _, spaceName: __, ...folderData } = args;
|
|
493
|
+
const folder = await clickup.createFolder(spaceId, folderData);
|
|
494
|
+
return {
|
|
495
|
+
content: [{
|
|
496
|
+
type: "text",
|
|
497
|
+
text: `Created folder ${folder.id}: ${folder.name}`
|
|
498
|
+
}]
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
case "create_list_in_folder": {
|
|
502
|
+
const args = request.params.arguments;
|
|
503
|
+
if (!args.name) {
|
|
504
|
+
throw new Error("name is required");
|
|
505
|
+
}
|
|
506
|
+
let folderId = args.folderId;
|
|
507
|
+
if (!folderId && args.folderName) {
|
|
508
|
+
const result = await clickup.findFolderByNameGlobally(config.teamId, args.folderName);
|
|
509
|
+
if (!result) {
|
|
510
|
+
throw new Error(`Folder with name "${args.folderName}" not found`);
|
|
511
|
+
}
|
|
512
|
+
folderId = result.folder.id;
|
|
513
|
+
}
|
|
514
|
+
if (!folderId) {
|
|
515
|
+
throw new Error("Either folderId or folderName is required");
|
|
516
|
+
}
|
|
517
|
+
const listData = {
|
|
518
|
+
name: args.name,
|
|
519
|
+
content: args.content,
|
|
520
|
+
status: args.status
|
|
521
|
+
};
|
|
522
|
+
try {
|
|
523
|
+
const list = await clickup.createListInFolder(folderId, listData);
|
|
524
|
+
return {
|
|
525
|
+
content: [{
|
|
526
|
+
type: "text",
|
|
527
|
+
text: `Created list ${list.id}: ${list.name} in folder`
|
|
528
|
+
}]
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
throw new Error(`Failed to create list: ${error.message}`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
case "move_task": {
|
|
536
|
+
const args = request.params.arguments;
|
|
537
|
+
if (!args.taskId) {
|
|
538
|
+
throw new Error("taskId is required");
|
|
539
|
+
}
|
|
540
|
+
let listId = args.listId;
|
|
541
|
+
if (!listId && args.listName) {
|
|
542
|
+
const result = await clickup.findListByNameGlobally(config.teamId, args.listName);
|
|
543
|
+
if (!result) {
|
|
544
|
+
throw new Error(`List with name "${args.listName}" not found`);
|
|
545
|
+
}
|
|
546
|
+
listId = result.list.id;
|
|
547
|
+
}
|
|
548
|
+
if (!listId) {
|
|
549
|
+
throw new Error("Either listId or listName is required");
|
|
550
|
+
}
|
|
551
|
+
const task = await clickup.moveTask(args.taskId, listId);
|
|
552
|
+
return {
|
|
553
|
+
content: [{
|
|
554
|
+
type: "text",
|
|
555
|
+
text: `Moved task ${task.id} to list ${listId}`
|
|
556
|
+
}]
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
case "duplicate_task": {
|
|
560
|
+
const args = request.params.arguments;
|
|
561
|
+
if (!args.taskId) {
|
|
562
|
+
throw new Error("taskId is required");
|
|
563
|
+
}
|
|
564
|
+
let listId = args.listId;
|
|
565
|
+
if (!listId && args.listName) {
|
|
566
|
+
const result = await clickup.findListByNameGlobally(config.teamId, args.listName);
|
|
567
|
+
if (!result) {
|
|
568
|
+
throw new Error(`List with name "${args.listName}" not found`);
|
|
569
|
+
}
|
|
570
|
+
listId = result.list.id;
|
|
571
|
+
}
|
|
572
|
+
if (!listId) {
|
|
573
|
+
throw new Error("Either listId or listName is required");
|
|
574
|
+
}
|
|
575
|
+
const task = await clickup.duplicateTask(args.taskId, listId);
|
|
576
|
+
return {
|
|
577
|
+
content: [{
|
|
578
|
+
type: "text",
|
|
579
|
+
text: `Duplicated task ${args.taskId} to new task ${task.id} in list ${listId}`
|
|
580
|
+
}]
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
case "update_task": {
|
|
584
|
+
const args = request.params.arguments;
|
|
585
|
+
if (!args.taskId) {
|
|
586
|
+
throw new Error("taskId is required");
|
|
587
|
+
}
|
|
588
|
+
const dueDate = args.due_date ? new Date(args.due_date).getTime() : undefined;
|
|
589
|
+
const task = await clickup.updateTask(args.taskId, {
|
|
590
|
+
name: args.name,
|
|
591
|
+
description: args.description,
|
|
592
|
+
status: args.status,
|
|
593
|
+
priority: args.priority,
|
|
594
|
+
due_date: dueDate
|
|
595
|
+
});
|
|
596
|
+
return {
|
|
597
|
+
content: [{
|
|
598
|
+
type: "text",
|
|
599
|
+
text: `Updated task ${task.id}: ${task.name}`
|
|
600
|
+
}]
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
default:
|
|
604
|
+
throw new Error("Unknown tool");
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
catch (error) {
|
|
608
|
+
console.error('Error executing tool:', error);
|
|
609
|
+
throw error;
|
|
610
|
+
}
|
|
164
611
|
});
|
|
165
|
-
|
|
166
|
-
|
|
612
|
+
/**
|
|
613
|
+
* Handler for listing available prompts.
|
|
614
|
+
*/
|
|
615
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
167
616
|
return {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
617
|
+
prompts: [
|
|
618
|
+
{
|
|
619
|
+
name: "summarize_tasks",
|
|
620
|
+
description: "Summarize all ClickUp tasks"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: "analyze_task_priorities",
|
|
624
|
+
description: "Analyze task priorities"
|
|
625
|
+
}
|
|
626
|
+
]
|
|
176
627
|
};
|
|
177
628
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
'clickup',
|
|
183
|
-
'clickup://task/{id}',
|
|
184
|
-
async (uri: URL) => {
|
|
629
|
+
/**
|
|
630
|
+
* Handler for getting a specific prompt.
|
|
631
|
+
*/
|
|
632
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
185
633
|
try {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
634
|
+
switch (request.params.name) {
|
|
635
|
+
case "summarize_tasks": {
|
|
636
|
+
const output = await handleSummarizeTasks(clickup, config.teamId);
|
|
637
|
+
return {
|
|
638
|
+
content: [{
|
|
639
|
+
type: "text",
|
|
640
|
+
text: output
|
|
641
|
+
}]
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
case "analyze_task_priorities": {
|
|
645
|
+
const output = await handleAnalyzeTaskPriorities(clickup, config.teamId);
|
|
646
|
+
return {
|
|
647
|
+
content: [{
|
|
648
|
+
type: "text",
|
|
649
|
+
text: output
|
|
650
|
+
}]
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
default:
|
|
654
|
+
throw new Error("Prompt not found");
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
catch (error) {
|
|
658
|
+
console.error('Error getting prompt:', error);
|
|
659
|
+
throw error;
|
|
197
660
|
}
|
|
198
|
-
|
|
199
|
-
);
|
|
200
|
-
*/
|
|
201
|
-
// Server startup logic
|
|
661
|
+
});
|
|
202
662
|
if (process.argv.includes('--stdio')) {
|
|
203
|
-
|
|
204
|
-
//
|
|
663
|
+
console.log('Starting server in stdio mode...');
|
|
664
|
+
// Set up stdio transport
|
|
205
665
|
const transport = new StdioServerTransport();
|
|
206
666
|
// Connect server with better error handling
|
|
207
|
-
|
|
667
|
+
server.connect(transport)
|
|
208
668
|
.then(() => {
|
|
209
|
-
|
|
210
|
-
logInfo('server', { status: 'ready' });
|
|
669
|
+
console.log('Server connected successfully to stdio transport');
|
|
211
670
|
// Keep the process alive
|
|
212
671
|
process.stdin.resume();
|
|
213
672
|
// Handle process termination
|
|
214
673
|
process.on('SIGINT', () => {
|
|
215
|
-
|
|
674
|
+
console.log('Received SIGINT. Shutting down...');
|
|
216
675
|
transport.close();
|
|
217
676
|
process.exit(0);
|
|
218
677
|
});
|
|
219
678
|
process.on('SIGTERM', () => {
|
|
220
|
-
|
|
679
|
+
console.log('Received SIGTERM. Shutting down...');
|
|
221
680
|
transport.close();
|
|
222
681
|
process.exit(0);
|
|
223
682
|
});
|
|
224
683
|
})
|
|
225
684
|
.catch(error => {
|
|
226
|
-
|
|
685
|
+
console.error('Failed to connect server to transport:', error);
|
|
227
686
|
process.exit(1);
|
|
228
687
|
});
|
|
229
688
|
}
|
|
230
|
-
|
|
689
|
+
else {
|
|
690
|
+
console.log('Starting server in standard mode...');
|
|
691
|
+
// Add your non-stdio server initialization here if needed
|
|
692
|
+
}
|
|
231
693
|
// Prevent unhandled promise rejections from crashing the server
|
|
232
694
|
process.on('unhandledRejection', (error) => {
|
|
233
|
-
|
|
695
|
+
console.error('Unhandled promise rejection:', error);
|
|
234
696
|
});
|