planko-mcp-server 0.5.1 → 0.6.0

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/index.js CHANGED
@@ -8,9 +8,12 @@
8
8
  * PLANKO_API_BASE — optional API base URL override
9
9
  *
10
10
  * Tools:
11
- * planko_setup — Configure sync for a project folder
12
- * planko_sync_preview — Preview what would be synced
13
- * planko_sync — Execute bidirectional sync with delete support
11
+ * planko_setup / planko_sync_preview / planko_sync — folder sync
12
+ * planko_create_* / planko_edit_* / planko_delete_* / planko_view_* / planko_list_*
13
+ * for tasks (type=1), notes (type=2) and sticky notes (type=3)
14
+ * planko_complete_task — works on any item id
15
+ * planko_list_all — tasks + sticky notes + notes in one listing
16
+ * planko_recommend_task — suggest a task for the account owner to accept/reject
14
17
  */
15
18
 
16
19
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
@@ -18,14 +21,32 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
18
21
  import { z } from 'zod';
19
22
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
20
23
  import { join } from 'node:path';
24
+ import { createRequire } from 'node:module';
21
25
 
22
26
  import { createApiClient } from './src/api.js';
27
+ import {
28
+ TYPE_TASK,
29
+ TYPE_NOTE,
30
+ TYPE_STICKY,
31
+ resolveBoardFilters,
32
+ renderList,
33
+ renderItem,
34
+ mergeAllLists,
35
+ renderAll,
36
+ } from './src/listing.js';
23
37
  import { isBlankValue, applyDueDateFallback } from './src/sanitize.js';
38
+ import {
39
+ buildRecommendationBody,
40
+ renderRecommendation,
41
+ describeLockError,
42
+ } from './src/recommend.js';
24
43
  import {
25
44
  lockProjectId,
26
45
  sanitizeFilters,
27
- ownerName,
28
46
  assertProjectAllowed,
47
+ stripHallucinatedListFilters,
48
+ matchesAssignee,
49
+ hasOwnerInfo,
29
50
  } from './src/projectLock.js';
