planko-mcp-server 0.7.0 → 0.9.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/README.md CHANGED
@@ -121,8 +121,9 @@ These work with the **same API key** and require **no folder setup**. Tasks, not
121
121
  | Property | Type | Notes |
122
122
  |---|---|---|
123
123
  | `description` | Markdown string | Converted to BlockNote JSON before saving |
124
- | `dueDate` | ISO 8601 string | |
125
- | `datePlain` | `YYYY-MM-DD` | |
124
+ | `dueDate` | ISO 8601 string | Execution date — when the task appears on the agenda/day view |
125
+ | `datePlain` | `YYYY-MM-DD` | Execution date, plain form — same meaning as `dueDate` |
126
+ | `deadline` | `YYYY-MM-DD`\|`null` | **Tasks only** (`planko_create_task`, `planko_edit_task`, `planko_recommend_task` — never notes or sticky notes). The final deadline, independent of `dueDate`/`datePlain`. `null` clears it on edit |
126
127
  | `time` / `endTime` | `HH:MM` | Start / end time |
127
128
  | `alert` | boolean | Whether a reminder is enabled |
128
129
  | `alertLeadTime` | `null`\|`ontime`\|`15min`\|`30min`\|`1hour`\|`1day` | Reminder lead time |
@@ -146,8 +147,10 @@ Notes:
146
147
 
147
148
  ```
148
149
  planko_create_task(name: "Ship v2", projectName: "Work", dueDate: "2026-08-01", priority: 1)
150
+ planko_create_task(name: "Renovar contrato", deadline: "2026-12-15")
149
151
  planko_create_note(name: "Meeting notes", description: "# Sync\n- point A\n- point B")
150
152
  planko_edit_task(taskId: "665f...c0", name: "Ship v2.1", alertLeadTime: "1hour")
153
+ planko_edit_task(taskId: "665f...c0", deadline: null)
151
154
  planko_complete_task(taskId: "665f...c0")
152
155
  planko_delete_note(taskId: "665f...aa")
153
156
  ```
@@ -164,6 +167,7 @@ Notes:
164
167
 
165
168
  - The recipient is **always the owner of the API key**, never other project members, even when the suggestion targets a shared workspace project.
166
169
  - `description` is Markdown, converted to BlockNote like the create tools. `datePlain` is derived from the date part of `dueDate` when only `dueDate` is given, because the owner's notification card shows `datePlain` (plus `time` and `priority`).
170
+ - `deadline` (`YYYY-MM-DD`) is accepted like on `planko_create_task`, applied to the task on accept.
167
171
  - A reference the owner cannot access (`projectId`, `parentId`, `tags`, `boardId`, `kanbanColumnId`) is rejected at send time with a `400`. A reference that becomes stale later is dropped when the owner accepts; the task is still created.
168
172
  - There is **no read-back**: the API has no endpoint to list recommendations or learn their outcome, and every call creates a new pending suggestion plus a new notification. Send each suggestion once; do not retry on a slow response.
169
173
  - Under `PLANKO_PROJECT_LOCK` the suggestion always targets the locked project (see below).
@@ -211,8 +215,9 @@ These also work with the **same API key** and require **no folder setup**. `list
211
215
  | `boardId` / `kanbanColumnId` | ObjectId | Direct id alternatives to the names (not offered under project lock) |
212
216
  | `tags` | array of ObjectId | AND semantics — item must have all tags |
213
217
  | `search` | string | Case-insensitive match on the name |
214
- | `dueDateFrom` / `dueDateTo` | `YYYY-MM-DD` | (tasks only) inclusive due-date bounds |
215
- | `sortBy` | `field:asc` \| `field:desc` | Fields: `dueDate`, `createdAt`, `updatedAt`, `priority`, `position`, `name`; default `updatedAt:desc` |
218
+ | `dueDateFrom` / `dueDateTo` | `YYYY-MM-DD` | (tasks only) inclusive due-date (execution date) bounds |
219
+ | `deadlineFrom` / `deadlineTo` | `YYYY-MM-DD` | Only on `planko_list_tasks` and `planko_list_all` (never `planko_list_notes`/`planko_list_sticky_notes`). Inclusive bounds on `deadline`. Matches **tasks only** (type=1); a recurring series appears as one item |
220
+ | `sortBy` | `field:asc` \| `field:desc` | Fields: `dueDate`, `deadline`, `createdAt`, `updatedAt`, `priority`, `position`, `name`; default `updatedAt:desc` |
216
221
  | `limit` | int | Default 50, max 200 |
217
222
  | `page` | int | Default 1 |
218
223
 
@@ -224,6 +229,7 @@ Board/column filters are ANDed onto the list scope. Boards belong to a user or a
224
229
 
225
230
  ```
