clickupc-mcp 1.5.0

Unofficial ClickUp MCP server library, shipped inside the clickupc binary
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
use rmcp::{
    handler::server::{router::tool::ToolRouter, wrapper::Parameters},
    model::{Implementation, ServerCapabilities, ServerConfig},
    tool, tool_handler, tool_router,
    transport::{
        stdio,
        streamable_http_server::{
            session::local::LocalSessionManager, StreamableHttpServerConfig, StreamableHttpService,
        },
    },
    ErrorData, Json, ServerHandler, ServiceExt,
};
use serde_json::Value;
use tokio_util::sync::CancellationToken;

use crate::{
    app,
    error::AppResult,
    models::{
        Account, ApiRequestArgs, AttachmentArgs, BatchArgs, BulkCreateArgs, BulkUpdateArgs,
        ChecklistAddArgs, ChecklistItemUpdateArgs, CommentAddArgs, CommentDeleteArgs,
        CommentIdArgs, CommentListArgs, CommentReplyArgs, CommentUpdateArgs, DependencyArgs,
        DocCreateArgs, DocGetArgs, DocIdArgs, DocPageCreateArgs, DocPageUpdateArgs, DocSearchArgs,
        FieldClearArgs, FieldSetArgs, FolderCreateArgs, HierarchyArgs, LinkArgs, ListArgs,
        ListCreateArgs, MemberListArgs, MemberResolveArgs, StandupArgs, TagArgs, TaskConfirmArgs,
        TaskCreateArgs, TaskGetArgs, TaskListArgs, TaskMoveArgs, TaskSearchArgs, TaskStatusArgs,
        TaskUpdateArgs, TimeAddArgs, TimeDeleteArgs, TimeInStatusArgs, TimeListArgs, TimeStartArgs,
        ToolResponse,
    },
};

#[derive(Clone)]
pub struct ClickUpMcpServer {
    tool_router: ToolRouter<Self>,
}

impl ClickUpMcpServer {
    pub fn new() -> Self {
        Self {
            tool_router: Self::tool_router(),
        }
    }
}

impl Default for ClickUpMcpServer {
    fn default() -> Self {
        Self::new()
    }
}

/// MCP stdio frames are single JSON lines and several clients cap line
/// length (e.g. 64 KB); keep responses comfortably below that.
const MAX_RESPONSE_BYTES: usize = 48 * 1024;
const MAX_STRING_CHARS: usize = 2000;

fn bound_response(mut value: Value) -> Value {
    if serde_json::to_string(&value).map_or(0, |s| s.len()) <= MAX_RESPONSE_BYTES {
        return value;
    }
    truncate_long_strings(&mut value, MAX_STRING_CHARS);
    if let Value::Object(map) = &mut value {
        map.insert("_truncated".into(), Value::Bool(true));
    }
    value
}

fn truncate_long_strings(value: &mut Value, max: usize) {
    match value {
        Value::String(text) if text.chars().count() > max => {
            let kept: String = text.chars().take(max).collect();
            *text = format!("{kept}…[truncated]");
        }
        Value::Array(items) => items.iter_mut().for_each(|v| truncate_long_strings(v, max)),
        Value::Object(map) => map.values_mut().for_each(|v| truncate_long_strings(v, max)),
        _ => {}
    }
}

fn respond(result: AppResult<Value>) -> Result<Json<ToolResponse>, ErrorData> {
    result
        .map(|v| {
            Json(ToolResponse {
                result: bound_response(v),
            })
        })
        .map_err(|e| e.to_mcp())
}

#[tool_handler(router = self.tool_router)]
impl ServerHandler for ClickUpMcpServer {
    fn get_info(&self) -> ServerConfig {
        ServerConfig::new(ServerCapabilities::builder().enable_tools().build())
            .with_server_info(
                Implementation::new("clickupc", env!("CARGO_PKG_VERSION"))
                    .with_title("clickupc MCP")
                    .with_description("Unofficial ClickUp tools for MCP clients"),
            )
            .with_instructions(
                "Use the clickup_* tools for ClickUp tasks, comments, custom fields, time tracking, docs and raw API access. Inputs accept names (lists, statuses, members, fields, options) or ids, and dates like 'tomorrow' or '2026-10-20'. Every tool takes optional `profile` (account, see clickup_profile_list) and `workspace` to switch account or workspace per call. Delete/remove/clear tools require confirm=true. Use clickup_field_set to change custom fields.",
            )
    }
}

