clokio-mcp 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -140,10 +140,14 @@ that employee:
140
140
  - A document the employee cannot see answers **`404`**, the same as one that
141
141
  does not exist (the API never confirms an id to someone not allowed to know it).
142
142
  - A visible document they may not change answers **`403`**.
143
- - The employee's role gates each call: `docs.view` for reads, `docs.create`
144
- for content writes, `docs.manage` for delete and sharing. Per document,
145
- roles are `view` < `comment` < `edit` < `admin`; each tool's description
146
- names what it needs.
143
+ - Two separate gates, both named in each tool's description:
144
+ - the employee's **role** must hold the section permission: `docs.view`
145
+ for reads, `docs.create` for creating, editing, moving, archiving,
146
+ comments, version restores and uploads, `docs.manage` for delete, members,
147
+ teams and share links (and for standalone documents). A `403`
148
+ `Forbidden: Insufficient permissions` means this gate refused;
149
+ - the **document role**, `view` < `comment` < `edit` < `admin`. A `403`
150
+ with any other message means that role is too low.
147
151
 
148
152
  | Tool | Endpoint |
149
153
  |------|----------|
@@ -25,7 +25,16 @@ import { registerTool } from './helpers.js';
25
25
  * same way: the record or rows in `data`, paging / permissions / counts in
26
26
  * `meta`. See shape*() below.
27
27
  */
28
- const ACCESS = 'Docs access: see clokio_list_docs.';
28
+ /**
29
+ * Per-tool access tag: the SECTION permission the acting employee's role
30
+ * must hold (the backend's sectionGate() per route), on top of the doc role
31
+ * each description names ("needs edit", "needs admin"). The full rule lives
32
+ * once, on clokio_list_docs. Verified against
33
+ * app/Http/Controllers/EmployeeApi/Doc*.php (sectionGate calls).
34
+ */
35
+ const VIEW = 'Needs docs.view; see clokio_list_docs.';
36
+ const CREATE = 'Needs docs.create; see clokio_list_docs.';
37
+ const MANAGE = 'Needs docs.manage; see clokio_list_docs.';
29
38
  const docId = z.number().int().positive().describe('Document id');
30
39
  const CONTENT_FORMATS = ['markdown', 'html', 'json'];
31
40
  const contentArg = z
