foldnotes-mcp 2.4.0__tar.gz → 2.5.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: foldnotes-mcp
3
- Version: 2.4.0
3
+ Version: 2.5.0
4
4
  Summary: MCP server exposing the FoldNotes CLI (fn) as tools for Claude Desktop, Claude Code, and other MCP clients.
5
5
  Project-URL: Homepage, https://foldnotes.io
6
6
  Project-URL: Documentation, https://foldnotes.io/advanced/ai-integration/
@@ -26,7 +26,7 @@ Configure in Claude Desktop's claude_desktop_config.json:
26
26
  }
27
27
  """
28
28
 
29
- __version__ = "2.4.0"
29
+ __version__ = "2.5.0"
30
30
 
31
31
  import json
32
32
  import os
@@ -54,6 +54,15 @@ def _find_fn() -> str:
54
54
 
55
55
  FN_BIN = _find_fn()
56
56
 
57
+ # Seconds before an `fn` invocation is abandoned. 60, not 30: the FIRST call
58
+ # in a session is far slower than the rest — the cold run resolves the iCloud
59
+ # container, opens the SwiftData cache and may create that day's daily note.
60
+ # Measured 2026-08-09: first call >30 s (timed out), second 12.6 s, then
61
+ # 0.06 s warm. 30 s failed only ever on that first call, and the retry always
62
+ # worked — which is a confusing way for a tool to behave.
63
+ FN_TIMEOUT = 60
64
+
65
+
57
66
 
58
67
  def run_fn(args: list[str], collection: str | None = None) -> dict:
59
68
  """Run an fn CLI command and return parsed JSON or raw text."""
@@ -64,11 +73,11 @@ def run_fn(args: list[str], collection: str | None = None) -> dict:
64
73
  cmd += ["--collection", collection]
65
74
 
66
75
  try:
67
- result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
76
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=FN_TIMEOUT)
68
77
  except FileNotFoundError:
69
78
  return {"error": f"fn CLI not found. Tried: {FN_BIN}"}
70
79
  except subprocess.TimeoutExpired:
71
- return {"error": "fn command timed out after 30 seconds"}
80
+ return {"error": f"fn command timed out after {FN_TIMEOUT} seconds"}
72
81
 
73
82
  output = result.stdout.strip()
74
83
  if result.returncode != 0:
@@ -90,7 +99,7 @@ def run_fn_raw(args: list[str], collection: str | None = None) -> str:
90
99
  cmd += ["--collection", collection]
91
100
 
92
101
  try:
93
- result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
102
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=FN_TIMEOUT)
94
103
  except FileNotFoundError:
95
104
  return f"Error: fn CLI not found at {FN_BIN}"
96
105
  except subprocess.TimeoutExpired:
@@ -117,6 +126,11 @@ def _task_selector(text: str | None, task_id: str | None) -> list[str] | None:
117
126
  return None
118
127
 
119
128
 
129
+ def _note_args(note: str | None) -> list[str]:
130
+ """`--note` only when a note was named; `fn` then searches every note."""
131
+ return ["--note", note] if note else []
132
+
133
+
120
134
  # ---------------------------------------------------------------------------
121
135
  # MCP Server
122
136
  # ---------------------------------------------------------------------------
@@ -255,18 +269,25 @@ def create_note(
255
269
  content: str | None = None,
256
270
  tags: list[str] | None = None,
257
271
  properties: list[str] | None = None,
272
+ favourite: bool = False,
258
273
  collection: str | None = None,
259
274
  ) -> str:
260
275
  """Create a new note with optional content, tags, and properties.
261
276
 
277
+ The title is the note's name and is locked, so the note is never renamed
278
+ to follow its first heading.
279
+
262
280
  Args:
263
281
  title: Note title (becomes the filename).
264
282
  content: Note body content (markdown).
