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