@@ -159,7 +168,11 @@ export function registerDocTools(server, config) {
159
168
  'or, if the key has none, as the key\'s creator - only when the key lists docs:read / docs:write ' +
160
169
  'explicitly ("*" is not enough). Otherwise every docs tool returns 403: set an acts-as employee or add ' +
161
170
  'the docs scopes in Settings > API keys. Reads need scope docs:read, everything else docs:write. You see ' +
162
- 'exactly what that employee sees; a doc they cannot see is 404.',
171
+ 'exactly what that employee sees; a doc they cannot see is 404. ' +
172
+ 'Two separate gates: the employee\'s ROLE must hold the section permission each tool names (docs.view ' +
173
+ 'reads; docs.create writes, comments, uploads; docs.manage delete and sharing) - a 403 "Forbidden: ' +
174
+ 'Insufficient permissions" means it does not; and the DOC role (view<comment<edit<admin, "needs edit" ' +
175
+ 'etc.) - a 403 with another message means that is too low. Needs docs.view.',
163
176
  schema: {
164
177
  project_id: scopeArg,
165
178
  parent_id: z
@@ -184,7 +197,7 @@ export function registerDocTools(server, config) {
184
197
  });
185
198
  registerTool(server, config, {
186
199
  name: 'clokio_get_doc_tree',
187
- description: `Documents you can view as a nested tree (children), paged over the top level. ${ACCESS}`,
200
+ description: `Documents you can view as a nested tree (children), paged over the top level. ${VIEW}`,
188
201
  schema: {
189
202
  project_id: scopeArg,
190
203
  archived: archivedArg,
@@ -203,7 +216,7 @@ export function registerDocTools(server, config) {
203
216
  });
204
217
  registerTool(server, config, {
205
218
  name: 'clokio_search_docs',
206
- description: `Search titles and body text (not archived), newest first; each row has a snippet. ${ACCESS}`,
219
+ description: `Search titles and body text (not archived), newest first; each row has a snippet. ${VIEW}`,
207
220
  schema: {
208
221
  q: z.string().min(2).max(120),
209
222
  project_id: z.number().int().positive().optional(),
@@ -214,7 +227,7 @@ export function registerDocTools(server, config) {
214
227
  registerTool(server, config, {
215
228
  name: 'clokio_get_doc',
216
229
  description: 'Read a document: data = the record plus its body; meta = your role and breadcrumbs. Keep ' +
217
- `data.content_version for clokio_update_doc_content. ${ACCESS}`,
230
+ `data.content_version for clokio_update_doc_content. ${VIEW}`,
218
231
  schema: { id: docId, format: readFormatArg, include_title: includeTitleArg },
219
232
  handler: async (args, cfg) => shapeDocRead(await request(cfg, `/docs/${seg(args.id)}`, {
220
233
  query: { format: args.format ?? 'markdown', include_title: args.include_title ? 1 : undefined },
@@ -224,8 +237,8 @@ export function registerDocTools(server, config) {
224
237
  registerTool(server, config, {
225
238
  name: 'clokio_create_doc',
226
239
  description: 'Create a document. parent_id = sub-page (needs edit on the parent); project_id = in that project; ' +
227
- 'neither = standalone (org admins only). Starts at content_version 0. ' +
228
- ACCESS,
240
+ 'neither = standalone (needs docs.manage). Starts at content_version 0. ' +
241
+ CREATE,
229
242
  mutates: true,
230
243
  schema: {
231
244
  title: z.string().min(1).max(255),
@@ -253,7 +266,7 @@ export function registerDocTools(server, config) {
253
266
  name: 'clokio_update_doc_content',
254
267
  description: 'REPLACE the whole body (needs edit). base_version = the content_version you last read. On 409 do not ' +
255
268
  'retry the same base_version: re-read, reconcile, write with the new version. Empty content clears. ' +
256
- ACCESS,
269
+ CREATE,
257
270
  mutates: true,
258
271
  schema: {
259
272
  id: docId,
@@ -270,7 +283,7 @@ export function registerDocTools(server, config) {
270
283
  name: 'clokio_update_doc_meta',
271
284
  description: 'Change metadata; send only what changes. title/icon/full_width/sort_order need edit; visibility, ' +
272
285
  'inherit_permissions, is_archived need admin. Use clokio_move_doc for parent/project. ' +
273
- ACCESS,
286
+ CREATE,
274
287
  mutates: true,
275
288
  schema: {
276
289
  id: docId,
@@ -294,7 +307,7 @@ export function registerDocTools(server, config) {
294
307
  registerTool(server, config, {
295
308
  name: 'clokio_move_doc',
296
309
  description: 'Move a document and its sub-pages (needs admin). Send both parent_id and project_id; null = top ' +
297
- `level / standalone. With a parent, the parent's project wins. ${ACCESS}`,
310
+ `level / standalone. With a parent, the parent's project wins. ${CREATE}`,
298
311
  mutates: true,
299
312
  schema: {
300
313
  id: docId,
@@ -309,21 +322,21 @@ export function registerDocTools(server, config) {
309
322
  });
310
323
  registerTool(server, config, {
311
324
  name: 'clokio_archive_doc',
312
- description: `Archive a document (needs admin; reversible with clokio_restore_doc). ${ACCESS}`,
325
+ description: `Archive a document (needs admin; reversible with clokio_restore_doc). ${CREATE}`,
313
326
  mutates: true,
314
327
  schema: { id: docId },
315
328
  handler: async (args, cfg) => liftKey(await request(cfg, `/docs/${seg(args.id)}/archive`, { method: 'POST' }), 'doc'),
316
329
  });
317
330
  registerTool(server, config, {
318
331
  name: 'clokio_restore_doc',
319
- description: `Un-archive a document (needs admin). ${ACCESS}`,
332
+ description: `Un-archive a document (needs admin). ${CREATE}`,
320
333
  mutates: true,
321
334
  schema: { id: docId },
322
335
  handler: async (args, cfg) => liftKey(await request(cfg, `/docs/${seg(args.id)}/restore`, { method: 'POST' }), 'doc'),
323
336
  });
324
337
  registerTool(server, config, {
325
338
  name: 'clokio_delete_doc',
326
- description: `DELETE a document (needs admin and docs.manage; not restorable via the API - prefer archive). ${ACCESS}`,
339
+ description: `DELETE a document (needs admin; not restorable via the API - prefer archive). ${MANAGE}`,
327
340
  mutates: 'destructive',
328
341
  schema: { id: docId },
329
342
  handler: (args, cfg) => request(cfg, `/docs/${seg(args.id)}`, { method: 'DELETE' }),
@@ -331,13 +344,13 @@ export function registerDocTools(server, config) {
331
344
  // -------------------------------------------------------------- templates
332
345
  registerTool(server, config, {
333
346
  name: 'clokio_list_doc_templates',
334
- description: `List document templates (key, name, description). ${ACCESS}`,
347
+ description: `List document templates (key, name, description). ${VIEW}`,
335
348
  schema: {},
336
349
  handler: async (_args, cfg) => liftKey(await request(cfg, '/docs/templates'), 'templates'),
337
350
  });
338
351
  registerTool(server, config, {
339
352
  name: 'clokio_create_doc_from_template',
340
- description: `Create a top-level document from a template key. No project_id = standalone (admins only). ${ACCESS}`,
353
+ description: `Create a top-level document from a template key. No project_id = standalone (needs docs.manage). ${CREATE}`,
341
354
  mutates: true,
342
355
  schema: {
343
356
  template: z.string().min(1).max(60),
@@ -353,7 +366,7 @@ export function registerDocTools(server, config) {
353
366
  registerTool(server, config, {
354
367
  name: 'clokio_list_doc_members',
355
368
  description: 'Who a document is shared with (needs admin): data = members, teams, inherited (change those on the ' +
356
- `parent); meta = visibility, inherit_permissions, share_link. ${ACCESS}`,
369
+ `parent); meta = visibility, inherit_permissions, share_link. ${VIEW}`,
357
370
  schema: {
358
371
  id: docId,
359
372
  include_avatars: z.boolean().optional().describe('Include profile pictures (default false)'),
@@ -371,7 +384,7 @@ export function registerDocTools(server, config) {
371
384
  });
372
385
  registerTool(server, config, {
373
386
  name: 'clokio_list_doc_shareable_teams',
374
- description: `Teams this document can be shared with (needs admin); use id as team_id. ${ACCESS}`,
387
+ description: `Teams this document can be shared with (needs admin); use id as team_id. ${VIEW}`,
375
388
  schema: { id: docId },
376
389
  handler: async (args, cfg) => liftKey(await request(cfg, `/docs/${seg(args.id)}/shareable-teams`), 'teams'),
377
390
  });
@@ -397,7 +410,7 @@ export function registerDocTools(server, config) {
397
410
  }
398
411
  registerTool(server, config, {
399
412
  name: 'clokio_add_doc_member',
400
- description: `Share a document with a person or change their role (needs admin; they are notified once). ${ACCESS}`,
413
+ description: `Share a document with a person or change their role (needs admin; they are notified once). ${MANAGE}`,
401
414
  mutates: true,
402
415
  schema: { id: docId, ...personArgs, role: memberRole },
403
416
  handler: async (args, cfg) => envelope(await request(cfg, `/docs/${seg(args.id)}/members`, {
@@ -407,7 +420,7 @@ export function registerDocTools(server, config) {
407
420
  });
408
421
  registerTool(server, config, {
409
422
  name: 'clokio_update_doc_member',
410
- description: `Change a person's direct role (needs admin; demoting the last admin is 422). ${ACCESS}`,
423
+ description: `Change a person's direct role (needs admin; demoting the last admin is 422). ${MANAGE}`,
411
424
  mutates: true,
412
425
  schema: { id: docId, ...personArgs, role: memberRole },
413
426
  handler: async (args, cfg) => {
@@ -427,7 +440,7 @@ export function registerDocTools(server, config) {
427
440
  });
428
441
  registerTool(server, config, {
429
442
  name: 'clokio_remove_doc_member',
430
- description: `Remove a person's direct grant (needs admin; a code may name someone who has left). ${ACCESS}`,
443
+ description: `Remove a person's direct grant (needs admin; a code may name someone who has left). ${MANAGE}`,
431
444
  mutates: 'destructive',
432
445
  schema: { id: docId, ...personArgs },
433
446
  handler: (args, cfg) => {
@@ -447,7 +460,7 @@ export function registerDocTools(server, config) {
447
460
  const teamId = z.number().int().positive().describe('From clokio_list_doc_shareable_teams');
448
461
  registerTool(server, config, {
449
462
  name: 'clokio_add_doc_team',
450
- description: `Share a document with a team (needs admin; teams cannot be admins). ${ACCESS}`,
463
+ description: `Share a document with a team (needs admin; teams cannot be admins). ${MANAGE}`,
451
464
  mutates: true,
452
465
  schema: { id: docId, team_id: teamId, role: teamRole },
453
466
  handler: async (args, cfg) => envelope(await request(cfg, `/docs/${seg(args.id)}/teams`, {
@@ -457,7 +470,7 @@ export function registerDocTools(server, config) {
457
470
  });
458
471
  registerTool(server, config, {
459
472
  name: 'clokio_update_doc_team',
460
- description: `Change a team's role on a document (needs admin). ${ACCESS}`,
473
+ description: `Change a team's role on a document (needs admin). ${MANAGE}`,
461
474
  mutates: true,
462
475
  schema: { id: docId, team_id: teamId, role: teamRole },
463
476
  handler: async (args, cfg) => envelope(await request(cfg, `/docs/${seg(args.id)}/teams/${seg(args.team_id)}`, {
@@ -467,7 +480,7 @@ export function registerDocTools(server, config) {
467
480
  });
468
481
  registerTool(server, config, {
469
482
  name: 'clokio_remove_doc_team',
470
- description: `Remove a team's grant (needs admin). ${ACCESS}`,
483
+ description: `Remove a team's grant (needs admin). ${MANAGE}`,
471
484
  mutates: 'destructive',
472
485
  schema: { id: docId, team_id: teamId },
473
486
  handler: (args, cfg) => request(cfg, `/docs/${seg(args.id)}/teams/${seg(args.team_id)}`, { method: 'DELETE' }),
@@ -475,7 +488,7 @@ export function registerDocTools(server, config) {
475
488
  registerTool(server, config, {
476
489
  name: 'clokio_create_doc_share_link',
477
490
  description: 'Create or REPLACE the public read link (needs admin; the old URL stops working). Expires in 30 days ' +
478
- `unless expires_at or never_expires is given. ${ACCESS}`,
491
+ `unless expires_at or never_expires is given. ${MANAGE}`,
479
492
  mutates: true,
480
493
  schema: {
481
494
  id: docId,
@@ -494,7 +507,7 @@ export function registerDocTools(server, config) {
494
507
  });
495
508
  registerTool(server, config, {
496
509
  name: 'clokio_revoke_doc_share_link',
497
- description: `Revoke the public link (needs admin). ${ACCESS}`,
510
+ description: `Revoke the public link (needs admin). ${MANAGE}`,
498
511
  mutates: 'destructive',
499
512
  schema: { id: docId },
500
513
  handler: (args, cfg) => request(cfg, `/docs/${seg(args.id)}/share-link`, { method: 'DELETE' }),
@@ -502,7 +515,7 @@ export function registerDocTools(server, config) {
502
515
  // --------------------------------------------------------------- comments
503
516
  registerTool(server, config, {
504
517
  name: 'clokio_list_doc_comments',
505
- description: `Comment threads, newest first, replies nested; meta has counts. ${ACCESS}`,
518
+ description: `Comment threads, newest first, replies nested; meta has counts. ${VIEW}`,
506
519
  schema: {
507
520
  id: docId,
508
521
  filter: z.enum(['unresolved', 'resolved', 'all']).optional().describe('Default unresolved'),
@@ -514,7 +527,7 @@ export function registerDocTools(server, config) {
514
527
  });
515
528
  registerTool(server, config, {
516
529
  name: 'clokio_add_doc_comment',
517
- description: `Comment, or reply to a thread with parent_id (needs comment). Markdown or HTML; @Full Name notifies. ${ACCESS}`,
530
+ description: `Comment, or reply to a thread with parent_id (needs comment). Markdown or HTML; @Full Name notifies. ${CREATE}`,
518
531
  mutates: true,
519
532
  schema: {
520
533
  id: docId,
@@ -529,14 +542,14 @@ export function registerDocTools(server, config) {
529
542
  });
530
543
  registerTool(server, config, {
531
544
  name: 'clokio_resolve_doc_comment',
532
- description: `Resolve a comment thread (needs comment). ${ACCESS}`,
545
+ description: `Resolve a comment thread (needs comment). ${CREATE}`,
533
546
  mutates: true,
534
547
  schema: { id: docId, comment_id: z.number().int().positive() },
535
548
  handler: async (args, cfg) => liftKey(stripAvatars(await request(cfg, `/docs/${seg(args.id)}/comments/${seg(args.comment_id)}/resolve`, { method: 'POST' })), 'comment'),
536
549
  });
537
550
  registerTool(server, config, {
538
551
  name: 'clokio_reopen_doc_comment',
539
- description: `Reopen a resolved comment thread (needs comment). ${ACCESS}`,
552
+ description: `Reopen a resolved comment thread (needs comment). ${CREATE}`,
540
553
  mutates: true,
541
554
  schema: { id: docId, comment_id: z.number().int().positive() },
542
555
  handler: async (args, cfg) => liftKey(stripAvatars(await request(cfg, `/docs/${seg(args.id)}/comments/${seg(args.comment_id)}/reopen`, { method: 'POST' })), 'comment'),
@@ -544,13 +557,13 @@ export function registerDocTools(server, config) {
544
557
  // --------------------------------------------------------------- versions
545
558
  registerTool(server, config, {
546
559
  name: 'clokio_list_doc_versions',
547
- description: `Version history, newest first. Pass a row's id (not its version number) to the other version tools. ${ACCESS}`,
560
+ description: `Version history, newest first. Pass a row's id (not its version number) to the other version tools. ${VIEW}`,
548
561
  schema: { id: docId },
549
562
  handler: async (args, cfg) => liftKey(await request(cfg, `/docs/${seg(args.id)}/versions`), 'versions'),
550
563
  });
551
564
  registerTool(server, config, {
552
565
  name: 'clokio_get_doc_version',
553
- description: `Read one version snapshot. ${ACCESS}`,
566
+ description: `Read one version snapshot. ${VIEW}`,
554
567
  schema: {
555
568
  id: docId,
556
569
  version_id: z.number().int().positive(),
@@ -563,7 +576,7 @@ export function registerDocTools(server, config) {
563
576
  });
564
577
  registerTool(server, config, {
565
578
  name: 'clokio_restore_doc_version',
566
- description: `Restore a snapshot over the content (needs edit). content_version moves: use the returned one. ${ACCESS}`,
579
+ description: `Restore a snapshot over the content (needs edit). content_version moves: use the returned one. ${CREATE}`,
567
580
  mutates: true,
568
581
  schema: { id: docId, version_id: z.number().int().positive() },
569
582
  handler: async (args, cfg) => envelope(await request(cfg, `/docs/${seg(args.id)}/versions/${seg(args.version_id)}/restore`, { method: 'POST' })),
@@ -571,14 +584,14 @@ export function registerDocTools(server, config) {
571
584
  // ------------------------------------------------------------ attachments
572
585
  registerTool(server, config, {
573
586
  name: 'clokio_list_doc_attachments',
574
- description: `Files uploaded to a document: name, size, mime, uploaded_at, path (for download). ${ACCESS}`,
587
+ description: `Files uploaded to a document: name, size, mime, uploaded_at, path (for download). ${VIEW}`,
575
588
  schema: { id: docId },
576
589
  handler: async (args, cfg) => shapeAttachments(await request(cfg, `/docs/${seg(args.id)}/attachments`)),
577
590
  });
578
591
  registerTool(server, config, {
579
592
  name: 'clokio_upload_doc_attachment',
580
593
  description: 'Upload a LOCAL file (needs edit). kind file (default, 100 MB) or media (images/video, 50 MB). Does not ' +
581
- `change the text: reference the returned url in the body yourself. ${ACCESS}`,
594
+ `change the text: reference the returned url in the body yourself. ${CREATE}`,
582
595
  mutates: true,
583
596
  schema: {
584
597
  id: docId,
@@ -590,7 +603,7 @@ export function registerDocTools(server, config) {
590
603
  registerTool(server, config, {
591
604
  name: 'clokio_download_doc_attachment',
592
605
  description: 'Download an attachment by its path. save_path writes it to disk; otherwise text, PDF text, ZIP entries ' +
593
- `or an image come back inline. ${ACCESS}`,
606
+ `or an image come back inline. ${VIEW}`,
594
607
  schema: {
595
608
  id: docId,
596
609
  path: z.string().min(1).max(1024).describe('`path` from clokio_list_doc_attachments'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clokio-mcp",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "Model Context Protocol (MCP) server for Clokio - manage tasks, projects, clients, employees, attendance and documents from Claude and any MCP client.",
5
5
  "type": "module",
6
6
  "bin": {