30
51
  import {
31
52
  blockNoteToMarkdown,
@@ -370,9 +391,11 @@ async function executeSync(projectId, folder, sync) {
370
391
 
371
392
  // --- MCP Server ---
372
393
 
394
+ const { version: PKG_VERSION } = createRequire(import.meta.url)('./package.json');
395
+
373
396
  const server = new McpServer({
374
397
  name: 'planko-mcp-server',
375
- version: '0.5.0',
398
+ version: PKG_VERSION,
376
399
  });
377
400
 
378
401
  // ---- planko_setup ----
@@ -426,16 +449,16 @@ server.tool(
426
449
  const syncState = createSyncState(match._id, match.name, type);
427
450
  writeSyncState(folderPath, syncState);
428
451
 
429
- const typeLabel = type === 2 ? 'Notes' : 'Tasks';
452
+ const syncLabel = type === 2 ? 'Notes' : 'Tasks';
430
453
 
431
454
  return toolOk(
432
455
  `Setup complete for project "${match.name}".\n` +
433
456
  ` Project ID: ${match._id}\n` +
434
457
  ` Folder: ${folderPath}\n` +
435
458
  ` Email: ${email}\n` +
436
- ` Syncs: ${typeLabel} (type=${type})\n` +
459
+ ` Syncs: ${syncLabel} (type=${type})\n` +
437
460
  ` Workspace: ${match.isWorkspace ? 'Yes' : 'No (personal)'}\n\n` +
438
- `Run planko_sync to pull ${typeLabel.toLowerCase()} into this folder.`
461
+ `Run planko_sync to pull ${syncLabel.toLowerCase()} into this folder.`
439
462
  );
440
463
  } catch (err) {
441
464
  return toolError(`Setup failed: ${err.message}`);
@@ -588,8 +611,14 @@ server.tool(
588
611
 
589
612
  // --- Standalone CRUD tools (Part B) ---
590
613
  // These operate directly via the user-scoped API key and do NOT require any
591
- // folder to be configured with planko_setup. Notes are Task docs with type=2;
592
- // tasks are type=1. Edit/Delete work on both; Complete is task-oriented.
614
+ // folder to be configured with planko_setup. Notes are Task docs with type=2,
615
+ // sticky notes type=3, tasks type=1. Edit/Delete/View work on any of them;
616
+ // Complete is task-oriented but accepts any id.
617
+
618
+ const editableType = z
619
+ .union([z.literal(1), z.literal(2), z.literal(3)])
620
+ .optional()
621
+ .describe('Change type: 1=task, 2=note, 3=sticky note');
593
622
 
594
623
  const objectId = z
595
624
  .string()
@@ -627,7 +656,14 @@ const taskProps = {
627
656
  .nullable()
628
657
  .optional()
629
658
  .describe('Recurrence rule (null or one of the recurrence keywords)'),
630
- repeatDate: z.string().optional().describe('Recurrence end/anchor date (ISO 8601 string)'),
659
+ // The backend stores an integer here (Joi.number().integer()), NOT a date:
660
+ // the weekday (1-7) for weekly repeats or the day of month (1-31) for monthly.
661
+ repeatDate: z
662
+ .number()
663
+ .int()
664
+ .nullable()
665
+ .optional()
666
+ .describe('Recurrence day (integer, not a date): weekday 1-7 for weekly, day of month 1-31 for monthly'),
631
667
  selectedWeekdays: z
632
668
  .array(z.number().int().min(0).max(6))
633
669
  .optional()
@@ -749,7 +785,7 @@ async function handleEdit(params, kindLabel) {
749
785
  // ---- planko_create_task ----
750
786
  server.tool(
751
787
  'planko_create_task',
752
- 'Create a Planko task (type=1) directly via your API key. Works without any folder setup. Provide a name (required); all other properties are optional. Optionally target a project by name (otherwise your default project is used).',
788
+ 'Create a Planko task (type=1) directly via your API key, immediately and without approval. Works without any folder setup. Provide a name (required); all other properties are optional. Optionally target a project by name (otherwise your default project is used). To propose a task for the account owner to accept or reject instead, use planko_recommend_task.',
753
789
  {
754
790
  name: z.string().describe('Task name (required)'),
755
791
  projectName: z
@@ -760,7 +796,7 @@ server.tool(
760
796
  },
761
797
  async (params) => {
762
798
  try {
763
- return await handleCreate(1, params, 'task');
799
+ return await handleCreate(TYPE_TASK, params, 'task');
764
800
  } catch (err) {
765
801
  return toolError(`Create task failed: ${err.message}`);
766
802
  }
@@ -781,13 +817,83 @@ server.tool(
781
817
  },
782
818
  async (params) => {
783
819
  try {
784
- return await handleCreate(2, params, 'note');
820
+ return await handleCreate(TYPE_NOTE, params, 'note');
785
821
  } catch (err) {
786
822
  return toolError(`Create note failed: ${err.message}`);
787
823
  }
788
824
  }
789
825
  );
790
826
 
827
+ // ---- planko_create_sticky_note ----
828
+ server.tool(
829
+ 'planko_create_sticky_note',
830
+ 'Create a Planko sticky note (type=3) directly via your API key. A sticky note is a task-page item with every task property (dates, priority, tags, kanban column). Provide a name (required); all other properties are optional. Optionally target a project by name (otherwise your default project is used).',
831
+ {
832
+ name: z.string().describe('Sticky note name (required)'),
833
+ projectName: z
834
+ .string()
835
+ .optional()
836
+ .describe('Project name to create the sticky note in (optional — omit for your default project)'),
837
+ ...taskProps,
838
+ },
839
+ async (params) => {
840
+ try {
841
+ return await handleCreate(TYPE_STICKY, params, 'sticky note');
842
+ } catch (err) {
843
+ return toolError(`Create sticky note failed: ${err.message}`);
844
+ }
845
+ }
846
+ );
847
+
848
+ // ---- planko_recommend_task ----
849
+ // PL274: a SUGGESTION, not a write. The backend stores it as a pending
850
+ // recommendation addressed to the API key's owner and notifies them; the task is
851
+ // created only if they accept it in Planko. There is no read-back endpoint.
852
+ server.tool(
853
+ 'planko_recommend_task',
854
+ 'Suggest a new task to the Planko account owner instead of creating it. The owner gets a notification (notification centre + push) with Accept/Reject buttons; the task is created only when they accept. Use this when a human should approve before anything is written, or when you must not create tasks directly; use planko_create_task to create immediately. The recipient is always the owner of the API key (never other project members). Provide a title (required); all other task properties are optional and are applied to the task on accept. The outcome cannot be read back afterwards and re-sending creates a duplicate suggestion, so send each suggestion once.',
855
+ {
856
+ title: z.string().trim().min(1).max(500).describe('Suggested task name (required, up to 500 characters)'),
857
+ projectName: z
858
+ .string()
859
+ .optional()
860
+ .describe('Project name the task would be created in (optional — omit for the owner\'s default project)'),
861
+ ...taskProps,
862
+ },
863
+ async (params) => {
864
+ try {
865
+ const { title, projectName, ...rest } = params;
866
+ const body = buildTaskBody(rest);
867
+ let projectNameIgnored = false;
868
+
869
+ if (PROJECT_LOCK) {
870
+ // Same hard override as handleCreate: the suggestion can only target
871
+ // the locked project; projectName is neither resolved nor honoured.
872
+ body.projectId = lockProjectId(PROJECT_LOCK, body.projectId);
873
+ projectNameIgnored = !isBlankValue(projectName);
874
+ } else if (!isBlankValue(projectName)) {
875
+ body.projectId = await resolveProjectId(projectName);
876
+ }
877
+
878
+ let res;
879
+ try {
880
+ res = await api.createRecommendation(buildRecommendationBody(title, body));
881
+ } catch (err) {
882
+ throw describeLockError(err, PROJECT_LOCK);
883
+ }
884
+ return toolOk(
885
+ renderRecommendation(res, {
886
+ projectId: body.projectId,
887
+ lock: PROJECT_LOCK,
888
+ projectNameIgnored,
889
+ })
890
+ );
891
+ } catch (err) {
892
+ return toolError(`Recommend task failed: ${err.message}`);
893
+ }
894
+ }
895
+ );
896
+
791
897
  // ---- planko_edit_task ----
792
898
  server.tool(
793
899
  'planko_edit_task',
@@ -795,10 +901,7 @@ server.tool(
795
901
  {
796
902
  taskId: objectId.describe('Id of the task to edit (required)'),
797
903
  name: z.string().optional().describe('New task name'),
798
- type: z
799
- .union([z.literal(1), z.literal(2)])
800
- .optional()
801
- .describe('Change type: 1=task, 2=note'),
904
+ type: editableType,
802
905
  projectId: objectId.optional().describe('Move to a different project by id'),
803
906
  ...taskProps,
804
907
  },
@@ -818,10 +921,7 @@ server.tool(
818
921
  {
819
922
  taskId: objectId.describe('Id of the note to edit (required)'),
820
923
  name: z.string().optional().describe('New note name'),
821
- type: z
822
- .union([z.literal(1), z.literal(2)])
823
- .optional()
824
- .describe('Change type: 1=task, 2=note'),
924
+ type: editableType,
825
925
  projectId: objectId.optional().describe('Move to a different project by id'),
826
926
  ...taskProps,
827
927
  },
@@ -834,10 +934,30 @@ server.tool(
834
934
  }
835
935
  );
836
936
 
937
+ // ---- planko_edit_sticky_note ----
938
+ server.tool(
939
+ 'planko_edit_sticky_note',
940
+ 'Edit an existing Planko sticky note by id (shares the task edit endpoint). Provide the taskId and any properties to change. The Markdown description is converted to BlockNote JSON.',
941
+ {
942
+ taskId: objectId.describe('Id of the sticky note to edit (required)'),
943
+ name: z.string().optional().describe('New sticky note name'),
944
+ type: editableType,
945
+ projectId: objectId.optional().describe('Move to a different project by id'),
946
+ ...taskProps,
947
+ },
948
+ async (params) => {
949
+ try {
950
+ return await handleEdit(params, 'sticky note');
951
+ } catch (err) {
952
+ return toolError(`Edit sticky note failed: ${err.message}`);
953
+ }
954
+ }
955
+ );
956
+
837
957
  // ---- planko_complete_task ----
838
958
  server.tool(
839
959
  'planko_complete_task',
840
- 'Mark a Planko task complete (status=2) by id.',
960
+ 'Mark a Planko task complete (status=2) by id. Also works on a sticky note id (sticky notes have the same status field).',
841
961
  {
842
962
  taskId: objectId.describe('Id of the task to complete (required)'),
843
963
  },
@@ -889,10 +1009,29 @@ server.tool(
889
1009
  }
890
1010
  );
891
1011
 
1012
+ // ---- planko_delete_sticky_note ----
1013
+ server.tool(
1014
+ 'planko_delete_sticky_note',
1015
+ 'Delete a Planko sticky note by id (shares the task delete endpoint).',
1016
+ {
1017
+ taskId: objectId.describe('Id of the sticky note to delete (required)'),
1018
+ },
1019
+ async ({ taskId }) => {
1020
+ try {
1021
+ await assertTaskInLock(taskId);
1022
+ await api.deleteTask(taskId);
1023
+ return toolOk(`Deleted sticky note (id: ${taskId}).`);
1024
+ } catch (err) {
1025
+ return toolError(`Delete sticky note failed: ${err.message}`);
1026
+ }
1027
+ }
1028
+ );
1029
+
892
1030
  // --- Standalone READ tools (Part C) ---
893
1031
  // Read-only, user-scoped via API key; no folder setup required. List tools send
894
- // `type` (1=tasks, 2=notes) and parametrized filters; view tools fetch one item
895
- // by id and render its BlockNote description as Markdown. No mutation.
1032
+ // `type` (1=tasks, 2=notes, 3=sticky notes; omitted = tasks + sticky notes) and
1033
+ // parametrized filters; view tools fetch one item by id and render its
1034
+ // BlockNote description as Markdown. No mutation.
896
1035
 
897
1036
  const datePlain = z
898
1037
  .string()
@@ -904,99 +1043,43 @@ const sortBySchema = z
904
1043
  "Sort as 'field:asc' or 'field:desc'. Allowed fields: dueDate, createdAt, updatedAt, priority, position, name. Default updatedAt:desc."
905
1044
  );
906
1045
 
907
- const STATUS_LABEL = { 1: 'open', 2: 'complete' };
908
-
909
- /** Human label for a status code. */
910
- function statusLabel(status) {
911
- return STATUS_LABEL[status] || (status == null ? 'unknown' : String(status));
912
- }
913
-
914
- /** Render a task/note's tags as a comma list of names (fallback to ids). */
915
- function formatTags(tags) {
916
- if (!Array.isArray(tags) || tags.length === 0) return null;
917
- return tags
918
- .map((t) => (t && typeof t === 'object' ? t.name || t._id : t))
919
- .filter(Boolean)
920
- .join(', ');
921
- }
922
-
923
- /** Build the API filter params from tool params, resolving projectName. */
1046
+ /**
1047
+ * Build the API filter params from tool params, resolving projectName and the
1048
+ * kanban board/column names. `type` may be undefined (backend: tasks + sticky).
1049
+ */
924
1050
  async function buildListParams(type, params) {
925
- const { projectName, ...rest } = params;
1051
+ // assigneeName / boardName / kanbanColumnName are resolved client-side and
1052
+ // must never reach the backend, which rejects unknown query keys.
1053
+ const { projectName, assigneeName, boardName, kanbanColumnName, ...rest } = params;
926
1054
  // Sanitize scalar filters (drops blank/placeholder values, incl. a blank
927
- // assigneeId => "all members"). projectId/assigneeId pass through here.
928
- const out = { type, ...sanitizeFilters(rest) };
1055
+ // assigneeId => "all members").
1056
+ const out = { ...sanitizeFilters(rest) };
1057
+ if (type != null) out.type = type;
929
1058
  if (PROJECT_LOCK) {
1059
+ // Drop the id narrowers this class of agent fabricates with non-blank
1060
+ // garbage (parentId=projectId, assigneeId from a chat id, guessed priority,
1061
+ // a boardId copied from somewhere) that would silently zero the "list the
1062
+ // whole team" result. Board/column narrowing under lock is by NAME below.
1063
+ stripHallucinatedListFilters(out);
930
1064
  // Hard override: force the project regardless of caller input. Do NOT
931
1065
  // resolve projectName here — the override wins unconditionally, so an
932
- // invalid projectName must not be able to fail an otherwise-locked list
933
- // (keeps list consistent with create, which also ignores projectName).
1066
+ // invalid projectName must not be able to fail an otherwise-locked list.
934
1067
  out.projectId = lockProjectId(PROJECT_LOCK, out.projectId);
935
1068
  } else if (!isBlankValue(projectName)) {
936
1069
  // Unlocked (default) path: unchanged behavior.
937
1070
  out.projectId = await resolveProjectId(projectName);
938
1071
  }
939
- return out;
940
- }
941
-
942
- /** One concise summary line per item for list output. */
943
- function summarizeItem(item, index) {
944
- const parts = [];
945
- parts.push(`status: ${statusLabel(item.status)}`);
946
- if (item.priority != null) parts.push(`priority: ${item.priority}`);
947
- if (item.dueDate) parts.push(`due: ${item.dueDate}${item.time ? ` ${item.time}` : ''}`);
948
- else if (item.datePlain) parts.push(`due: ${item.datePlain}${item.time ? ` ${item.time}` : ''}`);
949
- const tagStr = formatTags(item.tags);
950
- if (tagStr) parts.push(`tags: ${tagStr}`);
951
- if (item.projectId) parts.push(`project: ${item.projectId}`);
952
- const owner = ownerName(item.userId);
953
- if (owner) parts.push(`owner: ${owner}`);
954
- return (
955
- `${index}. ${item.name || '(untitled)'} [id: ${item._id ?? item.id}]\n` +
956
- ` ${parts.join(' | ')}`
957
- );
958
- }
959
-
960
- /** Render a list response as a concise, readable summary (not raw JSON). */
961
- function renderList(result, kindLabelPlural) {
962
- const tasks = Array.isArray(result?.tasks) ? result.tasks : [];
963
- const total = result?.total ?? tasks.length;
964
- const page = result?.page ?? 1;
965
- const limit = result?.limit ?? tasks.length;
966
-
967
- if (tasks.length === 0) {
968
- return `No ${kindLabelPlural} found (total: ${total}, page ${page}).`;
1072
+ if (!isBlankValue(boardName) || !isBlankValue(kanbanColumnName)) {
1073
+ const boards = await api.boards();
1074
+ Object.assign(
1075
+ out,
1076
+ resolveBoardFilters(
1077
+ { boardName, kanbanColumnName, boardId: out.boardId, kanbanColumnId: out.kanbanColumnId },
1078
+ boards
1079
+ )
1080
+ );
969
1081
  }
970
-
971
- const lines = tasks.map((t, i) => summarizeItem(t, i + 1));
972
- const footer = `\nShowing ${tasks.length} of ${total} ${kindLabelPlural} (page ${page}, limit ${limit}).`;
973
- return `${lines.join('\n')}\n${footer}`;
974
- }
975
-
976
- /** Render one item's full detail with the description converted to Markdown. */
977
- function renderItem(item, kindLabel) {
978
- const lines = [];
979
- lines.push(`${item.name || '(untitled)'}`);
980
- lines.push(`id: ${item._id ?? item.id}`);
981
- lines.push(`type: ${item.type === 2 ? 'note' : 'task'} (${kindLabel})`);
982
- lines.push(`status: ${statusLabel(item.status)}`);
983
- if (item.priority != null) lines.push(`priority: ${item.priority}`);
984
- if (item.dueDate) lines.push(`due: ${item.dueDate}${item.time ? ` ${item.time}` : ''}`);
985
- else if (item.datePlain) lines.push(`due: ${item.datePlain}${item.time ? ` ${item.time}` : ''}`);
986
- const tagStr = formatTags(item.tags);
987
- if (tagStr) lines.push(`tags: ${tagStr}`);
988
- if (item.projectId) lines.push(`project: ${item.projectId}`);
989
- const owner = ownerName(item.userId);
990
- if (owner) lines.push(`owner: ${owner}`);
991
- if (item.parentId) lines.push(`parent: ${item.parentId}`);
992
- if (item.createdAt) lines.push(`created: ${item.createdAt}`);
993
- if (item.updatedAt) lines.push(`updated: ${item.updatedAt}`);
994
-
995
- const md = descriptionToMarkdown(item.description);
996
- lines.push('');
997
- lines.push('--- description ---');
998
- lines.push(md && md.trim() ? md : '(empty)');
999
- return lines.join('\n');
1082
+ return out;
1000
1083
  }
1001
1084
 
1002
1085
  /** Extract a single item from a view response (shape-tolerant). */
@@ -1032,35 +1115,121 @@ const listLimit = z
1032
1115
  .optional()
1033
1116
  .describe('Max items to return (default 50, max 200)');
1034
1117
  const listPage = z.number().int().min(1).optional().describe('Page number (default 1)');
1035
-
1036
- // ---- planko_list_tasks ----
1037
- server.tool(
1038
- 'planko_list_tasks',
1039
- 'List your Planko tasks (type=1) via your API key, no folder setup required. Filters are optional. Without projectId/projectName the list is scoped to your own tasks; with a project it includes that project\'s (incl. workspace-shared) tasks. Note: recurring tasks appear as separate dated occurrences. Returns a concise summary, not raw JSON.',
1040
- {
1041
- status: listStatus,
1042
- showCompleted: listShowCompleted,
1043
- priority: z
1044
- .union([z.literal(1), z.literal(2), z.literal(3)])
1045
- .optional()
1046
- .describe('Filter by priority: 1, 2, or 3'),
1047
- projectName: listProjectName,
1048
- projectId: listProjectId,
1049
- assigneeId: listAssigneeId,
1050
- parentId: objectId.optional().describe('List subtasks of this parent task id'),
1118
+ const listPriority = z
1119
+ .union([z.literal(1), z.literal(2), z.literal(3)])
1120
+ .optional()
1121
+ .describe('Filter by priority: 1, 2, or 3');
1122
+ const listParentId = objectId.optional().describe('List subtasks of this parent task id');
1123
+ const listAssigneeName = z
1124
+ .string()
1125
+ .optional()
1126
+ .describe(
1127
+ 'Narrow to ONE team member by their NAME or email (case-insensitive). ' +
1128
+ 'Omit to list the WHOLE team (all members). Only set this when the user ' +
1129
+ 'explicitly names a person; never guess.'
1130
+ );
1131
+ const listBoardName = z
1132
+ .string()
1133
+ .optional()
1134
+ .describe(
1135
+ 'Filter by kanban board NAME (case-insensitive, resolved against your own and workspace boards). ' +
1136
+ 'Only set this when the user explicitly names a board; never guess.'
1137
+ );
1138
+ const listKanbanColumnName = z
1139
+ .string()
1140
+ .optional()
1141
+ .describe(
1142
+ 'Filter by kanban column NAME (e.g. "To Do", "Done"). Resolved inside boardName when given; ' +
1143
+ 'without a board the name must be unique across your boards. Only set this when the user ' +
1144
+ 'explicitly names a column; never guess.'
1145
+ );
1146
+ const listBoardId = objectId.optional().describe('Filter by kanban board id');
1147
+ const listKanbanColumnId = objectId.optional().describe('Filter by kanban column id');
1148
+
1149
+ // Build the list-filter schema. Under PROJECT_LOCK the project is forced and the
1150
+ // caller is a bespoke, project-scoped agent whose model fabricates id/priority
1151
+ // narrowers (parentId/assigneeId/priority/boardId/kanbanColumnId) that silently
1152
+ // zero the result — so those fields are NOT offered; member and board/column
1153
+ // narrowing is by NAME instead. Unlocked (default, e.g. clawis) keeps the full
1154
+ // surface. `kind`: 'task' | 'note' | 'sticky' | 'all' — status/due-date filters
1155
+ // are offered for every task-page kind (sticky notes carry the same fields).
1156
+ function listSchema(kind) {
1157
+ const taskLike = kind !== 'note';
1158
+ const base = { showCompleted: listShowCompleted };
1159
+ if (taskLike) base.status = listStatus;
1160
+ const tail = {
1051
1161
  tags: listTags,
1052
1162
  search: listSearch,
1053
- dueDateFrom: datePlain.optional().describe('Inclusive lower bound on due date (YYYY-MM-DD)'),
1054
- dueDateTo: datePlain.optional().describe('Inclusive upper bound on due date (YYYY-MM-DD)'),
1163
+ boardName: listBoardName,
1164
+ kanbanColumnName: listKanbanColumnName,
1165
+ ...(taskLike
1166
+ ? {
1167
+ dueDateFrom: datePlain.optional().describe('Inclusive lower bound on due date (YYYY-MM-DD)'),
1168
+ dueDateTo: datePlain.optional().describe('Inclusive upper bound on due date (YYYY-MM-DD)'),
1169
+ }
1170
+ : {}),
1055
1171
  sortBy: listSortBy,
1056
1172
  limit: listLimit,
1057
- page: listPage,
1058
- },
1173
+ ...(kind === 'all' ? {} : { page: listPage }),
1174
+ };
1175
+ if (PROJECT_LOCK) {
1176
+ return { ...base, assigneeName: listAssigneeName, ...tail };
1177
+ }
1178
+ return {
1179
+ ...base,
1180
+ priority: listPriority,
1181
+ projectName: listProjectName,
1182
+ projectId: listProjectId,
1183
+ assigneeId: listAssigneeId,
1184
+ ...(taskLike ? { parentId: listParentId } : {}),
1185
+ boardId: listBoardId,
1186
+ kanbanColumnId: listKanbanColumnId,
1187
+ ...tail,
1188
+ };
1189
+ }
1190
+
1191
+ const BOARD_SCOPE_NOTE =
1192
+ ' Board/column filters match items on your own and workspace boards; with a project scope, teammates’ items on their personal boards are not matched.';
1193
+
1194
+ /**
1195
+ * Client-side member narrowing by NAME (used under PROJECT_LOCK, where the
1196
+ * agent narrows by a person's name instead of a fabricated user id). Returns
1197
+ * { result, note }. When assigneeName is blank, the result is unchanged. When
1198
+ * items lack populated owner info (backend owner-populate not deployed yet),
1199
+ * the filter can't be applied — the full list is returned with an explanatory
1200
+ * note rather than a misleading empty result.
1201
+ */
1202
+ function applyAssigneeName(result, assigneeName) {
1203
+ if (isBlankValue(assigneeName)) return { result, note: null };
1204
+ const tasks = Array.isArray(result?.tasks) ? result.tasks : [];
1205
+ if (!hasOwnerInfo(tasks)) {
1206
+ return {
1207
+ result,
1208
+ note: `Could not narrow to "${assigneeName}" — owner info is not available yet; showing all members.`,
1209
+ };
1210
+ }
1211
+ const filtered = tasks.filter((t) => matchesAssignee(t.userId, assigneeName));
1212
+ return { result: { ...result, tasks: filtered, total: filtered.length }, note: null };
1213
+ }
1214
+
1215
+ /** Shared list handler: one backend call for a single type. */
1216
+ async function handleList(type, params, kindLabelPlural) {
1217
+ const apiParams = await buildListParams(type, params);
1218
+ const result = await api.listTasks(apiParams);
1219
+ const { result: filtered, note } = applyAssigneeName(result, params.assigneeName);
1220
+ const out = renderList(filtered, kindLabelPlural);
1221
+ return toolOk(note ? `${out}\n\nNote: ${note}` : out);
1222
+ }
1223
+
1224
+ // ---- planko_list_tasks ----
1225
+ server.tool(
1226
+ 'planko_list_tasks',
1227
+ 'List Planko tasks (type=1) via your API key, no folder setup required. All filters are optional; omit any the user did not explicitly ask for. Recurring tasks appear as separate dated occurrences. Returns a concise summary, not raw JSON.' +
1228
+ BOARD_SCOPE_NOTE,
1229
+ listSchema('task'),
1059
1230
  async (params) => {
1060
1231
  try {
1061
- const apiParams = await buildListParams(1, params);
1062
- const result = await api.listTasks(apiParams);
1063
- return toolOk(renderList(result, 'tasks'));
1232
+ return await handleList(TYPE_TASK, params, 'tasks');
1064
1233
  } catch (err) {
1065
1234
  return toolError(`List tasks failed: ${err.message}`);
1066
1235
  }
@@ -1070,42 +1239,74 @@ server.tool(
1070
1239
  // ---- planko_list_notes ----
1071
1240
  server.tool(
1072
1241
  'planko_list_notes',
1073
- 'List your Planko notes (type=2) via your API key, no folder setup required. Filters are optional. Without projectId/projectName the list is scoped to your own notes; with a project it includes that project\'s (incl. workspace-shared) notes. Deleted and recurring-copy notes are excluded. Returns a concise summary, not raw JSON.',
1074
- {
1075
- showCompleted: listShowCompleted,
1076
- projectName: listProjectName,
1077
- projectId: listProjectId,
1078
- assigneeId: listAssigneeId,
1079
- tags: listTags,
1080
- search: listSearch,
1081
- sortBy: listSortBy,
1082
- limit: listLimit,
1083
- page: listPage,
1084
- },
1242
+ 'List Planko notes (type=2) via your API key, no folder setup required. All filters are optional; omit any the user did not explicitly ask for. Deleted and recurring-copy notes are excluded. Returns a concise summary, not raw JSON.' +
1243
+ BOARD_SCOPE_NOTE,
1244
+ listSchema('note'),
1085
1245
  async (params) => {
1086
1246
  try {
1087
- const apiParams = await buildListParams(2, params);
1088
- const result = await api.listTasks(apiParams);
1089
- return toolOk(renderList(result, 'notes'));
1247
+ return await handleList(TYPE_NOTE, params, 'notes');
1090
1248
  } catch (err) {
1091
1249
  return toolError(`List notes failed: ${err.message}`);
1092
1250
  }
1093
1251
  }
1094
1252
  );
1095
1253
 
1254
+ // ---- planko_list_sticky_notes ----
1255
+ server.tool(
1256
+ 'planko_list_sticky_notes',
1257
+ 'List Planko sticky notes (type=3) via your API key, no folder setup required. Sticky notes are task-page items, so the same filters as planko_list_tasks apply. All filters are optional; omit any the user did not explicitly ask for. Returns a concise summary, not raw JSON.' +
1258
+ BOARD_SCOPE_NOTE,
1259
+ listSchema('sticky'),
1260
+ async (params) => {
1261
+ try {
1262
+ return await handleList(TYPE_STICKY, params, 'sticky notes');
1263
+ } catch (err) {
1264
+ return toolError(`List sticky notes failed: ${err.message}`);
1265
+ }
1266
+ }
1267
+ );
1268
+
1269
+ // ---- planko_list_all ----
1270
+ server.tool(
1271
+ 'planko_list_all',
1272
+ 'List Planko tasks, sticky notes AND notes together in one result. Runs two backend queries (tasks + sticky notes; notes) with the same filters and merges them by sortBy (default updatedAt:desc), cut to `limit`; there is no page parameter. All filters are optional; omit any the user did not explicitly ask for. Returns a concise summary, not raw JSON.' +
1273
+ BOARD_SCOPE_NOTE,
1274
+ listSchema('all'),
1275
+ async (params) => {
1276
+ try {
1277
+ const limit = params.limit || 50;
1278
+ const taskParams = await buildListParams(undefined, { ...params, limit, page: 1 });
1279
+ const noteParams = { ...taskParams, type: TYPE_NOTE };
1280
+ const [taskRes, noteRes] = await Promise.all([api.listTasks(taskParams), api.listTasks(noteParams)]);
1281
+ const t = applyAssigneeName(taskRes, params.assigneeName);
1282
+ const n = applyAssigneeName(noteRes, params.assigneeName);
1283
+ const out = renderAll(mergeAllLists(t.result, n.result, limit, params.sortBy));
1284
+ const notes = [t.note, n.note].filter(Boolean);
1285
+ return toolOk(notes.length ? `${out}\n\nNote: ${notes.join(' ')}` : out);
1286
+ } catch (err) {
1287
+ return toolError(`List all failed: ${err.message}`);
1288
+ }
1289
+ }
1290
+ );
1291
+
1292
+ /** Shared view handler: the type shown comes from the item itself. */
1293
+ async function handleView(taskId) {
1294
+ const res = await api.getTask(taskId);
1295
+ const item = unwrapItem(res);
1296
+ assertProjectAllowed(PROJECT_LOCK, item);
1297
+ return toolOk(renderItem(item));
1298
+ }
1299
+
1096
1300
  // ---- planko_view_task ----
1097
1301
  server.tool(
1098
1302
  'planko_view_task',
1099
- 'View one Planko task by id, with its description rendered as Markdown. The type is informational — this endpoint returns the item regardless of task/note type.',
1303
+ 'View one Planko task by id, with its description rendered as Markdown. The type is informational — this endpoint returns the item regardless of task/note/sticky-note type.',
1100
1304
  {
1101
1305
  taskId: objectId.describe('Id of the task to view (required)'),
1102
1306
  },
1103
1307
  async ({ taskId }) => {
1104
1308
  try {
1105
- const res = await api.getTask(taskId);
1106
- const item = unwrapItem(res);
1107
- assertProjectAllowed(PROJECT_LOCK, item);
1108
- return toolOk(renderItem(item, 'task'));
1309
+ return await handleView(taskId);
1109
1310
  } catch (err) {
1110
1311
  return toolError(`View task failed: ${err.message}`);
1111
1312
  }
@@ -1115,22 +1316,35 @@ server.tool(
1115
1316
  // ---- planko_view_note ----
1116
1317
  server.tool(
1117
1318
  'planko_view_note',
1118
- 'View one Planko note by id, with its description rendered as Markdown. The type is informational — this endpoint returns the item regardless of task/note type.',
1319
+ 'View one Planko note by id, with its description rendered as Markdown. The type is informational — this endpoint returns the item regardless of task/note/sticky-note type.',
1119
1320
  {
1120
1321
  taskId: objectId.describe('Id of the note to view (required)'),
1121
1322
  },
1122
1323
  async ({ taskId }) => {
1123
1324
  try {
1124
- const res = await api.getTask(taskId);
1125
- const item = unwrapItem(res);
1126
- assertProjectAllowed(PROJECT_LOCK, item);
1127
- return toolOk(renderItem(item, 'note'));
1325
+ return await handleView(taskId);
1128
1326
  } catch (err) {
1129
1327
  return toolError(`View note failed: ${err.message}`);
1130
1328
  }
1131
1329
  }
1132
1330
  );
1133
1331
 
1332
+ // ---- planko_view_sticky_note ----
1333
+ server.tool(
1334
+ 'planko_view_sticky_note',
1335
+ 'View one Planko sticky note by id, with its description rendered as Markdown. The type is informational — this endpoint returns the item regardless of task/note/sticky-note type.',
1336
+ {
1337
+ taskId: objectId.describe('Id of the sticky note to view (required)'),
1338
+ },
1339
+ async ({ taskId }) => {
1340
+ try {
1341
+ return await handleView(taskId);
1342
+ } catch (err) {
1343
+ return toolError(`View sticky note failed: ${err.message}`);
1344
+ }
1345
+ }
1346
+ );
1347
+
1134
1348
  // --- Start server ---
1135
1349
 
1136
1350
  async function main() {