265
283
  tags: Tags to add (without #).
266
284
  properties: User properties as key=value strings.
285
+ favourite: Mark the new note as a favourite.
267
286
  collection: Collection name, UUID, or path.
268
287
  """
269
288
  args = ["create", title]
289
+ if favourite:
290
+ args.append("--favourite")
270
291
  if content:
271
292
  args += ["--content", content]
272
293
  for t in tags or []:
@@ -445,12 +466,42 @@ def list_tags(
445
466
  return json.dumps(run_fn(args, collection), indent=2)
446
467
 
447
468
 
469
+ # ---- Tags: Rename ----
470
+
471
+ @mcp.tool()
472
+ def rename_tag(
473
+ old_tag: str,
474
+ new_tag: str,
475
+ merge: bool = False,
476
+ collection: str | None = None,
477
+ ) -> str:
478
+ """Rename a tag, or move it under another parent, in every note that uses it.
479
+
480
+ Child tags move with it (renaming `work` also renames `work/clients`), notes
481
+ in the Trash are updated too, and manual-sort order and the tag's icon are
482
+ kept. Renaming onto a tag that already exists merges the two, which is
483
+ refused unless `merge` is true.
484
+
485
+ Args:
486
+ old_tag: Existing tag path, e.g. "work/clients" (with or without #).
487
+ new_tag: New tag path, e.g. "clients".
488
+ merge: Allow merging into a tag that already exists.
489
+ collection: Collection name, UUID, or path.
490
+ """
491
+ args = ["tags", "rename", old_tag, new_tag]
492
+ if merge:
493
+ args.append("--merge")
494
+ return json.dumps(run_fn(args, collection), indent=2)
495
+
496
+
448
497
  # ---- Tasks: List ----
449
498
 
450
499
  @mcp.tool()
451
500
  def list_tasks(
452
501
  due_today: bool = False,
502
+ due_tomorrow: bool = False,
453
503
  due_this_week: bool = False,
504
+ days: int | None = None,
454
505
  overdue: bool = False,
455
506
  status: str | None = None,
456
507
  priority: str | None = None,
@@ -465,8 +516,11 @@ def list_tasks(
465
516
  """List tasks across all notes with filtering.
466
517
 
467
518
  Args:
468
- due_today: Show only tasks due today.
469
- due_this_week: Show tasks due this week.
519
+ due_today: Show tasks due today and not yet overdue (a task due today
520
+ becomes overdue at 5 PM). Several due filters combine as "any of".
521
+ due_tomorrow: Show tasks due tomorrow.
522
+ due_this_week: Show tasks due this week (today and the next six days).
523
+ days: Show tasks due in the next N days, counting today.
470
524
  overdue: Show only overdue tasks.
471
525
  status: Filter by status: not-started, in-progress, done, cancelled.
472
526
  priority: Filter by priority: high, medium, low.
@@ -481,8 +535,12 @@ def list_tasks(
481
535
  args = ["tasks"]
482
536
  if due_today:
483
537
  args.append("--due-today")
538
+ if due_tomorrow:
539
+ args.append("--due-tomorrow")
484
540
  if due_this_week:
485
541
  args.append("--due-this-week")
542
+ if days:
543
+ args += ["--days", str(days)]
486
544
  if overdue:
487
545
  args.append("--overdue")
488
546
  if status:
@@ -509,25 +567,26 @@ def list_tasks(
509
567
  @mcp.tool()
510
568
  def add_task(
511
569
  text: str,
512
- note: str,
570
+ note: str | None = None,
513
571
  due: str | None = None,
514
572
  priority: str | None = None,
515
573
  project: str | None = None,
516
574
  context: str | None = None,
517
575
  collection: str | None = None,
518
576
  ) -> str:
519
- """Add a new task to a note.
577
+ """Add a new task to a note, or to today's daily note.
520
578
 
521
579
  Args:
522
580
  text: Task description text.
523
- note: Target note title to add the task to.
581
+ note: Target note title. Omit to add the task to the end of today's
582
+ daily note (created if needed) — the same rule as Siri's Add Task.
524
583
  due: Due date (YYYY-MM-DD, 'today', 'tomorrow', 'next monday', etc.).
525
584
  priority: Priority level: high, medium, low.
526
585
  project: Project name for the task.
527
586
  context: Context(s) for the task; comma-separate for several (e.g. "errand,phone").
528
587
  collection: Collection name, UUID, or path.
529
588
  """
530
- args = ["tasks", "add", text, "--note", note]
589
+ args = ["tasks", "add", text] + _note_args(note)
531
590
  if due:
532
591
  args += ["--due", due]
533
592
  if priority:
@@ -543,7 +602,7 @@ def add_task(
543
602
 
544
603
  @mcp.tool()
545
604
  def complete_task(
546
- note: str,
605
+ note: str | None = None,
547
606
  text: str | None = None,
548
607
  task_id: str | None = None,
549
608
  collection: str | None = None,
@@ -553,7 +612,9 @@ def complete_task(
553
612
  Identify the task by `task_id` (exact, preferred) or `text` (substring).
554
613
 
555
614
  Args:
556
- note: Note title containing the task.
615
+ note: Note title containing the task. Optional — without it the task is
616
+ found across all notes, and a text match in more than one note is
617
+ refused (the error lists the candidates; pass task_id).
557
618
  text: Task text to match (case-insensitive substring). Must match exactly
558
619
  one task; if several match, the command is refused — pass task_id.
559
620
  task_id: Exact task UUID from `list_tasks`. Preferred — it targets the
@@ -563,14 +624,14 @@ def complete_task(
563
624
  sel = _task_selector(text, task_id)
564
625
  if sel is None:
565
626
  return json.dumps({"error": "Provide either text or task_id."}, indent=2)
566
- return json.dumps(run_fn(["tasks", "complete"] + sel + ["--note", note], collection), indent=2)
627
+ return json.dumps(run_fn(["tasks", "complete"] + sel + _note_args(note), collection), indent=2)
567
628
 
568
629
 
569
630
  # ---- Tasks: Cancel ----
570
631
 
571
632
  @mcp.tool()
572
633
  def cancel_task(
573
- note: str,
634
+ note: str | None = None,
574
635
  text: str | None = None,
575
636
  task_id: str | None = None,
576
637
  collection: str | None = None,
@@ -580,7 +641,9 @@ def cancel_task(
580
641
  Identify the task by `task_id` (exact, preferred) or `text` (substring).
581
642
 
582
643
  Args:
583
- note: Note title containing the task.
644
+ note: Note title containing the task. Optional — without it the task is
645
+ found across all notes, and a text match in more than one note is
646
+ refused (the error lists the candidates; pass task_id).
584
647
  text: Task text to match (case-insensitive substring). Must match exactly
585
648
  one task; if several match, the command is refused — pass task_id.
586
649
  task_id: Exact task UUID from `list_tasks`. Preferred — it targets the
@@ -590,14 +653,14 @@ def cancel_task(
590
653
  sel = _task_selector(text, task_id)
591
654
  if sel is None:
592
655
  return json.dumps({"error": "Provide either text or task_id."}, indent=2)
593
- return json.dumps(run_fn(["tasks", "cancel"] + sel + ["--note", note], collection), indent=2)
656
+ return json.dumps(run_fn(["tasks", "cancel"] + sel + _note_args(note), collection), indent=2)
594
657
 
595
658
 
596
659
  # ---- Tasks: Progress ----
597
660
 
598
661
  @mcp.tool()
599
662
  def start_task(
600
- note: str,
663
+ note: str | None = None,
601
664
  text: str | None = None,
602
665
  task_id: str | None = None,
603
666
  collection: str | None = None,
@@ -607,7 +670,9 @@ def start_task(
607
670
  Identify the task by `task_id` (exact, preferred) or `text` (substring).
608
671
 
609
672
  Args:
610
- note: Note title containing the task.
673
+ note: Note title containing the task. Optional — without it the task is
674
+ found across all notes, and a text match in more than one note is
675
+ refused (the error lists the candidates; pass task_id).
611
676
  text: Task text to match (case-insensitive substring). Must match exactly
612
677
  one task; if several match, the command is refused — pass task_id.
613
678
  task_id: Exact task UUID from `list_tasks`. Preferred — it targets the
@@ -617,14 +682,14 @@ def start_task(
617
682
  sel = _task_selector(text, task_id)
618
683
  if sel is None:
619
684
  return json.dumps({"error": "Provide either text or task_id."}, indent=2)
620
- return json.dumps(run_fn(["tasks", "progress"] + sel + ["--note", note], collection), indent=2)
685
+ return json.dumps(run_fn(["tasks", "progress"] + sel + _note_args(note), collection), indent=2)
621
686
 
622
687
 
623
688
  # ---- Tasks: Reset ----
624
689
 
625
690
  @mcp.tool()
626
691
  def reset_task(
627
- note: str,
692
+ note: str | None = None,
628
693
  text: str | None = None,
629
694
  task_id: str | None = None,
630
695
  collection: str | None = None,
@@ -634,7 +699,9 @@ def reset_task(
634
699
  Identify the task by `task_id` (exact, preferred) or `text` (substring).
635
700
 
636
701
  Args:
637
- note: Note title containing the task.
702
+ note: Note title containing the task. Optional — without it the task is
703
+ found across all notes, and a text match in more than one note is
704
+ refused (the error lists the candidates; pass task_id).
638
705
  text: Task text to match (case-insensitive substring). Must match exactly
639
706
  one task; if several match, the command is refused — pass task_id.
640
707
  task_id: Exact task UUID from `list_tasks`. Preferred — it targets the
@@ -644,14 +711,14 @@ def reset_task(
644
711
  sel = _task_selector(text, task_id)
645
712
  if sel is None:
646
713
  return json.dumps({"error": "Provide either text or task_id."}, indent=2)
647
- return json.dumps(run_fn(["tasks", "reset"] + sel + ["--note", note], collection), indent=2)
714
+ return json.dumps(run_fn(["tasks", "reset"] + sel + _note_args(note), collection), indent=2)
648
715
 
649
716
 
650
717
  # ---- Tasks: Set (amend due / priority / project) ----
651
718
 
652
719
  @mcp.tool()
653
720
  def set_task(
654
- note: str,
721
+ note: str | None = None,
655
722
  text: str | None = None,
656
723
  task_id: str | None = None,
657
724
  due: str | None = None,
@@ -671,7 +738,9 @@ def set_task(
671
738
  task's stable UUID (identity is hashed over the prose, not the metadata).
672
739
 
673
740
  Args:
674
- note: Note title containing the task.
741
+ note: Note title containing the task. Optional — without it the task is
742
+ found across all notes, and a text match in more than one note is
743
+ refused (the error lists the candidates; pass task_id).
675
744
  text: Task text to match (case-insensitive substring). Must match exactly
676
745
  one task; if several match, the command is refused — pass task_id.
677
746
  task_id: Exact task UUID from `list_tasks`. Preferred.
@@ -688,7 +757,7 @@ def set_task(
688
757
  sel = _task_selector(text, task_id)
689
758
  if sel is None:
690
759
  return json.dumps({"error": "Provide either text or task_id."}, indent=2)
691
- args = ["tasks", "set"] + sel + ["--note", note]
760
+ args = ["tasks", "set"] + sel + _note_args(note)
692
761
  if due:
693
762
  args += ["--due", due]
694
763
  if clear_due:
@@ -712,7 +781,7 @@ def set_task(
712
781
 
713
782
  @mcp.tool()
714
783
  def remove_task(
715
- note: str,
784
+ note: str | None = None,
716
785
  text: str | None = None,
717
786
  task_id: str | None = None,
718
787
  collection: str | None = None,
@@ -725,7 +794,9 @@ def remove_task(
725
794
  `list_tasks` first when matching by text. Surviving tasks keep their UUIDs.
726
795
 
727
796
  Args:
728
- note: Note title containing the task.
797
+ note: Note title containing the task. Optional — without it the task is
798
+ found across all notes, and a text match in more than one note is
799
+ refused (the error lists the candidates; pass task_id).
729
800
  text: Task text to match (case-insensitive substring). Must match exactly
730
801
  one task; if several match, the command is refused — pass task_id.
731
802
  task_id: Exact task UUID from `list_tasks`. Preferred.
@@ -734,7 +805,7 @@ def remove_task(
734
805
  sel = _task_selector(text, task_id)
735
806
  if sel is None:
736
807
  return json.dumps({"error": "Provide either text or task_id."}, indent=2)
737
- return json.dumps(run_fn(["tasks", "remove"] + sel + ["--note", note], collection), indent=2)
808
+ return json.dumps(run_fn(["tasks", "remove"] + sel + _note_args(note), collection), indent=2)
738
809
 
739
810
 
740
811
  # ---- Tasks: Projects ----
@@ -1149,7 +1220,10 @@ def strip_context(name: str, collection: str | None = None) -> str:
1149
1220
 
1150
1221
  @mcp.tool()
1151
1222
  def list_attachments(collection: str | None = None) -> str:
1152
- """List images with size and reference count.
1223
+ """List attachments with size and reference count.
1224
+
1225
+ Covers every file in the collection's attachments folder — images, PDFs,
1226
+ Office and iWork documents, and audio — not images alone.
1153
1227
 
1154
1228
  Args:
1155
1229
  collection: Collection name, UUID, or path.
@@ -1159,7 +1233,9 @@ def list_attachments(collection: str | None = None) -> str:
1159
1233
 
1160
1234
  @mcp.tool()
1161
1235
  def orphan_attachments(collection: str | None = None) -> str:
1162
- """List images that no note references.
1236
+ """List attachments that no note references.
1237
+
1238
+ Covers documents and audio as well as images.
1163
1239
 
1164
1240
  Args:
1165
1241
  collection: Collection name, UUID, or path.
@@ -1169,10 +1245,14 @@ def orphan_attachments(collection: str | None = None) -> str:
1169
1245
 
1170
1246
  @mcp.tool()
1171
1247
  def prune_attachments(force: bool = False, collection: str | None = None) -> str:
1172
- """Delete orphaned images. Without force, only reports what would be deleted.
1248
+ """Delete orphaned attachments. Without force, only reports what would be deleted.
1249
+
1250
+ DESTRUCTIVE with force=True, and it deletes DOCUMENTS AND AUDIO as well as
1251
+ images — a PDF, spreadsheet or voice memo no note references is removed just
1252
+ the same. Run the dry-run first and read what it lists.
1173
1253
 
1174
1254
  Args:
1175
- force: Actually delete the orphaned images (default: dry-run).
1255
+ force: Actually delete the orphaned attachments (default: dry-run).
1176
1256
  collection: Collection name, UUID, or path.
1177
1257
  """
1178
1258
  args = ["attachments", "prune"]
File without changes
File without changes
File without changes