BareGit

Trilium: fix updating note and listing note children.

Author: MetroWind <chris.corsair@gmail.com>
Date: Tue Feb 24 14:36:00 2026 -0800
Commit: 4fb6dbf2f5433bb82219af349d3c28bac31b254c

Changes

diff --git a/skills/trilium/mcp/src/trilium_client.py b/skills/trilium/mcp/src/trilium_client.py
index 64b006b..e626f1a 100644
--- a/skills/trilium/mcp/src/trilium_client.py
+++ b/skills/trilium/mcp/src/trilium_client.py
@@ -49,19 +49,18 @@ class TriliumClient:
 
     def getNoteChildren(self, note_id: str) -> List[Dict[str, Any]]:
         """List children of a specified note."""
-        # Note: In some versions, parentNoteId must be explicitly in query or the search query
+        # ancestorNoteId and ancestorDepth=eq1 is the supported way to list direct children
+        # the search parameter is mandatory, so we use a generic query that matches all notes
+        params = {
+            "search": "note.title *= ''",
+            "ancestorNoteId": note_id,
+            "ancestorDepth": "eq1"
+        }
         response = requests.get(
             f"{self.url}/etapi/notes",
-            params={"parentNoteId": note_id},
+            params=params,
             headers=self._get_headers()
         )
-        if response.status_code == 400:
-             # Fallback to searching for children if direct query fails
-             response = requests.get(
-                f"{self.url}/etapi/notes",
-                params={"search": f"parent.noteId = '{note_id}'"},
-                headers=self._get_headers()
-            )
         response.raise_for_status()
         return response.json()
 
@@ -105,6 +104,6 @@ class TriliumClient:
         response = requests.put(
             f"{self.url}/etapi/notes/{note_id}/content",
             data=content.encode('utf-8'),
-            headers=self._get_headers("text/html")
+            headers=self._get_headers("text/plain")
         )
         response.raise_for_status()