@monadsag/productive-mcp 1.2.48

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.
Files changed (63) hide show
  1. package/LICENSE +190 -0
  2. package/NOTICE +6 -0
  3. package/README.md +353 -0
  4. package/build/api/bookings-client.js +249 -0
  5. package/build/api/capacity.js +279 -0
  6. package/build/api/client.js +1296 -0
  7. package/build/api/errors.js +50 -0
  8. package/build/api/invoice-time-entries.js +256 -0
  9. package/build/api/pages-tree.js +106 -0
  10. package/build/api/time-entry-notes.js +75 -0
  11. package/build/api/types.js +1 -0
  12. package/build/auth/logo.js +21 -0
  13. package/build/auth/self-resolver.js +61 -0
  14. package/build/config/index.js +24 -0
  15. package/build/index.js +15 -0
  16. package/build/prompts/timesheet.js +285 -0
  17. package/build/server.js +55 -0
  18. package/build/tools/absences.js +502 -0
  19. package/build/tools/activities.js +140 -0
  20. package/build/tools/bookings.js +531 -0
  21. package/build/tools/budget-services.js +168 -0
  22. package/build/tools/budgets.js +276 -0
  23. package/build/tools/capacity.js +281 -0
  24. package/build/tools/changeset.js +41 -0
  25. package/build/tools/comments.js +469 -0
  26. package/build/tools/companies.js +73 -0
  27. package/build/tools/custom-field-resolver.js +92 -0
  28. package/build/tools/custom-fields.js +155 -0
  29. package/build/tools/folders.js +516 -0
  30. package/build/tools/include-resolver.js +45 -0
  31. package/build/tools/invoice-actions.js +476 -0
  32. package/build/tools/invoice-defaults.js +65 -0
  33. package/build/tools/invoice-time-entries.js +320 -0
  34. package/build/tools/invoices.js +657 -0
  35. package/build/tools/my-tasks.js +100 -0
  36. package/build/tools/page-children.js +129 -0
  37. package/build/tools/pages.js +466 -0
  38. package/build/tools/people.js +147 -0
  39. package/build/tools/projects.js +77 -0
  40. package/build/tools/recent-updates.js +112 -0
  41. package/build/tools/registry.js +409 -0
  42. package/build/tools/subtasks.js +245 -0
  43. package/build/tools/task-backlog.js +106 -0
  44. package/build/tools/task-dependencies.js +244 -0
  45. package/build/tools/task-list-move.js +65 -0
  46. package/build/tools/task-lists.js +535 -0
  47. package/build/tools/task-reposition.js +199 -0
  48. package/build/tools/task-status.js +178 -0
  49. package/build/tools/tasks.js +738 -0
  50. package/build/tools/time-entries.js +736 -0
  51. package/build/tools/time-entry-approval.js +103 -0
  52. package/build/tools/time-entry-delete.js +72 -0
  53. package/build/tools/time-entry-update.js +126 -0
  54. package/build/tools/timers.js +195 -0
  55. package/build/tools/todos.js +342 -0
  56. package/build/tools/tool-helpers.js +114 -0
  57. package/build/tools/toolsets.js +153 -0
  58. package/build/tools/whoami.js +64 -0
  59. package/build/tools/workflow-statuses.js +81 -0
  60. package/build/utils/errors.js +67 -0
  61. package/build/utils/mentions.js +98 -0
  62. package/npm-shrinkwrap.json +1159 -0
  63. package/package.json +79 -0
