reflect-mcp 1.0.9 → 1.0.11

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.
@@ -622,13 +622,13 @@ export function registerTools(server, dbPath) {
622
622
  // Tool: Create a new note in Reflect via API
623
623
  server.addTool({
624
624
  name: "create_note",
625
- description: "Create a new note in Reflect. Must add the tasks field if there are any actionable items to add. Pass in the user's timezone to ensure the note is created with the correct date. Check what tags the user has already created, and determine which tag to use for this content, or create a new tag if no tags fit the content.",
625
+ description: "Create a new note in Reflect. Must add the tasks field if there are any actionable items to add. Pass in the user's timezone to ensure the note is created with the correct date. The backlink_note parameter creates a backlink to another note (e.g., 'Project Planning' creates [[Project Planning]]). For actual tags, use get_tags to see available tags and add them separately if needed.",
626
626
  parameters: z.object({
627
627
  subject: z.string().describe("The title/subject of the note. Example: 'Meeting Summary - Project Planning'"),
628
628
  content: z.string().describe("The markdown content for the note. This is the main body of the note."),
629
629
  graph_id: z.string().describe("The unique identifier of the Reflect graph where the note should be created."),
630
630
  timezone: z.string().describe("The user's timezone in IANA format. Example: 'America/New_York', 'Europe/London', 'Asia/Tokyo'. Used to determine the correct date for the daily note backlink."),
631
- tag: z.string().describe("The tag to add to the note. Example: 'personal'"),
631
+ backlink_note: z.string().describe("The name of an existing note to backlink to. This creates a backlink [[backlink_note]] in the new note. Example: 'Project Planning' creates [[Project Planning]]. This is NOT a tag - use get_tags for actual tags."),
632
632
  tasks: z.array(z.string()).optional().describe("A list of tasks to add to the note. Must add this field if there are any actionable items. Example: ['Review PR', 'Schedule meeting']"),
633
633
  }),
634
634
  execute: async (args, { session }) => {
@@ -643,11 +643,11 @@ export function registerTools(server, dbPath) {
643
643
  };
644
644
  }
645
645
  const { accessToken } = session;
646
- const { subject, content, graph_id, timezone, tag, tasks } = args;
646
+ const { subject, content, graph_id, timezone, backlink_note, tasks } = args;
647
647
  const todayDate = getDateForTimezone(timezone);
648
648
  const contentParts = [];
649
649
  contentParts.push(`#ai-generated\n`);
650
- contentParts.push(`- [[${tag}]]\n`);
650
+ contentParts.push(`- [[${backlink_note}]]\n`);
651
651
  const contentLines = content.split('\n');
652
652
  const indentedContent = contentLines.map(line => ` ${line}`).join('\n');
653
653
  contentParts.push(indentedContent);
@@ -686,14 +686,14 @@ export function registerTools(server, dbPath) {
686
686
  date: todayDate,
687
687
  text: `[[${subject}]]`,
688
688
  transform_type: "list-append",
689
- list_name: `[[${tag}]]`,
689
+ list_name: `[[${backlink_note}]]`,
690
690
  }),
691
691
  });
692
692
  if (!dailyNoteResponse.ok) {
693
693
  const errorText = await dailyNoteResponse.text();
694
694
  console.error(`Failed to append to daily notes: ${dailyNoteResponse.status}, ${errorText}`);
695
695
  }
