reflect-mcp 1.0.9 → 1.0.10
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/utils.d.ts +10 -1
- package/dist/utils.js +69 -2
- package/package.json +2 -2
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
|
-
|
|
7
|
-
|
|
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.
|
|
3
|
+
"version": "1.0.10",
|
|
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.
|
|
42
|
+
"reflect-mcp": "^1.0.9",
|
|
43
43
|
"zod": "^4.1.13"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|