ofw-mcp 2.24.0 → 2.26.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/dist/config.js CHANGED
@@ -174,9 +174,10 @@ export function getAllowMarkRead() {
174
174
  * inbox message silently: it shows the subject, sender and sent time and asks
175
175
  * the user to confirm — through the same gate as a send (an elicitation prompt
176
176
  * where the client supports one, otherwise the two-phase confirmToken flow).
177
- * The bulk paths that stamp (`ofw_sync_messages fetchUnreadBodies`, the
178
- * `allowMarkRead` probes of `ofw_check_freshness` / `ofw_status`) cannot ask
179
- * about each message, so they are switched off instead.
177
+ * `ofw_sync_messages fetchUnreadBodies` asks too: it syncs without stamping,
178
+ * then lists the cached unread messages it would open and waits for a yes.
179
+ * The `allowMarkRead` probes of `ofw_check_freshness` / `ofw_status` have no
180
+ * message to show before the request that stamps, so they are switched off.
180
181
  *
181
182
  * Default FALSE: unset is exactly the shipped behaviour. An unrecognized value
182
183
  * fails CLOSED to true, with a warning: someone who typed "ture" meant to turn
package/dist/sync.js CHANGED
@@ -528,6 +528,15 @@ export async function syncDrafts(client, draftsFolderId, store, budget) {
528
528
  await markFolderVerified(store, 'drafts', now);
529
529
  return { synced, done: true };
530
530
  }
531
+ /**
532
+ * The sync note for unread inbox messages cached without bodies. Exported so
533
+ * ofw_sync_messages can rewrite it after a confirmed open of some of them —
534
+ * a note still counting messages the same call opened would contradict
535
+ * `unreadInbox` in one payload.
536
+ */
537
+ export function unreadInboxNote(count) {
538
+ return `${count} unread inbox messages cached without bodies. Call ofw_get_message(id) to read them — this will mark them as read on OFW.`;
539
+ }
531
540
  export async function syncAll(client, opts, store) {
532
541
  const requested = opts.folders ?? ['inbox', 'sent', 'drafts'];
533
542
  // Drafts go FIRST. They are the only folder a destructive tool
@@ -616,7 +625,7 @@ export async function syncAll(client, opts, store) {
616
625
  notes.push('The drafts folder was NOT checked against OurFamilyWizard on this call (the request budget ran out first), so no drafts count is reported and the cached drafts are marked "unverified". Cached draft bodies may be behind the server. Call ofw_sync_messages again — or ofw_sync_messages with folders:["drafts"] — before editing or deleting a draft.');
617
626
  }
618
627
  if (unreadInbox.length > 0) {
619
- notes.push(`${unreadInbox.length} unread inbox messages cached without bodies. Call ofw_get_message(id) to read them — this will mark them as read on OFW.`);
628
+ notes.push(unreadInboxNote(unreadInbox.length));
620
629
  }
621
630
  if (notRefreshed.length > 0) {
622
631
  notes.push(`NOT checked against OurFamilyWizard on this call: ${notRefreshed.join(', ')}. No count is reported for ${notRefreshed.length > 1 ? 'those folders' : 'that folder'} — absence of a count means "not looked at", not "no changes". Cached contents may be behind the server; call ofw_sync_messages again to finish, or ofw_check_freshness for a cheap live confirmation.`);
@@ -9,6 +9,7 @@ import { resolve } from 'node:path';
9
9
  import { NodeAttachmentIO, resolveSaveDest } from './attachments.js';
10
10
  import { buildCalendarIcs, CALENDAR_ITEM_TYPES, filterCalendarTypes } from './calendar-ics.js';
11
11
  import { formatInstant, resolveTimeZoneArg } from '../timestamps.js';
12
+ import { briefDate, briefLine, briefText, familyMeta } from './hints.js';
12
13
  // OFW's real event-write API (reverse-engineered from the web app bundle):
13
14
  // POST /pub/v3/events create — 201 with the full event
14
15
  // GET /pub/v3/events/{eventRecurrenceId} detail
@@ -185,20 +186,53 @@ function icsSummary(built, args, timeZone) {
185
186
  snapshot: 'Static: it does not update when OurFamilyWizard changes. Re-importing a later export updates events in place.',
186
187
  };
187
188
  }
189
+ /**
190
+ * The calendar as brief lines (`view: "brief"`, the context-group canonical
191
+ * whats-on): one line per item of `calendarItems`, in OFW's order. The
192
+ * `guardianData` custody grid is not an item list and is never included.
193
+ */
194
+ export function calendarBriefLines(data, timeZone) {
195
+ const items = isRecord(data) && Array.isArray(data.calendarItems) ? data.calendarItems : [];
196
+ return items.filter(isRecord).map((item) => {
197
+ const start = isRecord(item.startDate) ? item.startDate.dateTime : undefined;
198
+ if (item.type === 'TRANSITION') {
199
+ const to = isRecord(item.transitionEndParent) ? item.transitionEndParent.name : undefined;
200
+ return briefLine(typeof to === 'string' && to ? `Custody handoff to ${to}` : 'Custody handoff', briefDate(start, timeZone), 'handoff');
201
+ }
202
+ const title = typeof item.title === 'string' ? item.title : '';
203
+ if (item.allDay === true) {
204
+ return briefLine(title, briefDate(typeof start === 'string' ? start.slice(0, 10) : undefined, timeZone), 'all day');
205
+ }
206
+ return briefLine(title, briefDate(start, timeZone), item.type === 'CONNECTED_EVENT' ? 'outside calendar' : 'event');
207
+ });
208
+ }
209
+ function isRecord(value) {
210
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
211
+ }
188
212
  export function registerCalendarTools(server, client, attachmentIO = new NodeAttachmentIO()) {
189
213
  // Calendar writes land on the court-visible record with no draft stage, but
190
214
  // events are reversible — 'all' mode, or 'drafts' + OFW_CALENDAR_WRITES=true.
191
215
  const allowWrites = getCalendarWritesAllowed();
192
216
  server.registerTool('ofw_list_events', {
217
+ _meta: familyMeta('whats-on', {
218
+ canonical: true,
219
+ when: { start: 'startDate', end: 'endDate' },
220
+ aliases: ['custody', 'parenting time', 'calendar', 'schedule', 'pickup', 'drop off', 'handoff', 'kids'],
221
+ }),
193
222
  description: "List OurFamilyWizard calendar items in a date range: events, connected (subscribed outside-calendar) events, custody handoffs (TRANSITION) and the per-day custody grid (guardianData, type SCHEDULE). Pass `types` to keep only some of them — the custody grid is most of a response's weight, so leave SCHEDULE out unless you need who-has-the-children per day. Times are OFW wall clock in the account's zone, rendered with an offset in `timeZone` (default: the server's DISPLAY_TZ). format:\"ics\" returns an iCalendar (.ics) text you can show or save — events, all-day events, and each custody period as a \"Parenting time\" event — after a short JSON summary of what was included and what was left out. To get a file or download link instead, use ofw_save_calendar_ics.",
194
223
  annotations: { readOnlyHint: true, openWorldHint: true },
195
224
  inputSchema: z.object({
196
225
  ...calendarRangeFields,
197
226
  detailed: z.boolean().describe('Return full event details (default false). Ignored for format:"ics", which always reads the detailed calendar').optional(),
198
227
  format: z.enum(['json', 'ics']).describe('json (default): the OFW payload. ics: a summary block, then the iCalendar text').optional(),
228
+ view: z.enum(['full', 'brief']).describe('full (default): the response `format` asks for. brief: plain text, one line per calendar item (the custody grid is never included) — title — start (ISO-8601, a bare date for all-day items) — event|all day|outside calendar|handoff; an empty range answers "-- none". Overrides format and detailed').optional(),
199
229
  }),
200
230
  }, async (args) => {
201
231
  const timeZone = resolveTimeZoneArg(args.timeZone);
232
+ if (args.view === 'brief') {
233
+ const data = filterCalendarTypes(await readDetailedCalendar(client, args.startDate, args.endDate), args.types);
234
+ return { content: [{ type: 'text', text: briefText(calendarBriefLines(data, timeZone)) }] };
235
+ }
202
236
  const ics = args.format === 'ics';
203
237
  const raw = await (ics || args.detailed
204
238
  ? readDetailedCalendar(client, args.startDate, args.endDate)
@@ -218,6 +252,7 @@ export function registerCalendarTools(server, client, attachmentIO = new NodeAtt
218
252
  // File delivery lives on its own tool so ofw_list_events stays read-only:
219
253
  // hosts auto-approve a read, and a tool that MAY write a file is not one.
220
254
  server.registerTool('ofw_save_calendar_ics', {
255
+ _meta: familyMeta('other'),
221
256
  description: "Save an OurFamilyWizard date range as an iCalendar (.ics) file the user can import into Google, Apple or Outlook calendar — events, all-day events, and each custody period as a \"Parenting time\" event (OFW's own export leaves the parenting schedule out). Same filters as ofw_list_events. On a hosted connector the file is uploaded and you get a private download link that expires (default 1 hour); locally it is written inside the attachments directory (OFW_ATTACHMENTS_DIR, default ~/Downloads/ofw-mcp) and you get its path. Never overwrites an existing file. The file is a snapshot: it does not update when OFW changes, and re-importing a later export updates events in place (stable UIDs).",
222
257
  // Additive: it adds a new local file (or a new uploaded object) and never
223
258
  // replaces one. Nothing reaches OFW.
@@ -277,6 +312,7 @@ export function registerCalendarTools(server, client, attachmentIO = new NodeAtt
277
312
  });
278
313
  if (allowWrites)
279
314
  server.registerTool('ofw_create_event', {
315
+ _meta: familyMeta('change'),
280
316
  description: 'Create a calendar event in OurFamilyWizard. Unless privateEvent is true, the event is immediately visible to the co-parent — there is no draft stage — so a shared event is confirmed first (a private one is not). If the request fails without a definitive answer the result is EVENT_UNCONFIRMED: the event may already exist, so do NOT retry until ofw_list_events shows it did not land. ' + CONFIRM_NOTE,
281
317
  // Destructive by the inverse test: a shared event is on the co-parent's
282
318
  // calendar the moment it lands, and ofw_delete_event removes it but cannot
@@ -329,6 +365,7 @@ export function registerCalendarTools(server, client, attachmentIO = new NodeAtt
329
365
  });
330
366
  if (allowWrites)
331
367
  server.registerTool('ofw_update_event', {
368
+ _meta: familyMeta('change'),
332
369
  description: 'Update an existing OurFamilyWizard calendar event. Fetches the event, applies the given changes, and writes the merged result back (OFW has no partial update). A change to an event the co-parent can see (shared before or after the change) is confirmed first; the confirmation is bound to the event exactly as read, so if it changes on OFW in between (say the co-parent edited it) the update is refused instead of overwriting their edit. If the write fails without a definitive answer, or lands but cannot be re-read to confirm it, the result is EVENT_UNCONFIRMED: the change may already be on OFW, so do NOT retry until ofw_list_events shows whether it landed. ' + CONFIRM_NOTE,
333
370
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
334
371
  inputSchema: z.object({
@@ -412,6 +449,7 @@ export function registerCalendarTools(server, client, attachmentIO = new NodeAtt
412
449
  });
413
450
  if (allowWrites)
414
451
  server.registerTool('ofw_delete_event', {
452
+ _meta: familyMeta('change'),
415
453
  description: 'Delete an OurFamilyWizard calendar event. Reads the event first; deleting one the co-parent can see is confirmed first, with a preview of exactly which event (title, date, time) is removed, and is refused if the event changed on OFW after that preview. If the request fails without a definitive answer the result is EVENT_UNCONFIRMED: the event may already be gone, so do NOT retry until ofw_list_events shows whether it is still there. ' + CONFIRM_NOTE,
416
454
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
417
455
  inputSchema: z.object({
@@ -2,6 +2,7 @@ import { parseLenient } from '@chrischall/mcp-utils';
2
2
  import { z } from 'zod';
3
3
  import { CONFIRM_NOTE, confirmTokenParam, confirmWrite, stateRevision } from './_confirm.js';
4
4
  import { jsonErrorResponse, jsonResponse, requestWrite, UnconfirmedWriteError, unconfirmedWriteResponse } from './_shared.js';
5
+ import { familyMeta } from './hints.js';
5
6
  // Allow ordinary binary floating point representations of exact cents, but
6
7
  // never round a genuinely fractional cent or accept an unsafe monetary value.
7
8
  const money = z.number().nonnegative().refine((v) => Number.isSafeInteger(Math.round(v * 100))
@@ -27,6 +28,7 @@ function immutableRevision(d) {
27
28
  /** Registered only by the full expense surface in write mode all. */
28
29
  export function registerExpenseReimbursementTool(server, client) {
29
30
  server.registerTool('ofw_mark_expense_reimbursed', {
31
+ _meta: familyMeta('change'),
30
32
  description: 'Irreversibly mark the FULL remaining expense balance reimbursed externally. Records an already completed outside-OFW reimbursement only: does NOT send money or use bank/payment endpoints; no partial amounts. Requires expectedRemainingAmount (currency units, positive exact cents) matching the current leftToPay, NOT the full expense total. Reads the current expense, binds the entire detail to confirmation, rechecks immediately before writing, then verifies paid status and unchanged fields. Cannot be undone. On EXPENSE_REIMBURSEMENT_UNCONFIRMED, mayHaveLanded=true: inspect the OFW Expenses log before any retry; never replay blindly. ' + CONFIRM_NOTE,
31
33
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
32
34
  inputSchema: z.object({
@@ -7,6 +7,7 @@ import { getExpenseUploadOnly, getWriteMode } from '../config.js';
7
7
  import { parseLenient } from '@chrischall/mcp-utils';
8
8
  import { RECEIPT_HOST_SUFFIX } from '../protocol.js';
9
9
  import { registerExpenseReimbursementTool } from './expense-reimbursement.js';
10
+ import { familyMeta } from './hints.js';
10
11
  const UploadedExpenseFileSchema = z.looseObject({
11
12
  fileId: z.number(),
12
13
  fileName: z.string().optional(),
@@ -211,6 +212,7 @@ export function registerExpenseTools(server, client, attachmentIO) {
211
212
  const allowReceiptUploads = allowWrites && attachmentIO !== undefined;
212
213
  if (!uploadOnly)
213
214
  server.registerTool('ofw_get_expense_totals', {
215
+ _meta: familyMeta('lookup', { aliases: ['expenses', 'owe', 'reimbursement'] }),
214
216
  description: 'Get OurFamilyWizard expense summary totals (owed/paid)',
215
217
  annotations: { readOnlyHint: true, openWorldHint: true },
216
218
  }, async () => {
@@ -219,6 +221,7 @@ export function registerExpenseTools(server, client, attachmentIO) {
219
221
  });
220
222
  if (!uploadOnly)
221
223
  server.registerTool('ofw_list_expense_categories', {
224
+ _meta: familyMeta('lookup'),
222
225
  description: 'List OurFamilyWizard expense categories, including preset and custom categories with their responsibility split metadata. Read-only.',
223
226
  annotations: { readOnlyHint: true, openWorldHint: true },
224
227
  }, async () => {
@@ -227,6 +230,7 @@ export function registerExpenseTools(server, client, attachmentIO) {
227
230
  });
228
231
  if (!uploadOnly)
229
232
  server.registerTool('ofw_list_expenses', {
233
+ _meta: familyMeta('lookup', { aliases: ['expenses', 'reimbursement', 'receipts'] }),
230
234
  description: 'List OurFamilyWizard expenses. OFW pages this endpoint with 1-based page/size parameters; its older start/max parameters are ignored and repeatedly return page 1. The response leads with hasMore and nextPage (null when exhausted) before the records. Continue by passing nextPage.',
231
235
  annotations: { readOnlyHint: true, openWorldHint: true },
232
236
  inputSchema: z.object({
@@ -276,6 +280,7 @@ export function registerExpenseTools(server, client, attachmentIO) {
276
280
  });
277
281
  if (allowReceiptUploads)
278
282
  server.registerTool('ofw_upload_expense_pdf', {
283
+ _meta: familyMeta('other'),
279
284
  // Destructive by the inverse test: always uploaded SHARED, so the
280
285
  // co-parent sees it in My Files at once, and no tool here deletes it.
281
286
  description: 'Upload a PDF to OurFamilyWizard My Files for later attachment to an expense. Accepts either a local path or a signed ChatGPT/oaiusercontent HTTPS URL plus fileName. Exactly one of path or url must be supplied. This tool accepts PDF files only and uploads them using the same SHARED file metadata as the OFW expense form so the returned fileId can be attached to an expense. A SHARED file is visible to the co-parent in My Files immediately, whatever the visibility of the expense it is later attached to (that is set separately by ofw_create_expense privateExpense). ' + CONFIRM_NOTE,
@@ -354,6 +359,7 @@ export function registerExpenseTools(server, client, attachmentIO) {
354
359
  });
355
360
  if (allowWrites)
356
361
  server.registerTool('ofw_update_expense', {
362
+ _meta: familyMeta('change'),
357
363
  description: `Change an existing OurFamilyWizard expense. Pass expenseId plus ONLY the fields you want to change; every field you omit keeps its current value. The tool reads the expense from OFW first and sends the merged result, because OFW's update replaces the whole expense and a field left out would otherwise be erased. If a field you did not pass cannot be read back from OFW, the update is refused as EXPENSE_FIELDS_UNREADABLE and names the field; pass it explicitly (description:null or receiptFileId:null to send none). receiptFileId REPLACES all current receipts; omit it to keep them. Set privateExpense=false to publish a private expense to the co-parent. The confirmation is bound to the expense exactly as read, so if it changes on OFW in between, the update is refused instead of overwriting that change. If the request fails without a definitive answer the result is EXPENSE_UNCONFIRMED: the update may already have been applied, so check ${checkIn} before retrying. ` + CONFIRM_NOTE,
358
364
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
359
365
  inputSchema: z.object({
@@ -529,6 +535,7 @@ export function registerExpenseTools(server, client, attachmentIO) {
529
535
  });
530
536
  if (allowWrites)
531
537
  server.registerTool('ofw_create_expense', {
538
+ _meta: familyMeta('change', { aliases: ['expense', 'reimbursement', 'split'] }),
532
539
  description: `Log a new expense in OurFamilyWizard using the current web-app expense contract. Required fields are title, amount, purchaseDate, categoryId, payerId (the parent who owes), and at least one child user id. Supports one previously-uploaded receipt PDF and private entries. privateExpense=true creates an expense visible only to you; false/default creates the normal shared expense. receiptFileId should come from ofw_upload_expense_pdf. A shared expense is a money claim that appears in the ledger in front of the co-parent immediately, and this server cannot delete it. If the request fails without a definitive answer the result is EXPENSE_UNCONFIRMED: the expense may already exist, so do NOT retry until ${checkIn} shows it did not land. ` + CONFIRM_NOTE,
533
540
  // Not a harmless local write: a shared claim is co-parent-visible at once
534
541
  // and this server has no way to take it back. destructiveHint keeps a host
@@ -0,0 +1,43 @@
1
+ import { formatInstant, parseTimestampValue } from '../timestamps.js';
2
+ /** `_meta` for an OFW tool: every tool here is in the `family` group. */
3
+ export function familyMeta(intent, extra = {}) {
4
+ return { mint: { domain: 'family', intent, ...extra } };
5
+ }
6
+ /** The longest line a `view: "brief"` answer emits. */
7
+ export const BRIEF_MAX = 120;
8
+ /**
9
+ * One `view: "brief"` line: `title — <ISO date | no date> — <status>`, at most
10
+ * {@link BRIEF_MAX} chars. The title is what gets shortened, never the date or
11
+ * the status a host reads back.
12
+ */
13
+ export function briefLine(title, date, status) {
14
+ const flat = title.replace(/\s+/g, ' ').trim() || '(untitled)';
15
+ const tail = ` — ${date ?? 'no date'} — ${status}`;
16
+ const room = BRIEF_MAX - tail.length;
17
+ const shown = flat.length > room ? `${flat.slice(0, Math.max(room - 1, 0))}…` : flat;
18
+ return `${shown}${tail}`;
19
+ }
20
+ /**
21
+ * A `view: "brief"` answer: the item lines, then the contract's `-- ` note
22
+ * lines — `-- N of M shown` when `page` is a slice of a larger result (so a
23
+ * host never mistakes a truncated page for the whole range), and `-- none`
24
+ * when there is nothing to list (never an empty text).
25
+ */
26
+ export function briefText(lines, page) {
27
+ if (page && page.shown < page.total)
28
+ return [...lines, `-- ${page.shown} of ${page.total} shown`].join('\n');
29
+ return lines.length ? lines.join('\n') : '-- none';
30
+ }
31
+ /**
32
+ * An OFW date or timestamp as ISO-8601 for a brief line: a bare `YYYY-MM-DD`
33
+ * stays a date (an all-day item has no time to invent), a naive wall clock is
34
+ * read in `tz` and gains its offset, and anything else is `null`.
35
+ */
36
+ export function briefDate(value, tz) {
37
+ if (typeof value !== 'string')
38
+ return null;
39
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value))
40
+ return value;
41
+ const instant = parseTimestampValue('date', value, tz);
42
+ return instant ? formatInstant(instant, tz).iso : null;
43
+ }
@@ -2,10 +2,12 @@ import { z } from 'zod';
2
2
  import { jsonResponse, requestWrite, UnconfirmedWriteError, unconfirmedWriteResponse } from './_shared.js';
3
3
  import { offsetState, readUpstreamPaging, withPaginationFirst } from './pagination.js';
4
4
  import { getWriteMode } from '../config.js';
5
+ import { familyMeta } from './hints.js';
5
6
  export function registerJournalTools(server, client) {
6
7
  // Journal writes land on the court-visible record — OFW_WRITE_MODE 'all' only.
7
8
  const allowWrites = getWriteMode() === 'all';
8
9
  server.registerTool('ofw_list_journal_entries', {
10
+ _meta: familyMeta('lookup'),
9
11
  description: 'List OurFamilyWizard journal entries. Offset-paged via start/max (1-based). The response leads with its paging state — `hasMore` and `nextStart` (null when the list is exhausted) — BEFORE the records, so a truncated or partially-read response still says whether more remain. Never state an entry count or an absence from one page.',
10
12
  annotations: { readOnlyHint: true, openWorldHint: true },
11
13
  inputSchema: z.object({
@@ -38,6 +40,7 @@ export function registerJournalTools(server, client) {
38
40
  });
39
41
  if (allowWrites)
40
42
  server.registerTool('ofw_create_journal_entry', {
43
+ _meta: familyMeta('change', { aliases: ['journal', 'note'] }),
41
44
  // Destructive by the inverse test: the entry lands on the court-visible
42
45
  // record and no tool here edits or deletes a journal entry.
43
46
  description: 'Create a new journal entry in OurFamilyWizard',