#[tool_router(router = tool_router)]
impl ClickUpMcpServer {
    #[tool(
        name = "clickup_auth_status",
        description = "Show the active profile, workspace id, whether a token is configured (masked), and the config path. No API call. Use first when other tools return auth_missing."
    )]
    pub async fn clickup_auth_status(
        &self,
        Parameters(args): Parameters<Account>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::auth_status(args))
    }

    #[tool(
        name = "clickup_profile_list",
        description = "List the clickupc profiles (ClickUp accounts) configured on this machine and which one is active. Pass `profile` and/or `workspace` to any clickup_* tool to run it as another account or in another workspace."
    )]
    pub async fn clickup_profile_list(&self) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::profile_list())
    }

    #[tool(
        name = "clickup_whoami",
        description = "Show the authenticated ClickUp user (id, username, email, timezone) plus the current workspace and plan."
    )]
    pub async fn clickup_whoami(
        &self,
        Parameters(args): Parameters<Account>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::whoami(args).await)
    }

    #[tool(
        name = "clickup_workspace_list",
        description = "List workspaces the token can access and which one is current. Workspace = 'team' in ClickUp API v2."
    )]
    pub async fn clickup_workspace_list(
        &self,
        Parameters(args): Parameters<Account>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::workspace_list(args).await)
    }

    #[tool(
        name = "clickup_hierarchy",
        description = "Space → Folder → List tree with ids and names (cached for 1 hour; refresh=true to bypass). Use it to discover list names before searching or creating tasks."
    )]
    pub async fn clickup_hierarchy(
        &self,
        Parameters(args): Parameters<HierarchyArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::hierarchy(args).await)
    }

    #[tool(
        name = "clickup_list_get",
        description = "Details for one list: statuses (name, type, order), custom fields (name, type, options) and members. Call before creating/updating tasks to learn valid statuses and field names."
    )]
    pub async fn clickup_list_get(
        &self,
        Parameters(args): Parameters<ListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::list_get(args).await)
    }

    #[tool(
        name = "clickup_member_list",
        description = "List workspace members, or members of one list."
    )]
    pub async fn clickup_member_list(
        &self,
        Parameters(args): Parameters<MemberListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::member_list(args).await)
    }

    #[tool(
        name = "clickup_member_resolve",
        description = "Resolve names, emails or 'me' to ClickUp user ids. Unresolved queries return resolve_error data with suggestions."
    )]
    pub async fn clickup_member_resolve(
        &self,
        Parameters(args): Parameters<MemberResolveArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::member_resolve(args).await)
    }

    #[tool(
        name = "clickup_api_request",
        description = "Raw ClickUp API call for endpoints without a dedicated tool. Path must start with /v2/ or /v3/; '{workspace}' is substituted. Non-GET requires confirm=true."
    )]
    pub async fn clickup_api_request(
        &self,
        Parameters(args): Parameters<ApiRequestArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::api_request(args).await)
    }

    #[tool(
        name = "clickup_task_search",
        description = "Search tasks by list/folder/space, status, assignee, tag, dates, custom fields and task type. Names are resolved for you. Returns compact summaries (detail='full' for everything). Closed tasks need include_closed=true. If the profile has several active workspaces and no `workspace` is given, searches all of them: each task gets a `workspace` name and failed workspaces are listed in `skipped`."
    )]
    pub async fn clickup_task_search(
        &self,
        Parameters(args): Parameters<TaskSearchArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_search(args).await)
    }

    #[tool(
        name = "clickup_task_get",
        description = "Get one task by id, custom id (DEV-123) or URL. detail='full' adds markdown description, custom fields, checklists and relations; include_comments adds the newest 25 comments."
    )]
    pub async fn clickup_task_get(
        &self,
        Parameters(args): Parameters<TaskGetArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_get(args).await)
    }

    #[tool(
        name = "clickup_task_create",
        description = "Create a task in a list. Accepts names for status, assignees, task type and custom fields; dates like 'tomorrow' or '2026-10-20'; estimate like '2h'. Description is markdown."
    )]
    pub async fn clickup_task_create(
        &self,
        Parameters(args): Parameters<TaskCreateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_create(args).await)
    }

    #[tool(
        name = "clickup_task_update",
        description = "Update task fields. Use assignees_add/assignees_remove (not a full list). custom_fields are applied afterwards via Set Custom Field and reported per field; use clickup_field_set for a single field. Set due/estimate to 'none' to clear."
    )]
    pub async fn clickup_task_update(
        &self,
        Parameters(args): Parameters<TaskUpdateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_update(args).await)
    }

    #[tool(
        name = "clickup_task_set_status",
        description = "Change a task's status; validated against the task's list (case-insensitive). Mismatches return resolve_error with suggestions."
    )]
    pub async fn clickup_task_set_status(
        &self,
        Parameters(args): Parameters<TaskStatusArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_set_status(args).await)
    }

    #[tool(
        name = "clickup_task_move",
        description = "Move a task to a new home list. If the current status doesn't exist in the target list, pass status_map {old: new}; otherwise the error lists the target list's statuses."
    )]
    pub async fn clickup_task_move(
        &self,
        Parameters(args): Parameters<TaskMoveArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_move(args).await)
    }

    #[tool(
        name = "clickup_task_delete",
        description = "Permanently delete a task. Requires confirm=true."
    )]
    pub async fn clickup_task_delete(
        &self,
        Parameters(args): Parameters<TaskConfirmArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_delete(args).await)
    }

    #[tool(
        name = "clickup_task_bulk_create",
        description = "Create many tasks in one list with bounded concurrency and per-item results. dry_run=true returns the plan only."
    )]
    pub async fn clickup_task_bulk_create(
        &self,
        Parameters(args): Parameters<BulkCreateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_bulk_create(args).await)
    }

    #[tool(
        name = "clickup_task_bulk_update",
        description = "Apply the same changes (status, priority, assignees_add, tags_add, due) to explicit tasks or to every task matching a search filter. dry_run=true lists matches; more than 1 task requires confirm=true."
    )]
    pub async fn clickup_task_bulk_update(
        &self,
        Parameters(args): Parameters<BulkUpdateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_bulk_update(args).await)
    }

    #[tool(
        name = "clickup_task_batch",
        description = "Run mixed operations in sequence: create, update, status, comment, delete. dry_run=true returns the plan; more than 1 op or any delete requires confirm=true. Per-op results are returned."
    )]
    pub async fn clickup_task_batch(
        &self,
        Parameters(args): Parameters<BatchArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_batch(args).await)
    }

    #[tool(
        name = "clickup_comment_list",
        description = "List task comments, newest first (default 25; pagination handled)."
    )]
    pub async fn clickup_comment_list(
        &self,
        Parameters(args): Parameters<CommentListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::comment_list(args).await)
    }

    #[tool(
        name = "clickup_comment_add",
        description = "Add a plain-text comment to a task, optionally assigned to a member."
    )]
    pub async fn clickup_comment_add(
        &self,
        Parameters(args): Parameters<CommentAddArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::comment_add(args).await)
    }

    #[tool(
        name = "clickup_comment_update",
        description = "Edit a comment's text and/or mark it resolved."
    )]
    pub async fn clickup_comment_update(
        &self,
        Parameters(args): Parameters<CommentUpdateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::comment_update(args).await)
    }

    #[tool(
        name = "clickup_comment_delete",
        description = "Delete a comment. Requires confirm=true."
    )]
    pub async fn clickup_comment_delete(
        &self,
        Parameters(args): Parameters<CommentDeleteArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::comment_delete(args).await)
    }

    #[tool(
        name = "clickup_comment_replies",
        description = "List threaded replies to a comment."
    )]
    pub async fn clickup_comment_replies(
        &self,
        Parameters(args): Parameters<CommentIdArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::comment_replies(args).await)
    }

    #[tool(
        name = "clickup_comment_reply",
        description = "Reply in a comment thread."
    )]
    pub async fn clickup_comment_reply(
        &self,
        Parameters(args): Parameters<CommentReplyArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::comment_reply(args).await)
    }

    #[tool(
        name = "clickup_field_list",
        description = "Custom fields available in a list: name, id, type, options."
    )]
    pub async fn clickup_field_list(
        &self,
        Parameters(args): Parameters<ListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::field_list(args).await)
    }

    #[tool(
        name = "clickup_field_set",
        description = "Set one custom field on a task from a human value (option name, labels, date, number, checkbox, members). This is the only way to change custom fields; clickup_task_update applies them through this same call."
    )]
    pub async fn clickup_field_set(
        &self,
        Parameters(args): Parameters<FieldSetArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::field_set(args).await)
    }

    #[tool(
        name = "clickup_field_clear",
        description = "Remove a custom field's value from a task. Requires confirm=true."
    )]
    pub async fn clickup_field_clear(
        &self,
        Parameters(args): Parameters<FieldClearArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::field_clear(args).await)
    }

    #[tool(
        name = "clickup_tag_add",
        description = "Add existing space tags to a task."
    )]
    pub async fn clickup_tag_add(
        &self,
        Parameters(args): Parameters<TagArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::tag_add(args).await)
    }

    #[tool(name = "clickup_tag_remove", description = "Remove tags from a task.")]
    pub async fn clickup_tag_remove(
        &self,
        Parameters(args): Parameters<TagArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::tag_remove(args).await)
    }

    #[tool(name = "clickup_link_add", description = "Link two tasks.")]
    pub async fn clickup_link_add(
        &self,
        Parameters(args): Parameters<LinkArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::link_add(args).await)
    }

    #[tool(
        name = "clickup_link_remove",
        description = "Remove a link between two tasks. Requires confirm=true."
    )]
    pub async fn clickup_link_remove(
        &self,
        Parameters(args): Parameters<LinkArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::link_remove(args).await)
    }

    #[tool(
        name = "clickup_dependency_add",
        description = "Add a dependency: `blocks` (this task blocks the other) or `waiting_on` (this task waits on the other)."
    )]
    pub async fn clickup_dependency_add(
        &self,
        Parameters(args): Parameters<DependencyArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::dependency_add(args).await)
    }

    #[tool(
        name = "clickup_dependency_remove",
        description = "Remove a dependency. Requires confirm=true."
    )]
    pub async fn clickup_dependency_remove(
        &self,
        Parameters(args): Parameters<DependencyArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::dependency_remove(args).await)
    }

    #[tool(
        name = "clickup_checklist_add",
        description = "Create a checklist on a task, optionally with items."
    )]
    pub async fn clickup_checklist_add(
        &self,
        Parameters(args): Parameters<ChecklistAddArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::checklist_add(args).await)
    }

    #[tool(
        name = "clickup_checklist_item_update",
        description = "Resolve/unresolve or rename a checklist item."
    )]
    pub async fn clickup_checklist_item_update(
        &self,
        Parameters(args): Parameters<ChecklistItemUpdateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::checklist_item_update(args).await)
    }

    #[tool(
        name = "clickup_attachment_upload",
        description = "Upload a local file as a task attachment."
    )]
    pub async fn clickup_attachment_upload(
        &self,
        Parameters(args): Parameters<AttachmentArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::attachment_upload(args).await)
    }

    #[tool(
        name = "clickup_task_add_to_list",
        description = "Add a task to an additional list (Tasks in Multiple Lists); its home list is unchanged."
    )]
    pub async fn clickup_task_add_to_list(
        &self,
        Parameters(args): Parameters<TaskListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_add_to_list(args).await)
    }

    #[tool(
        name = "clickup_task_remove_from_list",
        description = "Remove a task from an additional list. Requires confirm=true."
    )]
    pub async fn clickup_task_remove_from_list(
        &self,
        Parameters(args): Parameters<TaskListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::task_remove_from_list(args).await)
    }

    #[tool(
        name = "clickup_time_list",
        description = "List time entries (default: last 30 days, current user) with durations like '1h 30m' and a total."
    )]
    pub async fn clickup_time_list(
        &self,
        Parameters(args): Parameters<TimeListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::time_list(args).await)
    }

    #[tool(
        name = "clickup_time_add",
        description = "Log time on a task, e.g. duration '1h30m'. Default start is now minus the duration."
    )]
    pub async fn clickup_time_add(
        &self,
        Parameters(args): Parameters<TimeAddArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::time_add(args).await)
    }

    #[tool(
        name = "clickup_time_start",
        description = "Start a timer, optionally on a task."
    )]
    pub async fn clickup_time_start(
        &self,
        Parameters(args): Parameters<TimeStartArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::time_start(args).await)
    }

    #[tool(name = "clickup_time_stop", description = "Stop the running timer.")]
    pub async fn clickup_time_stop(
        &self,
        Parameters(args): Parameters<Account>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::time_stop(args).await)
    }

    #[tool(
        name = "clickup_time_current",
        description = "The running time entry, or null."
    )]
    pub async fn clickup_time_current(
        &self,
        Parameters(args): Parameters<Account>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::time_current(args).await)
    }

    #[tool(
        name = "clickup_time_delete",
        description = "Delete a time entry. Requires confirm=true."
    )]
    pub async fn clickup_time_delete(
        &self,
        Parameters(args): Parameters<TimeDeleteArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::time_delete(args).await)
    }

    #[tool(
        name = "clickup_time_in_status",
        description = "How long a task (or several tasks) spent in each status."
    )]
    pub async fn clickup_time_in_status(
        &self,
        Parameters(args): Parameters<TimeInStatusArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::time_in_status(args).await)
    }

    #[tool(
        name = "clickup_standup",
        description = "Standup summary for a user (default me): tasks closed and updated since (default yesterday), in progress, due within 3 days, overdue. With several active workspaces (and no `workspace`), returns one standup per workspace under `workspaces`."
    )]
    pub async fn clickup_standup(
        &self,
        Parameters(args): Parameters<StandupArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::standup(args).await)
    }

    #[tool(
        name = "clickup_list_summary",
        description = "Counts for a list: total, by status, by assignee, overdue."
    )]
    pub async fn clickup_list_summary(
        &self,
        Parameters(args): Parameters<ListArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::list_summary(args).await)
    }

    #[tool(
        name = "clickup_list_create",
        description = "Create a list in a folder, or a folderless list in a space."
    )]
    pub async fn clickup_list_create(
        &self,
        Parameters(args): Parameters<ListCreateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::list_create(args).await)
    }

    #[tool(
        name = "clickup_folder_create",
        description = "Create a folder in a space."
    )]
    pub async fn clickup_folder_create(
        &self,
        Parameters(args): Parameters<FolderCreateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::folder_create(args).await)
    }

    #[tool(
        name = "clickup_doc_search",
        description = "List docs in the workspace, optionally filtered by a name substring."
    )]
    pub async fn clickup_doc_search(
        &self,
        Parameters(args): Parameters<DocSearchArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::doc_search(args).await)
    }

    #[tool(
        name = "clickup_doc_get",
        description = "Get a doc and its page listing, or one page's markdown with page_id."
    )]
    pub async fn clickup_doc_get(
        &self,
        Parameters(args): Parameters<DocGetArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::doc_get(args).await)
    }

    #[tool(
        name = "clickup_doc_pages",
        description = "All pages of a doc with markdown content."
    )]
    pub async fn clickup_doc_pages(
        &self,
        Parameters(args): Parameters<DocIdArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::doc_pages(args).await)
    }

    #[tool(
        name = "clickup_doc_create",
        description = "Create a doc in the workspace or under a space, folder or list."
    )]
    pub async fn clickup_doc_create(
        &self,
        Parameters(args): Parameters<DocCreateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::doc_create(args).await)
    }

    #[tool(
        name = "clickup_doc_page_create",
        description = "Add a markdown page to a doc."
    )]
    pub async fn clickup_doc_page_create(
        &self,
        Parameters(args): Parameters<DocPageCreateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::doc_page_create(args).await)
    }

    #[tool(
        name = "clickup_doc_page_update",
        description = "Edit a doc page: replace, append or prepend markdown content, or rename it."
    )]
    pub async fn clickup_doc_page_update(
        &self,
        Parameters(args): Parameters<DocPageUpdateArgs>,
    ) -> Result<Json<ToolResponse>, ErrorData> {
        respond(app::doc_page_update(args).await)
    }
}

pub async fn run_stdio() -> anyhow::Result<()> {
    let server = ClickUpMcpServer::new().serve(stdio()).await?;
    server.waiting().await?;
    Ok(())
}

pub async fn run_streamable_http(host: &str, port: u16, path: &str) -> anyhow::Result<()> {
    let cancellation_token = CancellationToken::new();
    let allowed_hosts = [
        format!("{host}:{port}"),
        host.to_string(),
        format!("127.0.0.1:{port}"),
        "127.0.0.1".to_string(),
        format!("localhost:{port}"),
        "localhost".to_string(),
    ];
    let service = StreamableHttpService::new(
        || Ok(ClickUpMcpServer::new()),
        LocalSessionManager::default().into(),
        StreamableHttpServerConfig::default()
            .with_cancellation_token(cancellation_token.child_token())
            .with_allowed_hosts(allowed_hosts),
    );
    let router = axum::Router::new().nest_service(path, service);
    let listener = tokio::net::TcpListener::bind(format!("{host}:{port}")).await?;
    axum::serve(listener, router)
        .with_graceful_shutdown(async move {
            let _ = tokio::signal::ctrl_c().await;
            cancellation_token.cancel();
        })
        .await?;
    Ok(())
}