226
231
  planko_list_tasks(status: 1, priority: 1, dueDateFrom: "2026-07-20", dueDateTo: "2026-07-26", sortBy: "dueDate:asc")
232
+ planko_list_tasks(deadlineFrom: "2026-12-01", deadlineTo: "2026-12-31", sortBy: "deadline:asc")
227
233
  planko_list_tasks(projectName: "Work", search: "invoice", limit: 20)
228
234
  planko_list_tasks(boardName: "Time Planko", kanbanColumnName: "In Progress")
229
235
  planko_list_sticky_notes(showCompleted: false)
@@ -255,7 +261,8 @@ Sync order: delete, pull, push. Local changes overwrite remote on conflict.
255
261
 
256
262
  | Variable | Required | Description |
257
263
  |---|---|---|
258
- | `PLANKO_API_KEY` | Yes | Your MCP API key from app.planko.io/integrations |
264
+ | `PLANKO_API_KEY` | Yes (user mode) | Your MCP API key from app.planko.io/integrations |
265
+ | `PLANKO_RUNNER_TOKEN` | No | Runner token (`pk_run_…`). When set, the server starts in **runner mode** (see below) and `PLANKO_API_KEY` is not required. |
259
266
  | `PLANKO_API_BASE` | No | API base URL override (defaults to production) |
260
267
  | `PLANKO_PROJECT_LOCK` | No | Confine every operation to a single project id (see below). **Off by default** — when unset the server behaves exactly as before. |
261
268
 
@@ -309,6 +316,44 @@ applies and the server is fully backward-compatible.
309
316
  }
