@hauptsache.net/clickup-mcp 1.0.2 → 1.0.3

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 (2) hide show
  1. package/dist/index.js +44 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19,11 +19,22 @@ exports.server = new mcp_js_1.McpServer({
19
19
  name: "Clickup MCP",
20
20
  version: "1.0.0",
21
21
  });
22
+ /**
23
+ * Checks if a string looks like a valid ClickUp task ID
24
+ * Valid task IDs are 7-9 characters long and contain only alphanumeric characters
25
+ */
26
+ function isTaskId(str) {
27
+ // Task IDs are 7-9 characters long and contain only alphanumeric characters
28
+ return /^[a-z0-9]{7,9}$/i.test(str);
29
+ }
22
30
  exports.server.tool("getTaskById", "Get a Clickup task with images and comments by ID", {
23
31
  id: zod_1.z
24
32
  .string()
25
33
  .min(7)
26
34
  .max(9)
35
+ .refine(val => isTaskId(val), {
36
+ message: "Task ID must be 7-9 alphanumeric characters only"
37
+ })
27
38
  .describe(`The 7-9 character ID of the task to get without a prefix like "#", "CU-" or "https://app.clickup.com/t/"`),
28
39
  }, async ({ id }) => {
29
40
  const [content, comments] = await Promise.all([
@@ -158,10 +169,41 @@ exports.server.tool("searchTask", [
158
169
  const searchTerms = terms
159
170
  .split("|")
160
171
  .map((term) => term.trim().toLowerCase());
161
- const tasks = cachedTasks.filter((task) => {
172
+ // Check if any search term looks like a task ID
173
+ const potentialTaskIds = searchTerms.filter(isTaskId);
174
+ // Fetch tasks from cache that match search terms
175
+ const tasksFromCache = cachedTasks.filter((task) => {
162
176
  const taskNameLower = task.name.toLowerCase();
163
- return searchTerms.some((term) => taskNameLower.includes(term));
177
+ const taskId = task.id.toLowerCase();
178
+ return searchTerms.some((term) => taskNameLower.includes(term) || taskId.includes(term));
179
+ });
180
+ // Fetch tasks by ID directly if they look like task IDs and they're not already in the cache
181
+ const tasksToFetch = potentialTaskIds.filter(id => {
182
+ // Check if this ID is already in the tasksFromCache
183
+ return !tasksFromCache.some(task => task.id.toLowerCase() === id.toLowerCase());
164
184
  });
185
+ const taskPromises = tasksToFetch.map(async (id) => {
186
+ try {
187
+ // Fetch task directly from API
188
+ const response = await fetch(`https://api.clickup.com/api/v2/task/${id}`, { headers: { Authorization: CONFIG.apiKey } });
189
+ if (!response.ok)
190
+ return null;
191
+ const task = await response.json();
192
+ return task;
193
+ }
194
+ catch (error) {
195
+ console.error(`Error fetching task ${id}:`, error);
196
+ return null;
197
+ }
198
+ });
199
+ // Wait for all task fetches to complete
200
+ const directlyFetchedTasks = await Promise.all(taskPromises);
201
+ // Combine tasks from cache and directly fetched tasks, removing nulls
202
+ const allTasks = [
203
+ ...tasksFromCache,
204
+ ...directlyFetchedTasks.filter(Boolean)
205
+ ];
206
+ const tasks = allTasks;
165
207
  if (tasks.length === 0) {
166
208
  return {
167
209
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hauptsache.net/clickup-mcp",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A minimal implementation of a Model Context Protocol (MCP) server for ClickUp integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",