@@ -0,0 +1,531 @@
1
+ /**
2
+ * Project capacity tools: plan a person onto a service, adjust it, read it back.
3
+ *
4
+ * Same `bookings` resource as absences -- the difference is that these carry a
5
+ * service_id instead of an event_id. See docs/resource-management-spec.md.
6
+ */
7
+ import { z } from 'zod';
8
+ import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
9
+ import { BOOKING_METHOD, buildQuantity, countWorkingDays, describeApprovalState, formatMinutes, isCapacityBooking, MAX_PAGE_SIZE, } from '../api/bookings-client.js';
10
+ import { projectUtilisation } from './capacity.js';
11
+ import { parseDate } from './time-entries.js';
12
+ import { buildIncludeMap, resolveName } from './include-resolver.js';
13
+ import { coerceBoolean, describePerson, personWorkingDays, resolvePersonId, rethrowToolError, toNumericId, } from './tool-helpers.js';
14
+ // --- create_booking ----------------------------------------------------------
15
+ const createBookingSchema = z
16
+ .object({
17
+ person_id: z.string().min(1).default('me'),
18
+ service_id: z.string().min(1, 'service_id is required'),
19
+ date_from: z.string().min(1, 'date_from is required'),
20
+ date_to: z.string().min(1, 'date_to is required'),
21
+ percentage: z.coerce.number().min(1).max(100).optional(),
22
+ hours_per_day: z.coerce.number().positive().max(24).optional(),
23
+ booking_method_id: z.coerce.number().int().min(1).max(3).optional(),
24
+ note: z.string().optional(),
25
+ confirm: coerceBoolean.optional().default(false),
26
+ })
27
+ .refine((v) => v.percentage !== undefined || v.hours_per_day !== undefined, {
28
+ message: 'Provide either percentage or hours_per_day',
29
+ });
30
+ export async function createBookingTool(client, args, config) {
31
+ try {
32
+ const params = createBookingSchema.parse(args);
33
+ const personId = resolvePersonId(params.person_id, config);
34
+ const from = parseDate(params.date_from);
35
+ const to = parseDate(params.date_to);
36
+ if (to < from) {
37
+ throw new McpError(ErrorCode.InvalidParams, `date_to (${to}) is before date_from (${from}).`);
38
+ }
39
+ const method = (params.booking_method_id ??
40
+ (params.percentage !== undefined
41
+ ? BOOKING_METHOD.PERCENTAGE
42
+ : BOOKING_METHOD.HOURS_PER_DAY));
43
+ const workingDays = method === BOOKING_METHOD.TOTAL_HOURS
44
+ ? await personWorkingDays(client, personId, from, to)
45
+ : countWorkingDays(from, to);
46
+ if (workingDays === 0) {
47
+ throw new McpError(ErrorCode.InvalidParams, `${from} to ${to} contains no working days (weekends only).`);
48
+ }
49
+ let quantity;
50
+ try {
51
+ quantity = buildQuantity(method, {
52
+ hoursPerDay: params.hours_per_day,
53
+ percentage: params.percentage,
54
+ workingDays,
55
+ });
56
+ }
57
+ catch (error) {
58
+ throw new McpError(ErrorCode.InvalidParams, error instanceof Error ? error.message : 'Invalid booking amount');
59
+ }
60
+ if (!params.confirm) {
61
+ const [who, hint] = await Promise.all([
62
+ describePerson(client, personId),
63
+ projectUtilisation(client, personId, from, to, quantity),
64
+ ]);
65
+ return {
66
+ content: [
67
+ {
68
+ type: 'text',
69
+ text: `Project booking ready to create:
70
+
71
+ Person: ${who}${params.person_id === 'me' ? ' (me)' : ''}
72
+ Service ID: ${params.service_id}
73
+ Period: ${from} to ${to} (${workingDays} working day(s))
74
+ Amount: ${params.percentage !== undefined ? `${params.percentage}%` : `${params.hours_per_day}h per day`}
75
+ Booking method: ${method}
76
+ ${params.note ? `Note: ${params.note}` : 'No note'}
77
+ ${hint ? `\n${hint}` : ''}
78
+
79
+ Call again with "confirm": true to create it.`,
80
+ },
81
+ ],
82
+ };
83
+ }
84
+ const payload = {
85
+ data: {
86
+ type: 'bookings',
87
+ attributes: {
88
+ person_id: toNumericId(personId, 'person_id'),
89
+ service_id: toNumericId(params.service_id, 'service_id'),
90
+ started_on: from,
91
+ ended_on: to,
92
+ booking_method_id: method,
93
+ ...quantity,
94
+ ...(params.note ? { note: params.note } : {}),
95
+ },
96
+ },
97
+ };
98
+ const created = await client.createBooking(payload);
99
+ const a = created.data.attributes;
100
+ return {
101
+ content: [
102
+ {
103
+ type: 'text',
104
+ text: `Project booking created (ID: ${created.data.id})
105
+
106
+ Service ID: ${params.service_id}
107
+ Period: ${a.started_on} to ${a.ended_on} · ${a.total_working_days ?? workingDays} working day(s)
108
+ ${typeof a.total_time === 'number' ? `Planned: ${formatMinutes(a.total_time)}` : ''}${typeof a.percentage === 'number' && a.percentage ? `\nAllocation: ${a.percentage}%` : ''}
109
+ Status: ${describeApprovalState(created.data)}`,
110
+ },
111
+ ],
112
+ };
113
+ }
114
+ catch (error) {
115
+ rethrowToolError(error);
116
+ }
117
+ }
118
+ // --- update_booking ----------------------------------------------------------
119
+ const updateBookingSchema = z
120
+ .object({
121
+ booking_id: z.string().min(1, 'booking_id is required'),
122
+ date_from: z.string().optional(),
123
+ date_to: z.string().optional(),
124
+ percentage: z.coerce.number().min(1).max(100).optional(),
125
+ hours_per_day: z.coerce.number().positive().max(24).optional(),
126
+ note: z.string().optional(),
127
+ confirm: coerceBoolean.optional().default(false),
128
+ })
129
+ .refine((v) => v.date_from !== undefined ||
130
+ v.date_to !== undefined ||
131
+ v.percentage !== undefined ||
132
+ v.hours_per_day !== undefined ||
133
+ v.note !== undefined, { message: 'Provide at least one field to change' });
134
+ export async function updateBookingTool(client, args) {
135
+ try {
136
+ const params = updateBookingSchema.parse(args);
137
+ const current = await client.getBooking(params.booking_id);
138
+ const a = current.data.attributes;
139
+ // create_absence caps absences at booking method 1 or 3 on purpose; without
140
+ // this check the percentage method reaches them through the back door and
141
+ // sizes somebody's time off against a share of their contract instead of
142
+ // real hours.
143
+ if (params.percentage !== undefined && current.data.relationships?.event?.data?.id) {
144
+ throw new McpError(ErrorCode.InvalidParams, 'booking_method_id must be 1 (hours per day) or 3 (total hours) for absences. ' +
145
+ 'Use hours_per_day instead of percentage to change an absence.');
146
+ }
147
+ const from = params.date_from ? parseDate(params.date_from) : a.started_on;
148
+ const to = params.date_to ? parseDate(params.date_to) : a.ended_on;
149
+ if (to < from) {
150
+ throw new McpError(ErrorCode.InvalidParams, `date_to (${to}) is before date_from (${from}).`);
151
+ }
152
+ const attributes = {};
153
+ if (params.date_from)
154
+ attributes.started_on = from;
155
+ if (params.date_to)
156
+ attributes.ended_on = to;
157
+ if (params.note !== undefined)
158
+ attributes.note = params.note;
159
+ if (params.percentage !== undefined) {
160
+ attributes.booking_method_id = BOOKING_METHOD.PERCENTAGE;
161
+ attributes.percentage = params.percentage;
162
+ // Clear the amounts of the previous method; a stale total_time would win
163
+ // when the booking is read back.
164
+ attributes.total_time = 0;
165
+ attributes.hours = 0;
166
+ attributes.time = 0;
167
+ }
168
+ else if (params.hours_per_day !== undefined) {
169
+ const method = (a.booking_method_id ?? BOOKING_METHOD.HOURS_PER_DAY);
170
+ const effective = method === BOOKING_METHOD.PERCENTAGE ? BOOKING_METHOD.HOURS_PER_DAY : method;
171
+ attributes.booking_method_id = effective;
172
+ // The mirror of the branch above: a left-over percentage wins when the
173
+ // booking is read back (list_bookings prefers it over total_time), so a
174
+ // booking switched from 50% to 8h/day would keep reporting "50%".
175
+ attributes.percentage = 0;
176
+ Object.assign(attributes, buildQuantity(effective, {
177
+ hoursPerDay: params.hours_per_day,
178
+ workingDays: effective === BOOKING_METHOD.TOTAL_HOURS
179
+ ? await personWorkingDays(client, current.data.relationships?.person?.data?.id, from, to)
180
+ : countWorkingDays(from, to),
181
+ }));
182
+ }
183
+ else if ((params.date_from !== undefined || params.date_to !== undefined) &&
184
+ a.booking_method_id === BOOKING_METHOD.TOTAL_HOURS &&
185
+ typeof a.total_time === 'number' &&
186
+ a.total_time > 0) {
187
+ // Moving the dates of a total-hours booking without resizing it silently
188
+ // changes the daily load: a 5-day, 40h holiday stretched over two weeks
189
+ // reads back as 4h of leave per day. Keep the hours per working day and
190
+ // rescale the total, which is what the caller asking for a longer period
191
+ // means -- and it shows up in the confirmation, so it is never silent.
192
+ const personId = current.data.relationships?.person?.data?.id;
193
+ const [oldDays, newDays] = await Promise.all([
194
+ personWorkingDays(client, personId, a.started_on, a.ended_on),
195
+ personWorkingDays(client, personId, from, to),
196
+ ]);
197
+ if (oldDays > 0 && newDays > 0 && newDays !== oldDays) {
198
+ attributes.total_time = Math.round((a.total_time * newDays) / oldDays);
199
+ }
200
+ }
201
+ if (!params.confirm) {
202
+ const changes = Object.entries(attributes)
203
+ .map(([k, v]) => ` ${k}: ${String(v)}`)
204
+ .join('\n');
205
+ // Naming the person and the kind of booking makes a mistyped ID obvious
206
+ // before it silently overwrites somebody else's entry.
207
+ const personId = current.data.relationships?.person?.data?.id;
208
+ const who = personId ? await describePerson(client, personId) : 'unknown person';
209
+ const kind = current.data.relationships?.event?.data?.id
210
+ ? 'ABSENCE'
211
+ : 'project capacity booking';
212
+ return {
213
+ content: [
214
+ {
215
+ type: 'text',
216
+ text: `Booking ${params.booking_id} — ${kind}
217
+ Person: ${who}
218
+ Current period: ${a.started_on} to ${a.ended_on}
219
+ Status: ${describeApprovalState(current.data)}
220
+
221
+ Will be changed to:
222
+
223
+ ${changes}
224
+
225
+ Check the person and type above before confirming. Call again with "confirm": true to apply.`,
226
+ },
227
+ ],
228
+ };
229
+ }
230
+ const updated = await client.updateBooking(params.booking_id, {
231
+ data: { type: 'bookings', id: params.booking_id, attributes },
232
+ });
233
+ const u = updated.data.attributes;
234
+ return {
235
+ content: [
236
+ {
237
+ type: 'text',
238
+ text: `Booking ${updated.data.id} updated.
239
+
240
+ Period: ${u.started_on} to ${u.ended_on} · ${u.total_working_days ?? '?'} working day(s)
241
+ ${typeof u.total_time === 'number' ? `Planned: ${formatMinutes(u.total_time)}` : ''}${typeof u.percentage === 'number' && u.percentage ? `\nAllocation: ${u.percentage}%` : ''}
242
+ Status: ${describeApprovalState(updated.data)}`,
243
+ },
244
+ ],
245
+ };
246
+ }
247
+ catch (error) {
248
+ rethrowToolError(error);
249
+ }
250
+ }
251
+ // --- delete_booking ----------------------------------------------------------
252
+ const deleteBookingSchema = z.object({
253
+ booking_id: z.string().min(1, 'booking_id is required'),
254
+ confirm: coerceBoolean.optional().default(false),
255
+ });
256
+ export async function deleteBookingTool(client, args) {
257
+ try {
258
+ const params = deleteBookingSchema.parse(args);
259
+ // Read it first, so the preview can name whose entry is about to go and
260
+ // what kind it is. A booking id carries none of that on its face, and this
261
+ // is the one call in the set that cannot be undone.
262
+ const current = await client.getBooking(params.booking_id);
263
+ const a = current.data.attributes;
264
+ const personId = current.data.relationships?.person?.data?.id;
265
+ const who = personId ? await describePerson(client, personId) : 'unknown person';
266
+ const kind = current.data.relationships?.event?.data?.id
267
+ ? 'ABSENCE'
268
+ : 'project capacity booking';
269
+ if (!params.confirm) {
270
+ return {
271
+ content: [
272
+ {
273
+ type: 'text',
274
+ text: `Booking ${params.booking_id} — ${kind}
275
+ Person: ${who}
276
+ Period: ${a.started_on} to ${a.ended_on}${typeof a.total_time === 'number' ? ` · ${formatMinutes(a.total_time)}` : ''}
277
+ Status: ${describeApprovalState(current.data)}
278
+
279
+ Deleting removes it outright — there is no undo, and an approved absence
280
+ disappears from the person's records with it. To take it back without losing
281
+ the entry, cancel it in Productive instead.
282
+
283
+ Call again with "confirm": true to delete it.`,
284
+ },
285
+ ],
286
+ };
287
+ }
288
+ await client.deleteBooking(params.booking_id);
289
+ return {
290
+ content: [
291
+ {
292
+ type: 'text',
293
+ text: `Booking ${params.booking_id} (${kind}, ${who}, ${a.started_on} to ${a.ended_on}) has been deleted.`,
294
+ },
295
+ ],
296
+ };
297
+ }
298
+ catch (error) {
299
+ rethrowToolError(error);
300
+ }
301
+ }
302
+ // --- list_bookings -----------------------------------------------------------
303
+ const listBookingsSchema = z.object({
304
+ person_id: z.string().optional(),
305
+ project_id: z.string().optional(),
306
+ date_from: z.string().optional(),
307
+ date_to: z.string().optional(),
308
+ include_absences: coerceBoolean.optional().default(false),
309
+ limit: z.coerce.number().min(1).max(200).default(50),
310
+ });
311
+ export async function listBookingsTool(client, args, config) {
312
+ try {
313
+ const params = listBookingsSchema.parse(args);
314
+ const personId = params.person_id ? resolvePersonId(params.person_id, config) : undefined;
315
+ // Absences are dropped here, not by the API, so `limit` has to be applied
316
+ // after the split -- otherwise a page full of absences reports no bookings.
317
+ //
318
+ // Except with project_id: an absence has no project, so the filter already
319
+ // excludes them server-side, nothing is dropped, and the limit can go
320
+ // straight through.
321
+ //
322
+ // The inverse ("project bookings only") has no server-side filter at all,
323
+ // which is why the over-fetch has to stay. Both candidates were checked
324
+ // live: the documented filter[booking_type] is accepted and then ignored
325
+ // (every value, plain or [eq], returns the unfiltered set), and
326
+ // filter[event_id][not_eq] over every event id answers 0 rows, because it
327
+ // only ever matches inside the bookings that have an event.
328
+ //
329
+ // When it does have to split, it asks for a whole page rather than a
330
+ // multiple of `limit`: a date range can hold nothing but absences for far
331
+ // longer than three rows (verified live -- a full year in the test org holds
332
+ // 25 bookings, every one of them an absence), and a short over-fetch then
333
+ // reports "no project bookings" for a window that has plenty just below the
334
+ // cut. One request either way.
335
+ const splitClientSide = !params.include_absences && !params.project_id;
336
+ const fetchLimit = splitClientSide ? MAX_PAGE_SIZE : params.limit;
337
+ const response = await client.listBookings({
338
+ person_id: personId,
339
+ project_id: params.project_id,
340
+ after: params.date_from ? parseDate(params.date_from) : undefined,
341
+ before: params.date_to ? parseDate(params.date_to) : undefined,
342
+ limit: fetchLimit,
343
+ });
344
+ const all = response.data ?? [];
345
+ const pageWasFull = all.length >= fetchLimit;
346
+ const matching = params.include_absences ? all : all.filter(isCapacityBooking);
347
+ const moreAvailable = pageWasFull || matching.length > params.limit;
348
+ const bookings = matching.slice(0, params.limit);
349
+ if (bookings.length === 0) {
350
+ const crowdedOut = pageWasFull
351
+ ? ' The page came back full of absences, so raising limit or narrowing the date range may still turn some up.'
352
+ : '';
353
+ return {
354
+ content: [
355
+ {
356
+ type: 'text',
357
+ text: `No project bookings found for these filters.${crowdedOut}\n\nNote: a regular API token only sees its own resource planning, so an empty result does not prove none exist for other people.`,
358
+ },
359
+ ],
360
+ };
361
+ }
362
+ const names = buildIncludeMap(response.included);
363
+ const lines = bookings.map((booking) => {
364
+ const a = booking.attributes;
365
+ const pid = booking.relationships?.person?.data?.id;
366
+ const sid = booking.relationships?.service?.data?.id;
367
+ const eid = booking.relationships?.event?.data?.id;
368
+ const person = resolveName(names, 'people', pid) ?? pid ?? 'Unknown';
369
+ const what = sid
370
+ ? `Service: ${resolveName(names, 'services', sid) ?? sid}`
371
+ : `Absence: ${resolveName(names, 'events', eid) ?? eid ?? '?'}`;
372
+ const amount = typeof a.percentage === 'number' && a.percentage
373
+ ? `${a.percentage}%`
374
+ : typeof a.total_time === 'number'
375
+ ? formatMinutes(a.total_time)
376
+ : '?';
377
+ return `• ${person} (ID: ${booking.id})
378
+ ${what}
379
+ ${a.started_on} to ${a.ended_on} · ${a.total_working_days ?? '?'} working day(s) · ${amount}
380
+ Status: ${describeApprovalState(booking)}`;
381
+ });
382
+ return {
383
+ content: [
384
+ {
385
+ type: 'text',
386
+ text: `${bookings.length} booking${bookings.length !== 1 ? 's' : ''} found:\n\n${lines.join('\n\n')}${moreAvailable ? '\n\nThere may be more -- raise limit or narrow the date range.' : ''}`,
387
+ },
388
+ ],
389
+ };
390
+ }
391
+ catch (error) {
392
+ rethrowToolError(error);
393
+ }
394
+ }
395
+ // --- definitions -------------------------------------------------------------
396
+ export const createBookingDefinition = {
397
+ name: 'create_booking',
398
+ description: 'Plan a person onto a project service for a date range (capacity planning, not absences — use create_absence for those). Give the load either as percentage or as hours_per_day. Requires confirmation: the first call previews the booking and warns if it would overbook the person, then repeat with "confirm": true to write it. Overbooking is reported, never blocked.',
399
+ inputSchema: {
400
+ type: 'object',
401
+ properties: {
402
+ person_id: {
403
+ type: 'string',
404
+ description: 'Person to plan. "me" uses PRODUCTIVE_USER_ID. Default "me".',
405
+ default: 'me',
406
+ },
407
+ service_id: {
408
+ type: 'string',
409
+ description: 'Service to book onto (required). Find it via list_project_deals then list_deal_services.',
410
+ },
411
+ date_from: { type: 'string', description: 'First day, YYYY-MM-DD or "today" (required)' },
412
+ date_to: { type: 'string', description: 'Last day, inclusive (required)' },
413
+ percentage: {
414
+ type: 'number',
415
+ description: 'Allocation as a percentage of contracted time (1-100)',
416
+ minimum: 1,
417
+ maximum: 100,
418
+ },
419
+ hours_per_day: { type: 'number', description: 'Allocation as hours per working day' },
420
+ booking_method_id: {
421
+ type: 'number',
422
+ description: 'Override booking method: 1 = hours per day, 2 = percentage, 3 = total hours',
423
+ minimum: 1,
424
+ maximum: 3,
425
+ },
426
+ note: { type: 'string', description: 'Optional note' },
427
+ confirm: {
428
+ type: 'boolean',
429
+ description: 'Set true to actually create. Call without it first to preview.',
430
+ default: false,
431
+ },
432
+ },
433
+ required: ['service_id', 'date_from', 'date_to'],
434
+ },
435
+ annotations: {
436
+ title: 'Create project booking',
437
+ readOnlyHint: false,
438
+ destructiveHint: false,
439
+ idempotentHint: false,
440
+ openWorldHint: true,
441
+ },
442
+ };
443
+ export const updateBookingDefinition = {
444
+ name: 'update_booking',
445
+ description: 'Change an existing booking: move its dates, adjust the allocation, or edit the note. Requires confirmation — the first call shows what would change, then repeat with "confirm": true. Works for both project bookings and absences.',
446
+ inputSchema: {
447
+ type: 'object',
448
+ properties: {
449
+ booking_id: { type: 'string', description: 'ID of the booking to change (required)' },
450
+ date_from: { type: 'string', description: 'New first day (YYYY-MM-DD)' },
451
+ date_to: { type: 'string', description: 'New last day, inclusive' },
452
+ percentage: {
453
+ type: 'number',
454
+ description: 'New allocation percentage (1-100). Project bookings only — absences take hours_per_day instead.',
455
+ minimum: 1,
456
+ maximum: 100,
457
+ },
458
+ hours_per_day: { type: 'number', description: 'New allocation in hours per working day' },
459
+ note: { type: 'string', description: 'New note' },
460
+ confirm: {
461
+ type: 'boolean',
462
+ description: 'Set true to apply. Call without it first to preview.',
463
+ default: false,
464
+ },
465
+ },
466
+ required: ['booking_id'],
467
+ },
468
+ annotations: {
469
+ title: 'Update booking',
470
+ readOnlyHint: false,
471
+ destructiveHint: false,
472
+ idempotentHint: true,
473
+ openWorldHint: true,
474
+ },
475
+ };
476
+ export const deleteBookingDefinition = {
477
+ name: 'delete_booking',
478
+ description: 'Delete a booking outright — a project booking or an absence. Requires confirmation: the first call names the person, the kind of booking and the period, then repeat with "confirm": true. This cannot be undone; to withdraw an absence while keeping the record, cancel it in Productive instead of deleting it. Use update_booking to correct dates or amounts.',
479
+ inputSchema: {
480
+ type: 'object',
481
+ properties: {
482
+ booking_id: { type: 'string', description: 'ID of the booking to delete (required)' },
483
+ confirm: {
484
+ type: 'boolean',
485
+ description: 'Set true to actually delete. Call without it first to see what would go.',
486
+ default: false,
487
+ },
488
+ },
489
+ required: ['booking_id'],
490
+ },
491
+ annotations: {
492
+ title: 'Delete booking',
493
+ readOnlyHint: false,
494
+ destructiveHint: true,
495
+ idempotentHint: true,
496
+ openWorldHint: true,
497
+ },
498
+ };
499
+ export const listBookingsDefinition = {
500
+ name: 'list_bookings',
501
+ description: 'Read project capacity bookings — who is planned onto which service, when, and at what load. Pass project_id to answer "who is planned on project X?". Absences are excluded unless include_absences is set (use list_absences for those). Note that a regular API token only sees its own resource planning, so an empty result does not prove none exist for other people.',
502
+ inputSchema: {
503
+ type: 'object',
504
+ properties: {
505
+ person_id: {
506
+ type: 'string',
507
+ description: 'Filter by person. "me" uses PRODUCTIVE_USER_ID.',
508
+ },
509
+ project_id: {
510
+ type: 'string',
511
+ description: 'Filter by project, for "who is planned on this project?". Absences never carry a project, so this also excludes them.',
512
+ },
513
+ date_from: { type: 'string', description: 'Only bookings after this date (YYYY-MM-DD)' },
514
+ date_to: { type: 'string', description: 'Only bookings before this date (YYYY-MM-DD)' },
515
+ include_absences: {
516
+ type: 'boolean',
517
+ description: 'Also include absence bookings (default false)',
518
+ default: false,
519
+ },
520
+ limit: {
521
+ type: 'number',
522
+ description: 'Number of bookings to return (1-200)',
523
+ minimum: 1,
524
+ maximum: 200,
525
+ default: 50,
526
+ },
527
+ },
528
+ required: [],
529
+ },
530
+ annotations: { title: 'List project bookings', readOnlyHint: true, openWorldHint: true },
531
+ };