310
317
  ```
311
318
 
319
+ ### Runner mode (`PLANKO_RUNNER_TOKEN`)
320
+
321
+ Runner mode serves the agent that executes Planko **agentic tasks**. It is enabled by
322
+ setting `PLANKO_RUNNER_TOKEN` to a runner token generated in the Planko app (screen
323
+ *Agente → Conectar agente*). A runner token:
324
+
325
+ - belongs to one user and is bound to **one or more projects** of that user — the
326
+ runner only ever sees that user's queued agentic tasks of those projects;
327
+ - is **shown once**, when it is created; Planko stores only its hash. Lost token →
328
+ create a new one. Revoking it stops the runner immediately and returns any task it
329
+ was running to the queue.
330
+
331
+ Runner mode is **exclusive**: it registers only the three runner tools below (no user
332
+ CRUD, no folder sync), all authenticated with the runner token:
333
+
334
+ | Tool | What it does |
335
+ |---|---|
336
+ | `planko_agent_claim` | Long-poll for the oldest queued agentic task (`waitSeconds` 0–25). Returns its id, `claimSeq`, name, project, timeout, instructions (Markdown) and the parent context for a subtask, or `No task available.` |
337
+ | `planko_agent_finish` | Report the result (Markdown) of a claimed task with the `claimSeq` returned by the claim, and `error: true` when it failed. The task goes to validation, or is concluded automatically when its recurring model does not require validation. |
338
+ | `planko_agent_suggest_subtask` | Suggest a subtask (name, Markdown instructions, optional `timeoutMin`) under an agentic task. The owner accepts or rejects it in the app. |
339
+
340
+ Every error (invalid/revoked token, task outside the token's scope, stale claim) is
341
+ returned as a tool error carrying the HTTP status.
342
+
343
+ ```json
344
+ {
345
+ "mcpServers": {
346
+ "planko-runner": {
347
+ "command": "npx",
348
+ "args": ["-y", "planko-mcp-server"],
349
+ "env": {
350
+ "PLANKO_RUNNER_TOKEN": "pk_run_..."
351
+ }
352
+ }
353
+ }
354
+ }
355
+ ```
356
+
312
357
  ## How it works
313
358
 
314
359
  - Each Planko task/note maps to a local `.md` file (task name becomes filename)
package/index.js CHANGED
@@ -4,7 +4,9 @@
4
4
  * planko-mcp-server — MCP server for syncing Planko tasks with local .md files.
5
5
  *
6
6
  * Environment variables:
7
- * PLANKO_API_KEY (required) — user-scoped MCP API key
7
+ * PLANKO_API_KEY (required in user mode) — user-scoped MCP API key
8
+ * PLANKO_RUNNER_TOKEN — runner token (pk_run_…); when set, the server starts in
9
+ * runner mode and exposes ONLY the runner tools (PLANKO_API_KEY not required)
8
10
  * PLANKO_API_BASE — optional API base URL override
9
11
  *
10
12
  * Tools:
@@ -14,6 +16,9 @@
14
16
  * planko_complete_task — works on any item id
15
17
  * planko_list_all — tasks + sticky notes + notes in one listing
16
18
  * planko_recommend_task — suggest a task for the account owner to accept/reject
19
+ *
20
+ * Runner mode tools (PL330 agentic tasks):
21
+ * planko_agent_claim / planko_agent_finish / planko_agent_suggest_subtask
17
22
  */
18
23
 
19
24
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
@@ -23,8 +28,9 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
23
28
  import { join } from 'node:path';
24
29
  import { createRequire } from 'node:module';
25
30
 
26
- import { createApiClient } from './src/api.js';
31
+ import { createApiClient, createRunnerApiClient } from './src/api.js';
27
32
  import { registerStandaloneTools, toolOk, toolError } from './src/tools.js';
33
+ import { registerRunnerTools } from './src/runnerTools.js';
28
34
  import {
29
35
  markdownToBlockNote,
30
36
  descriptionToMarkdown,
@@ -46,8 +52,11 @@ import {
46
52
 
47
53
  // --- Startup validation ---
48
54
 
55
+ // PL330: runner mode — token-scoped, exclusive (no user-wide CRUD), no API key needed.
56
+ const RUNNER_TOKEN = (process.env.PLANKO_RUNNER_TOKEN || '').trim();
57
+
49
58
  const API_KEY = process.env.PLANKO_API_KEY;
50
- if (!API_KEY) {
59
+ if (!API_KEY && !RUNNER_TOKEN) {
51
60
  console.error(
52
61
  'Fatal: PLANKO_API_KEY environment variable is required.'
53
62
  );
@@ -579,6 +588,12 @@ registerStandaloneTools(server, { api, projectLock: PROJECT_LOCK });
579
588
  // --- Start server ---
580
589
 
581
590
  async function main() {
591
+ if (RUNNER_TOKEN) {
592
+ const runnerServer = new McpServer({ name: 'planko-runner', version: PKG_VERSION });
593
+ registerRunnerTools(runnerServer, { api: createRunnerApiClient({ runnerToken: RUNNER_TOKEN }) });
594
+ await runnerServer.connect(new StdioServerTransport());
595
+ return;
596
+ }
582
597
  const transport = new StdioServerTransport();
583
598
  await server.connect(transport);
584
599
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "planko-mcp-server",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "MCP server for syncing Planko tasks with local Markdown files",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "scripts": {
23
23
  "test": "vitest run",
24
- "prepublishOnly": "node --check index.js && node --check src/api.js && node --check src/converters.js && node --check src/sync-state.js && node --check src/projectLock.js && node --check src/sanitize.js && node --check src/listing.js && node --check src/recommend.js && node --check src/tools.js"
24
+ "prepublishOnly": "node --check index.js && node --check src/api.js && node --check src/converters.js && node --check src/sync-state.js && node --check src/projectLock.js && node --check src/sanitize.js && node --check src/listing.js && node --check src/recommend.js && node --check src/tools.js && node --check src/runnerTools.js"
25
25
  },
26
26
  "dependencies": {
27
27
  "@modelcontextprotocol/sdk": "^1.12.1",
package/src/api.js CHANGED
@@ -7,12 +7,15 @@
7
7
 
8
8
  const DEFAULT_API_BASE = 'https://api.planko.io/v1';
9
9
 
10
- export function createApiClient({ apiKey, apiBase }) {
11
- const base = apiBase || process.env.PLANKO_API_BASE || DEFAULT_API_BASE;
12
-
13
- async function request(method, path, body) {
10
+ /**
11
+ * Build a JSON request function bound to a base URL and auth headers.
12
+ * `statusInMessage` prefixes errors with the HTTP status (runner mode: the agent
13
+ * must see *why* a call failed). The user client keeps the plain backend message.
14
+ */
15
+ function makeRequest({ base, headers: authHeaders, statusInMessage = false }) {
16
+ return async function request(method, path, body) {
14
17
  const url = `${base}${path}`;
15
- const headers = { 'x-api-key': apiKey };
18
+ const headers = { ...authHeaders };
16
19
 
17
20
  const options = { method, headers };
18
21
 
@@ -36,11 +39,18 @@ export function createApiClient({ apiKey, apiBase }) {
36
39
  typeof data === 'object' && data.message
37
40
  ? data.message
38
41
  : `API returned HTTP ${res.status}`;
39
- throw new Error(msg);
42
+ const err = new Error(statusInMessage ? `HTTP ${res.status}: ${msg}` : msg);
43
+ err.status = res.status;
44
+ throw err;
40
45
  }
41
46
 
42
47
  return data;
43
- }
48
+ };
49
+ }
50
+
51
+ export function createApiClient({ apiKey, apiBase }) {
52
+ const base = apiBase || process.env.PLANKO_API_BASE || DEFAULT_API_BASE;
53
+ const request = makeRequest({ base, headers: { 'x-api-key': apiKey } });
44
54
 
45
55
  return {
46
56
  /**
@@ -172,3 +182,27 @@ export function createApiClient({ apiKey, apiBase }) {
172
182
  },
173
183
  };
174
184
  }
185
+
186
+ /**
187
+ * PL330 — API client of the agentic-tasks runner, authenticated with a runner
188
+ * token (`pk_run_…`, per project), never with the user API key.
189
+ */
190
+ export function createRunnerApiClient({ runnerToken, apiBase }) {
191
+ const request = makeRequest({
192
+ base: apiBase || process.env.PLANKO_API_BASE || DEFAULT_API_BASE,
193
+ headers: { Authorization: `Bearer ${runnerToken}` },
194
+ statusInMessage: true,
195
+ });
196
+
197
+ return {
198
+ /** POST /agent/runner/claim — long-poll; { task } or { task: null } */
199
+ claim: (waitSec) => request('POST', '/agent/runner/claim', waitSec == null ? {} : { waitSec }),
200
+
201
+ /** POST /agent/runner/tasks/:taskId/finish — bound to the claim by claimSeq */
202
+ finish: (taskId, { result, error, claimSeq }) =>
203
+ request('POST', `/agent/runner/tasks/${taskId}/finish`, { result, error: !!error, claimSeq }),
204
+
205
+ /** POST /agent/runner/tasks/:taskId/subtasks — suggest a subtask under an agentic task */
206
+ suggestSubtask: (taskId, body) => request('POST', `/agent/runner/tasks/${taskId}/subtasks`, body),
207
+ };
208
+ }
package/src/listing.js CHANGED
@@ -166,6 +166,7 @@ export function summarizeItem(item, index) {
166
166
  if (item.priority != null) parts.push(`priority: ${item.priority}`);
167
167
  if (item.dueDate) parts.push(`due: ${item.dueDate}${item.time ? ` ${item.time}` : ''}`);
168
168
  else if (item.datePlain) parts.push(`due: ${item.datePlain}${item.time ? ` ${item.time}` : ''}`);
169
+ if (item.type === TYPE_TASK && item.deadline) parts.push(`deadline: ${item.deadline}`);
169
170
  const tagStr = formatTags(item.tags);
170
171
  if (tagStr) parts.push(`tags: ${tagStr}`);
171
172
  const board = boardLabel(item);
@@ -207,6 +208,7 @@ export function renderItem(item) {
207
208
  if (item.priority != null) lines.push(`priority: ${item.priority}`);
208
209
  if (item.dueDate) lines.push(`due: ${item.dueDate}${item.time ? ` ${item.time}` : ''}`);
209
210
  else if (item.datePlain) lines.push(`due: ${item.datePlain}${item.time ? ` ${item.time}` : ''}`);
211
+ if (item.type === TYPE_TASK && item.deadline) lines.push(`deadline: ${item.deadline}`);
210
212
  const tagStr = formatTags(item.tags);
211
213
  if (tagStr) lines.push(`tags: ${tagStr}`);
212
214
  const board = boardLabel(item);
@@ -227,8 +229,8 @@ export function renderItem(item) {
227
229
  return lines.join('\n');
228
230
  }
229
231
 
230
- const SORTABLE_FIELDS = new Set(['dueDate', 'createdAt', 'updatedAt', 'priority', 'position', 'name']);
231
- const DATE_FIELDS = new Set(['dueDate', 'createdAt', 'updatedAt']);
232
+ const SORTABLE_FIELDS = new Set(['dueDate', 'deadline', 'createdAt', 'updatedAt', 'priority', 'position', 'name']);
233
+ const DATE_FIELDS = new Set(['dueDate', 'deadline', 'createdAt', 'updatedAt']);
232
234
 
233
235
  /** Parse 'field:dir' with the backend's whitelist; default updatedAt:desc. */
234
236
  export function parseSort(sortBy) {
@@ -0,0 +1,116 @@
1
+ /**
2
+ * PL330 — tools of the agentic-tasks runner (runner mode, PLANKO_RUNNER_TOKEN).
3
+ * Each tool maps 1:1 to a /v1/agent/runner endpoint; the backend scopes every call
4
+ * to the token's projects and owner. Errors are always returned as tool errors.
5
+ */
6
+ import { z } from 'zod';
7
+
8
+ import { toolOk, toolError } from './tools.js';
9
+ import { descriptionToMarkdown, markdownToDescription } from './converters.js';
10
+
11
+ const ANNOTATIONS = {
12
+ WRITE: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
13
+ IDEMPOTENT_WRITE: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
14
+ };
15
+
16
+ const objectId = z.string().regex(/^[a-fA-F\d]{24}$/, 'Must be a 24-character hex ObjectId');
17
+
18
+ export function registerRunnerTools(server, { api }) {
19
+ // ---- planko_agent_claim ----
20
+ server.registerTool(
21
+ 'planko_agent_claim',
22
+ {
23
+ title: 'Claim agentic task',
24
+ description:
25
+ 'Take the oldest queued agentic task of this runner (long-poll). Returns its id, claimSeq and instructions, or "No task available.". The claimSeq must be sent back on planko_agent_finish.',
26
+ inputSchema: {
27
+ waitSeconds: z
28
+ .number()
29
+ .int()
30
+ .min(0)
31
+ .max(25)
32
+ .optional()
33
+ .describe('How long to wait for a task, in seconds (default: server maximum)'),
34
+ },
35
+ annotations: ANNOTATIONS.WRITE,
36
+ },
37
+ async ({ waitSeconds }) => {
38
+ try {
39
+ const { task } = await api.claim(waitSeconds);
40
+ if (!task) return toolOk('No task available.');
41
+ const payload = {
42
+ id: task.id,
43
+ claimSeq: task.claimSeq,
44
+ name: task.name,
45
+ projectName: task.projectName ?? null,
46
+ timeoutMin: task.agentTimeoutMin ?? null,
47
+ instructions: descriptionToMarkdown(task.description),
48
+ parentContext: task.parent
49
+ ? {
50
+ id: task.parent.id,
51
+ name: task.parent.name,
52
+ instructions: descriptionToMarkdown(task.parent.description),
53
+ }
54
+ : null,
55
+ };
56
+ return toolOk(`Claimed task ${task.id}.\n\n${JSON.stringify(payload, null, 2)}`);
57
+ } catch (err) {
58
+ return toolError(`planko_agent_claim failed: ${err.message}`);
59
+ }
60
+ }
61
+ );
62
+
63
+ // ---- planko_agent_finish ----
64
+ server.registerTool(
65
+ 'planko_agent_finish',
66
+ {
67
+ title: 'Finish agentic task',
68
+ description:
69
+ 'Report the result of a claimed agentic task (Markdown). Set error=true when the task could not be completed. The task goes to validation, or is concluded automatically when its model allows it.',
70
+ inputSchema: {
71
+ taskId: objectId.describe('Id of the claimed task'),
72
+ claimSeq: z.number().int().min(1).describe('claimSeq returned by planko_agent_claim for this task'),
73
+ result: z.string().max(100000).describe('Markdown output'),
74
+ error: z.boolean().optional().describe('true when the task failed'),
75
+ },
76
+ annotations: ANNOTATIONS.IDEMPOTENT_WRITE,
77
+ },
78
+ async ({ taskId, claimSeq, result, error }) => {
79
+ try {
80
+ const { task } = await api.finish(taskId, { result, error: !!error, claimSeq });
81
+ const auto = task.agentDecision === 'auto' ? ' (auto)' : '';
82
+ return toolOk(`Finished task ${task.id}: ${task.agentStatus}${auto}`);
83
+ } catch (err) {
84
+ return toolError(`planko_agent_finish failed: ${err.message}`);
85
+ }
86
+ }
87
+ );
88
+
89
+ // ---- planko_agent_suggest_subtask ----
90
+ server.registerTool(
91
+ 'planko_agent_suggest_subtask',
92
+ {
93
+ title: 'Suggest subtask',
94
+ description:
95
+ 'Suggest a subtask under an agentic task. It is created as a suggestion that the owner accepts or rejects; it never runs before being accepted.',
96
+ inputSchema: {
97
+ parentTaskId: objectId.describe('Id of the agentic parent task'),
98
+ name: z.string().min(1).max(200).describe('Subtask title'),
99
+ description: z.string().optional().describe('Instructions for the subtask, as Markdown'),
100
+ timeoutMin: z.number().int().min(1).max(1440).optional().describe('Timeout in minutes (default 60)'),
101
+ },
102
+ annotations: ANNOTATIONS.WRITE,
103
+ },
104
+ async ({ parentTaskId, name, description, timeoutMin }) => {
105
+ try {
106
+ const body = { name, description: markdownToDescription(description) };
107
+ if (timeoutMin !== undefined) body.agentTimeoutMin = timeoutMin;
108
+ if (body.description == null) delete body.description;
109
+ const { task } = await api.suggestSubtask(parentTaskId, body);
110
+ return toolOk(`Suggested subtask "${task.name}" (id: ${task.id}) under ${parentTaskId}: ${task.agentStatus}`);
111
+ } catch (err) {
112
+ return toolError(`planko_agent_suggest_subtask failed: ${err.message}`);
113
+ }
114
+ }
115
+ );
116
+ }
package/src/tools.js CHANGED
@@ -68,12 +68,21 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
68
68
  .string()
69
69
  .optional()
70
70
  .describe('Body as Markdown (converted to BlockNote JSON before saving)'),
71
- dueDate: z.string().optional().describe('Due date (ISO 8601 string)'),
71
+ dueDate: z
72
+ .string()
73
+ .optional()
74
+ .describe(
75
+ 'Execution date (ISO 8601 string): when the task appears on the agenda/day view. ' +
76
+ 'Independent of deadline (the final deadline, when supported).'
77
+ ),
72
78
  datePlain: z
73
79
  .string()
74
80
  .regex(/^\d{4}-\d{2}-\d{2}$/, 'Must be YYYY-MM-DD')
75
81
  .optional()
76
- .describe('Plain date, YYYY-MM-DD'),
82
+ .describe(
83
+ 'Execution date, plain YYYY-MM-DD: when the task appears on the agenda/day view. ' +
84
+ 'Independent of deadline (the final deadline, when supported).'
85
+ ),
77
86
  time: z.string().regex(timeRegex, 'Must be HH:MM').optional().describe('Start time, HH:MM'),
78
87
  endTime: z.string().regex(timeRegex, 'Must be HH:MM').optional().describe('End time, HH:MM'),
79
88
  alert: z.boolean().optional().describe('Whether an alert/reminder is enabled'),
@@ -109,13 +118,43 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
109
118
  boardId: objectId.optional().describe('Board id'),
110
119
  };
111
120
 
121
+ // Task-only properties (PL328): never offered on note/sticky-note tools.
122
+ // `deadline` is independent of dueDate/datePlain (the execution date) — it is
123
+ // the day by which the task must be done. `null` clears it; omitted leaves it
124
+ // unchanged.
125
+ const deadlineProps = {
126
+ deadline: z
127
+ .string()
128
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'Must be YYYY-MM-DD')
129
+ .nullable()
130
+ .optional()
131
+ .describe(
132
+ 'Prazo final (YYYY-MM-DD): até quando a tarefa precisa estar pronta. ' +
133
+ 'É independente de dueDate/datePlain (data de execução, quando a tarefa aparece na agenda). ' +
134
+ 'null remove o prazo. Só para tarefas (type=1) — nunca para notas ou sticky notes.'
135
+ ),
136
+ };
137
+
138
+ // Fields that support an explicit null to clear a value on edit (as opposed to
139
+ // isBlankValue's "omitted" semantics, which would otherwise drop the null).
140
+ // '' is treated the same as null so a model that sends an empty string still
141
+ // clears the field.
142
+ const NULLABLE_CLEAR_FIELDS = new Set(['deadline']);
143
+
112
144
  /**
113
145
  * Build a request body from tool params: drop undefined values and convert the
114
- * Markdown `description` into BlockNote JSON.
146
+ * Markdown `description` into BlockNote JSON. Fields in NULLABLE_CLEAR_FIELDS
147
+ * keep an explicit null (and treat '' as null) so the model can clear them;
148
+ * omitted stays omitted.
115
149
  */
116
150
  function buildTaskBody(params) {
117
151
  const body = {};
118
152
  for (const [key, value] of Object.entries(params)) {
153
+ if (NULLABLE_CLEAR_FIELDS.has(key)) {
154
+ if (value === undefined) continue;
155
+ body[key] = value === '' ? null : value;
156
+ continue;
157
+ }
119
158
  if (isBlankValue(value)) continue;
120
159
  body[key] = value;
121
160
  }
@@ -230,6 +269,7 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
230
269
  .optional()
231
270
  .describe('Project name to create the task in (optional — omit for your default project)'),
232
271
  ...taskProps,
272
+ ...deadlineProps,
233
273
  },
234
274
  annotations: ANNOTATIONS.WRITE,
235
275
  },
@@ -308,6 +348,7 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
308
348
  .optional()
309
349
  .describe('Project name the task would be created in (optional — omit for the owner\'s default project)'),
310
350
  ...taskProps,
351
+ ...deadlineProps,
311
352
  },
312
353
  annotations: ANNOTATIONS.WRITE,
313
354
  },
@@ -357,6 +398,7 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
357
398
  type: editableType,
358
399
  projectId: objectId.optional().describe('Move to a different project by id'),
359
400
  ...taskProps,
401
+ ...deadlineProps,
360
402
  },
361
403
  annotations: ANNOTATIONS.IDEMPOTENT_WRITE,
362
404
  },
@@ -519,7 +561,7 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
519
561
  const sortBySchema = z
520
562
  .string()
521
563
  .describe(
522
- "Sort as 'field:asc' or 'field:desc'. Allowed fields: dueDate, createdAt, updatedAt, priority, position, name. Default updatedAt:desc."
564
+ "Sort as 'field:asc' or 'field:desc'. Allowed fields: dueDate, deadline, createdAt, updatedAt, priority, position, name. Default updatedAt:desc."
523
565
  );
524
566
 
525
567
  /**
@@ -634,6 +676,7 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
634
676
  // are offered for every task-page kind (sticky notes carry the same fields).
635
677
  function listSchema(kind) {
636
678
  const taskLike = kind !== 'note';
679
+ const deadlineLike = kind === 'task' || kind === 'all';
637
680
  const base = { showCompleted: listShowCompleted };
638
681
  if (taskLike) base.status = listStatus;
639
682
  const tail = {
@@ -647,6 +690,22 @@ export function registerStandaloneTools(server, { api, projectLock = null, wrapH
647
690
  dueDateTo: datePlain.optional().describe('Inclusive upper bound on due date (YYYY-MM-DD)'),
648
691
  }
649
692
  : {}),
693
+ ...(deadlineLike
694
+ ? {
695
+ deadlineFrom: datePlain
696
+ .optional()
697
+ .describe(
698
+ 'Inclusive lower bound on deadline/prazo final (YYYY-MM-DD). Tasks only (type=1): never matches ' +
699
+ 'notes or sticky notes. A recurring series appears as one item.'
700
+ ),
701
+ deadlineTo: datePlain
702
+ .optional()
703
+ .describe(
704
+ 'Inclusive upper bound on deadline/prazo final (YYYY-MM-DD). Tasks only (type=1): never matches ' +
705
+ 'notes or sticky notes. A recurring series appears as one item.'
706
+ ),
707
+ }
708
+ : {}),
650
709
  sortBy: listSortBy,
651
710
  limit: listLimit,
652
711
  ...(kind === 'all' ? {} : { page: listPage }),