696
- const message = `Note "${subject}" created with tag [[${tag}]]${tasks?.length ? ` and ${tasks.length} task(s)` : ''} and linked in daily notes`;
696
+ const message = `Note "${subject}" created with backlink to [[${backlink_note}]]${tasks?.length ? ` and ${tasks.length} task(s)` : ''} and linked in daily notes`;
697
697
  return {
698
698
  content: [
699
699
  {
package/dist/utils.d.ts CHANGED
@@ -1,11 +1,20 @@
1
1
  /**
2
2
  * Utility functions for the Reflect MCP Server
3
3
  */
4
- export declare const DEFAULT_DB_PATH = "~/Library/Application Support/Reflect/File System/000/t/00/00000000";
5
4
  /**
6
5
  * Expands ~ to the user's home directory
7
6
  */
8
7
  export declare function expandPath(filePath: string): string;
8
+ /**
9
+ * Searches for the Reflect local database file
10
+ * Returns the first valid database path found, or null if not found
11
+ */
12
+ export declare function findLocalDatabase(): string | null;
13
+ /**
14
+ * Gets the default database path, searching for it if not provided
15
+ */
16
+ export declare function getDefaultDbPath(): string;
17
+ export declare const DEFAULT_DB_PATH: string;
9
18
  /**
10
19
  * Strips HTML tags from a string, converting <br> to newlines
11
20
  */
package/dist/utils.js CHANGED
@@ -3,8 +3,9 @@
3
3
  */
4
4
  import * as path from "path";
5
5
  import * as os from "os";
6
- // Reflect local database path
7
- export const DEFAULT_DB_PATH = "~/Library/Application Support/Reflect/File System/000/t/00/00000000";
6
+ import * as fs from "fs";
7
+ // Base path for Reflect local database
8
+ const REFLECT_BASE_PATH = "~/Library/Application Support/Reflect/File System";
8
9
  /**
9
10
  * Expands ~ to the user's home directory
10
11
  */
@@ -14,6 +15,72 @@ export function expandPath(filePath) {
14
15
  }
15
16
  return filePath;
16
17
  }
18
+ /**
19
+ * Searches for the Reflect local database file
20
+ * Returns the first valid database path found, or null if not found
21
+ */
22
+ export function findLocalDatabase() {
23
+ const basePath = expandPath(REFLECT_BASE_PATH);
24
+ if (!fs.existsSync(basePath)) {
25
+ return null;
26
+ }
27
+ // Search for database files in the File System directory
28
+ // Structure is typically: File System/XXX/t/XX/XXXXXXXX
29
+ try {
30
+ const entries = fs.readdirSync(basePath);
31
+ for (const entry of entries) {
32
+ const entryPath = path.join(basePath, entry);
33
+ const tPath = path.join(entryPath, "t");
34
+ if (fs.existsSync(tPath) && fs.statSync(tPath).isDirectory()) {
35
+ // Look for subdirectories in t/
36
+ const tEntries = fs.readdirSync(tPath);
37
+ for (const tEntry of tEntries) {
38
+ const subPath = path.join(tPath, tEntry);
39
+ if (fs.statSync(subPath).isDirectory()) {
40
+ // Look for database files (8-char hex names)
41
+ const dbFiles = fs.readdirSync(subPath);
42
+ for (const dbFile of dbFiles) {
43
+ const dbPath = path.join(subPath, dbFile);
44
+ // Check if it's a valid SQLite database (starts with SQLite header)
45
+ if (fs.statSync(dbPath).isFile()) {
46
+ try {
47
+ const header = Buffer.alloc(16);
48
+ const fd = fs.openSync(dbPath, 'r');
49
+ fs.readSync(fd, header, 0, 16, 0);
50
+ fs.closeSync(fd);
51
+ // SQLite files start with "SQLite format 3"
52
+ if (header.toString('utf8', 0, 15) === 'SQLite format 3') {
53
+ return dbPath;
54
+ }
55
+ }
56
+ catch {
57
+ // Not a readable file, skip
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ catch {
67
+ return null;
68
+ }
69
+ return null;
70
+ }
71
+ /**
72
+ * Gets the default database path, searching for it if not provided
73
+ */
74
+ export function getDefaultDbPath() {
75
+ const found = findLocalDatabase();
76
+ if (found) {
77
+ return found;
78
+ }
79
+ // Fallback to a common path pattern
80
+ return expandPath("~/Library/Application Support/Reflect/File System/000/t/00/00000000");
81
+ }
82
+ // For backwards compatibility
83
+ export const DEFAULT_DB_PATH = getDefaultDbPath();
17
84
  /**
18
85
  * Strips HTML tags from a string, converting <br> to newlines
19
86
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reflect-mcp",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "MCP server for Reflect Notes - connect your notes to Claude Desktop. Just run: npx reflect-mcp",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",
@@ -39,7 +39,7 @@
39
39
  "@modelcontextprotocol/sdk": "^1.25.1",
40
40
  "better-sqlite3": "^11.10.0",
41
41
  "fastmcp": "^3.25.4",
42
- "reflect-mcp": "^1.0.3",
42
+ "reflect-mcp": "^1.0.10",
43
43
  "zod": "^4.1.13"
44
44
  },
45
45
  "devDependencies": {