1use crate::client::ClickUpClient;
2use crate::config::Config;
3use crate::output::compact_items;
4use serde_json::{json, Value};
5use tokio::io::{AsyncBufReadExt, BufReader};
6
7pub mod classify;
8pub mod filter;
9
10fn ok_response(id: &Value, result: Value) -> Value {
13 json!({"jsonrpc":"2.0","id":id,"result":result})
14}
15
16fn error_response(id: &Value, code: i64, message: &str) -> Value {
17 json!({"jsonrpc":"2.0","id":id,"error":{"code":code,"message":message}})
18}
19
20fn tool_result(text: String) -> Value {
21 json!({"content":[{"type":"text","text":text}]})
22}
23
24fn tool_error(msg: String) -> Value {
25 json!({"content":[{"type":"text","text":msg}],"isError":true})
26}
27
28pub fn handle_tools_call_early(
33 id: &Value,
34 params: &Value,
35 filter: &filter::Filter,
36) -> Option<Value> {
37 let tool_name = params.get("name").and_then(|v| v.as_str()).unwrap_or("");
38
39 if tool_name.is_empty() {
40 return Some(ok_response(id, tool_error("Missing tool name".to_string())));
41 }
42
43 if !filter.allows(tool_name) {
44 return Some(error_response(
45 id,
46 -32601,
47 &format!("Method not found: {} (filtered out at startup)", tool_name),
48 ));
49 }
50
51 None
52}
53
54pub fn tool_list() -> Value {
57 json!([
58 {
59 "name": "clickup_whoami",
60 "description": "Get the currently authenticated ClickUp user",
61 "inputSchema": {
62 "type": "object",
63 "properties": {},
64 "required": []
65 }
66 },
67 {
68 "name": "clickup_workspace_list",
69 "description": "List all ClickUp workspaces (teams) accessible to the current user",
70 "inputSchema": {
71 "type": "object",
72 "properties": {},
73 "required": []
74 }
75 },
76 {
77 "name": "clickup_space_list",
78 "description": "List all spaces in a ClickUp workspace. Spaces are the top-level containers below the workspace and hold folders, lists, and tasks. Returns a compact array of space objects (id, name, private, archived). Use clickup_folder_list or clickup_list_list with a space_id to drill down.",
79 "inputSchema": {
80 "type": "object",
81 "properties": {
82 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config (defaults.workspace_id)."},
83 "archived": {"type": "boolean", "description": "true = include archived spaces in the result; false or omitted = only active spaces. Defaults to false."}
84 },
85 "required": []
86 }
87 },
88 {
89 "name": "clickup_folder_list",
90 "description": "List all folders in a ClickUp space. Folders are optional groupings that contain lists; a space may also have folderless lists (use clickup_list_list with space_id for those). Returns a compact array of folder objects (id, name, task_count, archived).",
91 "inputSchema": {
92 "type": "object",
93 "properties": {
94 "space_id": {"type": "string", "description": "ID of the parent space. Obtain from clickup_space_list (field: id)."},
95 "archived": {"type": "boolean", "description": "true = include archived folders; false or omitted = only active folders. Defaults to false."}
96 },
97 "required": ["space_id"]
98 }
99 },
100 {
101 "name": "clickup_list_list",
102 "description": "List ClickUp lists under either a folder or a space (folderless lists). Exactly one of folder_id or space_id must be provided. Returns a compact array of list objects (id, name, task_count, archived). Use clickup_task_list to drill into a specific list.",
103 "inputSchema": {
104 "type": "object",
105 "properties": {
106 "folder_id": {"type": "string", "description": "ID of the parent folder. Obtain from clickup_folder_list (field: id). Mutually exclusive with space_id."},
107 "space_id": {"type": "string", "description": "ID of a space — returns only the folderless lists attached directly to the space. Obtain from clickup_space_list (field: id). Mutually exclusive with folder_id."},
108 "archived": {"type": "boolean", "description": "true = include archived lists; false or omitted = only active lists. Defaults to false."}
109 },
110 "required": []
111 }
112 },
113 {
114 "name": "clickup_task_list",
115 "description": "List tasks in a specific ClickUp list with optional status/assignee filters. Returns the first page of task objects in compact form (id, name, status, assignees, due_date). For cross-list or cross-space queries use clickup_task_search instead; for a single task use clickup_task_get.",
116 "inputSchema": {
117 "type": "object",
118 "properties": {
119 "list_id": {"type": "string", "description": "ID of the list to read tasks from. Obtain from clickup_list_list (field: id)."},
120 "statuses": {
121 "type": "array",
122 "items": {"type": "string"},
123 "description": "Status names to include (e.g. ['open','in progress']). Case-sensitive, must match a status defined on the list. Omit to return tasks in any open status."
124 },
125 "assignees": {
126 "type": "array",
127 "items": {"type": "string"},
128 "description": "User IDs (as strings) to filter assignees. Obtain from clickup_member_list or clickup_user_get. Omit to return tasks regardless of assignee."
129 },
130 "include_closed": {"type": "boolean", "description": "true = include tasks whose status is in the 'closed' group; false or omitted = exclude closed tasks from the response."}
131 },
132 "required": ["list_id"]
133 }
134 },
135 {
136 "name": "clickup_task_get",
137 "description": "Fetch the full object for a single ClickUp task — name, description, status, assignees, tags, custom fields, checklists, due date, time estimates, dependencies, and more. Returns the task object. Use clickup_task_list or clickup_task_search to find a task_id.",
138 "inputSchema": {
139 "type": "object",
140 "properties": {
141 "task_id": {"type": "string", "description": "ID of the task to fetch. Obtain from clickup_task_list (field: id) or clickup_task_search."},
142 "include_subtasks": {"type": "boolean", "description": "true = include the task's subtasks in the response under the 'subtasks' field; false or omitted = return only the parent task."}
143 },
144 "required": ["task_id"]
145 }
146 },
147 {
148 "name": "clickup_task_create",
149 "description": "Create a new task in a ClickUp list. The task starts in the list's default status unless 'status' is supplied. Returns the created task object including its new id, which you can pass to clickup_task_update, clickup_task_get, etc.",
150 "inputSchema": {
151 "type": "object",
152 "properties": {
153 "list_id": {"type": "string", "description": "ID of the list the task will live in. Obtain from clickup_list_list (field: id)."},
154 "name": {"type": "string", "description": "Task title shown in the list view. Required and non-empty."},
155 "description": {"type": "string", "description": "Task body. Markdown supported (headings, links, checkboxes, @mentions). Omit to create the task with no description."},
156 "status": {"type": "string", "description": "Status name to start in (case-sensitive; must match a status configured on the list). Omit to use the list's default initial status."},
157 "priority": {"type": "integer", "description": "Task priority: 1=Urgent, 2=High, 3=Normal, 4=Low. Omit for no priority."},
158 "assignees": {
159 "type": "array",
160 "items": {"type": "integer"},
161 "description": "User IDs to assign to the task. Obtain from clickup_member_list or clickup_user_get. Omit for an unassigned task."
162 },
163 "tags": {
164 "type": "array",
165 "items": {"type": "string"},
166 "description": "Tag names to apply. Tags must already exist in the parent space (use clickup_tag_list to see available tags or clickup_tag_create to add new ones)."
167 },
168 "due_date": {"type": "integer", "description": "Due date as a Unix timestamp in milliseconds (e.g. 1735689600000 for 2025-01-01). Omit for no due date."}
169 },
170 "required": ["list_id", "name"]
171 }
172 },
173 {
174 "name": "clickup_task_update",
175 "description": "Update fields on an existing ClickUp task — name, description, status, priority, and incrementally add/remove assignees. Only provided fields are changed; omitted fields keep their current value. For tags use clickup_task_add_tag/remove_tag; for moving between lists use clickup_task_move. Returns the updated task object.",
176 "inputSchema": {
177 "type": "object",
178 "properties": {
179 "task_id": {"type": "string", "description": "ID of the task to update. Obtain from clickup_task_list (field: id) or clickup_task_search."},
180 "name": {"type": "string", "description": "New task title. Omit to keep current name."},
181 "status": {"type": "string", "description": "New status name (case-sensitive, must match a status defined on the parent list). Omit to keep current status."},
182 "priority": {"type": "integer", "description": "New priority: 1=Urgent, 2=High, 3=Normal, 4=Low. Omit to keep current priority."},
183 "description": {"type": "string", "description": "New task body — replaces the current description entirely. Markdown supported. Omit to keep current description."},
184 "add_assignees": {
185 "type": "array",
186 "items": {"type": "integer"},
187 "description": "User IDs to add as assignees (additive; does not replace existing assignees). Obtain from clickup_member_list."
188 },
189 "rem_assignees": {
190 "type": "array",
191 "items": {"type": "integer"},
192 "description": "User IDs to remove from assignees (no-op if the user is not currently assigned)."
193 }
194 },
195 "required": ["task_id"]
196 }
197 },
198 {
199 "name": "clickup_task_delete",
200 "description": "Permanently delete a ClickUp task along with all its subtasks, comments, checklists, attachments, and time entries. Destructive, irreversible, and cascading — confirm with the user before calling. To mark a task done without deleting, use clickup_task_update with a 'closed' status instead. Returns an empty object on success.",
201 "inputSchema": {
202 "type": "object",
203 "properties": {
204 "task_id": {"type": "string", "description": "ID of the task to delete. Obtain from clickup_task_list (field: id) or clickup_task_search. All subtasks, comments, checklists, attachments, and time entries on this task are deleted with it."}
205 },
206 "required": ["task_id"]
207 }
208 },
209 {
210 "name": "clickup_task_search",
211 "description": "Search tasks across an entire ClickUp workspace with optional space/list/status/assignee filters — useful for cross-list queries. Returns a paginated array of task objects. For tasks in a single list, prefer clickup_task_list (fewer parameters, same shape).",
212 "inputSchema": {
213 "type": "object",
214 "properties": {
215 "team_id": {"type": "string", "description": "Workspace (team) ID to search within. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
216 "space_ids": {
217 "type": "array",
218 "items": {"type": "string"},
219 "description": "Restrict results to these space IDs. Obtain from clickup_space_list (field: id). Omit to search all spaces."
220 },
221 "list_ids": {
222 "type": "array",
223 "items": {"type": "string"},
224 "description": "Restrict results to these list IDs. Obtain from clickup_list_list (field: id). Omit to search all lists."
225 },
226 "statuses": {
227 "type": "array",
228 "items": {"type": "string"},
229 "description": "Status names to include (e.g. ['open','in review']). Case-sensitive. Omit for any open status."
230 },
231 "assignees": {
232 "type": "array",
233 "items": {"type": "string"},
234 "description": "User IDs (as strings) to restrict to tasks assigned to them. Obtain from clickup_member_list. Omit to return tasks regardless of assignee."
235 }
236 },
237 "required": []
238 }
239 },
240 {
241 "name": "clickup_comment_list",
242 "description": "List comments on a ClickUp task in chronological order (oldest first). Only top-level comments are returned; use clickup_comment_replies to fetch a threaded reply chain. Returns a compact array of comment objects (id, comment_text, user, resolved, date).",
243 "inputSchema": {
244 "type": "object",
245 "properties": {
246 "task_id": {"type": "string", "description": "ID of the task to read comments from. Obtain from clickup_task_list (field: id) or clickup_task_search."}
247 },
248 "required": ["task_id"]
249 }
250 },
251 {
252 "name": "clickup_comment_create",
253 "description": "Post a new top-level comment on a ClickUp task. Supports markdown and @mentions in the text body. Returns the created comment object including its new id, which you can pass to clickup_comment_reply, clickup_comment_update, etc.",
254 "inputSchema": {
255 "type": "object",
256 "properties": {
257 "task_id": {"type": "string", "description": "ID of the task to comment on. Obtain from clickup_task_list (field: id) or clickup_task_search."},
258 "text": {"type": "string", "description": "Comment body. Markdown and @mentions (e.g. '@username') are supported."},
259 "assignee": {"type": "integer", "description": "Optional user ID to assign the comment to — they will receive a notification. Obtain from clickup_member_list."},
260 "notify_all": {"type": "boolean", "description": "true = send a notification to every assignee of the task; false or omitted = only notify people mentioned or the explicit assignee."}
261 },
262 "required": ["task_id", "text"]
263 }
264 },
265 {
266 "name": "clickup_field_list",
267 "description": "List the custom field definitions available on a ClickUp list — field id, name, type (text, number, dropdown, labels, date, url, email, phone, money, progress, formula, etc.), and for dropdown/labels fields the permitted option values. Use this before clickup_field_set to learn the correct field_id and value shape. Returns an array of custom field definitions.",
268 "inputSchema": {
269 "type": "object",
270 "properties": {
271 "list_id": {"type": "string", "description": "ID of the list whose custom fields to enumerate. Obtain from clickup_list_list (field: id). Fields are defined per-list (or inherited from folder/space)."}
272 },
273 "required": ["list_id"]
274 }
275 },
276 {
277 "name": "clickup_field_set",
278 "description": "Set or overwrite a single custom field value on a ClickUp task. The value's JSON shape must match the field type (string for text/url/email, number for number/currency/progress, array of option ids for dropdown/labels, Unix ms for date, etc.). Use clickup_field_list first to see the field type and option ids. Use clickup_field_unset to clear a value. Returns an empty object on success.",
279 "inputSchema": {
280 "type": "object",
281 "properties": {
282 "task_id": {"type": "string", "description": "ID of the task whose field value should change. Obtain from clickup_task_list (field: id)."},
283 "field_id": {"type": "string", "description": "ID of the custom field to set. Obtain from clickup_field_list (field: id) or clickup_task_get (custom_fields[].id)."},
284 "value": {"description": "New value; the accepted type depends on the custom field type. Examples: 'hello' (text), 42 (number), ['option-uuid'] (dropdown), 1735689600000 (date as Unix ms). See clickup_field_list for the field's type."}
285 },
286 "required": ["task_id", "field_id", "value"]
287 }
288 },
289 {
290 "name": "clickup_time_start",
291 "description": "Start a live time-tracking timer for the authenticated user. If a timer is already running it will be stopped first. Pair with clickup_time_stop to end the timer and record the entry. Use clickup_time_current to inspect the running timer. Returns the newly started time entry object.",
292 "inputSchema": {
293 "type": "object",
294 "properties": {
295 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
296 "task_id": {"type": "string", "description": "ID of the task to attribute this timer to. Obtain from clickup_task_list (field: id). Omit to track time without a task."},
297 "description": {"type": "string", "description": "Free-text description shown on the time entry (e.g. 'pair debugging session'). Optional."},
298 "billable": {"type": "boolean", "description": "true = mark this time entry as billable (shows as $ in reports); false or omitted = non-billable."}
299 },
300 "required": []
301 }
302 },
303 {
304 "name": "clickup_time_stop",
305 "description": "Stop the currently running time tracking entry",
306 "inputSchema": {
307 "type": "object",
308 "properties": {
309 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."}
310 },
311 "required": []
312 }
313 },
314 {
315 "name": "clickup_time_list",
316 "description": "List historical time tracking entries for a workspace, optionally filtered by date range and/or task. Covers both manually-created entries and stopped timers. Returns a compact array of time entry objects (id, user, task, start, duration, billable, description).",
317 "inputSchema": {
318 "type": "object",
319 "properties": {
320 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
321 "start_date": {"type": "integer", "description": "Inclusive lower bound as a Unix timestamp in milliseconds (e.g. 1735689600000 for 2025-01-01). Omit for no lower bound."},
322 "end_date": {"type": "integer", "description": "Inclusive upper bound as a Unix timestamp in milliseconds. Omit for no upper bound. Note: ClickUp caps the range to ~30 days by default."},
323 "task_id": {"type": "string", "description": "Return only entries attributed to this task. Obtain from clickup_task_list (field: id). Omit to list entries across all tasks."}
324 },
325 "required": []
326 }
327 },
328 {
329 "name": "clickup_checklist_create",
330 "description": "Create a new checklist (to-do group) on a ClickUp task. The checklist starts empty — add items via clickup_checklist_add_item. A task can have multiple checklists. Returns the created checklist object including its new id.",
331 "inputSchema": {
332 "type": "object",
333 "properties": {
334 "task_id": {"type": "string", "description": "ID of the task to attach the checklist to. Obtain from clickup_task_list (field: id)."},
335 "name": {"type": "string", "description": "Display name for the checklist (e.g. 'Launch prep', 'QA steps'). Shown as a heading above the items."}
336 },
337 "required": ["task_id", "name"]
338 }
339 },
340 {
341 "name": "clickup_checklist_delete",
342 "description": "Permanently delete an entire checklist from a ClickUp task, including all its items. Destructive and irreversible. To remove a single item instead, use clickup_checklist_delete_item. Returns an empty object on success.",
343 "inputSchema": {
344 "type": "object",
345 "properties": {
346 "checklist_id": {"type": "string", "description": "ID of the checklist to delete. Obtain from clickup_task_get (field: checklists[].id). All items on this checklist are deleted with it."}
347 },
348 "required": ["checklist_id"]
349 }
350 },
351 {
352 "name": "clickup_goal_list",
353 "description": "List all ClickUp goals in a workspace. Each goal represents an OKR-style objective and can have multiple key results (sub-targets). Returns a compact array of goal objects (id, name, percent_completed, due_date). Use clickup_goal_get for the full goal including its key_results.",
354 "inputSchema": {
355 "type": "object",
356 "properties": {
357 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
358 },
359 "required": []
360 }
361 },
362 {
363 "name": "clickup_goal_get",
364 "description": "Fetch a single ClickUp goal including its key results, owners, due date, and current percent-complete. Returns the goal object with its key_results array populated.",
365 "inputSchema": {
366 "type": "object",
367 "properties": {
368 "goal_id": {"type": "string", "description": "ID of the goal to fetch. Obtain from clickup_goal_list (field: id). The authenticated user must have view access to the goal's workspace."}
369 },
370 "required": ["goal_id"]
371 }
372 },
373 {
374 "name": "clickup_goal_create",
375 "description": "Create a new OKR-style goal in a workspace. The goal starts with zero key results — add them via clickup_goal_add_kr. The goal's percent-complete is auto-calculated from the average progress of its key results. Returns the created goal object including its new id.",
376 "inputSchema": {
377 "type": "object",
378 "properties": {
379 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
380 "name": {"type": "string", "description": "Goal title (e.g. 'Q1 revenue target'). Required and non-empty."},
381 "due_date": {"type": "integer", "description": "Target completion date as a Unix timestamp in milliseconds (e.g. 1735689600000 for 2025-01-01)."},
382 "description": {"type": "string", "description": "Goal description / rationale. Markdown supported. Omit for no description."},
383 "owner_ids": {
384 "type": "array",
385 "items": {"type": "integer"},
386 "description": "User IDs to assign as goal owners (they receive notifications about progress). Obtain from clickup_member_list."
387 }
388 },
389 "required": ["name"]
390 }
391 },
392 {
393 "name": "clickup_goal_update",
394 "description": "Modify a ClickUp goal's top-level fields (name, description, due date). To change progress, update the goal's key results instead via clickup_goal_update_kr — the goal's percent complete is derived automatically. Returns the updated goal object.",
395 "inputSchema": {
396 "type": "object",
397 "properties": {
398 "goal_id": {"type": "string", "description": "ID of the goal to update. Obtain from clickup_goal_list (field: id)."},
399 "name": {"type": "string", "description": "New goal title. Omit to keep current name."},
400 "due_date": {"type": "integer", "description": "New due date as a Unix timestamp in milliseconds (e.g. 1735689600000 for 2025-01-01)."},
401 "description": {"type": "string", "description": "New goal description. Markdown supported."}
402 },
403 "required": ["goal_id"]
404 }
405 },
406 {
407 "name": "clickup_view_list",
408 "description": "List saved views (board, list, calendar, gantt, timeline, etc.) attached to a space, folder, list, or the whole workspace. Exactly one of space_id/folder_id/list_id must be provided — or omit all three to list workspace-level views. Returns a compact array of view objects (id, name, type).",
409 "inputSchema": {
410 "type": "object",
411 "properties": {
412 "space_id": {"type": "string", "description": "Space ID whose views to list. Obtain from clickup_space_list. Mutually exclusive with folder_id/list_id."},
413 "folder_id": {"type": "string", "description": "Folder ID whose views to list. Obtain from clickup_folder_list. Mutually exclusive with space_id/list_id."},
414 "list_id": {"type": "string", "description": "List ID whose views to list. Obtain from clickup_list_list. Mutually exclusive with space_id/folder_id."},
415 "team_id": {"type": "string", "description": "Workspace (team) ID — used when all three scope IDs are omitted, to return workspace-level (Everything) views. Obtain from clickup_workspace_list. Omit to use the default workspace from config."}
416 },
417 "required": []
418 }
419 },
420 {
421 "name": "clickup_view_tasks",
422 "description": "Fetch the tasks currently visible in a ClickUp view, honouring the view's configured filters, sort order, and grouping. Returns a paginated array of task objects. Use clickup_view_list to discover view IDs and clickup_view_get for the view's definition.",
423 "inputSchema": {
424 "type": "object",
425 "properties": {
426 "view_id": {"type": "string", "description": "ID of the view to read tasks from. Obtain from clickup_view_list (field: id)."},
427 "page": {"type": "integer", "description": "Zero-indexed page number (default 0). Each page returns up to 30 tasks; increment to paginate."}
428 },
429 "required": ["view_id"]
430 }
431 },
432 {
433 "name": "clickup_doc_list",
434 "description": "List all ClickUp docs in a workspace. Docs are long-form markdown documents separate from tasks and can contain nested pages. Returns a compact array of doc objects (id, name, date_created, date_updated). Use clickup_doc_get for a single doc or clickup_doc_pages to list a doc's pages. Uses v3 cursor pagination.",
435 "inputSchema": {
436 "type": "object",
437 "properties": {
438 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
439 },
440 "required": []
441 }
442 },
443 {
444 "name": "clickup_doc_get",
445 "description": "Fetch metadata for a single ClickUp doc — name, parent, dates, type. Does not return the page bodies; use clickup_doc_pages (with content=true) or clickup_doc_get_page for the markdown content. Returns the doc object.",
446 "inputSchema": {
447 "type": "object",
448 "properties": {
449 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
450 "doc_id": {"type": "string", "description": "ID of the doc to fetch. Obtain from clickup_doc_list (field: id)."}
451 },
452 "required": ["doc_id"]
453 }
454 },
455 {
456 "name": "clickup_doc_pages",
457 "description": "List the pages inside a ClickUp doc, including any nested subpages. Returns an array of page objects (id, name, sub_title, parent_page_id, and optionally content). Pages are ordered by their tree position.",
458 "inputSchema": {
459 "type": "object",
460 "properties": {
461 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
462 "doc_id": {"type": "string", "description": "ID of the parent doc. Obtain from clickup_doc_list (field: id)."},
463 "content": {"type": "boolean", "description": "true = include each page's full markdown body in the 'content' field; false or omitted = return page metadata only (faster, smaller payload)."}
464 },
465 "required": ["doc_id"]
466 }
467 },
468 {
469 "name": "clickup_tag_list",
470 "description": "List all tags defined in a ClickUp space. Tags are space-scoped labels (with foreground/background hex colours) that can be applied to tasks within that space. Returns an array of tag objects (name, tag_fg, tag_bg, creator).",
471 "inputSchema": {
472 "type": "object",
473 "properties": {
474 "space_id": {"type": "string", "description": "ID of the space whose tags to list. Obtain from clickup_space_list (field: id). Tags are defined per-space, not workspace-wide."}
475 },
476 "required": ["space_id"]
477 }
478 },
479 {
480 "name": "clickup_task_add_tag",
481 "description": "Attach an existing tag to a ClickUp task. The tag must already be defined in the task's parent space — use clickup_tag_list to check and clickup_tag_create to add a new tag first. Tags are identified by name, not ID. Returns an empty object on success.",
482 "inputSchema": {
483 "type": "object",
484 "properties": {
485 "task_id": {"type": "string", "description": "ID of the task to tag. Obtain from clickup_task_list (field: id)."},
486 "tag_name": {"type": "string", "description": "Name of the tag to apply (case-sensitive, must already exist in the task's space). Obtain from clickup_tag_list."}
487 },
488 "required": ["task_id", "tag_name"]
489 }
490 },
491 {
492 "name": "clickup_task_remove_tag",
493 "description": "Detach a tag from a ClickUp task. The tag definition itself is preserved in the space — only this task's association with it is removed. No-op if the tag was not on the task. Returns an empty object on success.",
494 "inputSchema": {
495 "type": "object",
496 "properties": {
497 "task_id": {"type": "string", "description": "ID of the task to untag. Obtain from clickup_task_list (field: id) or clickup_task_get."},
498 "tag_name": {"type": "string", "description": "Name of the tag to remove (case-sensitive). See clickup_task_get (field: tags[].name) for tags currently on the task."}
499 },
500 "required": ["task_id", "tag_name"]
501 }
502 },
503 {
504 "name": "clickup_webhook_list",
505 "description": "List all webhooks registered on a ClickUp workspace. Each webhook specifies a target endpoint, subscribed events, and optional scope. Returns an array of webhook objects (id, endpoint, events, status, secret, health). Use clickup_webhook_create/update/delete to manage them.",
506 "inputSchema": {
507 "type": "object",
508 "properties": {
509 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
510 },
511 "required": []
512 }
513 },
514 {
515 "name": "clickup_member_list",
516 "description": "List members (users with direct access) of a specific task or list. Exactly one of task_id or list_id must be provided. Returns an array of user objects (id, username, email, color). Use clickup_user_invite to add people to the workspace first; use clickup_guest_share_task/list to add guests.",
517 "inputSchema": {
518 "type": "object",
519 "properties": {
520 "task_id": {"type": "string", "description": "Task ID whose members to list. Obtain from clickup_task_list (field: id). Mutually exclusive with list_id."},
521 "list_id": {"type": "string", "description": "List ID whose members to list. Obtain from clickup_list_list (field: id). Mutually exclusive with task_id."}
522 },
523 "required": []
524 }
525 },
526 {
527 "name": "clickup_template_list",
528 "description": "List the task templates available in a workspace. Task templates are saved task shapes (name, description, checklists, subtasks, custom fields, etc.) that can be applied via clickup_template_apply_task to create new tasks quickly. Returns an array of template objects (id, name).",
529 "inputSchema": {
530 "type": "object",
531 "properties": {
532 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
533 "page": {"type": "integer", "description": "Zero-indexed page number (default 0). Each page returns up to 100 templates; increment to paginate."}
534 },
535 "required": []
536 }
537 },
538 {
539 "name": "clickup_space_get",
540 "description": "Fetch the full object for a single ClickUp space — name, privacy, statuses, features (time tracking, tags, due dates enabled, etc.), and members. Returns the space object. Use clickup_folder_list or clickup_list_list to enumerate the space's contents.",
541 "inputSchema": {
542 "type": "object",
543 "properties": {
544 "space_id": {"type": "string", "description": "ID of the space to fetch. Obtain from clickup_space_list (field: id)."}
545 },
546 "required": ["space_id"]
547 }
548 },
549 {
550 "name": "clickup_space_create",
551 "description": "Create a new top-level space in a ClickUp workspace. The new space uses the workspace's default feature set and statuses — customise later via the web UI or by creating folders/lists under it. Returns the created space object including its new id.",
552 "inputSchema": {
553 "type": "object",
554 "properties": {
555 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
556 "name": {"type": "string", "description": "Display name for the space (shown in the sidebar)."},
557 "private": {"type": "boolean", "description": "true = private space (only explicit members see it); false or omitted = visible to the whole workspace."}
558 },
559 "required": ["name"]
560 }
561 },
562 {
563 "name": "clickup_space_update",
564 "description": "Modify a ClickUp space — rename it, toggle privacy, or archive/unarchive it. Archiving is the reversible alternative to deletion: archived spaces are hidden from default views but retain all their folders, lists, and tasks. Returns the updated space object.",
565 "inputSchema": {
566 "type": "object",
567 "properties": {
568 "space_id": {"type": "string", "description": "ID of the space to update. Obtain from clickup_space_list (field: id)."},
569 "name": {"type": "string", "description": "New space name. Omit to keep current name."},
570 "private": {"type": "boolean", "description": "true = space is private (visible only to explicit members); false = space is visible to the whole workspace."},
571 "archived": {"type": "boolean", "description": "true = archive (hide but preserve); false = restore from archive."}
572 },
573 "required": ["space_id"]
574 }
575 },
576 {
577 "name": "clickup_space_delete",
578 "description": "Permanently delete a ClickUp space along with every folder, list, and task inside it. Destructive, irreversible, and widely cascading — confirm with the user before calling. To hide a space without destroying its contents, use clickup_space_update with archived=true instead (archival is reversible). Returns an empty object on success.",
579 "inputSchema": {
580 "type": "object",
581 "properties": {
582 "space_id": {"type": "string", "description": "ID of the space to delete. Obtain from clickup_space_list (field: id). All descendant folders, lists, and tasks are deleted with it."}
583 },
584 "required": ["space_id"]
585 }
586 },
587 {
588 "name": "clickup_folder_get",
589 "description": "Fetch the full object for a single ClickUp folder — name, task_count (a string, per API), archived status, and its child lists. Returns the folder object. Use clickup_list_list with folder_id to get just the lists.",
590 "inputSchema": {
591 "type": "object",
592 "properties": {
593 "folder_id": {"type": "string", "description": "ID of the folder to fetch. Obtain from clickup_folder_list (field: id)."}
594 },
595 "required": ["folder_id"]
596 }
597 },
598 {
599 "name": "clickup_folder_create",
600 "description": "Create a new folder inside a ClickUp space. Folders group related lists and start empty — add lists via clickup_list_create with folder_id. Returns the created folder object including its new id.",
601 "inputSchema": {
602 "type": "object",
603 "properties": {
604 "space_id": {"type": "string", "description": "ID of the parent space. Obtain from clickup_space_list (field: id)."},
605 "name": {"type": "string", "description": "Display name for the folder. Must be non-empty and unique within the space."}
606 },
607 "required": ["space_id", "name"]
608 }
609 },
610 {
611 "name": "clickup_folder_update",
612 "description": "Rename a ClickUp folder. Only the folder's display name can be changed via this endpoint — to move the folder to a different space, delete and recreate. Returns the updated folder object.",
613 "inputSchema": {
614 "type": "object",
615 "properties": {
616 "folder_id": {"type": "string", "description": "ID of the folder to rename. Obtain from clickup_folder_list (field: id) or clickup_folder_get."},
617 "name": {"type": "string", "description": "New display name for the folder. Must be non-empty and unique within its parent space."}
618 },
619 "required": ["folder_id", "name"]
620 }
621 },
622 {
623 "name": "clickup_folder_delete",
624 "description": "Permanently delete a ClickUp folder along with every list and task inside it. Destructive, irreversible, and cascading — confirm with the user before calling. If you only want to hide the folder, use clickup_space_update with archived=true on the parent space instead (archival is reversible). Returns an empty object on success.",
625 "inputSchema": {
626 "type": "object",
627 "properties": {
628 "folder_id": {"type": "string", "description": "ID of the folder to delete. Obtain from clickup_folder_list (field: id). All descendant lists and tasks are deleted with it."}
629 },
630 "required": ["folder_id"]
631 }
632 },
633 {
634 "name": "clickup_list_get",
635 "description": "Fetch the full object for a single ClickUp list — name, content/description, statuses, task_count, assignees, due date, and parent folder/space. Returns the list object. Use clickup_task_list with list_id to enumerate tasks inside it.",
636 "inputSchema": {
637 "type": "object",
638 "properties": {
639 "list_id": {"type": "string", "description": "ID of the list to fetch. Obtain from clickup_list_list (field: id)."}
640 },
641 "required": ["list_id"]
642 }
643 },
644 {
645 "name": "clickup_list_create",
646 "description": "Create a new task list inside either a folder or a space (folderless). Exactly one of folder_id or space_id must be provided. Returns the created list object including its new id — use it as list_id for clickup_task_create and related calls.",
647 "inputSchema": {
648 "type": "object",
649 "properties": {
650 "folder_id": {"type": "string", "description": "ID of the parent folder. Obtain from clickup_folder_list (field: id). Mutually exclusive with space_id."},
651 "space_id": {"type": "string", "description": "ID of the parent space — creates a folderless list attached directly to the space. Obtain from clickup_space_list (field: id). Mutually exclusive with folder_id."},
652 "name": {"type": "string", "description": "Display name for the list. Required and non-empty."},
653 "content": {"type": "string", "description": "List description shown at the top of the list. Markdown supported. Omit for no description."},
654 "due_date": {"type": "integer", "description": "List-level due date as a Unix timestamp in milliseconds (e.g. 1735689600000 for 2025-01-01). Individual tasks retain their own due dates."},
655 "status": {"type": "string", "description": "Default status for tasks added to this list. Must match a status name from the parent space's status set."}
656 },
657 "required": ["name"]
658 }
659 },
660 {
661 "name": "clickup_list_update",
662 "description": "Modify a ClickUp list's name, description, due date, or status. To move tasks between lists use clickup_task_move, and to add or remove this list from tasks with multi-list membership use clickup_list_add_task / clickup_list_remove_task. Returns the updated list object.",
663 "inputSchema": {
664 "type": "object",
665 "properties": {
666 "list_id": {"type": "string", "description": "ID of the list to update. Obtain from clickup_list_list (field: id)."},
667 "name": {"type": "string", "description": "New list name. Omit to keep current name."},
668 "content": {"type": "string", "description": "New description for the list. Markdown supported."},
669 "due_date": {"type": "integer", "description": "List-level due date as a Unix timestamp in milliseconds. Individual tasks retain their own due dates."},
670 "status": {"type": "string", "description": "Default status for tasks added to this list (must match an existing status name in the list's status set)."}
671 },
672 "required": ["list_id"]
673 }
674 },
675 {
676 "name": "clickup_list_delete",
677 "description": "Permanently delete a ClickUp list along with every task inside it, plus their comments, checklists, and attachments. Destructive, irreversible, and cascading — confirm with the user before calling. To move tasks elsewhere first, use clickup_task_move on each, or use clickup_list_update to rename/archive instead. Returns an empty object on success.",
678 "inputSchema": {
679 "type": "object",
680 "properties": {
681 "list_id": {"type": "string", "description": "ID of the list to delete. Obtain from clickup_list_list (field: id). All tasks inside are deleted with it."}
682 },
683 "required": ["list_id"]
684 }
685 },
686 {
687 "name": "clickup_list_add_task",
688 "description": "Add a task to a secondary list (multi-list membership) without moving it. The task remains in its original home list and becomes additionally visible in this one — useful for shared roadmaps. To change the home list instead, use clickup_task_move. Returns an empty object on success.",
689 "inputSchema": {
690 "type": "object",
691 "properties": {
692 "list_id": {"type": "string", "description": "ID of the secondary list the task should also appear in. Obtain from clickup_list_list (field: id)."},
693 "task_id": {"type": "string", "description": "ID of the task to add. Obtain from clickup_task_list (field: id)."}
694 },
695 "required": ["list_id", "task_id"]
696 }
697 },
698 {
699 "name": "clickup_list_remove_task",
700 "description": "Remove a task from a secondary list it was added to via clickup_list_add_task. The task itself is NOT deleted — it remains in its home list (and any other secondary lists). Use clickup_task_delete to remove the task entirely. Returns an empty object on success.",
701 "inputSchema": {
702 "type": "object",
703 "properties": {
704 "list_id": {"type": "string", "description": "ID of the secondary list to detach the task from. Obtain from clickup_list_list (field: id). Must not be the task's home list."},
705 "task_id": {"type": "string", "description": "ID of the task to detach. Obtain from clickup_task_list (field: id)."}
706 },
707 "required": ["list_id", "task_id"]
708 }
709 },
710 {
711 "name": "clickup_comment_update",
712 "description": "Edit the text, assignee, or resolution state of a ClickUp comment on a task, list, or view. The entire comment body is replaced by the new text (no partial edits). Marking resolved=true strikes through the comment and closes the thread. Returns the updated comment object.",
713 "inputSchema": {
714 "type": "object",
715 "properties": {
716 "comment_id": {"type": "string", "description": "ID of the comment to edit. Obtain from clickup_comment_list (field: id)."},
717 "text": {"type": "string", "description": "Replacement body for the comment. ClickUp accepts markdown plus @mentions (e.g. '@username'). The previous body is overwritten entirely."},
718 "assignee": {"type": "integer", "description": "Reassign the comment to this user ID, who will receive a notification. Obtain from clickup_member_list."},
719 "resolved": {"type": "boolean", "description": "true = mark the comment thread resolved/closed; false = reopen it."}
720 },
721 "required": ["comment_id", "text"]
722 }
723 },
724 {
725 "name": "clickup_comment_delete",
726 "description": "Permanently delete a ClickUp comment from a task, list, or view. Destructive and irreversible — the comment and any threaded replies are removed. Use clickup_comment_update with resolved=true instead if you only want to mark the comment as handled. Returns an empty object on success.",
727 "inputSchema": {
728 "type": "object",
729 "properties": {
730 "comment_id": {"type": "string", "description": "ID of the comment to delete. Obtain from clickup_comment_list (field: id). The authenticated user must have edit permission on the parent task/list/view."}
731 },
732 "required": ["comment_id"]
733 }
734 },
735 {
736 "name": "clickup_task_add_dep",
737 "description": "Create a dependency relationship between two tasks — either 'task_id depends on depends_on' (blocks until that is done) or 'dependency_of depends on task_id' (task_id blocks that). Provide exactly one of depends_on or dependency_of. Use clickup_task_link for a simple non-blocking reference. Returns an empty object on success.",
738 "inputSchema": {
739 "type": "object",
740 "properties": {
741 "task_id": {"type": "string", "description": "ID of the primary task. Obtain from clickup_task_list (field: id)."},
742 "depends_on": {"type": "string", "description": "ID of a task that task_id should wait for (task_id is blocked until depends_on is complete). Obtain from clickup_task_list. Mutually exclusive with dependency_of."},
743 "dependency_of": {"type": "string", "description": "ID of a task that depends on task_id (that task is blocked until task_id is complete). Obtain from clickup_task_list. Mutually exclusive with depends_on."}
744 },
745 "required": ["task_id"]
746 }
747 },
748 {
749 "name": "clickup_task_remove_dep",
750 "description": "Remove an existing dependency relationship between two tasks. Provide exactly one of depends_on or dependency_of, matching the direction you set with clickup_task_add_dep. The tasks themselves are not affected. Returns an empty object on success.",
751 "inputSchema": {
752 "type": "object",
753 "properties": {
754 "task_id": {"type": "string", "description": "ID of the primary task in the dependency. Obtain from clickup_task_list (field: id) or clickup_task_get (field: dependencies[])."},
755 "depends_on": {"type": "string", "description": "ID of the upstream task to detach from task_id (removes the 'task_id waits for this' edge). Mutually exclusive with dependency_of."},
756 "dependency_of": {"type": "string", "description": "ID of the downstream task to detach (removes the 'this waits for task_id' edge). Mutually exclusive with depends_on."}
757 },
758 "required": ["task_id"]
759 }
760 },
761 {
762 "name": "clickup_task_link",
763 "description": "Create a bidirectional reference link between two tasks — a non-blocking 'see also' relationship, unlike dependencies. Both tasks show the other in their 'Linked tasks' panel. Use clickup_task_unlink to remove. For blocking relationships, use clickup_task_add_dep instead. Returns an empty object on success.",
764 "inputSchema": {
765 "type": "object",
766 "properties": {
767 "task_id": {"type": "string", "description": "ID of the first task. Obtain from clickup_task_list (field: id)."},
768 "links_to": {"type": "string", "description": "ID of the second task to link to. Obtain from clickup_task_list (field: id). The link is visible from both tasks."}
769 },
770 "required": ["task_id", "links_to"]
771 }
772 },
773 {
774 "name": "clickup_task_unlink",
775 "description": "Remove a bidirectional reference link previously created with clickup_task_link. The tasks themselves are not affected, only the link between them. No-op if no link exists. Returns an empty object on success.",
776 "inputSchema": {
777 "type": "object",
778 "properties": {
779 "task_id": {"type": "string", "description": "ID of the first task. Obtain from clickup_task_list (field: id) or clickup_task_get (field: linked_tasks[])."},
780 "links_to": {"type": "string", "description": "ID of the linked task to unlink from task_id."}
781 },
782 "required": ["task_id", "links_to"]
783 }
784 },
785 {
786 "name": "clickup_goal_delete",
787 "description": "Permanently delete a ClickUp goal along with all its key results. Destructive, irreversible, and cascading — confirm with the user before calling. Historical progress data on the goal is lost. Returns an empty object on success.",
788 "inputSchema": {
789 "type": "object",
790 "properties": {
791 "goal_id": {"type": "string", "description": "ID of the goal to delete. Obtain from clickup_goal_list (field: id) or clickup_goal_get. All child key results are deleted with it."}
792 },
793 "required": ["goal_id"]
794 }
795 },
796 {
797 "name": "clickup_goal_add_kr",
798 "description": "Add a new key result (KR / sub-target) to a ClickUp goal. KRs drive the goal's overall percent-complete — each KR's progress is averaged. For 'automatic' KRs, link tasks or lists and progress is derived from their status; for number/currency/percentage KRs, report progress via clickup_goal_update_kr. Returns the created key result object.",
799 "inputSchema": {
800 "type": "object",
801 "properties": {
802 "goal_id": {"type": "string", "description": "ID of the parent goal. Obtain from clickup_goal_list (field: id)."},
803 "name": {"type": "string", "description": "Display name of the key result (e.g. 'MRR reaches $50k')."},
804 "type": {"type": "string", "description": "Key result type: 'number' (numeric target), 'currency' (monetary target), 'boolean' (done/not-done), 'percentage' (0–100), or 'automatic' (derived from linked tasks/lists)."},
805 "steps_start": {"type": "number", "description": "Starting value of the metric (e.g. 0 for a from-zero KR, current baseline otherwise). Ignored for 'boolean'."},
806 "steps_end": {"type": "number", "description": "Target value the KR aims to reach. For 'percentage' KRs use 100; for 'boolean' use 1."},
807 "unit": {"type": "string", "description": "Unit label shown next to numeric values (e.g. 'USD', 'users', 'signups'). Ignored for 'boolean' and 'automatic'."},
808 "owner_ids": {"type": "array", "items": {"type": "integer"}, "description": "User IDs responsible for this KR. Obtain from clickup_member_list."},
809 "task_ids": {"type": "array", "items": {"type": "string"}, "description": "Task IDs whose completion drives progress (only for type='automatic'). Obtain from clickup_task_list."},
810 "list_ids": {"type": "array", "items": {"type": "string"}, "description": "List IDs whose task-completion percentage drives progress (only for type='automatic'). Obtain from clickup_list_list."}
811 },
812 "required": ["goal_id", "name", "type", "steps_start", "steps_end"]
813 }
814 },
815 {
816 "name": "clickup_goal_update_kr",
817 "description": "Update a key result (sub-target) on a ClickUp goal — typically to record current progress, rename, or adjust the unit label. The goal's completion percentage is auto-recalculated from all its key results. Returns the updated key result object.",
818 "inputSchema": {
819 "type": "object",
820 "properties": {
821 "kr_id": {"type": "string", "description": "Key result ID. Obtain from clickup_goal_get (field: key_results[].id) or the response of clickup_goal_add_kr."},
822 "steps_current": {"type": "number", "description": "Current progress toward steps_end. For boolean KRs use 0 (not done) or 1 (done). For percentage KRs use 0–100."},
823 "name": {"type": "string", "description": "New display name for the key result. Omit to keep current name."},
824 "unit": {"type": "string", "description": "Unit label shown next to numeric values (e.g. 'MRR', 'users'). Ignored for boolean and automatic types."}
825 },
826 "required": ["kr_id"]
827 }
828 },
829 {
830 "name": "clickup_goal_delete_kr",
831 "description": "Permanently delete a single key result from a ClickUp goal. Destructive and irreversible — the historical progress for this key result is lost, and the goal's overall completion percentage is recalculated from the remaining key results. Returns an empty object on success.",
832 "inputSchema": {
833 "type": "object",
834 "properties": {
835 "kr_id": {"type": "string", "description": "ID of the key result to delete. Obtain from clickup_goal_get (field: key_results[].id)."}
836 },
837 "required": ["kr_id"]
838 }
839 },
840 {
841 "name": "clickup_time_get",
842 "description": "Fetch the full object for a single time tracking entry — user, task, start timestamp, duration, description, billable flag, and tags. Returns the time entry object.",
843 "inputSchema": {
844 "type": "object",
845 "properties": {
846 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
847 "timer_id": {"type": "string", "description": "ID of the time entry. Obtain from clickup_time_list (field: id) or clickup_time_current."}
848 },
849 "required": ["timer_id"]
850 }
851 },
852 {
853 "name": "clickup_time_create",
854 "description": "Manually record a historical time tracking entry with a fixed start and duration. Use this for backfilling time (e.g. work done offline). For live timing use clickup_time_start/stop instead. Returns the created time entry object including its new id.",
855 "inputSchema": {
856 "type": "object",
857 "properties": {
858 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
859 "task_id": {"type": "string", "description": "ID of the task to attribute the time to. Obtain from clickup_task_list. Omit for a task-less time entry."},
860 "start": {"type": "integer", "description": "Entry start time as a Unix timestamp in milliseconds (e.g. 1735689600000 for 2025-01-01 00:00 UTC)."},
861 "duration": {"type": "integer", "description": "Duration in milliseconds (e.g. 3600000 for one hour)."},
862 "description": {"type": "string", "description": "Free-text description of the work logged. Optional."},
863 "billable": {"type": "boolean", "description": "true = mark as billable (shows with $ in reports); false or omitted = non-billable."}
864 },
865 "required": ["start", "duration"]
866 }
867 },
868 {
869 "name": "clickup_time_update",
870 "description": "Modify a recorded time tracking entry. Only the supplied fields are changed; omitted fields keep their current value. Use clickup_time_add_tags / remove_tags for tag changes. Returns the updated time entry object.",
871 "inputSchema": {
872 "type": "object",
873 "properties": {
874 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
875 "timer_id": {"type": "string", "description": "ID of the time entry to update. Obtain from clickup_time_list (field: id)."},
876 "start": {"type": "integer", "description": "New start time as a Unix timestamp in milliseconds. Omit to keep current start."},
877 "duration": {"type": "integer", "description": "New duration in milliseconds (e.g. 3600000 for one hour). Omit to keep current duration."},
878 "description": {"type": "string", "description": "New description for the entry. Omit to keep current description."},
879 "billable": {"type": "boolean", "description": "true = billable, false = non-billable. Omit to keep current value."}
880 },
881 "required": ["timer_id"]
882 }
883 },
884 {
885 "name": "clickup_time_delete",
886 "description": "Permanently delete a recorded time tracking entry. Destructive and irreversible — the logged time is removed from reports. To stop a currently running timer, use clickup_time_stop instead (which preserves the record). Returns an empty object on success.",
887 "inputSchema": {
888 "type": "object",
889 "properties": {
890 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
891 "timer_id": {"type": "string", "description": "ID of the time entry to delete. Obtain from clickup_time_list (field: id). Only the entry's owner (or a workspace admin) can delete it."}
892 },
893 "required": ["timer_id"]
894 }
895 },
896 {
897 "name": "clickup_view_get",
898 "description": "Fetch the full definition of a single ClickUp view — name, type (list/board/calendar/gantt/etc.), parent scope, filters, grouping, sort order, and column layout. Does not return the tasks inside the view; use clickup_view_tasks for that. Returns the view object.",
899 "inputSchema": {
900 "type": "object",
901 "properties": {
902 "view_id": {"type": "string", "description": "ID of the view to fetch. Obtain from clickup_view_list (field: id)."}
903 },
904 "required": ["view_id"]
905 }
906 },
907 {
908 "name": "clickup_view_create",
909 "description": "Create a new saved view (board, list, calendar, timeline, etc.) attached to a space, folder, list, or the workspace. Creates an empty view with default filters — customise filters/grouping/sort later via the web UI. Returns the created view object including its new id.",
910 "inputSchema": {
911 "type": "object",
912 "properties": {
913 "scope": {"type": "string", "description": "Where to attach the view: 'space', 'folder', 'list', or 'team' (workspace-level 'Everything' view)."},
914 "scope_id": {"type": "string", "description": "ID of the scope object. For scope='space' use a space_id, for 'folder' a folder_id, for 'list' a list_id, for 'team' a workspace/team id (from clickup_workspace_list)."},
915 "name": {"type": "string", "description": "Display name for the view."},
916 "type": {"type": "string", "description": "View type: 'list', 'board', 'calendar', 'table', 'timeline', 'gantt', 'map', 'workload', 'activity', 'chat', 'mind_map', 'doc', or 'form'."}
917 },
918 "required": ["scope", "scope_id", "name", "type"]
919 }
920 },
921 {
922 "name": "clickup_view_update",
923 "description": "Rename a view or change its display type (e.g. from list to board). To change filters, grouping, or sort order, use the ClickUp web UI — those are not exposed via the API. Returns the updated view object.",
924 "inputSchema": {
925 "type": "object",
926 "properties": {
927 "view_id": {"type": "string", "description": "ID of the view to update. Obtain from clickup_view_list (field: id)."},
928 "name": {"type": "string", "description": "New display name for the view."},
929 "type": {"type": "string", "description": "New view type: 'list', 'board', 'calendar', 'table', 'timeline', 'gantt', 'map', 'workload', 'activity', 'chat', 'mind_map', 'doc', or 'form'."}
930 },
931 "required": ["view_id", "name", "type"]
932 }
933 },
934 {
935 "name": "clickup_view_delete",
936 "description": "Permanently delete a ClickUp view (board, list, calendar, gantt, etc.). Destructive and irreversible for custom views — default views cannot be deleted and will return a 400 error. The underlying tasks are not affected, only the view definition. Returns an empty object on success.",
937 "inputSchema": {
938 "type": "object",
939 "properties": {
940 "view_id": {"type": "string", "description": "ID of the view to delete. Obtain from clickup_view_list (field: id). Must be a user-created view, not a ClickUp-default one."}
941 },
942 "required": ["view_id"]
943 }
944 },
945 {
946 "name": "clickup_doc_create",
947 "description": "Create a new ClickUp doc in a workspace. The doc starts with no pages — add pages via clickup_doc_add_page. Optionally attach the doc under a parent space/folder/list/task instead of the workspace root. Returns the created doc object including its new id.",
948 "inputSchema": {
949 "type": "object",
950 "properties": {
951 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
952 "name": {"type": "string", "description": "Display name for the doc (shown in the doc tree)."},
953 "parent": {"type": "object", "description": "Optional parent object to attach the doc under. Shape: { 'id': '<id>', 'type': <int> } where type is 4=space, 5=folder, 6=list, 7=task. Omit to create at the workspace root."}
954 },
955 "required": ["name"]
956 }
957 },
958 {
959 "name": "clickup_doc_add_page",
960 "description": "Create a new page inside an existing ClickUp doc. Pages support a markdown body plus optional subtitle. Supply parent_page_id to nest the page under another page (creates a page tree). Returns the created page object including its new id, which you can pass to clickup_doc_edit_page or clickup_doc_get_page.",
961 "inputSchema": {
962 "type": "object",
963 "properties": {
964 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."},
965 "doc_id": {"type": "string", "description": "ID of the parent doc. Obtain from clickup_doc_list (field: id)."},
966 "name": {"type": "string", "description": "Title shown in the doc's left-hand page navigator."},
967 "content": {"type": "string", "description": "Initial body of the page in ClickUp-flavoured markdown. Omit to create an empty page you can populate later via clickup_doc_edit_page."},
968 "sub_title": {"type": "string", "description": "Optional subtitle rendered under the page title."},
969 "parent_page_id": {"type": "string", "description": "ID of a sibling page to nest this page under. Omit to create a top-level page. Obtain from clickup_doc_pages (field: id)."}
970 },
971 "required": ["doc_id", "name"]
972 }
973 },
974 {
975 "name": "clickup_doc_edit_page",
976 "description": "Rename or rewrite an existing page inside a ClickUp doc. The supplied content replaces the current page body entirely (not an append). For a fresh page use clickup_doc_add_page instead. Returns the updated page object.",
977 "inputSchema": {
978 "type": "object",
979 "properties": {
980 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
981 "doc_id": {"type": "string", "description": "ID of the parent doc. Obtain from clickup_doc_list (field: id)."},
982 "page_id": {"type": "string", "description": "ID of the page to edit. Obtain from clickup_doc_pages (field: id)."},
983 "name": {"type": "string", "description": "New page title. Omit to keep current title."},
984 "content": {"type": "string", "description": "New page body in ClickUp-flavoured markdown. Replaces the existing body entirely. Omit to leave content unchanged."}
985 },
986 "required": ["doc_id", "page_id"]
987 }
988 },
989 {
990 "name": "clickup_chat_channel_create",
991 "description": "Create a new ClickUp Chat channel in a workspace. For one-on-one messages use clickup_chat_dm instead. Add members later via the channel-members endpoint. Returns the created channel object including its new id.",
992 "inputSchema": {
993 "type": "object",
994 "properties": {
995 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
996 "name": {"type": "string", "description": "Channel name (e.g. 'product-launch'). Must be unique within the workspace."},
997 "description": {"type": "string", "description": "Optional channel topic/description shown in the header."},
998 "visibility": {"type": "string", "description": "Channel visibility: 'public' (any workspace member can join) or 'private' (invite only). Defaults to 'public'."}
999 },
1000 "required": ["name"]
1001 }
1002 },
1003 {
1004 "name": "clickup_chat_channel_get",
1005 "description": "Fetch metadata for a single ClickUp chat channel — name, description, visibility, member count, latest activity. Does not return the messages themselves; use clickup_chat_message_list for that. Returns the channel object.",
1006 "inputSchema": {
1007 "type": "object",
1008 "properties": {
1009 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."},
1010 "channel_id": {"type": "string", "description": "ID of the channel to fetch. Obtain from clickup_chat_channel_list (field: id)."}
1011 },
1012 "required": ["channel_id"]
1013 }
1014 },
1015 {
1016 "name": "clickup_chat_channel_update",
1017 "description": "Rename a ClickUp chat channel or change its description. To change membership or visibility use the dedicated channel-members and channel-followers tools. Returns the updated channel object.",
1018 "inputSchema": {
1019 "type": "object",
1020 "properties": {
1021 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."},
1022 "channel_id": {"type": "string", "description": "ID of the channel to update. Obtain from clickup_chat_channel_list (field: id)."},
1023 "name": {"type": "string", "description": "New display name for the channel. Must be unique within the workspace."},
1024 "description": {"type": "string", "description": "New channel description/topic shown in the channel header. Markdown supported."}
1025 },
1026 "required": ["channel_id"]
1027 }
1028 },
1029 {
1030 "name": "clickup_chat_channel_delete",
1031 "description": "Permanently delete a ClickUp Chat channel along with every message and reply it contains. Destructive, irreversible, and cascading — confirm with the user before calling. The channel vanishes from the workspace for all members. Returns an empty object on success.",
1032 "inputSchema": {
1033 "type": "object",
1034 "properties": {
1035 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1036 "channel_id": {"type": "string", "description": "ID of the channel to delete. Obtain from clickup_chat_channel_list (field: id). All messages and replies inside are deleted with it."}
1037 },
1038 "required": ["channel_id"]
1039 }
1040 },
1041 {
1042 "name": "clickup_chat_message_list",
1043 "description": "List messages in a ClickUp Chat channel, newest first. Only top-level messages are returned; use clickup_chat_reply_list for threaded replies. Uses v3 cursor pagination — pass the 'cursor' from the previous response to page further back. Returns an array of message objects plus a next_cursor.",
1044 "inputSchema": {
1045 "type": "object",
1046 "properties": {
1047 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1048 "channel_id": {"type": "string", "description": "ID of the channel. Obtain from clickup_chat_channel_list (field: id)."},
1049 "cursor": {"type": "string", "description": "Opaque pagination cursor from the previous response's next_cursor field. Omit for the first page (newest messages)."}
1050 },
1051 "required": ["channel_id"]
1052 }
1053 },
1054 {
1055 "name": "clickup_chat_message_send",
1056 "description": "Post a new top-level message to a ClickUp Chat channel. For replies inside a thread use clickup_chat_reply_send; for DMs use clickup_chat_dm. Returns the created message object including its new id, which you can pass to clickup_chat_reaction_add, clickup_chat_reply_send, etc.",
1057 "inputSchema": {
1058 "type": "object",
1059 "properties": {
1060 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1061 "channel_id": {"type": "string", "description": "ID of the target channel. Obtain from clickup_chat_channel_list (field: id)."},
1062 "content": {"type": "string", "description": "Message body. Supports markdown, @mentions (e.g. '@username'), and emoji."}
1063 },
1064 "required": ["channel_id", "content"]
1065 }
1066 },
1067 {
1068 "name": "clickup_chat_message_delete",
1069 "description": "Permanently delete a message from a ClickUp chat channel or DM thread. Destructive and irreversible — the message and its threaded replies are removed for all viewers. Only the message author or a workspace admin can delete; other users will get a 403. Returns an empty object on success.",
1070 "inputSchema": {
1071 "type": "object",
1072 "properties": {
1073 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."},
1074 "message_id": {"type": "string", "description": "ID of the message to delete. Obtain from clickup_chat_message_list (field: id) or clickup_chat_reply_list."}
1075 },
1076 "required": ["message_id"]
1077 }
1078 },
1079 {
1080 "name": "clickup_chat_dm",
1081 "description": "Send a direct message from the authenticated user to another workspace member. If no DM channel exists between the two users, one is created automatically. Returns the created message object. Use clickup_chat_message_send for channel messages.",
1082 "inputSchema": {
1083 "type": "object",
1084 "properties": {
1085 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1086 "user_id": {"type": "integer", "description": "Numeric user ID of the recipient. Obtain from clickup_member_list or clickup_user_get (field: id)."},
1087 "content": {"type": "string", "description": "Message body. Supports markdown, emoji, and @mentions."}
1088 },
1089 "required": ["user_id", "content"]
1090 }
1091 },
1092 {
1093 "name": "clickup_webhook_create",
1094 "description": "Register an HTTPS endpoint that ClickUp will POST events to as things happen in the workspace (tasks created, comments added, status changes, etc.). Optionally scope the webhook to a single space, folder, list, or task. The response includes a 'secret' you should use to verify the X-Signature header on incoming payloads. Returns the created webhook object.",
1095 "inputSchema": {
1096 "type": "object",
1097 "properties": {
1098 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."},
1099 "endpoint": {"type": "string", "description": "Public HTTPS URL that will receive event POSTs. Must respond 2xx within 5 seconds or ClickUp will retry/suspend."},
1100 "events": {
1101 "type": "array",
1102 "items": {"type": "string"},
1103 "description": "Event names to subscribe to (e.g. ['taskCreated','taskUpdated','taskStatusUpdated','commentPosted']). Pass ['*'] to subscribe to every event ClickUp emits."
1104 },
1105 "space_id": {"type": "string", "description": "Scope events to this space only. Mutually exclusive with folder_id/list_id/task_id."},
1106 "folder_id": {"type": "string", "description": "Scope events to this folder only. Mutually exclusive with space_id/list_id/task_id."},
1107 "list_id": {"type": "string", "description": "Scope events to this list only. Mutually exclusive with space_id/folder_id/task_id."},
1108 "task_id": {"type": "string", "description": "Scope events to this task only. Mutually exclusive with space_id/folder_id/list_id."}
1109 },
1110 "required": ["endpoint", "events"]
1111 }
1112 },
1113 {
1114 "name": "clickup_webhook_update",
1115 "description": "Change the delivery endpoint, subscribed events, or active status of a ClickUp webhook. To temporarily pause deliveries without losing the webhook config, set status='suspended' (then resume later with status='active'). Returns the updated webhook object.",
1116 "inputSchema": {
1117 "type": "object",
1118 "properties": {
1119 "webhook_id": {"type": "string", "description": "ID of the webhook to update. Obtain from clickup_webhook_list (field: id)."},
1120 "endpoint": {"type": "string", "description": "New HTTPS URL that ClickUp will POST events to. Must be publicly reachable and respond with 2xx within 5 seconds."},
1121 "events": {
1122 "type": "array",
1123 "items": {"type": "string"},
1124 "description": "New list of event names to subscribe to (e.g. ['taskCreated','taskUpdated']). Pass ['*'] to subscribe to every event. Omit to leave subscriptions unchanged."
1125 },
1126 "status": {"type": "string", "description": "'active' to deliver events; 'suspended' to pause deliveries without deleting the webhook."}
1127 },
1128 "required": ["webhook_id"]
1129 }
1130 },
1131 {
1132 "name": "clickup_webhook_delete",
1133 "description": "Permanently delete a ClickUp webhook, stopping all future event deliveries to its endpoint. Destructive and irreversible — the webhook record is removed immediately. If you only want to pause deliveries, use clickup_webhook_update with status='suspended' instead. Returns an empty object on success.",
1134 "inputSchema": {
1135 "type": "object",
1136 "properties": {
1137 "webhook_id": {"type": "string", "description": "ID of the webhook to delete. Obtain from clickup_webhook_list (field: id). The authenticated user must own the webhook or be a workspace admin."}
1138 },
1139 "required": ["webhook_id"]
1140 }
1141 },
1142 {
1143 "name": "clickup_checklist_add_item",
1144 "description": "Append a new item to an existing ClickUp checklist on a task. The item starts unresolved. To edit or resolve items use clickup_checklist_update_item; to remove them use clickup_checklist_delete_item. Returns the updated checklist object (with all items).",
1145 "inputSchema": {
1146 "type": "object",
1147 "properties": {
1148 "checklist_id": {"type": "string", "description": "ID of the parent checklist. Obtain from clickup_task_get (field: checklists[].id)."},
1149 "name": {"type": "string", "description": "Display text of the new checklist item (e.g. 'Send release notes')."},
1150 "assignee": {"type": "integer", "description": "Optional user ID to assign this item to (they will see it on their assigned work). Obtain from clickup_member_list."}
1151 },
1152 "required": ["checklist_id", "name"]
1153 }
1154 },
1155 {
1156 "name": "clickup_checklist_update_item",
1157 "description": "Modify a single checklist item on a ClickUp task — rename it, toggle its resolved state, or change its assignee. Use clickup_checklist_add_item to create new items and clickup_checklist_delete_item to remove them. Returns the updated checklist object (all items).",
1158 "inputSchema": {
1159 "type": "object",
1160 "properties": {
1161 "checklist_id": {"type": "string", "description": "ID of the parent checklist. Obtain from clickup_task_get (field: checklists[].id)."},
1162 "item_id": {"type": "string", "description": "ID of the item to update. Obtain from clickup_task_get (field: checklists[].items[].id)."},
1163 "name": {"type": "string", "description": "New text for the item. Omit to keep current text."},
1164 "resolved": {"type": "boolean", "description": "true = mark as done (strike-through); false = mark as open."},
1165 "assignee": {"type": "integer", "description": "Reassign the item to this user ID. Obtain user IDs from clickup_member_list or clickup_user_get. Pass no value to leave assignee unchanged."}
1166 },
1167 "required": ["checklist_id", "item_id"]
1168 }
1169 },
1170 {
1171 "name": "clickup_checklist_delete_item",
1172 "description": "Permanently delete a single item from a ClickUp checklist. Destructive and irreversible. To resolve the item (mark done) without deleting, use clickup_checklist_update_item with resolved=true. Returns the updated checklist object (remaining items).",
1173 "inputSchema": {
1174 "type": "object",
1175 "properties": {
1176 "checklist_id": {"type": "string", "description": "ID of the parent checklist. Obtain from clickup_task_get (field: checklists[].id)."},
1177 "item_id": {"type": "string", "description": "ID of the item to delete. Obtain from clickup_task_get (field: checklists[].items[].id)."}
1178 },
1179 "required": ["checklist_id", "item_id"]
1180 }
1181 },
1182 {
1183 "name": "clickup_user_get",
1184 "description": "Fetch the profile of a specific member of a ClickUp workspace — username, email, color, profile picture, role. Returns the user object. Use clickup_member_list for task/list members; use clickup_whoami for the authenticated user.",
1185 "inputSchema": {
1186 "type": "object",
1187 "properties": {
1188 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1189 "user_id": {"type": "integer", "description": "Numeric user ID. Obtain from clickup_member_list or clickup_workspace_list (field: members[].user.id)."}
1190 },
1191 "required": ["user_id"]
1192 }
1193 },
1194 {
1195 "name": "clickup_workspace_seats",
1196 "description": "Get the seat-usage breakdown for a ClickUp workspace — how many paid member seats, guest seats, and internal seats are used vs. available. Useful before inviting new users to confirm capacity. Returns an object with member/guest/internal seat counts.",
1197 "inputSchema": {
1198 "type": "object",
1199 "properties": {
1200 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
1201 },
1202 "required": []
1203 }
1204 },
1205 {
1206 "name": "clickup_workspace_plan",
1207 "description": "Get the current subscription plan of a ClickUp workspace (Free, Unlimited, Business, Business Plus, Enterprise), along with plan_name and plan_id. Some features (guests, audit logs, ACLs) require Enterprise. Returns the plan object.",
1208 "inputSchema": {
1209 "type": "object",
1210 "properties": {
1211 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
1212 },
1213 "required": []
1214 }
1215 },
1216 {
1217 "name": "clickup_tag_create",
1218 "description": "Define a new tag in a ClickUp space. Tags are space-scoped and must be created before they can be applied to tasks via clickup_task_add_tag. Note: create uses tag_fg/tag_bg, but clickup_tag_update uses fg_color/bg_color (API inconsistency). Returns an empty object on success; use clickup_tag_list to see the created tag.",
1219 "inputSchema": {
1220 "type": "object",
1221 "properties": {
1222 "space_id": {"type": "string", "description": "ID of the space to create the tag in. Obtain from clickup_space_list (field: id)."},
1223 "name": {"type": "string", "description": "Tag name (e.g. 'blocked', 'priority'). Must be unique within the space."},
1224 "tag_fg": {"type": "string", "description": "Text (foreground) hex colour including leading '#' (e.g. '#FFFFFF'). Omit for default."},
1225 "tag_bg": {"type": "string", "description": "Pill (background) hex colour including leading '#' (e.g. '#FF0000'). Omit for default."}
1226 },
1227 "required": ["space_id", "name"]
1228 }
1229 },
1230 {
1231 "name": "clickup_tag_update",
1232 "description": "Rename a tag or change its colours within a ClickUp space. All tasks using the tag are automatically updated with the new name/colours. Note: update uses fg_color/bg_color whereas tag_create uses tag_fg/tag_bg (API inconsistency). Returns an empty object on success.",
1233 "inputSchema": {
1234 "type": "object",
1235 "properties": {
1236 "space_id": {"type": "string", "description": "ID of the space containing the tag. Obtain from clickup_space_list (field: id)."},
1237 "tag_name": {"type": "string", "description": "Current name of the tag to update. Obtain from clickup_tag_list (field: name)."},
1238 "name": {"type": "string", "description": "New tag name. Omit to keep current name."},
1239 "tag_fg": {"type": "string", "description": "New text (foreground) hex colour with leading '#'. Note: forwarded as fg_color to the API."},
1240 "tag_bg": {"type": "string", "description": "New pill (background) hex colour with leading '#'. Note: forwarded as bg_color to the API."}
1241 },
1242 "required": ["space_id", "tag_name"]
1243 }
1244 },
1245 {
1246 "name": "clickup_tag_delete",
1247 "description": "Delete a tag from a ClickUp space. The tag is removed from every task that uses it (the tasks themselves are not affected). Destructive and irreversible. Returns an empty object on success.",
1248 "inputSchema": {
1249 "type": "object",
1250 "properties": {
1251 "space_id": {"type": "string", "description": "ID of the space containing the tag. Obtain from clickup_space_list (field: id)."},
1252 "tag_name": {"type": "string", "description": "Name of the tag to delete. Obtain from clickup_tag_list (field: name)."}
1253 },
1254 "required": ["space_id", "tag_name"]
1255 }
1256 },
1257 {
1258 "name": "clickup_field_unset",
1259 "description": "Clear a custom field value on a ClickUp task — sets it back to empty/unset. The field definition on the list remains intact. Use clickup_field_set to assign a new value instead. Returns an empty object on success.",
1260 "inputSchema": {
1261 "type": "object",
1262 "properties": {
1263 "task_id": {"type": "string", "description": "ID of the task. Obtain from clickup_task_list (field: id)."},
1264 "field_id": {"type": "string", "description": "ID of the custom field to clear. Obtain from clickup_field_list (field: id) or clickup_task_get (field: custom_fields[].id)."}
1265 },
1266 "required": ["task_id", "field_id"]
1267 }
1268 },
1269 {
1270 "name": "clickup_attachment_list",
1271 "description": "List files attached to a ClickUp task — each attachment's id, title, size, mime type, url, and uploader. Extracts the attachments array from the Get Task response (ClickUp has no dedicated list endpoint). Use clickup_attachment_upload to add a new file. Returns an array of attachment objects.",
1272 "inputSchema": {
1273 "type": "object",
1274 "properties": {
1275 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1276 "task_id": {"type": "string", "description": "ID of the task whose attachments to list. Obtain from clickup_task_list (field: id)."}
1277 },
1278 "required": ["task_id"]
1279 }
1280 },
1281 {
1282 "name": "clickup_shared_list",
1283 "description": "List every task, list, and folder that has been explicitly shared with the authenticated user from outside their default hierarchy (e.g. items shared by other workspace members). Useful for discovering items you have access to but don't own. Returns an object with shared tasks, lists, and folders arrays.",
1284 "inputSchema": {
1285 "type": "object",
1286 "properties": {
1287 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
1288 },
1289 "required": []
1290 }
1291 },
1292 {
1293 "name": "clickup_group_list",
1294 "description": "List user groups (also called 'teams' in the ClickUp UI) in a workspace. A group is a named collection of users that can be @-mentioned or assigned as a unit. Returns an array of group objects (id, name, members).",
1295 "inputSchema": {
1296 "type": "object",
1297 "properties": {
1298 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1299 "group_ids": {
1300 "type": "array",
1301 "items": {"type": "string"},
1302 "description": "Optional filter to return only these group IDs. Omit to return all groups in the workspace."
1303 }
1304 },
1305 "required": []
1306 }
1307 },
1308 {
1309 "name": "clickup_group_create",
1310 "description": "Create a new user group ('team' in ClickUp's UI) in a workspace. Groups let you @-mention or assign multiple users as a unit. At least one initial member is required. Returns the created group object including its new id.",
1311 "inputSchema": {
1312 "type": "object",
1313 "properties": {
1314 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1315 "name": {"type": "string", "description": "Display name for the group (e.g. 'Frontend Engineers')."},
1316 "member_ids": {
1317 "type": "array",
1318 "items": {"type": "integer"},
1319 "description": "User IDs to add as initial members. Obtain from clickup_member_list or clickup_user_get (field: id)."
1320 }
1321 },
1322 "required": ["name"]
1323 }
1324 },
1325 {
1326 "name": "clickup_group_update",
1327 "description": "Rename a user group and/or add/remove its members. All changes are applied in one call. Use clickup_group_list first to see current membership. Returns the updated group object.",
1328 "inputSchema": {
1329 "type": "object",
1330 "properties": {
1331 "group_id": {"type": "string", "description": "ID of the group to update. Obtain from clickup_group_list (field: id)."},
1332 "name": {"type": "string", "description": "New display name. Omit to keep current name."},
1333 "add_members": {
1334 "type": "array",
1335 "items": {"type": "integer"},
1336 "description": "User IDs to add to the group (additive — does not replace current members)."
1337 },
1338 "rem_members": {
1339 "type": "array",
1340 "items": {"type": "integer"},
1341 "description": "User IDs to remove from the group (no-op if not currently a member)."
1342 }
1343 },
1344 "required": ["group_id"]
1345 }
1346 },
1347 {
1348 "name": "clickup_group_delete",
1349 "description": "Permanently delete a ClickUp user group. Destructive and irreversible — assignments and mentions that referenced the group remain as historical records, but the group can no longer be used going forward. The individual users are not affected. Returns an empty object on success.",
1350 "inputSchema": {
1351 "type": "object",
1352 "properties": {
1353 "group_id": {"type": "string", "description": "ID of the group to delete. Obtain from clickup_group_list (field: id)."}
1354 },
1355 "required": ["group_id"]
1356 }
1357 },
1358 {
1359 "name": "clickup_role_list",
1360 "description": "List the custom roles defined in a ClickUp workspace (Member, Guest, Admin, Owner, plus any custom roles on Enterprise plans). Roles define baseline permissions assigned to users. Returns an array of role objects (id, name, members).",
1361 "inputSchema": {
1362 "type": "object",
1363 "properties": {
1364 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
1365 },
1366 "required": []
1367 }
1368 },
1369 {
1370 "name": "clickup_guest_get",
1371 "description": "Fetch the profile of a specific guest user in a ClickUp workspace — email, permissions (can_edit_tags, can_see_time_spent, can_create_views), and shared items. Guests are external collaborators with limited access. Requires Enterprise plan. Returns the guest object.",
1372 "inputSchema": {
1373 "type": "object",
1374 "properties": {
1375 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1376 "guest_id": {"type": "integer", "description": "Numeric guest user ID. Obtain from clickup_guest_invite (returns the new guest) or the guest's entry in a shared-item's members list."}
1377 },
1378 "required": ["guest_id"]
1379 }
1380 },
1381 {
1382 "name": "clickup_task_time_in_status",
1383 "description": "Report how long a task has spent in each status since creation (e.g. 3 days in 'open', 1 day in 'in review'). Useful for cycle-time analysis. Returns an object mapping status names to total-time and since-timestamp values (all times in milliseconds).",
1384 "inputSchema": {
1385 "type": "object",
1386 "properties": {
1387 "task_id": {"type": "string", "description": "ID of the task. Obtain from clickup_task_list (field: id) or clickup_task_search."}
1388 },
1389 "required": ["task_id"]
1390 }
1391 },
1392 {
1393 "name": "clickup_task_move",
1394 "description": "Move a task to a different list (change home list)",
1395 "inputSchema": {
1396 "type": "object",
1397 "properties": {
1398 "task_id": {"type": "string", "description": "Task ID"},
1399 "list_id": {"type": "string", "description": "Destination list ID"},
1400 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."}
1401 },
1402 "required": ["task_id", "list_id"]
1403 }
1404 },
1405 {
1406 "name": "clickup_task_set_estimate",
1407 "description": "Set a per-user time estimate on a ClickUp task. Additive — other users' estimates are untouched. To replace all user estimates at once use clickup_task_replace_estimates instead. Estimates are used in workload views and reports. Returns the updated task estimate object.",
1408 "inputSchema": {
1409 "type": "object",
1410 "properties": {
1411 "task_id": {"type": "string", "description": "ID of the task. Obtain from clickup_task_list (field: id)."},
1412 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1413 "user_id": {"type": "integer", "description": "Numeric ID of the user whose estimate to set. Obtain from clickup_member_list."},
1414 "time_estimate": {"type": "integer", "description": "Estimated effort in milliseconds (e.g. 3600000 = 1 hour, 28800000 = 8 hours)."}
1415 },
1416 "required": ["task_id", "user_id", "time_estimate"]
1417 }
1418 },
1419 {
1420 "name": "clickup_task_replace_estimates",
1421 "description": "Replace all time estimates for a task (PUT replaces all user estimates)",
1422 "inputSchema": {
1423 "type": "object",
1424 "properties": {
1425 "task_id": {"type": "string", "description": "Task ID"},
1426 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."},
1427 "user_id": {"type": "integer", "description": "User ID"},
1428 "time_estimate": {"type": "integer", "description": "Time estimate in milliseconds"}
1429 },
1430 "required": ["task_id", "user_id", "time_estimate"]
1431 }
1432 },
1433 {
1434 "name": "clickup_auth_check",
1435 "description": "Verify that the configured ClickUp API token is valid by hitting the /user endpoint. Returns an ok:true result if the token is accepted, or an error if it's missing, malformed, expired, or revoked. Use clickup_whoami instead to also get the authenticated user's profile.",
1436 "inputSchema": {
1437 "type": "object",
1438 "properties": {},
1439 "required": []
1440 }
1441 },
1442 {
1443 "name": "clickup_checklist_update",
1444 "description": "Rename a checklist or change its position among the task's checklists. Does not affect the checklist's items — use clickup_checklist_update_item / add_item / delete_item for those. Returns the updated checklist object.",
1445 "inputSchema": {
1446 "type": "object",
1447 "properties": {
1448 "checklist_id": {"type": "string", "description": "ID of the checklist to update. Obtain from clickup_task_get (field: checklists[].id)."},
1449 "name": {"type": "string", "description": "New display name for the checklist. Omit to keep current name."},
1450 "position": {"type": "integer", "description": "Zero-indexed position among the task's checklists (0 = first). Omit to keep current position."}
1451 },
1452 "required": ["checklist_id"]
1453 }
1454 },
1455 {
1456 "name": "clickup_comment_replies",
1457 "description": "List the threaded replies attached to a top-level ClickUp comment, oldest first. Returns an array of reply objects (id, comment_text, user, date). Use clickup_comment_reply to post a new reply to the thread.",
1458 "inputSchema": {
1459 "type": "object",
1460 "properties": {
1461 "comment_id": {"type": "string", "description": "ID of the parent comment. Obtain from clickup_comment_list (field: id)."}
1462 },
1463 "required": ["comment_id"]
1464 }
1465 },
1466 {
1467 "name": "clickup_comment_reply",
1468 "description": "Post a threaded reply under an existing ClickUp comment. Replies appear indented beneath the parent comment. Returns the created reply object including its new id. For a top-level comment, use clickup_comment_create instead.",
1469 "inputSchema": {
1470 "type": "object",
1471 "properties": {
1472 "comment_id": {"type": "string", "description": "ID of the parent comment to reply to. Obtain from clickup_comment_list (field: id)."},
1473 "text": {"type": "string", "description": "Reply body. Markdown and @mentions supported."},
1474 "assignee": {"type": "integer", "description": "Optional user ID to assign the reply to — they receive a notification. Obtain from clickup_member_list."}
1475 },
1476 "required": ["comment_id", "text"]
1477 }
1478 },
1479 {
1480 "name": "clickup_chat_channel_list",
1481 "description": "List all ClickUp Chat channels in a workspace that the authenticated user can see. Uses v3 cursor pagination. Returns an array of channel objects (id, name, visibility, topic, last_message_at). Use clickup_chat_channel_create to create new channels.",
1482 "inputSchema": {
1483 "type": "object",
1484 "properties": {
1485 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1486 "include_closed": {"type": "boolean", "description": "true = include archived/closed channels in the result; false or omitted = only active channels."}
1487 },
1488 "required": []
1489 }
1490 },
1491 {
1492 "name": "clickup_chat_channel_followers",
1493 "description": "List the users who follow (receive notifications from) a ClickUp Chat channel. Followers are a subset of members — a member may or may not be a follower. Returns an array of user objects.",
1494 "inputSchema": {
1495 "type": "object",
1496 "properties": {
1497 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1498 "channel_id": {"type": "string", "description": "ID of the channel. Obtain from clickup_chat_channel_list (field: id)."}
1499 },
1500 "required": ["channel_id"]
1501 }
1502 },
1503 {
1504 "name": "clickup_chat_channel_members",
1505 "description": "List the users who are members of a ClickUp Chat channel (can read and post). For notification-receivers only use clickup_chat_channel_followers. Returns an array of user objects (id, username, email).",
1506 "inputSchema": {
1507 "type": "object",
1508 "properties": {
1509 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1510 "channel_id": {"type": "string", "description": "ID of the channel. Obtain from clickup_chat_channel_list (field: id)."}
1511 },
1512 "required": ["channel_id"]
1513 }
1514 },
1515 {
1516 "name": "clickup_chat_message_update",
1517 "description": "Edit the body of an existing ClickUp Chat message. Only the author (or a workspace admin) can edit a message; others will get a 403. The supplied text replaces the existing body entirely. Returns the updated message object.",
1518 "inputSchema": {
1519 "type": "object",
1520 "properties": {
1521 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1522 "message_id": {"type": "string", "description": "ID of the message to edit. Obtain from clickup_chat_message_list (field: id) or clickup_chat_reply_list."},
1523 "text": {"type": "string", "description": "Replacement body for the message. Markdown, emoji, and @mentions supported. Overwrites the existing body entirely."}
1524 },
1525 "required": ["message_id", "text"]
1526 }
1527 },
1528 {
1529 "name": "clickup_chat_reaction_list",
1530 "description": "List the emoji reactions on a ClickUp Chat message grouped by emoji — each entry includes the emoji, count, and the users who reacted with it. Returns an array of reaction summary objects.",
1531 "inputSchema": {
1532 "type": "object",
1533 "properties": {
1534 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1535 "message_id": {"type": "string", "description": "ID of the message whose reactions to list. Obtain from clickup_chat_message_list (field: id)."}
1536 },
1537 "required": ["message_id"]
1538 }
1539 },
1540 {
1541 "name": "clickup_chat_reaction_add",
1542 "description": "Add an emoji reaction from the authenticated user to a ClickUp Chat message. If the user has already reacted with the same emoji, the call is a no-op. Returns an empty object on success.",
1543 "inputSchema": {
1544 "type": "object",
1545 "properties": {
1546 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1547 "message_id": {"type": "string", "description": "ID of the message to react to. Obtain from clickup_chat_message_list (field: id) or clickup_chat_reply_list."},
1548 "emoji": {"type": "string", "description": "Unicode emoji character to add (e.g. '👍', '🎉', '❤️'). Custom Slack-style shortcodes (':+1:') are not supported — use the raw emoji character."}
1549 },
1550 "required": ["message_id", "emoji"]
1551 }
1552 },
1553 {
1554 "name": "clickup_chat_reaction_remove",
1555 "description": "Remove the authenticated user's emoji reaction from a ClickUp Chat message. Only removes your own reaction — other users' reactions of the same emoji are preserved. No-op if you haven't reacted with the given emoji. Returns an empty object on success.",
1556 "inputSchema": {
1557 "type": "object",
1558 "properties": {
1559 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1560 "message_id": {"type": "string", "description": "ID of the message. Obtain from clickup_chat_message_list (field: id)."},
1561 "emoji": {"type": "string", "description": "The Unicode emoji character to remove (e.g. '👍'). Must match the exact emoji you reacted with."}
1562 },
1563 "required": ["message_id", "emoji"]
1564 }
1565 },
1566 {
1567 "name": "clickup_chat_reply_list",
1568 "description": "List the threaded replies attached to a top-level ClickUp Chat message, oldest first. Returns an array of reply objects. Use clickup_chat_reply_send to post a new reply.",
1569 "inputSchema": {
1570 "type": "object",
1571 "properties": {
1572 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1573 "message_id": {"type": "string", "description": "ID of the parent message. Obtain from clickup_chat_message_list (field: id)."}
1574 },
1575 "required": ["message_id"]
1576 }
1577 },
1578 {
1579 "name": "clickup_chat_reply_send",
1580 "description": "Post a threaded reply beneath an existing ClickUp Chat message. The reply appears in the message's thread panel. Returns the created reply object. Use clickup_chat_message_send for new top-level messages.",
1581 "inputSchema": {
1582 "type": "object",
1583 "properties": {
1584 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1585 "message_id": {"type": "string", "description": "ID of the parent message to reply to. Obtain from clickup_chat_message_list (field: id)."},
1586 "text": {"type": "string", "description": "Reply body. Markdown, emoji, and @mentions supported."}
1587 },
1588 "required": ["message_id", "text"]
1589 }
1590 },
1591 {
1592 "name": "clickup_chat_tagged_users",
1593 "description": "List the users explicitly @-mentioned (tagged) in a ClickUp Chat message body. Useful for reading who a message was addressed to. Returns an array of user objects.",
1594 "inputSchema": {
1595 "type": "object",
1596 "properties": {
1597 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1598 "message_id": {"type": "string", "description": "ID of the message. Obtain from clickup_chat_message_list (field: id)."}
1599 },
1600 "required": ["message_id"]
1601 }
1602 },
1603 {
1604 "name": "clickup_time_current",
1605 "description": "Get the currently running time tracking entry",
1606 "inputSchema": {
1607 "type": "object",
1608 "properties": {
1609 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."}
1610 },
1611 "required": []
1612 }
1613 },
1614 {
1615 "name": "clickup_time_tags",
1616 "description": "List all time entry tags for a workspace",
1617 "inputSchema": {
1618 "type": "object",
1619 "properties": {
1620 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."}
1621 },
1622 "required": []
1623 }
1624 },
1625 {
1626 "name": "clickup_time_add_tags",
1627 "description": "Apply one or more tags to one or more time tracking entries in a single call. Tags are created automatically if they don't yet exist in the workspace's time-entry tag set. Use clickup_time_tags to list existing tags. Returns an empty object on success.",
1628 "inputSchema": {
1629 "type": "object",
1630 "properties": {
1631 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1632 "entry_ids": {
1633 "type": "array",
1634 "items": {"type": "string"},
1635 "description": "IDs of the time entries to tag. Obtain from clickup_time_list (field: id)."
1636 },
1637 "tag_names": {
1638 "type": "array",
1639 "items": {"type": "string"},
1640 "description": "Tag names to apply. Created if they don't exist in the workspace's tag set."
1641 }
1642 },
1643 "required": ["entry_ids", "tag_names"]
1644 }
1645 },
1646 {
1647 "name": "clickup_time_remove_tags",
1648 "description": "Detach one or more tags from one or more time tracking entries in a single call. The tag definitions themselves remain in the workspace. No-op for entries not currently carrying the tag. Returns an empty object on success.",
1649 "inputSchema": {
1650 "type": "object",
1651 "properties": {
1652 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1653 "entry_ids": {
1654 "type": "array",
1655 "items": {"type": "string"},
1656 "description": "IDs of the time entries to untag. Obtain from clickup_time_list (field: id)."
1657 },
1658 "tag_names": {
1659 "type": "array",
1660 "items": {"type": "string"},
1661 "description": "Tag names to remove. Obtain from clickup_time_tags (field: name)."
1662 }
1663 },
1664 "required": ["entry_ids", "tag_names"]
1665 }
1666 },
1667 {
1668 "name": "clickup_time_rename_tag",
1669 "description": "Rename a time-entry tag across the entire workspace. All historical time entries carrying the old name are updated. Cannot change colour via this endpoint. Returns an empty object on success.",
1670 "inputSchema": {
1671 "type": "object",
1672 "properties": {
1673 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1674 "name": {"type": "string", "description": "Current name of the tag to rename. Obtain from clickup_time_tags (field: name)."},
1675 "new_name": {"type": "string", "description": "Replacement name for the tag. Must not collide with an existing time-entry tag."}
1676 },
1677 "required": ["name", "new_name"]
1678 }
1679 },
1680 {
1681 "name": "clickup_time_history",
1682 "description": "Fetch the audit history of edits made to a time tracking entry — every start/duration/description/billable change, the user who made it, and when. Useful for auditing. Returns an array of history event objects.",
1683 "inputSchema": {
1684 "type": "object",
1685 "properties": {
1686 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1687 "timer_id": {"type": "string", "description": "ID of the time entry. Obtain from clickup_time_list (field: id)."}
1688 },
1689 "required": ["timer_id"]
1690 }
1691 },
1692 {
1693 "name": "clickup_guest_invite",
1694 "description": "Invite a new external guest user to a ClickUp workspace by email. Guests have limited access and don't consume paid member seats (they use guest seats). The invitation email is sent automatically; the guest must accept before they can log in. Share specific items with them via clickup_guest_share_task / _share_list / _share_folder. Requires Enterprise plan. Returns the created guest object including its new id.",
1695 "inputSchema": {
1696 "type": "object",
1697 "properties": {
1698 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1699 "email": {"type": "string", "description": "Email address to send the invitation to. Must be a valid email that isn't already a member or guest of the workspace."},
1700 "can_edit_tags": {"type": "boolean", "description": "true = allow the guest to create/rename/delete tags on items shared with them; false or omitted = tag management denied."},
1701 "can_see_time_spent": {"type": "boolean", "description": "true = allow the guest to see time-tracking data on shared tasks; false or omitted = hidden."},
1702 "can_create_views": {"type": "boolean", "description": "true = allow the guest to create their own saved views on shared items; false or omitted = cannot create views."}
1703 },
1704 "required": ["email"]
1705 }
1706 },
1707 {
1708 "name": "clickup_guest_update",
1709 "description": "Update a ClickUp guest's workspace-wide capability flags (edit tags, see time spent, create views). Does not change which items are shared with them — use clickup_guest_share_* / _unshare_* for that. Requires Enterprise plan. Returns the updated guest object.",
1710 "inputSchema": {
1711 "type": "object",
1712 "properties": {
1713 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1714 "guest_id": {"type": "integer", "description": "Numeric guest user ID. Obtain from clickup_guest_get or from clickup_guest_invite (response.id)."},
1715 "can_edit_tags": {"type": "boolean", "description": "true = allow the guest to manage tags on shared items; false = deny. Omit to keep current value."},
1716 "can_see_time_spent": {"type": "boolean", "description": "true = guest can see time-tracking on shared tasks; false = hidden. Omit to keep current value."},
1717 "can_create_views": {"type": "boolean", "description": "true = guest can create saved views; false = cannot. Omit to keep current value."}
1718 },
1719 "required": ["guest_id"]
1720 }
1721 },
1722 {
1723 "name": "clickup_guest_remove",
1724 "description": "Permanently revoke a guest user's access to a ClickUp workspace. All share-records for the guest are deleted and they can no longer log in. Destructive and irreversible — to re-invite, use clickup_guest_invite (a new guest_id will be assigned). Requires Enterprise plan. Returns an empty object on success.",
1725 "inputSchema": {
1726 "type": "object",
1727 "properties": {
1728 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1729 "guest_id": {"type": "integer", "description": "Numeric guest user ID to remove. Obtain from clickup_guest_get or clickup_guest_invite. All their shared-item access is revoked."}
1730 },
1731 "required": ["guest_id"]
1732 }
1733 },
1734 {
1735 "name": "clickup_guest_share_task",
1736 "description": "Grant a ClickUp guest user access to a single task at a specified permission level. Scopes strictly to that task — subtasks and the parent list are not shared. Use clickup_guest_unshare_task to revoke. Requires Enterprise plan. Returns the updated guest object.",
1737 "inputSchema": {
1738 "type": "object",
1739 "properties": {
1740 "task_id": {"type": "string", "description": "ID of the task to share. Obtain from clickup_task_list (field: id) or clickup_task_search."},
1741 "guest_id": {"type": "integer", "description": "Numeric ID of the guest user. Obtain from clickup_guest_get or clickup_guest_invite (response.id)."},
1742 "permission": {"type": "string", "description": "Access level: 'read' (view only), 'comment' (view + comment), 'create' (comment + create subtasks), 'edit' (full edit rights on this task)."}
1743 },
1744 "required": ["task_id", "guest_id", "permission"]
1745 }
1746 },
1747 {
1748 "name": "clickup_guest_unshare_task",
1749 "description": "Revoke a guest's access to a task",
1750 "inputSchema": {
1751 "type": "object",
1752 "properties": {
1753 "task_id": {"type": "string", "description": "Task ID"},
1754 "guest_id": {"type": "integer", "description": "Guest user ID"}
1755 },
1756 "required": ["task_id", "guest_id"]
1757 }
1758 },
1759 {
1760 "name": "clickup_guest_share_list",
1761 "description": "Grant a ClickUp guest user access to a specific list at a chosen permission level. Guests are external collaborators (not paid workspace seats); this is how you scope what a guest can see/do. To revoke access later use clickup_guest_unshare_list. Requires Enterprise plan. Returns the updated guest object.",
1762 "inputSchema": {
1763 "type": "object",
1764 "properties": {
1765 "list_id": {"type": "string", "description": "ID of the list to share. Obtain from clickup_list_list (field: id)."},
1766 "guest_id": {"type": "integer", "description": "Numeric ID of the guest user. Obtain from clickup_guest_get or the response of clickup_guest_invite."},
1767 "permission": {"type": "string", "description": "Access level: 'read' (view only), 'comment' (view + comment), 'create' (comment + create tasks), 'edit' (full edit rights on existing items)."}
1768 },
1769 "required": ["list_id", "guest_id", "permission"]
1770 }
1771 },
1772 {
1773 "name": "clickup_guest_unshare_list",
1774 "description": "Revoke a guest user's access to a specific list. The guest keeps any separate task-level or folder-level grants they may also have. Destructive in that the guest immediately loses access, but the guest account itself remains — re-share with clickup_guest_share_list. Requires Enterprise plan. Returns the updated guest object.",
1775 "inputSchema": {
1776 "type": "object",
1777 "properties": {
1778 "list_id": {"type": "string", "description": "ID of the list whose access to revoke. Obtain from clickup_list_list (field: id)."},
1779 "guest_id": {"type": "integer", "description": "Numeric guest user ID. Obtain from clickup_guest_get or clickup_guest_invite."}
1780 },
1781 "required": ["list_id", "guest_id"]
1782 }
1783 },
1784 {
1785 "name": "clickup_guest_share_folder",
1786 "description": "Grant a ClickUp guest user access to an entire folder — including all its lists and tasks — at a specified permission level. Use clickup_guest_share_list or _share_task for narrower scope. Use clickup_guest_unshare_folder to revoke. Requires Enterprise plan. Returns the updated guest object.",
1787 "inputSchema": {
1788 "type": "object",
1789 "properties": {
1790 "folder_id": {"type": "string", "description": "ID of the folder to share. Obtain from clickup_folder_list (field: id). All descendant lists and tasks are accessible via this grant."},
1791 "guest_id": {"type": "integer", "description": "Numeric ID of the guest user. Obtain from clickup_guest_get or clickup_guest_invite (response.id)."},
1792 "permission": {"type": "string", "description": "Access level applied to every descendant: 'read' (view only), 'comment' (view + comment), 'create' (comment + create tasks), 'edit' (full edit rights)."}
1793 },
1794 "required": ["folder_id", "guest_id", "permission"]
1795 }
1796 },
1797 {
1798 "name": "clickup_guest_unshare_folder",
1799 "description": "Revoke a guest user's access to a folder (and, cascading, to every list and task under it granted via the folder). Separate list-level or task-level grants are preserved. Re-share later with clickup_guest_share_folder. Requires Enterprise plan. Returns the updated guest object.",
1800 "inputSchema": {
1801 "type": "object",
1802 "properties": {
1803 "folder_id": {"type": "string", "description": "ID of the folder whose access to revoke. Obtain from clickup_folder_list (field: id)."},
1804 "guest_id": {"type": "integer", "description": "Numeric guest user ID. Obtain from clickup_guest_get or clickup_guest_invite."}
1805 },
1806 "required": ["folder_id", "guest_id"]
1807 }
1808 },
1809 {
1810 "name": "clickup_user_invite",
1811 "description": "Invite a new paid member to a ClickUp workspace by email. Consumes a member seat (see clickup_workspace_seats for availability). For external collaborators who shouldn't have full access, use clickup_guest_invite instead. Returns the created user object.",
1812 "inputSchema": {
1813 "type": "object",
1814 "properties": {
1815 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1816 "email": {"type": "string", "description": "Email address to send the invitation to. Must be a valid email not already a member or guest of the workspace."},
1817 "admin": {"type": "boolean", "description": "true = grant the Admin role (can manage settings, billing, users); false or omitted = standard Member role."}
1818 },
1819 "required": ["email"]
1820 }
1821 },
1822 {
1823 "name": "clickup_user_update",
1824 "description": "Update a ClickUp workspace member's username and/or admin role. Only the authenticated user (if self) or a workspace admin can call this. To change per-item permissions use role-based or share endpoints instead. Returns the updated user object.",
1825 "inputSchema": {
1826 "type": "object",
1827 "properties": {
1828 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1829 "user_id": {"type": "integer", "description": "Numeric user ID to update. Obtain from clickup_member_list or clickup_user_get (field: id)."},
1830 "username": {"type": "string", "description": "New display name. Omit to keep current username."},
1831 "admin": {"type": "boolean", "description": "true = grant Admin role, false = revoke Admin (revert to Member). Omit to keep current role."}
1832 },
1833 "required": ["user_id"]
1834 }
1835 },
1836 {
1837 "name": "clickup_user_remove",
1838 "description": "Remove a member from a ClickUp workspace, freeing their paid seat. Destructive — their assignments and comments are preserved as historical records but they lose access immediately. To re-add, use clickup_user_invite (a new invitation will be sent). Returns an empty object on success.",
1839 "inputSchema": {
1840 "type": "object",
1841 "properties": {
1842 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1843 "user_id": {"type": "integer", "description": "Numeric user ID to remove. Obtain from clickup_member_list (field: id). Cannot remove the workspace Owner."}
1844 },
1845 "required": ["user_id"]
1846 }
1847 },
1848 {
1849 "name": "clickup_template_apply_task",
1850 "description": "Create a new task in a list by instantiating a saved task template. The new task inherits the template's description, checklists, subtasks, custom fields, etc., but uses the supplied name. Use clickup_template_list to discover templates. Returns the created task object.",
1851 "inputSchema": {
1852 "type": "object",
1853 "properties": {
1854 "list_id": {"type": "string", "description": "ID of the list to create the task in. Obtain from clickup_list_list (field: id)."},
1855 "template_id": {"type": "string", "description": "ID of the task template to instantiate. Obtain from clickup_template_list (field: id)."},
1856 "name": {"type": "string", "description": "Name for the newly-created task. Overrides the template's default name."}
1857 },
1858 "required": ["list_id", "template_id", "name"]
1859 }
1860 },
1861 {
1862 "name": "clickup_template_apply_list",
1863 "description": "Create a list from a list template in a folder or space",
1864 "inputSchema": {
1865 "type": "object",
1866 "properties": {
1867 "template_id": {"type": "string", "description": "Template ID"},
1868 "name": {"type": "string", "description": "New list name"},
1869 "folder_id": {"type": "string", "description": "Folder ID (mutually exclusive with space_id)"},
1870 "space_id": {"type": "string", "description": "Space ID (mutually exclusive with folder_id)"}
1871 },
1872 "required": ["template_id", "name"]
1873 }
1874 },
1875 {
1876 "name": "clickup_template_apply_folder",
1877 "description": "Create a new folder in a space by instantiating a saved folder template. The new folder inherits the template's list structure, statuses, default fields, and other presets, using the supplied name. Use clickup_template_list to discover templates. Returns the created folder object.",
1878 "inputSchema": {
1879 "type": "object",
1880 "properties": {
1881 "space_id": {"type": "string", "description": "ID of the parent space. Obtain from clickup_space_list (field: id)."},
1882 "template_id": {"type": "string", "description": "ID of the folder template to instantiate. Obtain from clickup_template_list (field: id)."},
1883 "name": {"type": "string", "description": "Name for the newly-created folder. Must be unique within the parent space."}
1884 },
1885 "required": ["space_id", "template_id", "name"]
1886 }
1887 },
1888 {
1889 "name": "clickup_attachment_upload",
1890 "description": "Upload a local file as an attachment on a ClickUp task. The file is read from disk, posted as multipart/form-data, and stored on ClickUp's CDN. Use clickup_attachment_list to see attachments afterward. Returns the created attachment object (id, title, size, url).",
1891 "inputSchema": {
1892 "type": "object",
1893 "properties": {
1894 "task_id": {"type": "string", "description": "ID of the task to attach the file to. Obtain from clickup_task_list (field: id)."},
1895 "file_path": {"type": "string", "description": "Absolute path to a readable file on the server running this MCP. The filename (basename) is used as the attachment title; size limits apply per workspace plan."}
1896 },
1897 "required": ["task_id", "file_path"]
1898 }
1899 },
1900 {
1901 "name": "clickup_task_type_list",
1902 "description": "List the custom task types (ClickUp 'Custom Items' — e.g. Bug, Epic, Feature) defined at the workspace level. Each has an id, name, and icon and can be chosen when creating tasks. Returns an array of custom item type objects.",
1903 "inputSchema": {
1904 "type": "object",
1905 "properties": {
1906 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."}
1907 },
1908 "required": []
1909 }
1910 },
1911 {
1912 "name": "clickup_doc_get_page",
1913 "description": "Fetch a single page from a ClickUp doc including its full markdown content, title, subtitle, and parent-page link. Use clickup_doc_pages to list all pages in a doc first. Returns the page object with content.",
1914 "inputSchema": {
1915 "type": "object",
1916 "properties": {
1917 "team_id": {"type": "string", "description": "Workspace (team) ID. Omit to use the default workspace from config."},
1918 "doc_id": {"type": "string", "description": "ID of the parent doc. Obtain from clickup_doc_list (field: id)."},
1919 "page_id": {"type": "string", "description": "ID of the page to fetch. Obtain from clickup_doc_pages (field: id)."}
1920 },
1921 "required": ["doc_id", "page_id"]
1922 }
1923 },
1924 {
1925 "name": "clickup_audit_log_query",
1926 "description": "Query the ClickUp audit log (who did what, when) for a workspace — filter by event type, acting user, and date range. Requires Enterprise plan. Uses v3 cursor pagination. Returns an array of audit event objects (actor, event, target, timestamp).",
1927 "inputSchema": {
1928 "type": "object",
1929 "properties": {
1930 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1931 "type": {"type": "string", "description": "Audit event type filter (e.g. 'task_created', 'user_added', 'permission_changed'). Required. See ClickUp docs for the full list."},
1932 "user_id": {"type": "integer", "description": "Restrict to events performed by this user ID. Obtain from clickup_member_list. Omit for all users."},
1933 "start_date": {"type": "integer", "description": "Inclusive lower bound as a Unix timestamp in milliseconds (e.g. 1735689600000 for 2025-01-01). Omit for no lower bound."},
1934 "end_date": {"type": "integer", "description": "Inclusive upper bound as a Unix timestamp in milliseconds. Omit for no upper bound."}
1935 },
1936 "required": ["type"]
1937 }
1938 },
1939 {
1940 "name": "clickup_acl_update",
1941 "description": "Change the privacy (ACL) of a ClickUp hierarchy object — make a space/folder/list private (explicit members only) or public (whole workspace). Uses the v3 ACL endpoint. Requires Enterprise plan. Returns the updated object.",
1942 "inputSchema": {
1943 "type": "object",
1944 "properties": {
1945 "team_id": {"type": "string", "description": "Workspace (team) ID. Obtain from clickup_workspace_list (field: id). Omit to use the default workspace from config."},
1946 "object_type": {"type": "string", "description": "Type of object to change: 'space', 'folder', or 'list'."},
1947 "object_id": {"type": "string", "description": "ID of the space/folder/list. Obtain from the matching list endpoint (clickup_space_list, clickup_folder_list, or clickup_list_list)."},
1948 "private": {"type": "boolean", "description": "true = make the object private (only explicit members see it); false = make it public (visible to the whole workspace)."}
1949 },
1950 "required": ["object_type", "object_id"]
1951 }
1952 }
1953 ])
1954}
1955
1956pub fn filtered_tool_list(filter: &filter::Filter) -> serde_json::Value {
1958 let all = tool_list();
1959 let filtered: Vec<serde_json::Value> = all
1960 .as_array()
1961 .map(|arr| {
1962 arr.iter()
1963 .filter(|tool| {
1964 tool.get("name")
1965 .and_then(|v| v.as_str())
1966 .map(|n| filter.allows(n))
1967 .unwrap_or(false)
1968 })
1969 .cloned()
1970 .collect()
1971 })
1972 .unwrap_or_default();
1973 serde_json::Value::Array(filtered)
1974}
1975
1976async fn call_tool(
1979 name: &str,
1980 args: &Value,
1981 client: &ClickUpClient,
1982 workspace_id: &Option<String>,
1983) -> Value {
1984 let result = dispatch_tool(name, args, client, workspace_id).await;
1985 match result {
1986 Ok(v) => tool_result(v.to_string()),
1987 Err(e) => tool_error(format!("Error: {}", e)),
1988 }
1989}
1990
1991async fn dispatch_tool(
1992 name: &str,
1993 args: &Value,
1994 client: &ClickUpClient,
1995 workspace_id: &Option<String>,
1996) -> Result<Value, String> {
1997 let empty = json!({});
1998 let args = if args.is_null() { &empty } else { args };
1999
2000 let resolve_workspace = |args: &Value| -> Result<String, String> {
2002 if let Some(id) = args.get("team_id").and_then(|v| v.as_str()) {
2003 return Ok(id.to_string());
2004 }
2005 workspace_id
2006 .clone()
2007 .ok_or_else(|| "No workspace_id found in config. Please run `clickup setup` or provide team_id in the tool arguments.".to_string())
2008 };
2009
2010 match name {
2011 "clickup_whoami" => {
2012 let resp = client.get("/v2/user").await.map_err(|e| e.to_string())?;
2013 let user = resp.get("user").cloned().unwrap_or(resp);
2014 Ok(compact_items(&[user], &["id", "username", "email"]))
2015 }
2016
2017 "clickup_workspace_list" => {
2018 let resp = client.get("/v2/team").await.map_err(|e| e.to_string())?;
2019 let teams = resp
2020 .get("teams")
2021 .and_then(|t| t.as_array())
2022 .cloned()
2023 .unwrap_or_default();
2024 let items: Vec<Value> = teams.iter().map(|ws| {
2025 json!({
2026 "id": ws.get("id"),
2027 "name": ws.get("name"),
2028 "members": ws.get("members").and_then(|m| m.as_array()).map(|a| a.len()).unwrap_or(0),
2029 })
2030 }).collect();
2031 Ok(compact_items(&items, &["id", "name", "members"]))
2032 }
2033
2034 "clickup_space_list" => {
2035 let team_id = resolve_workspace(args)?;
2036 let archived = args
2037 .get("archived")
2038 .and_then(|v| v.as_bool())
2039 .unwrap_or(false);
2040 let path = format!("/v2/team/{}/space?archived={}", team_id, archived);
2041 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2042 let spaces = resp
2043 .get("spaces")
2044 .and_then(|s| s.as_array())
2045 .cloned()
2046 .unwrap_or_default();
2047 Ok(compact_items(
2048 &spaces,
2049 &["id", "name", "private", "archived"],
2050 ))
2051 }
2052
2053 "clickup_folder_list" => {
2054 let space_id = args
2055 .get("space_id")
2056 .and_then(|v| v.as_str())
2057 .ok_or("Missing required parameter: space_id")?;
2058 let archived = args
2059 .get("archived")
2060 .and_then(|v| v.as_bool())
2061 .unwrap_or(false);
2062 let path = format!("/v2/space/{}/folder?archived={}", space_id, archived);
2063 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2064 let folders = resp
2065 .get("folders")
2066 .and_then(|f| f.as_array())
2067 .cloned()
2068 .unwrap_or_default();
2069 let items: Vec<Value> = folders
2070 .iter()
2071 .map(|f| {
2072 let list_count = f
2073 .get("lists")
2074 .and_then(|l| l.as_array())
2075 .map(|a| a.len())
2076 .unwrap_or(0);
2077 json!({
2078 "id": f.get("id"),
2079 "name": f.get("name"),
2080 "task_count": f.get("task_count"),
2081 "list_count": list_count,
2082 })
2083 })
2084 .collect();
2085 Ok(compact_items(
2086 &items,
2087 &["id", "name", "task_count", "list_count"],
2088 ))
2089 }
2090
2091 "clickup_list_list" => {
2092 let archived = args
2093 .get("archived")
2094 .and_then(|v| v.as_bool())
2095 .unwrap_or(false);
2096 let path = if let Some(folder_id) = args.get("folder_id").and_then(|v| v.as_str()) {
2097 format!("/v2/folder/{}/list?archived={}", folder_id, archived)
2098 } else if let Some(space_id) = args.get("space_id").and_then(|v| v.as_str()) {
2099 format!("/v2/space/{}/list?archived={}", space_id, archived)
2100 } else {
2101 return Err("Provide either folder_id or space_id".to_string());
2102 };
2103 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2104 let lists = resp
2105 .get("lists")
2106 .and_then(|l| l.as_array())
2107 .cloned()
2108 .unwrap_or_default();
2109 Ok(compact_items(
2110 &lists,
2111 &["id", "name", "task_count", "status", "due_date"],
2112 ))
2113 }
2114
2115 "clickup_task_list" => {
2116 let list_id = args
2117 .get("list_id")
2118 .and_then(|v| v.as_str())
2119 .ok_or("Missing required parameter: list_id")?;
2120 let mut qs = String::new();
2121 if let Some(include_closed) = args.get("include_closed").and_then(|v| v.as_bool()) {
2122 qs.push_str(&format!("&include_closed={}", include_closed));
2123 }
2124 if let Some(statuses) = args.get("statuses").and_then(|v| v.as_array()) {
2125 for s in statuses {
2126 if let Some(s) = s.as_str() {
2127 qs.push_str(&format!("&statuses[]={}", s));
2128 }
2129 }
2130 }
2131 if let Some(assignees) = args.get("assignees").and_then(|v| v.as_array()) {
2132 for a in assignees {
2133 if let Some(a) = a.as_str() {
2134 qs.push_str(&format!("&assignees[]={}", a));
2135 }
2136 }
2137 }
2138 let path = format!("/v2/list/{}/task?{}", list_id, qs.trim_start_matches('&'));
2139 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2140 let tasks = resp
2141 .get("tasks")
2142 .and_then(|t| t.as_array())
2143 .cloned()
2144 .unwrap_or_default();
2145 Ok(compact_items(
2146 &tasks,
2147 &["id", "name", "status", "priority", "assignees", "due_date"],
2148 ))
2149 }
2150
2151 "clickup_task_get" => {
2152 let task_id = args
2153 .get("task_id")
2154 .and_then(|v| v.as_str())
2155 .ok_or("Missing required parameter: task_id")?;
2156 let include_subtasks = args
2157 .get("include_subtasks")
2158 .and_then(|v| v.as_bool())
2159 .unwrap_or(false);
2160 let path = format!("/v2/task/{}?include_subtasks={}", task_id, include_subtasks);
2161 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2162 Ok(compact_items(
2163 &[resp],
2164 &[
2165 "id",
2166 "name",
2167 "status",
2168 "priority",
2169 "assignees",
2170 "due_date",
2171 "description",
2172 ],
2173 ))
2174 }
2175
2176 "clickup_task_create" => {
2177 let list_id = args
2178 .get("list_id")
2179 .and_then(|v| v.as_str())
2180 .ok_or("Missing required parameter: list_id")?;
2181 let name = args
2182 .get("name")
2183 .and_then(|v| v.as_str())
2184 .ok_or("Missing required parameter: name")?;
2185 let mut body = json!({"name": name});
2186 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
2187 body["description"] = json!(desc);
2188 }
2189 if let Some(status) = args.get("status").and_then(|v| v.as_str()) {
2190 body["status"] = json!(status);
2191 }
2192 if let Some(priority) = args.get("priority").and_then(|v| v.as_i64()) {
2193 body["priority"] = json!(priority);
2194 }
2195 if let Some(assignees) = args.get("assignees") {
2196 body["assignees"] = assignees.clone();
2197 }
2198 if let Some(tags) = args.get("tags") {
2199 body["tags"] = tags.clone();
2200 }
2201 if let Some(due_date) = args.get("due_date").and_then(|v| v.as_i64()) {
2202 body["due_date"] = json!(due_date);
2203 }
2204 let path = format!("/v2/list/{}/task", list_id);
2205 let resp = client.post(&path, &body).await.map_err(|e| e.to_string())?;
2206 Ok(compact_items(
2207 &[resp],
2208 &["id", "name", "status", "priority", "assignees", "due_date"],
2209 ))
2210 }
2211
2212 "clickup_task_update" => {
2213 let task_id = args
2214 .get("task_id")
2215 .and_then(|v| v.as_str())
2216 .ok_or("Missing required parameter: task_id")?;
2217 let mut body = json!({});
2218 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
2219 body["name"] = json!(name);
2220 }
2221 if let Some(status) = args.get("status").and_then(|v| v.as_str()) {
2222 body["status"] = json!(status);
2223 }
2224 if let Some(priority) = args.get("priority").and_then(|v| v.as_i64()) {
2225 body["priority"] = json!(priority);
2226 }
2227 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
2228 body["description"] = json!(desc);
2229 }
2230 if let Some(add) = args.get("add_assignees") {
2231 body["assignees"] = json!({"add": add, "rem": args.get("rem_assignees").cloned().unwrap_or(json!([]))});
2232 } else if let Some(rem) = args.get("rem_assignees") {
2233 body["assignees"] = json!({"add": [], "rem": rem});
2234 }
2235 let path = format!("/v2/task/{}", task_id);
2236 let resp = client.put(&path, &body).await.map_err(|e| e.to_string())?;
2237 Ok(compact_items(
2238 &[resp],
2239 &["id", "name", "status", "priority", "assignees", "due_date"],
2240 ))
2241 }
2242
2243 "clickup_task_delete" => {
2244 let task_id = args
2245 .get("task_id")
2246 .and_then(|v| v.as_str())
2247 .ok_or("Missing required parameter: task_id")?;
2248 let path = format!("/v2/task/{}", task_id);
2249 client.delete(&path).await.map_err(|e| e.to_string())?;
2250 Ok(json!({"message": format!("Task {} deleted", task_id)}))
2251 }
2252
2253 "clickup_task_search" => {
2254 let team_id = resolve_workspace(args)?;
2255 let mut qs = String::new();
2256 if let Some(space_ids) = args.get("space_ids").and_then(|v| v.as_array()) {
2257 for id in space_ids {
2258 if let Some(id) = id.as_str() {
2259 qs.push_str(&format!("&space_ids[]={}", id));
2260 }
2261 }
2262 }
2263 if let Some(list_ids) = args.get("list_ids").and_then(|v| v.as_array()) {
2264 for id in list_ids {
2265 if let Some(id) = id.as_str() {
2266 qs.push_str(&format!("&list_ids[]={}", id));
2267 }
2268 }
2269 }
2270 if let Some(statuses) = args.get("statuses").and_then(|v| v.as_array()) {
2271 for s in statuses {
2272 if let Some(s) = s.as_str() {
2273 qs.push_str(&format!("&statuses[]={}", s));
2274 }
2275 }
2276 }
2277 if let Some(assignees) = args.get("assignees").and_then(|v| v.as_array()) {
2278 for a in assignees {
2279 if let Some(a) = a.as_str() {
2280 qs.push_str(&format!("&assignees[]={}", a));
2281 }
2282 }
2283 }
2284 let path = format!("/v2/team/{}/task?{}", team_id, qs.trim_start_matches('&'));
2285 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2286 let tasks = resp
2287 .get("tasks")
2288 .and_then(|t| t.as_array())
2289 .cloned()
2290 .unwrap_or_default();
2291 Ok(compact_items(
2292 &tasks,
2293 &["id", "name", "status", "priority", "assignees", "due_date"],
2294 ))
2295 }
2296
2297 "clickup_comment_list" => {
2298 let task_id = args
2299 .get("task_id")
2300 .and_then(|v| v.as_str())
2301 .ok_or("Missing required parameter: task_id")?;
2302 let path = format!("/v2/task/{}/comment", task_id);
2303 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2304 let comments = resp
2305 .get("comments")
2306 .and_then(|c| c.as_array())
2307 .cloned()
2308 .unwrap_or_default();
2309 Ok(compact_items(
2310 &comments,
2311 &["id", "user", "date", "comment_text"],
2312 ))
2313 }
2314
2315 "clickup_comment_create" => {
2316 let task_id = args
2317 .get("task_id")
2318 .and_then(|v| v.as_str())
2319 .ok_or("Missing required parameter: task_id")?;
2320 let text = args
2321 .get("text")
2322 .and_then(|v| v.as_str())
2323 .ok_or("Missing required parameter: text")?;
2324 let mut body = json!({"comment_text": text});
2325 if let Some(assignee) = args.get("assignee").and_then(|v| v.as_i64()) {
2326 body["assignee"] = json!(assignee);
2327 }
2328 if let Some(notify_all) = args.get("notify_all").and_then(|v| v.as_bool()) {
2329 body["notify_all"] = json!(notify_all);
2330 }
2331 let path = format!("/v2/task/{}/comment", task_id);
2332 let resp = client.post(&path, &body).await.map_err(|e| e.to_string())?;
2333 Ok(json!({"message": "Comment created", "id": resp.get("id")}))
2334 }
2335
2336 "clickup_field_list" => {
2337 let list_id = args
2338 .get("list_id")
2339 .and_then(|v| v.as_str())
2340 .ok_or("Missing required parameter: list_id")?;
2341 let path = format!("/v2/list/{}/field", list_id);
2342 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2343 let fields = resp
2344 .get("fields")
2345 .and_then(|f| f.as_array())
2346 .cloned()
2347 .unwrap_or_default();
2348 Ok(compact_items(&fields, &["id", "name", "type", "required"]))
2349 }
2350
2351 "clickup_field_set" => {
2352 let task_id = args
2353 .get("task_id")
2354 .and_then(|v| v.as_str())
2355 .ok_or("Missing required parameter: task_id")?;
2356 let field_id = args
2357 .get("field_id")
2358 .and_then(|v| v.as_str())
2359 .ok_or("Missing required parameter: field_id")?;
2360 let value = args
2361 .get("value")
2362 .ok_or("Missing required parameter: value")?;
2363 let body = json!({"value": value});
2364 let path = format!("/v2/task/{}/field/{}", task_id, field_id);
2365 client.post(&path, &body).await.map_err(|e| e.to_string())?;
2366 Ok(json!({"message": format!("Field {} set on task {}", field_id, task_id)}))
2367 }
2368
2369 "clickup_time_start" => {
2370 let team_id = resolve_workspace(args)?;
2371 let mut body = json!({});
2372 if let Some(task_id) = args.get("task_id").and_then(|v| v.as_str()) {
2373 body["tid"] = json!(task_id);
2374 }
2375 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
2376 body["description"] = json!(desc);
2377 }
2378 if let Some(billable) = args.get("billable").and_then(|v| v.as_bool()) {
2379 body["billable"] = json!(billable);
2380 }
2381 let path = format!("/v2/team/{}/time_entries/start", team_id);
2382 let resp = client.post(&path, &body).await.map_err(|e| e.to_string())?;
2383 let data = resp.get("data").cloned().unwrap_or(resp);
2384 Ok(compact_items(
2385 &[data],
2386 &["id", "task", "duration", "start", "billable"],
2387 ))
2388 }
2389
2390 "clickup_time_stop" => {
2391 let team_id = resolve_workspace(args)?;
2392 let path = format!("/v2/team/{}/time_entries/stop", team_id);
2393 let resp = client
2394 .post(&path, &json!({}))
2395 .await
2396 .map_err(|e| e.to_string())?;
2397 let data = resp.get("data").cloned().unwrap_or(resp);
2398 Ok(compact_items(
2399 &[data],
2400 &["id", "task", "duration", "start", "end", "billable"],
2401 ))
2402 }
2403
2404 "clickup_time_list" => {
2405 let team_id = resolve_workspace(args)?;
2406 let mut qs = String::new();
2407 if let Some(start_date) = args.get("start_date").and_then(|v| v.as_i64()) {
2408 qs.push_str(&format!("&start_date={}", start_date));
2409 }
2410 if let Some(end_date) = args.get("end_date").and_then(|v| v.as_i64()) {
2411 qs.push_str(&format!("&end_date={}", end_date));
2412 }
2413 if let Some(task_id) = args.get("task_id").and_then(|v| v.as_str()) {
2414 qs.push_str(&format!("&task_id={}", task_id));
2415 }
2416 let path = format!(
2417 "/v2/team/{}/time_entries?{}",
2418 team_id,
2419 qs.trim_start_matches('&')
2420 );
2421 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2422 let entries = resp
2423 .get("data")
2424 .and_then(|d| d.as_array())
2425 .cloned()
2426 .unwrap_or_default();
2427 Ok(compact_items(
2428 &entries,
2429 &["id", "task", "duration", "start", "billable"],
2430 ))
2431 }
2432
2433 "clickup_checklist_create" => {
2434 let task_id = args
2435 .get("task_id")
2436 .and_then(|v| v.as_str())
2437 .ok_or("Missing required parameter: task_id")?;
2438 let name = args
2439 .get("name")
2440 .and_then(|v| v.as_str())
2441 .ok_or("Missing required parameter: name")?;
2442 let path = format!("/v2/task/{}/checklist", task_id);
2443 let body = json!({"name": name});
2444 let resp = client.post(&path, &body).await.map_err(|e| e.to_string())?;
2445 let checklist = resp.get("checklist").cloned().unwrap_or(resp);
2446 Ok(compact_items(&[checklist], &["id", "name"]))
2447 }
2448
2449 "clickup_checklist_delete" => {
2450 let checklist_id = args
2451 .get("checklist_id")
2452 .and_then(|v| v.as_str())
2453 .ok_or("Missing required parameter: checklist_id")?;
2454 let path = format!("/v2/checklist/{}", checklist_id);
2455 client.delete(&path).await.map_err(|e| e.to_string())?;
2456 Ok(json!({"message": format!("Checklist {} deleted", checklist_id)}))
2457 }
2458
2459 "clickup_goal_list" => {
2460 let team_id = resolve_workspace(args)?;
2461 let path = format!("/v2/team/{}/goal", team_id);
2462 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2463 let goals = resp
2464 .get("goals")
2465 .and_then(|g| g.as_array())
2466 .cloned()
2467 .unwrap_or_default();
2468 Ok(compact_items(
2469 &goals,
2470 &["id", "name", "percent_completed", "due_date"],
2471 ))
2472 }
2473
2474 "clickup_goal_get" => {
2475 let goal_id = args
2476 .get("goal_id")
2477 .and_then(|v| v.as_str())
2478 .ok_or("Missing required parameter: goal_id")?;
2479 let path = format!("/v2/goal/{}", goal_id);
2480 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2481 let goal = resp.get("goal").cloned().unwrap_or(resp);
2482 Ok(compact_items(
2483 &[goal],
2484 &["id", "name", "percent_completed", "due_date", "description"],
2485 ))
2486 }
2487
2488 "clickup_goal_create" => {
2489 let team_id = resolve_workspace(args)?;
2490 let name = args
2491 .get("name")
2492 .and_then(|v| v.as_str())
2493 .ok_or("Missing required parameter: name")?;
2494 let mut body = json!({"name": name});
2495 if let Some(due_date) = args.get("due_date").and_then(|v| v.as_i64()) {
2496 body["due_date"] = json!(due_date);
2497 }
2498 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
2499 body["description"] = json!(desc);
2500 }
2501 if let Some(owner_ids) = args.get("owner_ids") {
2502 body["owners"] = owner_ids.clone();
2503 }
2504 let path = format!("/v2/team/{}/goal", team_id);
2505 let resp = client.post(&path, &body).await.map_err(|e| e.to_string())?;
2506 let goal = resp.get("goal").cloned().unwrap_or(resp);
2507 Ok(compact_items(&[goal], &["id", "name"]))
2508 }
2509
2510 "clickup_goal_update" => {
2511 let goal_id = args
2512 .get("goal_id")
2513 .and_then(|v| v.as_str())
2514 .ok_or("Missing required parameter: goal_id")?;
2515 let mut body = json!({});
2516 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
2517 body["name"] = json!(name);
2518 }
2519 if let Some(due_date) = args.get("due_date").and_then(|v| v.as_i64()) {
2520 body["due_date"] = json!(due_date);
2521 }
2522 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
2523 body["description"] = json!(desc);
2524 }
2525 let path = format!("/v2/goal/{}", goal_id);
2526 let resp = client.put(&path, &body).await.map_err(|e| e.to_string())?;
2527 let goal = resp.get("goal").cloned().unwrap_or(resp);
2528 Ok(compact_items(&[goal], &["id", "name"]))
2529 }
2530
2531 "clickup_view_list" => {
2532 let path = if let Some(space_id) = args.get("space_id").and_then(|v| v.as_str()) {
2533 format!("/v2/space/{}/view", space_id)
2534 } else if let Some(folder_id) = args.get("folder_id").and_then(|v| v.as_str()) {
2535 format!("/v2/folder/{}/view", folder_id)
2536 } else if let Some(list_id) = args.get("list_id").and_then(|v| v.as_str()) {
2537 format!("/v2/list/{}/view", list_id)
2538 } else {
2539 let team_id = resolve_workspace(args)?;
2540 format!("/v2/team/{}/view", team_id)
2541 };
2542 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2543 let views = resp
2544 .get("views")
2545 .and_then(|v| v.as_array())
2546 .cloned()
2547 .unwrap_or_default();
2548 Ok(compact_items(&views, &["id", "name", "type"]))
2549 }
2550
2551 "clickup_view_tasks" => {
2552 let view_id = args
2553 .get("view_id")
2554 .and_then(|v| v.as_str())
2555 .ok_or("Missing required parameter: view_id")?;
2556 let page = args.get("page").and_then(|v| v.as_i64()).unwrap_or(0);
2557 let path = format!("/v2/view/{}/task?page={}", view_id, page);
2558 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2559 let tasks = resp
2560 .get("tasks")
2561 .and_then(|t| t.as_array())
2562 .cloned()
2563 .unwrap_or_default();
2564 Ok(compact_items(
2565 &tasks,
2566 &["id", "name", "status", "priority", "assignees", "due_date"],
2567 ))
2568 }
2569
2570 "clickup_doc_list" => {
2571 let team_id = resolve_workspace(args)?;
2572 let path = format!("/v3/workspaces/{}/docs", team_id);
2573 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2574 let docs = resp
2575 .get("docs")
2576 .and_then(|d| d.as_array())
2577 .cloned()
2578 .unwrap_or_default();
2579 Ok(compact_items(&docs, &["id", "name", "date_created"]))
2580 }
2581
2582 "clickup_doc_get" => {
2583 let team_id = resolve_workspace(args)?;
2584 let doc_id = args
2585 .get("doc_id")
2586 .and_then(|v| v.as_str())
2587 .ok_or("Missing required parameter: doc_id")?;
2588 let path = format!("/v3/workspaces/{}/docs/{}", team_id, doc_id);
2589 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2590 Ok(compact_items(&[resp], &["id", "name", "date_created"]))
2591 }
2592
2593 "clickup_doc_pages" => {
2594 let team_id = resolve_workspace(args)?;
2595 let doc_id = args
2596 .get("doc_id")
2597 .and_then(|v| v.as_str())
2598 .ok_or("Missing required parameter: doc_id")?;
2599 let content = args
2600 .get("content")
2601 .and_then(|v| v.as_bool())
2602 .unwrap_or(false);
2603 let path = format!("/v3/workspaces/{}/docs/{}/pages?content_format=text/md&max_page_depth=-1&include_content={}", team_id, doc_id, content);
2604 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2605 let pages = resp
2606 .get("pages")
2607 .and_then(|p| p.as_array())
2608 .cloned()
2609 .unwrap_or_default();
2610 Ok(compact_items(&pages, &["id", "name"]))
2611 }
2612
2613 "clickup_tag_list" => {
2614 let space_id = args
2615 .get("space_id")
2616 .and_then(|v| v.as_str())
2617 .ok_or("Missing required parameter: space_id")?;
2618 let path = format!("/v2/space/{}/tag", space_id);
2619 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2620 let tags = resp
2621 .get("tags")
2622 .and_then(|t| t.as_array())
2623 .cloned()
2624 .unwrap_or_default();
2625 Ok(compact_items(&tags, &["name", "tag_fg", "tag_bg"]))
2626 }
2627
2628 "clickup_task_add_tag" => {
2629 let task_id = args
2630 .get("task_id")
2631 .and_then(|v| v.as_str())
2632 .ok_or("Missing required parameter: task_id")?;
2633 let tag_name = args
2634 .get("tag_name")
2635 .and_then(|v| v.as_str())
2636 .ok_or("Missing required parameter: tag_name")?;
2637 let path = format!("/v2/task/{}/tag/{}", task_id, tag_name);
2638 client
2639 .post(&path, &json!({}))
2640 .await
2641 .map_err(|e| e.to_string())?;
2642 Ok(json!({"message": format!("Tag '{}' added to task {}", tag_name, task_id)}))
2643 }
2644
2645 "clickup_task_remove_tag" => {
2646 let task_id = args
2647 .get("task_id")
2648 .and_then(|v| v.as_str())
2649 .ok_or("Missing required parameter: task_id")?;
2650 let tag_name = args
2651 .get("tag_name")
2652 .and_then(|v| v.as_str())
2653 .ok_or("Missing required parameter: tag_name")?;
2654 let path = format!("/v2/task/{}/tag/{}", task_id, tag_name);
2655 client.delete(&path).await.map_err(|e| e.to_string())?;
2656 Ok(json!({"message": format!("Tag '{}' removed from task {}", tag_name, task_id)}))
2657 }
2658
2659 "clickup_webhook_list" => {
2660 let team_id = resolve_workspace(args)?;
2661 let path = format!("/v2/team/{}/webhook", team_id);
2662 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2663 let webhooks = resp
2664 .get("webhooks")
2665 .and_then(|w| w.as_array())
2666 .cloned()
2667 .unwrap_or_default();
2668 Ok(compact_items(
2669 &webhooks,
2670 &["id", "endpoint", "events", "status"],
2671 ))
2672 }
2673
2674 "clickup_member_list" => {
2675 let path = if let Some(task_id) = args.get("task_id").and_then(|v| v.as_str()) {
2676 format!("/v2/task/{}/member", task_id)
2677 } else if let Some(list_id) = args.get("list_id").and_then(|v| v.as_str()) {
2678 format!("/v2/list/{}/member", list_id)
2679 } else {
2680 return Err("Provide either task_id or list_id".to_string());
2681 };
2682 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2683 let members = resp
2684 .get("members")
2685 .and_then(|m| m.as_array())
2686 .cloned()
2687 .unwrap_or_default();
2688 Ok(compact_items(&members, &["id", "username", "email"]))
2689 }
2690
2691 "clickup_template_list" => {
2692 let team_id = resolve_workspace(args)?;
2693 let page = args.get("page").and_then(|v| v.as_i64()).unwrap_or(0);
2694 let path = format!("/v2/team/{}/taskTemplate?page={}", team_id, page);
2695 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
2696 let templates = resp
2697 .get("templates")
2698 .and_then(|t| t.as_array())
2699 .cloned()
2700 .unwrap_or_default();
2701 Ok(compact_items(&templates, &["id", "name"]))
2702 }
2703
2704 "clickup_space_get" => {
2705 let space_id = args
2706 .get("space_id")
2707 .and_then(|v| v.as_str())
2708 .ok_or("Missing required parameter: space_id")?;
2709 let resp = client
2710 .get(&format!("/v2/space/{}", space_id))
2711 .await
2712 .map_err(|e| e.to_string())?;
2713 Ok(compact_items(
2714 &[resp],
2715 &["id", "name", "private", "archived"],
2716 ))
2717 }
2718
2719 "clickup_space_create" => {
2720 let team_id = resolve_workspace(args)?;
2721 let name = args
2722 .get("name")
2723 .and_then(|v| v.as_str())
2724 .ok_or("Missing required parameter: name")?;
2725 let mut body = json!({"name": name});
2726 if let Some(private) = args.get("private").and_then(|v| v.as_bool()) {
2727 body["private"] = json!(private);
2728 }
2729 let resp = client
2730 .post(&format!("/v2/team/{}/space", team_id), &body)
2731 .await
2732 .map_err(|e| e.to_string())?;
2733 Ok(compact_items(&[resp], &["id", "name", "private"]))
2734 }
2735
2736 "clickup_space_update" => {
2737 let space_id = args
2738 .get("space_id")
2739 .and_then(|v| v.as_str())
2740 .ok_or("Missing required parameter: space_id")?;
2741 let mut body = json!({});
2742 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
2743 body["name"] = json!(name);
2744 }
2745 if let Some(private) = args.get("private").and_then(|v| v.as_bool()) {
2746 body["private"] = json!(private);
2747 }
2748 if let Some(archived) = args.get("archived").and_then(|v| v.as_bool()) {
2749 body["archived"] = json!(archived);
2750 }
2751 let resp = client
2752 .put(&format!("/v2/space/{}", space_id), &body)
2753 .await
2754 .map_err(|e| e.to_string())?;
2755 Ok(compact_items(
2756 &[resp],
2757 &["id", "name", "private", "archived"],
2758 ))
2759 }
2760
2761 "clickup_space_delete" => {
2762 let space_id = args
2763 .get("space_id")
2764 .and_then(|v| v.as_str())
2765 .ok_or("Missing required parameter: space_id")?;
2766 client
2767 .delete(&format!("/v2/space/{}", space_id))
2768 .await
2769 .map_err(|e| e.to_string())?;
2770 Ok(json!({"message": format!("Space {} deleted", space_id)}))
2771 }
2772
2773 "clickup_folder_get" => {
2774 let folder_id = args
2775 .get("folder_id")
2776 .and_then(|v| v.as_str())
2777 .ok_or("Missing required parameter: folder_id")?;
2778 let resp = client
2779 .get(&format!("/v2/folder/{}", folder_id))
2780 .await
2781 .map_err(|e| e.to_string())?;
2782 Ok(compact_items(&[resp], &["id", "name", "task_count"]))
2783 }
2784
2785 "clickup_folder_create" => {
2786 let space_id = args
2787 .get("space_id")
2788 .and_then(|v| v.as_str())
2789 .ok_or("Missing required parameter: space_id")?;
2790 let name = args
2791 .get("name")
2792 .and_then(|v| v.as_str())
2793 .ok_or("Missing required parameter: name")?;
2794 let body = json!({"name": name});
2795 let resp = client
2796 .post(&format!("/v2/space/{}/folder", space_id), &body)
2797 .await
2798 .map_err(|e| e.to_string())?;
2799 Ok(compact_items(&[resp], &["id", "name"]))
2800 }
2801
2802 "clickup_folder_update" => {
2803 let folder_id = args
2804 .get("folder_id")
2805 .and_then(|v| v.as_str())
2806 .ok_or("Missing required parameter: folder_id")?;
2807 let name = args
2808 .get("name")
2809 .and_then(|v| v.as_str())
2810 .ok_or("Missing required parameter: name")?;
2811 let body = json!({"name": name});
2812 let resp = client
2813 .put(&format!("/v2/folder/{}", folder_id), &body)
2814 .await
2815 .map_err(|e| e.to_string())?;
2816 Ok(compact_items(&[resp], &["id", "name"]))
2817 }
2818
2819 "clickup_folder_delete" => {
2820 let folder_id = args
2821 .get("folder_id")
2822 .and_then(|v| v.as_str())
2823 .ok_or("Missing required parameter: folder_id")?;
2824 client
2825 .delete(&format!("/v2/folder/{}", folder_id))
2826 .await
2827 .map_err(|e| e.to_string())?;
2828 Ok(json!({"message": format!("Folder {} deleted", folder_id)}))
2829 }
2830
2831 "clickup_list_get" => {
2832 let list_id = args
2833 .get("list_id")
2834 .and_then(|v| v.as_str())
2835 .ok_or("Missing required parameter: list_id")?;
2836 let resp = client
2837 .get(&format!("/v2/list/{}", list_id))
2838 .await
2839 .map_err(|e| e.to_string())?;
2840 Ok(compact_items(
2841 &[resp],
2842 &["id", "name", "task_count", "status", "due_date"],
2843 ))
2844 }
2845
2846 "clickup_list_create" => {
2847 let name = args
2848 .get("name")
2849 .and_then(|v| v.as_str())
2850 .ok_or("Missing required parameter: name")?;
2851 let mut body = json!({"name": name});
2852 if let Some(content) = args.get("content").and_then(|v| v.as_str()) {
2853 body["content"] = json!(content);
2854 }
2855 if let Some(due_date) = args.get("due_date").and_then(|v| v.as_i64()) {
2856 body["due_date"] = json!(due_date);
2857 }
2858 if let Some(status) = args.get("status").and_then(|v| v.as_str()) {
2859 body["status"] = json!(status);
2860 }
2861 let path = if let Some(folder_id) = args.get("folder_id").and_then(|v| v.as_str()) {
2862 format!("/v2/folder/{}/list", folder_id)
2863 } else if let Some(space_id) = args.get("space_id").and_then(|v| v.as_str()) {
2864 format!("/v2/space/{}/list", space_id)
2865 } else {
2866 return Err("Provide either folder_id or space_id".to_string());
2867 };
2868 let resp = client.post(&path, &body).await.map_err(|e| e.to_string())?;
2869 Ok(compact_items(&[resp], &["id", "name"]))
2870 }
2871
2872 "clickup_list_update" => {
2873 let list_id = args
2874 .get("list_id")
2875 .and_then(|v| v.as_str())
2876 .ok_or("Missing required parameter: list_id")?;
2877 let mut body = json!({});
2878 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
2879 body["name"] = json!(name);
2880 }
2881 if let Some(content) = args.get("content").and_then(|v| v.as_str()) {
2882 body["content"] = json!(content);
2883 }
2884 if let Some(due_date) = args.get("due_date").and_then(|v| v.as_i64()) {
2885 body["due_date"] = json!(due_date);
2886 }
2887 if let Some(status) = args.get("status").and_then(|v| v.as_str()) {
2888 body["status"] = json!(status);
2889 }
2890 let resp = client
2891 .put(&format!("/v2/list/{}", list_id), &body)
2892 .await
2893 .map_err(|e| e.to_string())?;
2894 Ok(compact_items(
2895 &[resp],
2896 &["id", "name", "task_count", "status"],
2897 ))
2898 }
2899
2900 "clickup_list_delete" => {
2901 let list_id = args
2902 .get("list_id")
2903 .and_then(|v| v.as_str())
2904 .ok_or("Missing required parameter: list_id")?;
2905 client
2906 .delete(&format!("/v2/list/{}", list_id))
2907 .await
2908 .map_err(|e| e.to_string())?;
2909 Ok(json!({"message": format!("List {} deleted", list_id)}))
2910 }
2911
2912 "clickup_list_add_task" => {
2913 let list_id = args
2914 .get("list_id")
2915 .and_then(|v| v.as_str())
2916 .ok_or("Missing required parameter: list_id")?;
2917 let task_id = args
2918 .get("task_id")
2919 .and_then(|v| v.as_str())
2920 .ok_or("Missing required parameter: task_id")?;
2921 client
2922 .post(
2923 &format!("/v2/list/{}/task/{}", list_id, task_id),
2924 &json!({}),
2925 )
2926 .await
2927 .map_err(|e| e.to_string())?;
2928 Ok(json!({"message": format!("Task {} added to list {}", task_id, list_id)}))
2929 }
2930
2931 "clickup_list_remove_task" => {
2932 let list_id = args
2933 .get("list_id")
2934 .and_then(|v| v.as_str())
2935 .ok_or("Missing required parameter: list_id")?;
2936 let task_id = args
2937 .get("task_id")
2938 .and_then(|v| v.as_str())
2939 .ok_or("Missing required parameter: task_id")?;
2940 client
2941 .delete(&format!("/v2/list/{}/task/{}", list_id, task_id))
2942 .await
2943 .map_err(|e| e.to_string())?;
2944 Ok(json!({"message": format!("Task {} removed from list {}", task_id, list_id)}))
2945 }
2946
2947 "clickup_comment_update" => {
2948 let comment_id = args
2949 .get("comment_id")
2950 .and_then(|v| v.as_str())
2951 .ok_or("Missing required parameter: comment_id")?;
2952 let text = args
2953 .get("text")
2954 .and_then(|v| v.as_str())
2955 .ok_or("Missing required parameter: text")?;
2956 let mut body = json!({"comment_text": text});
2957 if let Some(assignee) = args.get("assignee").and_then(|v| v.as_i64()) {
2958 body["assignee"] = json!(assignee);
2959 }
2960 if let Some(resolved) = args.get("resolved").and_then(|v| v.as_bool()) {
2961 body["resolved"] = json!(resolved);
2962 }
2963 client
2964 .put(&format!("/v2/comment/{}", comment_id), &body)
2965 .await
2966 .map_err(|e| e.to_string())?;
2967 Ok(json!({"message": format!("Comment {} updated", comment_id)}))
2968 }
2969
2970 "clickup_comment_delete" => {
2971 let comment_id = args
2972 .get("comment_id")
2973 .and_then(|v| v.as_str())
2974 .ok_or("Missing required parameter: comment_id")?;
2975 client
2976 .delete(&format!("/v2/comment/{}", comment_id))
2977 .await
2978 .map_err(|e| e.to_string())?;
2979 Ok(json!({"message": format!("Comment {} deleted", comment_id)}))
2980 }
2981
2982 "clickup_task_add_dep" => {
2983 let task_id = args
2984 .get("task_id")
2985 .and_then(|v| v.as_str())
2986 .ok_or("Missing required parameter: task_id")?;
2987 let mut body = json!({});
2988 if let Some(dep) = args.get("depends_on").and_then(|v| v.as_str()) {
2989 body["depends_on"] = json!(dep);
2990 }
2991 if let Some(dep) = args.get("dependency_of").and_then(|v| v.as_str()) {
2992 body["dependency_of"] = json!(dep);
2993 }
2994 client
2995 .post(&format!("/v2/task/{}/dependency", task_id), &body)
2996 .await
2997 .map_err(|e| e.to_string())?;
2998 Ok(json!({"message": format!("Dependency added to task {}", task_id)}))
2999 }
3000
3001 "clickup_task_remove_dep" => {
3002 let task_id = args
3003 .get("task_id")
3004 .and_then(|v| v.as_str())
3005 .ok_or("Missing required parameter: task_id")?;
3006 let mut body = json!({});
3007 if let Some(dep) = args.get("depends_on").and_then(|v| v.as_str()) {
3008 body["depends_on"] = json!(dep);
3009 }
3010 if let Some(dep) = args.get("dependency_of").and_then(|v| v.as_str()) {
3011 body["dependency_of"] = json!(dep);
3012 }
3013 client
3014 .delete_with_body(&format!("/v2/task/{}/dependency", task_id), &body)
3015 .await
3016 .map_err(|e| e.to_string())?;
3017 Ok(json!({"message": format!("Dependency removed from task {}", task_id)}))
3018 }
3019
3020 "clickup_task_link" => {
3021 let task_id = args
3022 .get("task_id")
3023 .and_then(|v| v.as_str())
3024 .ok_or("Missing required parameter: task_id")?;
3025 let links_to = args
3026 .get("links_to")
3027 .and_then(|v| v.as_str())
3028 .ok_or("Missing required parameter: links_to")?;
3029 let resp = client
3030 .post(
3031 &format!("/v2/task/{}/link/{}", task_id, links_to),
3032 &json!({}),
3033 )
3034 .await
3035 .map_err(|e| e.to_string())?;
3036 Ok(json!({"message": format!("Task {} linked to {}", task_id, links_to), "data": resp}))
3037 }
3038
3039 "clickup_task_unlink" => {
3040 let task_id = args
3041 .get("task_id")
3042 .and_then(|v| v.as_str())
3043 .ok_or("Missing required parameter: task_id")?;
3044 let links_to = args
3045 .get("links_to")
3046 .and_then(|v| v.as_str())
3047 .ok_or("Missing required parameter: links_to")?;
3048 client
3049 .delete(&format!("/v2/task/{}/link/{}", task_id, links_to))
3050 .await
3051 .map_err(|e| e.to_string())?;
3052 Ok(json!({"message": format!("Task {} unlinked from {}", task_id, links_to)}))
3053 }
3054
3055 "clickup_goal_delete" => {
3056 let goal_id = args
3057 .get("goal_id")
3058 .and_then(|v| v.as_str())
3059 .ok_or("Missing required parameter: goal_id")?;
3060 client
3061 .delete(&format!("/v2/goal/{}", goal_id))
3062 .await
3063 .map_err(|e| e.to_string())?;
3064 Ok(json!({"message": format!("Goal {} deleted", goal_id)}))
3065 }
3066
3067 "clickup_goal_add_kr" => {
3068 let goal_id = args
3069 .get("goal_id")
3070 .and_then(|v| v.as_str())
3071 .ok_or("Missing required parameter: goal_id")?;
3072 let name = args
3073 .get("name")
3074 .and_then(|v| v.as_str())
3075 .ok_or("Missing required parameter: name")?;
3076 let kr_type = args
3077 .get("type")
3078 .and_then(|v| v.as_str())
3079 .ok_or("Missing required parameter: type")?;
3080 let steps_start = args
3081 .get("steps_start")
3082 .and_then(|v| v.as_f64())
3083 .ok_or("Missing required parameter: steps_start")?;
3084 let steps_end = args
3085 .get("steps_end")
3086 .and_then(|v| v.as_f64())
3087 .ok_or("Missing required parameter: steps_end")?;
3088 let mut body = json!({"name": name, "type": kr_type, "steps_start": steps_start, "steps_end": steps_end});
3089 if let Some(unit) = args.get("unit").and_then(|v| v.as_str()) {
3090 body["unit"] = json!(unit);
3091 }
3092 if let Some(owners) = args.get("owner_ids") {
3093 body["owners"] = owners.clone();
3094 }
3095 if let Some(task_ids) = args.get("task_ids") {
3096 body["task_ids"] = task_ids.clone();
3097 }
3098 if let Some(list_ids) = args.get("list_ids") {
3099 body["list_ids"] = list_ids.clone();
3100 }
3101 let resp = client
3102 .post(&format!("/v2/goal/{}/key_result", goal_id), &body)
3103 .await
3104 .map_err(|e| e.to_string())?;
3105 let kr = resp.get("key_result").cloned().unwrap_or(resp);
3106 Ok(compact_items(
3107 &[kr],
3108 &[
3109 "id",
3110 "name",
3111 "type",
3112 "steps_start",
3113 "steps_end",
3114 "steps_current",
3115 ],
3116 ))
3117 }
3118
3119 "clickup_goal_update_kr" => {
3120 let kr_id = args
3121 .get("kr_id")
3122 .and_then(|v| v.as_str())
3123 .ok_or("Missing required parameter: kr_id")?;
3124 let mut body = json!({});
3125 if let Some(v) = args.get("steps_current").and_then(|v| v.as_f64()) {
3126 body["steps_current"] = json!(v);
3127 }
3128 if let Some(v) = args.get("name").and_then(|v| v.as_str()) {
3129 body["name"] = json!(v);
3130 }
3131 if let Some(v) = args.get("unit").and_then(|v| v.as_str()) {
3132 body["unit"] = json!(v);
3133 }
3134 let resp = client
3135 .put(&format!("/v2/key_result/{}", kr_id), &body)
3136 .await
3137 .map_err(|e| e.to_string())?;
3138 let kr = resp.get("key_result").cloned().unwrap_or(resp);
3139 Ok(compact_items(
3140 &[kr],
3141 &["id", "name", "steps_current", "steps_end"],
3142 ))
3143 }
3144
3145 "clickup_goal_delete_kr" => {
3146 let kr_id = args
3147 .get("kr_id")
3148 .and_then(|v| v.as_str())
3149 .ok_or("Missing required parameter: kr_id")?;
3150 client
3151 .delete(&format!("/v2/key_result/{}", kr_id))
3152 .await
3153 .map_err(|e| e.to_string())?;
3154 Ok(json!({"message": format!("Key result {} deleted", kr_id)}))
3155 }
3156
3157 "clickup_time_get" => {
3158 let team_id = resolve_workspace(args)?;
3159 let timer_id = args
3160 .get("timer_id")
3161 .and_then(|v| v.as_str())
3162 .ok_or("Missing required parameter: timer_id")?;
3163 let resp = client
3164 .get(&format!("/v2/team/{}/time_entries/{}", team_id, timer_id))
3165 .await
3166 .map_err(|e| e.to_string())?;
3167 let data = resp.get("data").cloned().unwrap_or(resp);
3168 Ok(compact_items(
3169 &[data],
3170 &["id", "task", "duration", "start", "end", "billable"],
3171 ))
3172 }
3173
3174 "clickup_time_create" => {
3175 let team_id = resolve_workspace(args)?;
3176 let start = args
3177 .get("start")
3178 .and_then(|v| v.as_i64())
3179 .ok_or("Missing required parameter: start")?;
3180 let duration = args
3181 .get("duration")
3182 .and_then(|v| v.as_i64())
3183 .ok_or("Missing required parameter: duration")?;
3184 let mut body = json!({"start": start, "duration": duration});
3185 if let Some(task_id) = args.get("task_id").and_then(|v| v.as_str()) {
3186 body["tid"] = json!(task_id);
3187 }
3188 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
3189 body["description"] = json!(desc);
3190 }
3191 if let Some(billable) = args.get("billable").and_then(|v| v.as_bool()) {
3192 body["billable"] = json!(billable);
3193 }
3194 let resp = client
3195 .post(&format!("/v2/team/{}/time_entries", team_id), &body)
3196 .await
3197 .map_err(|e| e.to_string())?;
3198 let data = resp.get("data").cloned().unwrap_or(resp);
3199 Ok(compact_items(
3200 &[data],
3201 &["id", "task", "duration", "start", "billable"],
3202 ))
3203 }
3204
3205 "clickup_time_update" => {
3206 let team_id = resolve_workspace(args)?;
3207 let timer_id = args
3208 .get("timer_id")
3209 .and_then(|v| v.as_str())
3210 .ok_or("Missing required parameter: timer_id")?;
3211 let mut body = json!({});
3212 if let Some(start) = args.get("start").and_then(|v| v.as_i64()) {
3213 body["start"] = json!(start);
3214 }
3215 if let Some(duration) = args.get("duration").and_then(|v| v.as_i64()) {
3216 body["duration"] = json!(duration);
3217 }
3218 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
3219 body["description"] = json!(desc);
3220 }
3221 if let Some(billable) = args.get("billable").and_then(|v| v.as_bool()) {
3222 body["billable"] = json!(billable);
3223 }
3224 let resp = client
3225 .put(
3226 &format!("/v2/team/{}/time_entries/{}", team_id, timer_id),
3227 &body,
3228 )
3229 .await
3230 .map_err(|e| e.to_string())?;
3231 let data = resp.get("data").cloned().unwrap_or(resp);
3232 Ok(compact_items(
3233 &[data],
3234 &["id", "task", "duration", "start", "billable"],
3235 ))
3236 }
3237
3238 "clickup_time_delete" => {
3239 let team_id = resolve_workspace(args)?;
3240 let timer_id = args
3241 .get("timer_id")
3242 .and_then(|v| v.as_str())
3243 .ok_or("Missing required parameter: timer_id")?;
3244 client
3245 .delete(&format!("/v2/team/{}/time_entries/{}", team_id, timer_id))
3246 .await
3247 .map_err(|e| e.to_string())?;
3248 Ok(json!({"message": format!("Time entry {} deleted", timer_id)}))
3249 }
3250
3251 "clickup_view_get" => {
3252 let view_id = args
3253 .get("view_id")
3254 .and_then(|v| v.as_str())
3255 .ok_or("Missing required parameter: view_id")?;
3256 let resp = client
3257 .get(&format!("/v2/view/{}", view_id))
3258 .await
3259 .map_err(|e| e.to_string())?;
3260 let view = resp.get("view").cloned().unwrap_or(resp);
3261 Ok(compact_items(&[view], &["id", "name", "type"]))
3262 }
3263
3264 "clickup_view_create" => {
3265 let scope = args
3266 .get("scope")
3267 .and_then(|v| v.as_str())
3268 .ok_or("Missing required parameter: scope")?;
3269 let scope_id = args
3270 .get("scope_id")
3271 .and_then(|v| v.as_str())
3272 .ok_or("Missing required parameter: scope_id")?;
3273 let name = args
3274 .get("name")
3275 .and_then(|v| v.as_str())
3276 .ok_or("Missing required parameter: name")?;
3277 let view_type = args
3278 .get("type")
3279 .and_then(|v| v.as_str())
3280 .ok_or("Missing required parameter: type")?;
3281 let body = json!({"name": name, "type": view_type});
3282 let resp = client
3283 .post(&format!("/v2/{}/{}/view", scope, scope_id), &body)
3284 .await
3285 .map_err(|e| e.to_string())?;
3286 let view = resp.get("view").cloned().unwrap_or(resp);
3287 Ok(compact_items(&[view], &["id", "name", "type"]))
3288 }
3289
3290 "clickup_view_update" => {
3291 let view_id = args
3292 .get("view_id")
3293 .and_then(|v| v.as_str())
3294 .ok_or("Missing required parameter: view_id")?;
3295 let name = args
3296 .get("name")
3297 .and_then(|v| v.as_str())
3298 .ok_or("Missing required parameter: name")?;
3299 let view_type = args
3300 .get("type")
3301 .and_then(|v| v.as_str())
3302 .ok_or("Missing required parameter: type")?;
3303 let body = json!({"name": name, "type": view_type});
3304 let resp = client
3305 .put(&format!("/v2/view/{}", view_id), &body)
3306 .await
3307 .map_err(|e| e.to_string())?;
3308 let view = resp.get("view").cloned().unwrap_or(resp);
3309 Ok(compact_items(&[view], &["id", "name", "type"]))
3310 }
3311
3312 "clickup_view_delete" => {
3313 let view_id = args
3314 .get("view_id")
3315 .and_then(|v| v.as_str())
3316 .ok_or("Missing required parameter: view_id")?;
3317 client
3318 .delete(&format!("/v2/view/{}", view_id))
3319 .await
3320 .map_err(|e| e.to_string())?;
3321 Ok(json!({"message": format!("View {} deleted", view_id)}))
3322 }
3323
3324 "clickup_doc_create" => {
3325 let team_id = resolve_workspace(args)?;
3326 let name = args
3327 .get("name")
3328 .and_then(|v| v.as_str())
3329 .ok_or("Missing required parameter: name")?;
3330 let mut body = json!({"name": name});
3331 if let Some(parent) = args.get("parent") {
3332 body["parent"] = parent.clone();
3333 }
3334 let resp = client
3335 .post(&format!("/v3/workspaces/{}/docs", team_id), &body)
3336 .await
3337 .map_err(|e| e.to_string())?;
3338 Ok(compact_items(&[resp], &["id", "name"]))
3339 }
3340
3341 "clickup_doc_add_page" => {
3342 let team_id = resolve_workspace(args)?;
3343 let doc_id = args
3344 .get("doc_id")
3345 .and_then(|v| v.as_str())
3346 .ok_or("Missing required parameter: doc_id")?;
3347 let name = args
3348 .get("name")
3349 .and_then(|v| v.as_str())
3350 .ok_or("Missing required parameter: name")?;
3351 let mut body = json!({"name": name});
3352 if let Some(content) = args.get("content").and_then(|v| v.as_str()) {
3353 body["content"] = json!(content);
3354 }
3355 if let Some(subtitle) = args.get("sub_title").and_then(|v| v.as_str()) {
3356 body["sub_title"] = json!(subtitle);
3357 }
3358 if let Some(parent_page_id) = args.get("parent_page_id").and_then(|v| v.as_str()) {
3359 body["parent_page_id"] = json!(parent_page_id);
3360 }
3361 let resp = client
3362 .post(
3363 &format!("/v3/workspaces/{}/docs/{}/pages", team_id, doc_id),
3364 &body,
3365 )
3366 .await
3367 .map_err(|e| e.to_string())?;
3368 Ok(compact_items(&[resp], &["id", "name"]))
3369 }
3370
3371 "clickup_doc_edit_page" => {
3372 let team_id = resolve_workspace(args)?;
3373 let doc_id = args
3374 .get("doc_id")
3375 .and_then(|v| v.as_str())
3376 .ok_or("Missing required parameter: doc_id")?;
3377 let page_id = args
3378 .get("page_id")
3379 .and_then(|v| v.as_str())
3380 .ok_or("Missing required parameter: page_id")?;
3381 let mut body = json!({});
3382 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
3383 body["name"] = json!(name);
3384 }
3385 if let Some(content) = args.get("content").and_then(|v| v.as_str()) {
3386 body["content"] = json!(content);
3387 }
3388 let resp = client
3389 .put(
3390 &format!(
3391 "/v3/workspaces/{}/docs/{}/pages/{}",
3392 team_id, doc_id, page_id
3393 ),
3394 &body,
3395 )
3396 .await
3397 .map_err(|e| e.to_string())?;
3398 Ok(compact_items(&[resp], &["id", "name"]))
3399 }
3400
3401 "clickup_chat_channel_create" => {
3402 let team_id = resolve_workspace(args)?;
3403 let name = args
3404 .get("name")
3405 .and_then(|v| v.as_str())
3406 .ok_or("Missing required parameter: name")?;
3407 let mut body = json!({"name": name});
3408 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
3409 body["description"] = json!(desc);
3410 }
3411 if let Some(vis) = args.get("visibility").and_then(|v| v.as_str()) {
3412 body["visibility"] = json!(vis);
3413 }
3414 let resp = client
3415 .post(&format!("/v3/workspaces/{}/chat/channels", team_id), &body)
3416 .await
3417 .map_err(|e| e.to_string())?;
3418 Ok(compact_items(&[resp], &["id", "name", "visibility"]))
3419 }
3420
3421 "clickup_chat_channel_get" => {
3422 let team_id = resolve_workspace(args)?;
3423 let channel_id = args
3424 .get("channel_id")
3425 .and_then(|v| v.as_str())
3426 .ok_or("Missing required parameter: channel_id")?;
3427 let resp = client
3428 .get(&format!(
3429 "/v3/workspaces/{}/chat/channels/{}",
3430 team_id, channel_id
3431 ))
3432 .await
3433 .map_err(|e| e.to_string())?;
3434 Ok(compact_items(&[resp], &["id", "name", "visibility"]))
3435 }
3436
3437 "clickup_chat_channel_update" => {
3438 let team_id = resolve_workspace(args)?;
3439 let channel_id = args
3440 .get("channel_id")
3441 .and_then(|v| v.as_str())
3442 .ok_or("Missing required parameter: channel_id")?;
3443 let mut body = json!({});
3444 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
3445 body["name"] = json!(name);
3446 }
3447 if let Some(desc) = args.get("description").and_then(|v| v.as_str()) {
3448 body["description"] = json!(desc);
3449 }
3450 let resp = client
3451 .patch(
3452 &format!("/v3/workspaces/{}/chat/channels/{}", team_id, channel_id),
3453 &body,
3454 )
3455 .await
3456 .map_err(|e| e.to_string())?;
3457 Ok(compact_items(&[resp], &["id", "name"]))
3458 }
3459
3460 "clickup_chat_channel_delete" => {
3461 let team_id = resolve_workspace(args)?;
3462 let channel_id = args
3463 .get("channel_id")
3464 .and_then(|v| v.as_str())
3465 .ok_or("Missing required parameter: channel_id")?;
3466 client
3467 .delete(&format!(
3468 "/v3/workspaces/{}/chat/channels/{}",
3469 team_id, channel_id
3470 ))
3471 .await
3472 .map_err(|e| e.to_string())?;
3473 Ok(json!({"message": format!("Channel {} deleted", channel_id)}))
3474 }
3475
3476 "clickup_chat_message_list" => {
3477 let team_id = resolve_workspace(args)?;
3478 let channel_id = args
3479 .get("channel_id")
3480 .and_then(|v| v.as_str())
3481 .ok_or("Missing required parameter: channel_id")?;
3482 let mut path = format!(
3483 "/v3/workspaces/{}/chat/channels/{}/messages",
3484 team_id, channel_id
3485 );
3486 if let Some(cursor) = args.get("cursor").and_then(|v| v.as_str()) {
3487 path.push_str(&format!("?cursor={}", cursor));
3488 }
3489 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
3490 let messages = resp
3491 .get("messages")
3492 .and_then(|m| m.as_array())
3493 .cloned()
3494 .unwrap_or_default();
3495 Ok(compact_items(&messages, &["id", "content", "date"]))
3496 }
3497
3498 "clickup_chat_message_send" => {
3499 let team_id = resolve_workspace(args)?;
3500 let channel_id = args
3501 .get("channel_id")
3502 .and_then(|v| v.as_str())
3503 .ok_or("Missing required parameter: channel_id")?;
3504 let content = args
3505 .get("content")
3506 .and_then(|v| v.as_str())
3507 .ok_or("Missing required parameter: content")?;
3508 let body = json!({"content": content});
3509 let resp = client
3510 .post(
3511 &format!(
3512 "/v3/workspaces/{}/chat/channels/{}/messages",
3513 team_id, channel_id
3514 ),
3515 &body,
3516 )
3517 .await
3518 .map_err(|e| e.to_string())?;
3519 Ok(json!({"message": "Message sent", "id": resp.get("id")}))
3520 }
3521
3522 "clickup_chat_message_delete" => {
3523 let team_id = resolve_workspace(args)?;
3524 let message_id = args
3525 .get("message_id")
3526 .and_then(|v| v.as_str())
3527 .ok_or("Missing required parameter: message_id")?;
3528 client
3529 .delete(&format!(
3530 "/v3/workspaces/{}/chat/messages/{}",
3531 team_id, message_id
3532 ))
3533 .await
3534 .map_err(|e| e.to_string())?;
3535 Ok(json!({"message": format!("Message {} deleted", message_id)}))
3536 }
3537
3538 "clickup_chat_dm" => {
3539 let team_id = resolve_workspace(args)?;
3540 let user_id = args
3541 .get("user_id")
3542 .and_then(|v| v.as_i64())
3543 .ok_or("Missing required parameter: user_id")?;
3544 let content = args
3545 .get("content")
3546 .and_then(|v| v.as_str())
3547 .ok_or("Missing required parameter: content")?;
3548 let body = json!({"user_id": user_id, "content": content});
3549 let resp = client
3550 .post(
3551 &format!("/v3/workspaces/{}/chat/channels/direct_message", team_id),
3552 &body,
3553 )
3554 .await
3555 .map_err(|e| e.to_string())?;
3556 Ok(json!({"message": "DM sent", "id": resp.get("id")}))
3557 }
3558
3559 "clickup_webhook_create" => {
3560 let team_id = resolve_workspace(args)?;
3561 let endpoint = args
3562 .get("endpoint")
3563 .and_then(|v| v.as_str())
3564 .ok_or("Missing required parameter: endpoint")?;
3565 let events = args
3566 .get("events")
3567 .ok_or("Missing required parameter: events")?;
3568 let mut body = json!({"endpoint": endpoint, "events": events});
3569 if let Some(space_id) = args.get("space_id").and_then(|v| v.as_str()) {
3570 body["space_id"] = json!(space_id);
3571 }
3572 if let Some(folder_id) = args.get("folder_id").and_then(|v| v.as_str()) {
3573 body["folder_id"] = json!(folder_id);
3574 }
3575 if let Some(list_id) = args.get("list_id").and_then(|v| v.as_str()) {
3576 body["list_id"] = json!(list_id);
3577 }
3578 if let Some(task_id) = args.get("task_id").and_then(|v| v.as_str()) {
3579 body["task_id"] = json!(task_id);
3580 }
3581 let resp = client
3582 .post(&format!("/v2/team/{}/webhook", team_id), &body)
3583 .await
3584 .map_err(|e| e.to_string())?;
3585 let webhook = resp.get("webhook").cloned().unwrap_or(resp);
3586 Ok(compact_items(
3587 &[webhook],
3588 &["id", "endpoint", "events", "status"],
3589 ))
3590 }
3591
3592 "clickup_webhook_update" => {
3593 let webhook_id = args
3594 .get("webhook_id")
3595 .and_then(|v| v.as_str())
3596 .ok_or("Missing required parameter: webhook_id")?;
3597 let mut body = json!({});
3598 if let Some(endpoint) = args.get("endpoint").and_then(|v| v.as_str()) {
3599 body["endpoint"] = json!(endpoint);
3600 }
3601 if let Some(events) = args.get("events") {
3602 body["events"] = events.clone();
3603 }
3604 if let Some(status) = args.get("status").and_then(|v| v.as_str()) {
3605 body["status"] = json!(status);
3606 }
3607 let resp = client
3608 .put(&format!("/v2/webhook/{}", webhook_id), &body)
3609 .await
3610 .map_err(|e| e.to_string())?;
3611 let webhook = resp.get("webhook").cloned().unwrap_or(resp);
3612 Ok(compact_items(
3613 &[webhook],
3614 &["id", "endpoint", "events", "status"],
3615 ))
3616 }
3617
3618 "clickup_webhook_delete" => {
3619 let webhook_id = args
3620 .get("webhook_id")
3621 .and_then(|v| v.as_str())
3622 .ok_or("Missing required parameter: webhook_id")?;
3623 client
3624 .delete(&format!("/v2/webhook/{}", webhook_id))
3625 .await
3626 .map_err(|e| e.to_string())?;
3627 Ok(json!({"message": format!("Webhook {} deleted", webhook_id)}))
3628 }
3629
3630 "clickup_checklist_add_item" => {
3631 let checklist_id = args
3632 .get("checklist_id")
3633 .and_then(|v| v.as_str())
3634 .ok_or("Missing required parameter: checklist_id")?;
3635 let name = args
3636 .get("name")
3637 .and_then(|v| v.as_str())
3638 .ok_or("Missing required parameter: name")?;
3639 let mut body = json!({"name": name});
3640 if let Some(assignee) = args.get("assignee").and_then(|v| v.as_i64()) {
3641 body["assignee"] = json!(assignee);
3642 }
3643 let resp = client
3644 .post(
3645 &format!("/v2/checklist/{}/checklist_item", checklist_id),
3646 &body,
3647 )
3648 .await
3649 .map_err(|e| e.to_string())?;
3650 let item = resp.get("checklist").cloned().unwrap_or(resp);
3651 Ok(compact_items(&[item], &["id", "name"]))
3652 }
3653
3654 "clickup_checklist_update_item" => {
3655 let checklist_id = args
3656 .get("checklist_id")
3657 .and_then(|v| v.as_str())
3658 .ok_or("Missing required parameter: checklist_id")?;
3659 let item_id = args
3660 .get("item_id")
3661 .and_then(|v| v.as_str())
3662 .ok_or("Missing required parameter: item_id")?;
3663 let mut body = json!({});
3664 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
3665 body["name"] = json!(name);
3666 }
3667 if let Some(resolved) = args.get("resolved").and_then(|v| v.as_bool()) {
3668 body["resolved"] = json!(resolved);
3669 }
3670 if let Some(assignee) = args.get("assignee").and_then(|v| v.as_i64()) {
3671 body["assignee"] = json!(assignee);
3672 }
3673 client
3674 .put(
3675 &format!("/v2/checklist/{}/checklist_item/{}", checklist_id, item_id),
3676 &body,
3677 )
3678 .await
3679 .map_err(|e| e.to_string())?;
3680 Ok(json!({"message": format!("Checklist item {} updated", item_id)}))
3681 }
3682
3683 "clickup_checklist_delete_item" => {
3684 let checklist_id = args
3685 .get("checklist_id")
3686 .and_then(|v| v.as_str())
3687 .ok_or("Missing required parameter: checklist_id")?;
3688 let item_id = args
3689 .get("item_id")
3690 .and_then(|v| v.as_str())
3691 .ok_or("Missing required parameter: item_id")?;
3692 client
3693 .delete(&format!(
3694 "/v2/checklist/{}/checklist_item/{}",
3695 checklist_id, item_id
3696 ))
3697 .await
3698 .map_err(|e| e.to_string())?;
3699 Ok(json!({"message": format!("Checklist item {} deleted", item_id)}))
3700 }
3701
3702 "clickup_user_get" => {
3703 let team_id = resolve_workspace(args)?;
3704 let user_id = args
3705 .get("user_id")
3706 .and_then(|v| v.as_i64())
3707 .ok_or("Missing required parameter: user_id")?;
3708 let resp = client
3709 .get(&format!("/v2/team/{}/user/{}", team_id, user_id))
3710 .await
3711 .map_err(|e| e.to_string())?;
3712 let member = resp.get("member").cloned().unwrap_or(resp);
3713 Ok(compact_items(&[member], &["user", "role"]))
3714 }
3715
3716 "clickup_workspace_seats" => {
3717 let team_id = resolve_workspace(args)?;
3718 let resp = client
3719 .get(&format!("/v2/team/{}/seats", team_id))
3720 .await
3721 .map_err(|e| e.to_string())?;
3722 Ok(json!(resp))
3723 }
3724
3725 "clickup_workspace_plan" => {
3726 let team_id = resolve_workspace(args)?;
3727 let resp = client
3728 .get(&format!("/v2/team/{}/plan", team_id))
3729 .await
3730 .map_err(|e| e.to_string())?;
3731 Ok(json!(resp))
3732 }
3733
3734 "clickup_tag_create" => {
3735 let space_id = args
3736 .get("space_id")
3737 .and_then(|v| v.as_str())
3738 .ok_or("Missing required parameter: space_id")?;
3739 let name = args
3740 .get("name")
3741 .and_then(|v| v.as_str())
3742 .ok_or("Missing required parameter: name")?;
3743 let mut tag = json!({"name": name});
3744 if let Some(fg) = args.get("tag_fg").and_then(|v| v.as_str()) {
3745 tag["tag_fg"] = json!(fg);
3746 }
3747 if let Some(bg) = args.get("tag_bg").and_then(|v| v.as_str()) {
3748 tag["tag_bg"] = json!(bg);
3749 }
3750 let body = json!({"tag": tag});
3751 client
3752 .post(&format!("/v2/space/{}/tag", space_id), &body)
3753 .await
3754 .map_err(|e| e.to_string())?;
3755 Ok(json!({"message": format!("Tag '{}' created in space {}", name, space_id)}))
3756 }
3757
3758 "clickup_tag_update" => {
3759 let space_id = args
3760 .get("space_id")
3761 .and_then(|v| v.as_str())
3762 .ok_or("Missing required parameter: space_id")?;
3763 let tag_name = args
3764 .get("tag_name")
3765 .and_then(|v| v.as_str())
3766 .ok_or("Missing required parameter: tag_name")?;
3767 let mut tag = json!({});
3768 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
3769 tag["name"] = json!(name);
3770 }
3771 if let Some(fg) = args.get("tag_fg").and_then(|v| v.as_str()) {
3772 tag["tag_fg"] = json!(fg);
3773 }
3774 if let Some(bg) = args.get("tag_bg").and_then(|v| v.as_str()) {
3775 tag["tag_bg"] = json!(bg);
3776 }
3777 let body = json!({"tag": tag});
3778 client
3779 .put(&format!("/v2/space/{}/tag/{}", space_id, tag_name), &body)
3780 .await
3781 .map_err(|e| e.to_string())?;
3782 Ok(json!({"message": format!("Tag '{}' updated", tag_name)}))
3783 }
3784
3785 "clickup_tag_delete" => {
3786 let space_id = args
3787 .get("space_id")
3788 .and_then(|v| v.as_str())
3789 .ok_or("Missing required parameter: space_id")?;
3790 let tag_name = args
3791 .get("tag_name")
3792 .and_then(|v| v.as_str())
3793 .ok_or("Missing required parameter: tag_name")?;
3794 client
3795 .delete(&format!("/v2/space/{}/tag/{}", space_id, tag_name))
3796 .await
3797 .map_err(|e| e.to_string())?;
3798 Ok(json!({"message": format!("Tag '{}' deleted from space {}", tag_name, space_id)}))
3799 }
3800
3801 "clickup_field_unset" => {
3802 let task_id = args
3803 .get("task_id")
3804 .and_then(|v| v.as_str())
3805 .ok_or("Missing required parameter: task_id")?;
3806 let field_id = args
3807 .get("field_id")
3808 .and_then(|v| v.as_str())
3809 .ok_or("Missing required parameter: field_id")?;
3810 client
3811 .delete(&format!("/v2/task/{}/field/{}", task_id, field_id))
3812 .await
3813 .map_err(|e| e.to_string())?;
3814 Ok(json!({"message": format!("Field {} unset on task {}", field_id, task_id)}))
3815 }
3816
3817 "clickup_attachment_list" => {
3818 let task_id = args
3819 .get("task_id")
3820 .and_then(|v| v.as_str())
3821 .ok_or("Missing required parameter: task_id")?;
3822 let resp = client
3825 .get(&format!("/v2/task/{}", task_id))
3826 .await
3827 .map_err(|e| e.to_string())?;
3828 let attachments = resp
3829 .get("attachments")
3830 .and_then(|a| a.as_array())
3831 .cloned()
3832 .unwrap_or_default();
3833 Ok(compact_items(&attachments, &["id", "title", "url", "date"]))
3834 }
3835
3836 "clickup_shared_list" => {
3837 let team_id = resolve_workspace(args)?;
3838 let resp = client
3839 .get(&format!("/v2/team/{}/shared", team_id))
3840 .await
3841 .map_err(|e| e.to_string())?;
3842 Ok(json!(resp))
3843 }
3844
3845 "clickup_group_list" => {
3846 let team_id = resolve_workspace(args)?;
3847 let mut qs = format!("team_id={}", team_id);
3848 if let Some(group_ids) = args.get("group_ids").and_then(|v| v.as_array()) {
3849 for id in group_ids {
3850 if let Some(id) = id.as_str() {
3851 qs.push_str(&format!("&group_ids[]={}", id));
3852 }
3853 }
3854 }
3855 let resp = client
3856 .get(&format!("/v2/group?{}", qs))
3857 .await
3858 .map_err(|e| e.to_string())?;
3859 let groups = resp
3860 .get("groups")
3861 .and_then(|g| g.as_array())
3862 .cloned()
3863 .unwrap_or_default();
3864 Ok(compact_items(&groups, &["id", "name", "members"]))
3865 }
3866
3867 "clickup_group_create" => {
3868 let team_id = resolve_workspace(args)?;
3869 let name = args
3870 .get("name")
3871 .and_then(|v| v.as_str())
3872 .ok_or("Missing required parameter: name")?;
3873 let mut body = json!({"name": name});
3874 if let Some(members) = args.get("member_ids") {
3875 body["members"] = members.clone();
3876 }
3877 let resp = client
3878 .post(&format!("/v2/team/{}/group", team_id), &body)
3879 .await
3880 .map_err(|e| e.to_string())?;
3881 Ok(compact_items(&[resp], &["id", "name"]))
3882 }
3883
3884 "clickup_group_update" => {
3885 let group_id = args
3886 .get("group_id")
3887 .and_then(|v| v.as_str())
3888 .ok_or("Missing required parameter: group_id")?;
3889 let mut body = json!({});
3890 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
3891 body["name"] = json!(name);
3892 }
3893 if let Some(add) = args.get("add_members") {
3894 body["members"] = json!({"add": add, "rem": args.get("rem_members").cloned().unwrap_or(json!([]))});
3895 } else if let Some(rem) = args.get("rem_members") {
3896 body["members"] = json!({"add": [], "rem": rem});
3897 }
3898 let resp = client
3899 .put(&format!("/v2/group/{}", group_id), &body)
3900 .await
3901 .map_err(|e| e.to_string())?;
3902 Ok(compact_items(&[resp], &["id", "name"]))
3903 }
3904
3905 "clickup_group_delete" => {
3906 let group_id = args
3907 .get("group_id")
3908 .and_then(|v| v.as_str())
3909 .ok_or("Missing required parameter: group_id")?;
3910 client
3911 .delete(&format!("/v2/group/{}", group_id))
3912 .await
3913 .map_err(|e| e.to_string())?;
3914 Ok(json!({"message": format!("Group {} deleted", group_id)}))
3915 }
3916
3917 "clickup_role_list" => {
3918 let team_id = resolve_workspace(args)?;
3919 let resp = client
3920 .get(&format!("/v2/team/{}/customroles", team_id))
3921 .await
3922 .map_err(|e| e.to_string())?;
3923 let roles = resp
3924 .get("roles")
3925 .and_then(|r| r.as_array())
3926 .cloned()
3927 .unwrap_or_default();
3928 Ok(compact_items(&roles, &["id", "name"]))
3929 }
3930
3931 "clickup_guest_get" => {
3932 let team_id = resolve_workspace(args)?;
3933 let guest_id = args
3934 .get("guest_id")
3935 .and_then(|v| v.as_i64())
3936 .ok_or("Missing required parameter: guest_id")?;
3937 let resp = client
3938 .get(&format!("/v2/team/{}/guest/{}", team_id, guest_id))
3939 .await
3940 .map_err(|e| e.to_string())?;
3941 let guest = resp.get("guest").cloned().unwrap_or(resp);
3942 Ok(compact_items(&[guest], &["user", "role"]))
3943 }
3944
3945 "clickup_task_time_in_status" => {
3946 let task_id = args
3947 .get("task_id")
3948 .and_then(|v| v.as_str())
3949 .ok_or("Missing required parameter: task_id")?;
3950 let resp = client
3951 .get(&format!("/v2/task/{}/time_in_status", task_id))
3952 .await
3953 .map_err(|e| e.to_string())?;
3954 Ok(resp)
3955 }
3956
3957 "clickup_task_move" => {
3958 let team_id = resolve_workspace(args)?;
3959 let task_id = args
3960 .get("task_id")
3961 .and_then(|v| v.as_str())
3962 .ok_or("Missing required parameter: task_id")?;
3963 let list_id = args
3964 .get("list_id")
3965 .and_then(|v| v.as_str())
3966 .ok_or("Missing required parameter: list_id")?;
3967 client
3968 .put(
3969 &format!(
3970 "/v3/workspaces/{}/tasks/{}/home_list/{}",
3971 team_id, task_id, list_id
3972 ),
3973 &json!({}),
3974 )
3975 .await
3976 .map_err(|e| e.to_string())?;
3977 Ok(json!({"message": format!("Task {} moved to list {}", task_id, list_id)}))
3978 }
3979
3980 "clickup_task_set_estimate" => {
3981 let team_id = resolve_workspace(args)?;
3982 let task_id = args
3983 .get("task_id")
3984 .and_then(|v| v.as_str())
3985 .ok_or("Missing required parameter: task_id")?;
3986 let user_id = args
3987 .get("user_id")
3988 .and_then(|v| v.as_i64())
3989 .ok_or("Missing required parameter: user_id")?;
3990 let time_estimate = args
3991 .get("time_estimate")
3992 .and_then(|v| v.as_i64())
3993 .ok_or("Missing required parameter: time_estimate")?;
3994 let body =
3995 json!({"time_estimates": [{"user_id": user_id, "time_estimate": time_estimate}]});
3996 client
3997 .patch(
3998 &format!(
3999 "/v3/workspaces/{}/tasks/{}/time_estimates_by_user",
4000 team_id, task_id
4001 ),
4002 &body,
4003 )
4004 .await
4005 .map_err(|e| e.to_string())?;
4006 Ok(json!({"message": format!("Time estimate set for task {}", task_id)}))
4007 }
4008
4009 "clickup_task_replace_estimates" => {
4010 let team_id = resolve_workspace(args)?;
4011 let task_id = args
4012 .get("task_id")
4013 .and_then(|v| v.as_str())
4014 .ok_or("Missing required parameter: task_id")?;
4015 let user_id = args
4016 .get("user_id")
4017 .and_then(|v| v.as_i64())
4018 .ok_or("Missing required parameter: user_id")?;
4019 let time_estimate = args
4020 .get("time_estimate")
4021 .and_then(|v| v.as_i64())
4022 .ok_or("Missing required parameter: time_estimate")?;
4023 let body =
4024 json!({"time_estimates": [{"user_id": user_id, "time_estimate": time_estimate}]});
4025 client
4026 .put(
4027 &format!(
4028 "/v3/workspaces/{}/tasks/{}/time_estimates_by_user",
4029 team_id, task_id
4030 ),
4031 &body,
4032 )
4033 .await
4034 .map_err(|e| e.to_string())?;
4035 Ok(json!({"message": format!("Time estimates replaced for task {}", task_id)}))
4036 }
4037
4038 "clickup_auth_check" => {
4039 client.get("/v2/user").await.map_err(|e| e.to_string())?;
4040 Ok(json!({"message": "Token valid"}))
4041 }
4042
4043 "clickup_checklist_update" => {
4044 let checklist_id = args
4045 .get("checklist_id")
4046 .and_then(|v| v.as_str())
4047 .ok_or("Missing required parameter: checklist_id")?;
4048 let mut body = json!({});
4049 if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
4050 body["name"] = json!(name);
4051 }
4052 if let Some(position) = args.get("position").and_then(|v| v.as_i64()) {
4053 body["position"] = json!(position);
4054 }
4055 let resp = client
4056 .put(&format!("/v2/checklist/{}", checklist_id), &body)
4057 .await
4058 .map_err(|e| e.to_string())?;
4059 let checklist = resp.get("checklist").cloned().unwrap_or(resp);
4060 Ok(compact_items(&[checklist], &["id", "name"]))
4061 }
4062
4063 "clickup_comment_replies" => {
4064 let comment_id = args
4065 .get("comment_id")
4066 .and_then(|v| v.as_str())
4067 .ok_or("Missing required parameter: comment_id")?;
4068 let resp = client
4069 .get(&format!("/v2/comment/{}/reply", comment_id))
4070 .await
4071 .map_err(|e| e.to_string())?;
4072 let comments = resp
4073 .get("comments")
4074 .or_else(|| resp.get("replies"))
4075 .and_then(|c| c.as_array())
4076 .cloned()
4077 .unwrap_or_default();
4078 Ok(compact_items(
4079 &comments,
4080 &["id", "user", "date", "comment_text"],
4081 ))
4082 }
4083
4084 "clickup_comment_reply" => {
4085 let comment_id = args
4086 .get("comment_id")
4087 .and_then(|v| v.as_str())
4088 .ok_or("Missing required parameter: comment_id")?;
4089 let text = args
4090 .get("text")
4091 .and_then(|v| v.as_str())
4092 .ok_or("Missing required parameter: text")?;
4093 let mut body = json!({"comment_text": text});
4094 if let Some(assignee) = args.get("assignee").and_then(|v| v.as_i64()) {
4095 body["assignee"] = json!(assignee);
4096 }
4097 let resp = client
4098 .post(&format!("/v2/comment/{}/reply", comment_id), &body)
4099 .await
4100 .map_err(|e| e.to_string())?;
4101 Ok(json!({"message": "Reply posted", "id": resp.get("id")}))
4102 }
4103
4104 "clickup_chat_channel_list" => {
4105 let team_id = resolve_workspace(args)?;
4106 let mut path = format!("/v3/workspaces/{}/chat/channels", team_id);
4107 if let Some(include_closed) = args.get("include_closed").and_then(|v| v.as_bool()) {
4108 path.push_str(&format!("?include_closed={}", include_closed));
4109 }
4110 let resp = client.get(&path).await.map_err(|e| e.to_string())?;
4111 let channels = resp
4112 .get("channels")
4113 .and_then(|c| c.as_array())
4114 .cloned()
4115 .unwrap_or_default();
4116 Ok(compact_items(&channels, &["id", "name", "type"]))
4117 }
4118
4119 "clickup_chat_channel_followers" => {
4120 let team_id = resolve_workspace(args)?;
4121 let channel_id = args
4122 .get("channel_id")
4123 .and_then(|v| v.as_str())
4124 .ok_or("Missing required parameter: channel_id")?;
4125 let resp = client
4126 .get(&format!(
4127 "/v3/workspaces/{}/chat/channels/{}/followers",
4128 team_id, channel_id
4129 ))
4130 .await
4131 .map_err(|e| e.to_string())?;
4132 Ok(resp)
4133 }
4134
4135 "clickup_chat_channel_members" => {
4136 let team_id = resolve_workspace(args)?;
4137 let channel_id = args
4138 .get("channel_id")
4139 .and_then(|v| v.as_str())
4140 .ok_or("Missing required parameter: channel_id")?;
4141 let resp = client
4142 .get(&format!(
4143 "/v3/workspaces/{}/chat/channels/{}/members",
4144 team_id, channel_id
4145 ))
4146 .await
4147 .map_err(|e| e.to_string())?;
4148 Ok(resp)
4149 }
4150
4151 "clickup_chat_message_update" => {
4152 let team_id = resolve_workspace(args)?;
4153 let message_id = args
4154 .get("message_id")
4155 .and_then(|v| v.as_str())
4156 .ok_or("Missing required parameter: message_id")?;
4157 let text = args
4158 .get("text")
4159 .and_then(|v| v.as_str())
4160 .ok_or("Missing required parameter: text")?;
4161 let body = json!({"content": text});
4162 client
4163 .patch(
4164 &format!("/v3/workspaces/{}/chat/messages/{}", team_id, message_id),
4165 &body,
4166 )
4167 .await
4168 .map_err(|e| e.to_string())?;
4169 Ok(json!({"message": format!("Message {} updated", message_id)}))
4170 }
4171
4172 "clickup_chat_reaction_list" => {
4173 let team_id = resolve_workspace(args)?;
4174 let message_id = args
4175 .get("message_id")
4176 .and_then(|v| v.as_str())
4177 .ok_or("Missing required parameter: message_id")?;
4178 let resp = client
4179 .get(&format!(
4180 "/v3/workspaces/{}/chat/messages/{}/reactions",
4181 team_id, message_id
4182 ))
4183 .await
4184 .map_err(|e| e.to_string())?;
4185 Ok(resp)
4186 }
4187
4188 "clickup_chat_reaction_add" => {
4189 let team_id = resolve_workspace(args)?;
4190 let message_id = args
4191 .get("message_id")
4192 .and_then(|v| v.as_str())
4193 .ok_or("Missing required parameter: message_id")?;
4194 let emoji = args
4195 .get("emoji")
4196 .and_then(|v| v.as_str())
4197 .ok_or("Missing required parameter: emoji")?;
4198 let body = json!({"emoji": emoji});
4199 client
4200 .post(
4201 &format!(
4202 "/v3/workspaces/{}/chat/messages/{}/reactions",
4203 team_id, message_id
4204 ),
4205 &body,
4206 )
4207 .await
4208 .map_err(|e| e.to_string())?;
4209 Ok(json!({"message": format!("Reaction '{}' added to message {}", emoji, message_id)}))
4210 }
4211
4212 "clickup_chat_reaction_remove" => {
4213 let team_id = resolve_workspace(args)?;
4214 let message_id = args
4215 .get("message_id")
4216 .and_then(|v| v.as_str())
4217 .ok_or("Missing required parameter: message_id")?;
4218 let emoji = args
4219 .get("emoji")
4220 .and_then(|v| v.as_str())
4221 .ok_or("Missing required parameter: emoji")?;
4222 client
4223 .delete(&format!(
4224 "/v3/workspaces/{}/chat/messages/{}/reactions/{}",
4225 team_id, message_id, emoji
4226 ))
4227 .await
4228 .map_err(|e| e.to_string())?;
4229 Ok(
4230 json!({"message": format!("Reaction '{}' removed from message {}", emoji, message_id)}),
4231 )
4232 }
4233
4234 "clickup_chat_reply_list" => {
4235 let team_id = resolve_workspace(args)?;
4236 let message_id = args
4237 .get("message_id")
4238 .and_then(|v| v.as_str())
4239 .ok_or("Missing required parameter: message_id")?;
4240 let resp = client
4241 .get(&format!(
4242 "/v3/workspaces/{}/chat/messages/{}/replies",
4243 team_id, message_id
4244 ))
4245 .await
4246 .map_err(|e| e.to_string())?;
4247 Ok(resp)
4248 }
4249
4250 "clickup_chat_reply_send" => {
4251 let team_id = resolve_workspace(args)?;
4252 let message_id = args
4253 .get("message_id")
4254 .and_then(|v| v.as_str())
4255 .ok_or("Missing required parameter: message_id")?;
4256 let text = args
4257 .get("text")
4258 .and_then(|v| v.as_str())
4259 .ok_or("Missing required parameter: text")?;
4260 let body = json!({"content": text});
4261 let resp = client
4262 .post(
4263 &format!(
4264 "/v3/workspaces/{}/chat/messages/{}/replies",
4265 team_id, message_id
4266 ),
4267 &body,
4268 )
4269 .await
4270 .map_err(|e| e.to_string())?;
4271 Ok(json!({"message": "Reply sent", "id": resp.get("id")}))
4272 }
4273
4274 "clickup_chat_tagged_users" => {
4275 let team_id = resolve_workspace(args)?;
4276 let message_id = args
4277 .get("message_id")
4278 .and_then(|v| v.as_str())
4279 .ok_or("Missing required parameter: message_id")?;
4280 let resp = client
4281 .get(&format!(
4282 "/v3/workspaces/{}/chat/messages/{}/tagged_users",
4283 team_id, message_id
4284 ))
4285 .await
4286 .map_err(|e| e.to_string())?;
4287 Ok(resp)
4288 }
4289
4290 "clickup_time_current" => {
4291 let team_id = resolve_workspace(args)?;
4292 let resp = client
4293 .get(&format!("/v2/team/{}/time_entries/current", team_id))
4294 .await
4295 .map_err(|e| e.to_string())?;
4296 let data = resp.get("data").cloned().unwrap_or(resp);
4297 Ok(compact_items(
4298 &[data],
4299 &["id", "task", "duration", "start", "billable"],
4300 ))
4301 }
4302
4303 "clickup_time_tags" => {
4304 let team_id = resolve_workspace(args)?;
4305 let resp = client
4306 .get(&format!("/v2/team/{}/time_entries/tags", team_id))
4307 .await
4308 .map_err(|e| e.to_string())?;
4309 let tags = resp
4310 .get("data")
4311 .and_then(|d| d.as_array())
4312 .cloned()
4313 .unwrap_or_default();
4314 Ok(compact_items(&tags, &["name"]))
4315 }
4316
4317 "clickup_time_add_tags" => {
4318 let team_id = resolve_workspace(args)?;
4319 let entry_ids = args
4320 .get("entry_ids")
4321 .and_then(|v| v.as_array())
4322 .ok_or("Missing required parameter: entry_ids")?;
4323 let tag_names = args
4324 .get("tag_names")
4325 .and_then(|v| v.as_array())
4326 .ok_or("Missing required parameter: tag_names")?;
4327 let tags: Vec<Value> = tag_names
4328 .iter()
4329 .filter_map(|n| n.as_str())
4330 .map(|n| json!({"name": n}))
4331 .collect();
4332 let body = json!({"time_entry_ids": entry_ids, "tags": tags});
4333 client
4334 .post(&format!("/v2/team/{}/time_entries/tags", team_id), &body)
4335 .await
4336 .map_err(|e| e.to_string())?;
4337 Ok(json!({"message": "Tags added to time entries"}))
4338 }
4339
4340 "clickup_time_remove_tags" => {
4341 let team_id = resolve_workspace(args)?;
4342 let entry_ids = args
4343 .get("entry_ids")
4344 .and_then(|v| v.as_array())
4345 .ok_or("Missing required parameter: entry_ids")?;
4346 let tag_names = args
4347 .get("tag_names")
4348 .and_then(|v| v.as_array())
4349 .ok_or("Missing required parameter: tag_names")?;
4350 let tags: Vec<Value> = tag_names
4351 .iter()
4352 .filter_map(|n| n.as_str())
4353 .map(|n| json!({"name": n}))
4354 .collect();
4355 let body = json!({"time_entry_ids": entry_ids, "tags": tags});
4356 client
4357 .delete_with_body(&format!("/v2/team/{}/time_entries/tags", team_id), &body)
4358 .await
4359 .map_err(|e| e.to_string())?;
4360 Ok(json!({"message": "Tags removed from time entries"}))
4361 }
4362
4363 "clickup_time_rename_tag" => {
4364 let team_id = resolve_workspace(args)?;
4365 let name = args
4366 .get("name")
4367 .and_then(|v| v.as_str())
4368 .ok_or("Missing required parameter: name")?;
4369 let new_name = args
4370 .get("new_name")
4371 .and_then(|v| v.as_str())
4372 .ok_or("Missing required parameter: new_name")?;
4373 let body = json!({"name": name, "new_name": new_name});
4374 client
4375 .put(&format!("/v2/team/{}/time_entries/tags", team_id), &body)
4376 .await
4377 .map_err(|e| e.to_string())?;
4378 Ok(json!({"message": format!("Tag '{}' renamed to '{}'", name, new_name)}))
4379 }
4380
4381 "clickup_time_history" => {
4382 let team_id = resolve_workspace(args)?;
4383 let timer_id = args
4384 .get("timer_id")
4385 .and_then(|v| v.as_str())
4386 .ok_or("Missing required parameter: timer_id")?;
4387 let resp = client
4388 .get(&format!(
4389 "/v2/team/{}/time_entries/{}/history",
4390 team_id, timer_id
4391 ))
4392 .await
4393 .map_err(|e| e.to_string())?;
4394 Ok(resp)
4395 }
4396
4397 "clickup_guest_invite" => {
4398 let team_id = resolve_workspace(args)?;
4399 let email = args
4400 .get("email")
4401 .and_then(|v| v.as_str())
4402 .ok_or("Missing required parameter: email")?;
4403 let mut body = json!({"email": email});
4404 if let Some(v) = args.get("can_edit_tags").and_then(|v| v.as_bool()) {
4405 body["can_edit_tags"] = json!(v);
4406 }
4407 if let Some(v) = args.get("can_see_time_spent").and_then(|v| v.as_bool()) {
4408 body["can_see_time_spent"] = json!(v);
4409 }
4410 if let Some(v) = args.get("can_create_views").and_then(|v| v.as_bool()) {
4411 body["can_create_views"] = json!(v);
4412 }
4413 let resp = client
4414 .post(&format!("/v2/team/{}/guest", team_id), &body)
4415 .await
4416 .map_err(|e| e.to_string())?;
4417 let guest = resp.get("guest").cloned().unwrap_or(resp);
4418 let user = guest.get("user").cloned().unwrap_or(guest);
4419 Ok(compact_items(&[user], &["id", "email"]))
4420 }
4421
4422 "clickup_guest_update" => {
4423 let team_id = resolve_workspace(args)?;
4424 let guest_id = args
4425 .get("guest_id")
4426 .and_then(|v| v.as_i64())
4427 .ok_or("Missing required parameter: guest_id")?;
4428 let mut body = json!({});
4429 if let Some(v) = args.get("can_edit_tags").and_then(|v| v.as_bool()) {
4430 body["can_edit_tags"] = json!(v);
4431 }
4432 if let Some(v) = args.get("can_see_time_spent").and_then(|v| v.as_bool()) {
4433 body["can_see_time_spent"] = json!(v);
4434 }
4435 if let Some(v) = args.get("can_create_views").and_then(|v| v.as_bool()) {
4436 body["can_create_views"] = json!(v);
4437 }
4438 client
4439 .put(&format!("/v2/team/{}/guest/{}", team_id, guest_id), &body)
4440 .await
4441 .map_err(|e| e.to_string())?;
4442 Ok(json!({"message": format!("Guest {} updated", guest_id)}))
4443 }
4444
4445 "clickup_guest_remove" => {
4446 let team_id = resolve_workspace(args)?;
4447 let guest_id = args
4448 .get("guest_id")
4449 .and_then(|v| v.as_i64())
4450 .ok_or("Missing required parameter: guest_id")?;
4451 client
4452 .delete(&format!("/v2/team/{}/guest/{}", team_id, guest_id))
4453 .await
4454 .map_err(|e| e.to_string())?;
4455 Ok(json!({"message": format!("Guest {} removed", guest_id)}))
4456 }
4457
4458 "clickup_guest_share_task" => {
4459 let task_id = args
4460 .get("task_id")
4461 .and_then(|v| v.as_str())
4462 .ok_or("Missing required parameter: task_id")?;
4463 let guest_id = args
4464 .get("guest_id")
4465 .and_then(|v| v.as_i64())
4466 .ok_or("Missing required parameter: guest_id")?;
4467 let permission = args
4468 .get("permission")
4469 .and_then(|v| v.as_str())
4470 .ok_or("Missing required parameter: permission")?;
4471 let body = json!({"permission_level": permission});
4472 client
4473 .post(&format!("/v2/task/{}/guest/{}", task_id, guest_id), &body)
4474 .await
4475 .map_err(|e| e.to_string())?;
4476 Ok(json!({"message": format!("Task {} shared with guest {}", task_id, guest_id)}))
4477 }
4478
4479 "clickup_guest_unshare_task" => {
4480 let task_id = args
4481 .get("task_id")
4482 .and_then(|v| v.as_str())
4483 .ok_or("Missing required parameter: task_id")?;
4484 let guest_id = args
4485 .get("guest_id")
4486 .and_then(|v| v.as_i64())
4487 .ok_or("Missing required parameter: guest_id")?;
4488 client
4489 .delete(&format!("/v2/task/{}/guest/{}", task_id, guest_id))
4490 .await
4491 .map_err(|e| e.to_string())?;
4492 Ok(json!({"message": format!("Guest {} unshared from task {}", guest_id, task_id)}))
4493 }
4494
4495 "clickup_guest_share_list" => {
4496 let list_id = args
4497 .get("list_id")
4498 .and_then(|v| v.as_str())
4499 .ok_or("Missing required parameter: list_id")?;
4500 let guest_id = args
4501 .get("guest_id")
4502 .and_then(|v| v.as_i64())
4503 .ok_or("Missing required parameter: guest_id")?;
4504 let permission = args
4505 .get("permission")
4506 .and_then(|v| v.as_str())
4507 .ok_or("Missing required parameter: permission")?;
4508 let body = json!({"permission_level": permission});
4509 client
4510 .post(&format!("/v2/list/{}/guest/{}", list_id, guest_id), &body)
4511 .await
4512 .map_err(|e| e.to_string())?;
4513 Ok(json!({"message": format!("List {} shared with guest {}", list_id, guest_id)}))
4514 }
4515
4516 "clickup_guest_unshare_list" => {
4517 let list_id = args
4518 .get("list_id")
4519 .and_then(|v| v.as_str())
4520 .ok_or("Missing required parameter: list_id")?;
4521 let guest_id = args
4522 .get("guest_id")
4523 .and_then(|v| v.as_i64())
4524 .ok_or("Missing required parameter: guest_id")?;
4525 client
4526 .delete(&format!("/v2/list/{}/guest/{}", list_id, guest_id))
4527 .await
4528 .map_err(|e| e.to_string())?;
4529 Ok(json!({"message": format!("Guest {} unshared from list {}", guest_id, list_id)}))
4530 }
4531
4532 "clickup_guest_share_folder" => {
4533 let folder_id = args
4534 .get("folder_id")
4535 .and_then(|v| v.as_str())
4536 .ok_or("Missing required parameter: folder_id")?;
4537 let guest_id = args
4538 .get("guest_id")
4539 .and_then(|v| v.as_i64())
4540 .ok_or("Missing required parameter: guest_id")?;
4541 let permission = args
4542 .get("permission")
4543 .and_then(|v| v.as_str())
4544 .ok_or("Missing required parameter: permission")?;
4545 let body = json!({"permission_level": permission});
4546 client
4547 .post(
4548 &format!("/v2/folder/{}/guest/{}", folder_id, guest_id),
4549 &body,
4550 )
4551 .await
4552 .map_err(|e| e.to_string())?;
4553 Ok(json!({"message": format!("Folder {} shared with guest {}", folder_id, guest_id)}))
4554 }
4555
4556 "clickup_guest_unshare_folder" => {
4557 let folder_id = args
4558 .get("folder_id")
4559 .and_then(|v| v.as_str())
4560 .ok_or("Missing required parameter: folder_id")?;
4561 let guest_id = args
4562 .get("guest_id")
4563 .and_then(|v| v.as_i64())
4564 .ok_or("Missing required parameter: guest_id")?;
4565 client
4566 .delete(&format!("/v2/folder/{}/guest/{}", folder_id, guest_id))
4567 .await
4568 .map_err(|e| e.to_string())?;
4569 Ok(json!({"message": format!("Guest {} unshared from folder {}", guest_id, folder_id)}))
4570 }
4571
4572 "clickup_user_invite" => {
4573 let team_id = resolve_workspace(args)?;
4574 let email = args
4575 .get("email")
4576 .and_then(|v| v.as_str())
4577 .ok_or("Missing required parameter: email")?;
4578 let mut body = json!({"email": email});
4579 if let Some(admin) = args.get("admin").and_then(|v| v.as_bool()) {
4580 body["admin"] = json!(admin);
4581 }
4582 let resp = client
4583 .post(&format!("/v2/team/{}/user", team_id), &body)
4584 .await
4585 .map_err(|e| e.to_string())?;
4586 let member = resp.get("member").cloned().unwrap_or(resp);
4587 let user = member.get("user").cloned().unwrap_or(member);
4588 Ok(compact_items(&[user], &["id", "username", "email"]))
4589 }
4590
4591 "clickup_user_update" => {
4592 let team_id = resolve_workspace(args)?;
4593 let user_id = args
4594 .get("user_id")
4595 .and_then(|v| v.as_i64())
4596 .ok_or("Missing required parameter: user_id")?;
4597 let mut body = json!({});
4598 if let Some(username) = args.get("username").and_then(|v| v.as_str()) {
4599 body["username"] = json!(username);
4600 }
4601 if let Some(admin) = args.get("admin").and_then(|v| v.as_bool()) {
4602 body["admin"] = json!(admin);
4603 }
4604 client
4605 .put(&format!("/v2/team/{}/user/{}", team_id, user_id), &body)
4606 .await
4607 .map_err(|e| e.to_string())?;
4608 Ok(json!({"message": format!("User {} updated", user_id)}))
4609 }
4610
4611 "clickup_user_remove" => {
4612 let team_id = resolve_workspace(args)?;
4613 let user_id = args
4614 .get("user_id")
4615 .and_then(|v| v.as_i64())
4616 .ok_or("Missing required parameter: user_id")?;
4617 client
4618 .delete(&format!("/v2/team/{}/user/{}", team_id, user_id))
4619 .await
4620 .map_err(|e| e.to_string())?;
4621 Ok(json!({"message": format!("User {} removed from workspace", user_id)}))
4622 }
4623
4624 "clickup_template_apply_task" => {
4625 let list_id = args
4626 .get("list_id")
4627 .and_then(|v| v.as_str())
4628 .ok_or("Missing required parameter: list_id")?;
4629 let template_id = args
4630 .get("template_id")
4631 .and_then(|v| v.as_str())
4632 .ok_or("Missing required parameter: template_id")?;
4633 let name = args
4634 .get("name")
4635 .and_then(|v| v.as_str())
4636 .ok_or("Missing required parameter: name")?;
4637 let body = json!({"name": name});
4638 let resp = client
4639 .post(
4640 &format!("/v2/list/{}/taskTemplate/{}", list_id, template_id),
4641 &body,
4642 )
4643 .await
4644 .map_err(|e| e.to_string())?;
4645 Ok(compact_items(&[resp], &["id", "name"]))
4646 }
4647
4648 "clickup_template_apply_list" => {
4649 let template_id = args
4650 .get("template_id")
4651 .and_then(|v| v.as_str())
4652 .ok_or("Missing required parameter: template_id")?;
4653 let name = args
4654 .get("name")
4655 .and_then(|v| v.as_str())
4656 .ok_or("Missing required parameter: name")?;
4657 let body = json!({"name": name});
4658 let path = if let Some(folder_id) = args.get("folder_id").and_then(|v| v.as_str()) {
4659 format!("/v2/folder/{}/list_template/{}", folder_id, template_id)
4660 } else if let Some(space_id) = args.get("space_id").and_then(|v| v.as_str()) {
4661 format!("/v2/space/{}/list_template/{}", space_id, template_id)
4662 } else {
4663 return Err("Provide either folder_id or space_id".to_string());
4664 };
4665 client.post(&path, &body).await.map_err(|e| e.to_string())?;
4666 Ok(json!({"message": format!("List '{}' created from template {}", name, template_id)}))
4667 }
4668
4669 "clickup_template_apply_folder" => {
4670 let space_id = args
4671 .get("space_id")
4672 .and_then(|v| v.as_str())
4673 .ok_or("Missing required parameter: space_id")?;
4674 let template_id = args
4675 .get("template_id")
4676 .and_then(|v| v.as_str())
4677 .ok_or("Missing required parameter: template_id")?;
4678 let name = args
4679 .get("name")
4680 .and_then(|v| v.as_str())
4681 .ok_or("Missing required parameter: name")?;
4682 let body = json!({"name": name});
4683 client
4684 .post(
4685 &format!("/v2/space/{}/folder_template/{}", space_id, template_id),
4686 &body,
4687 )
4688 .await
4689 .map_err(|e| e.to_string())?;
4690 Ok(
4691 json!({"message": format!("Folder '{}' created from template {}", name, template_id)}),
4692 )
4693 }
4694
4695 "clickup_attachment_upload" => {
4696 let task_id = args
4697 .get("task_id")
4698 .and_then(|v| v.as_str())
4699 .ok_or("Missing required parameter: task_id")?;
4700 let file_path = args
4701 .get("file_path")
4702 .and_then(|v| v.as_str())
4703 .ok_or("Missing required parameter: file_path")?;
4704 let path = format!("/v2/task/{}/attachment", task_id);
4705 let resp = client
4706 .upload_file(&path, std::path::Path::new(file_path))
4707 .await
4708 .map_err(|e| e.to_string())?;
4709 Ok(json!({"message": "File uploaded", "id": resp.get("id"), "url": resp.get("url")}))
4710 }
4711
4712 "clickup_task_type_list" => {
4713 let team_id = resolve_workspace(args)?;
4714 let resp = client
4715 .get(&format!("/v2/team/{}/custom_item", team_id))
4716 .await
4717 .map_err(|e| e.to_string())?;
4718 let items = resp
4719 .get("custom_items")
4720 .and_then(|i| i.as_array())
4721 .cloned()
4722 .unwrap_or_default();
4723 Ok(compact_items(&items, &["id", "name", "name_plural"]))
4724 }
4725
4726 "clickup_doc_get_page" => {
4727 let team_id = resolve_workspace(args)?;
4728 let doc_id = args
4729 .get("doc_id")
4730 .and_then(|v| v.as_str())
4731 .ok_or("Missing required parameter: doc_id")?;
4732 let page_id = args
4733 .get("page_id")
4734 .and_then(|v| v.as_str())
4735 .ok_or("Missing required parameter: page_id")?;
4736 let resp = client
4737 .get(&format!(
4738 "/v3/workspaces/{}/docs/{}/pages/{}",
4739 team_id, doc_id, page_id
4740 ))
4741 .await
4742 .map_err(|e| e.to_string())?;
4743 Ok(resp)
4744 }
4745
4746 "clickup_audit_log_query" => {
4747 let team_id = resolve_workspace(args)?;
4748 let event_type = args
4749 .get("type")
4750 .and_then(|v| v.as_str())
4751 .ok_or("Missing required parameter: type")?;
4752 let mut body = json!({"type": event_type});
4753 if let Some(user_id) = args.get("user_id").and_then(|v| v.as_i64()) {
4754 body["user_id"] = json!(user_id);
4755 }
4756 if let Some(start_date) = args.get("start_date").and_then(|v| v.as_i64()) {
4757 body["date_filter"] = json!({"start_date": start_date, "end_date": args.get("end_date").and_then(|v| v.as_i64()).unwrap_or(i64::MAX)});
4758 } else if let Some(end_date) = args.get("end_date").and_then(|v| v.as_i64()) {
4759 body["date_filter"] = json!({"end_date": end_date});
4760 }
4761 let resp = client
4762 .post(&format!("/v3/workspaces/{}/auditlogs", team_id), &body)
4763 .await
4764 .map_err(|e| e.to_string())?;
4765 Ok(resp)
4766 }
4767
4768 "clickup_acl_update" => {
4769 let team_id = resolve_workspace(args)?;
4770 let object_type = args
4771 .get("object_type")
4772 .and_then(|v| v.as_str())
4773 .ok_or("Missing required parameter: object_type")?;
4774 let object_id = args
4775 .get("object_id")
4776 .and_then(|v| v.as_str())
4777 .ok_or("Missing required parameter: object_id")?;
4778 let mut body = json!({});
4779 if let Some(private) = args.get("private").and_then(|v| v.as_bool()) {
4780 body["private"] = json!(private);
4781 }
4782 client
4783 .patch(
4784 &format!(
4785 "/v3/workspaces/{}/{}/{}/acls",
4786 team_id, object_type, object_id
4787 ),
4788 &body,
4789 )
4790 .await
4791 .map_err(|e| e.to_string())?;
4792 Ok(json!({"message": format!("ACL updated for {} {}", object_type, object_id)}))
4793 }
4794
4795 unknown => Err(format!("Unknown tool: {}", unknown)),
4796 }
4797}
4798
4799pub async fn serve(filter: filter::Filter) -> Result<(), Box<dyn std::error::Error>> {
4802 let token = std::env::var("CLICKUP_TOKEN")
4804 .ok()
4805 .filter(|t| !t.is_empty())
4806 .or_else(|| {
4807 Config::load()
4808 .ok()
4809 .map(|c| c.auth.token)
4810 .filter(|t| !t.is_empty())
4811 })
4812 .ok_or("No API token. Set CLICKUP_TOKEN env var or run `clickup setup`.")?;
4813
4814 let workspace_id = std::env::var("CLICKUP_WORKSPACE")
4816 .ok()
4817 .filter(|w| !w.is_empty())
4818 .or_else(|| Config::load().ok().and_then(|c| c.defaults.workspace_id));
4819
4820 let client = ClickUpClient::new(&token, 30)
4821 .map_err(|e| format!("Failed to create HTTP client: {}", e))?;
4822
4823 let stdin = tokio::io::stdin();
4824 let reader = BufReader::new(stdin);
4825 let mut lines = reader.lines();
4826
4827 let groups_str = filter
4828 .groups
4829 .as_ref()
4830 .map(|g| format!(", groups=[{}]", g.join(",")))
4831 .unwrap_or_default();
4832 let excluded_groups_str = filter
4833 .exclude_groups
4834 .as_ref()
4835 .map(|g| format!(", exclude-groups=[{}]", g.join(",")))
4836 .unwrap_or_default();
4837 eprintln!(
4838 "MCP: profile={}{}{}, exposing {}/{} tools",
4839 filter.profile.as_str(),
4840 groups_str,
4841 excluded_groups_str,
4842 filter.allowed_count(),
4843 tool_list().as_array().map(Vec::len).unwrap_or(0),
4844 );
4845
4846 while let Some(line) = lines.next_line().await? {
4847 let line = line.trim().to_string();
4848 if line.is_empty() {
4849 continue;
4850 }
4851
4852 let msg: Value = match serde_json::from_str(&line) {
4853 Ok(v) => v,
4854 Err(e) => {
4855 let resp = error_response(&Value::Null, -32700, &format!("Parse error: {}", e));
4857 println!("{}", resp);
4858 continue;
4859 }
4860 };
4861
4862 let id = msg.get("id").cloned().unwrap_or(Value::Null);
4864 let method = msg.get("method").and_then(|v| v.as_str()).unwrap_or("");
4865
4866 if id.is_null() && method.starts_with("notifications/") {
4867 continue;
4869 }
4870
4871 let resp = match method {
4872 "initialize" => {
4873 let version = msg
4874 .get("params")
4875 .and_then(|p| p.get("protocolVersion"))
4876 .and_then(|v| v.as_str())
4877 .unwrap_or("2024-11-05");
4878 ok_response(
4879 &id,
4880 json!({
4881 "protocolVersion": version,
4882 "capabilities": {"tools": {}},
4883 "serverInfo": {
4884 "name": "clickup-cli",
4885 "version": env!("CARGO_PKG_VERSION")
4886 }
4887 }),
4888 )
4889 }
4890
4891 "tools/list" => ok_response(&id, json!({"tools": filtered_tool_list(&filter)})),
4892
4893 "tools/call" => {
4894 let params = msg.get("params").cloned().unwrap_or(json!({}));
4895 if let Some(response) = handle_tools_call_early(&id, ¶ms, &filter) {
4896 response
4897 } else {
4898 let tool_name = params.get("name").and_then(|v| v.as_str()).unwrap_or("");
4899 let arguments = params.get("arguments").cloned().unwrap_or(json!({}));
4900 let result = call_tool(tool_name, &arguments, &client, &workspace_id).await;
4901 ok_response(&id, result)
4902 }
4903 }
4904
4905 other => {
4906 eprintln!("Unknown method: {}", other);
4908 error_response(&id, -32601, &format!("Method not found: {}", other))
4909 }
4910 };
4911
4912 println!("{}", resp);
4913 }
4914
4915 Ok(())
4916}