reflect-mcp 1.0.0 → 1.0.2
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/README.md +78 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +196 -38
- package/dist/pkcehandler.d.ts +1 -0
- package/dist/pkcehandler.js +10 -0
- package/package.json +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Reflect MCP Server
|
|
2
|
+
|
|
3
|
+
Connect your [Reflect](https://reflect.app) notes to Claude Desktop.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
**1. Install the server:**
|
|
8
|
+
```bash
|
|
9
|
+
npx reflect-mcp install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**2. Add to Claude Desktop config** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"reflect": {
|
|
17
|
+
"command": "npx",
|
|
18
|
+
"args": ["-y", "mcp-remote", "http://localhost:3000/mcp"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**3. Restart Claude Desktop**
|
|
25
|
+
|
|
26
|
+
That's it! First time you use a Reflect tool, your browser will open to authenticate.
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
reflect-mcp install [db-path] # Install as auto-start service
|
|
32
|
+
reflect-mcp uninstall # Remove auto-start service
|
|
33
|
+
reflect-mcp status # Check service status
|
|
34
|
+
reflect-mcp [db-path] # Run server manually
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Options
|
|
38
|
+
|
|
39
|
+
| Option | Description | Default |
|
|
40
|
+
|--------|-------------|---------|
|
|
41
|
+
| `db-path` | Path to Reflect SQLite database | `~/Library/Application Support/Reflect/File System/000/t/00/00000000` |
|
|
42
|
+
| `--port <port>` | Server port | `3000` |
|
|
43
|
+
|
|
44
|
+
## Examples
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Install with default settings
|
|
48
|
+
npx reflect-mcp install
|
|
49
|
+
|
|
50
|
+
# Install with custom database path
|
|
51
|
+
npx reflect-mcp install ~/custom/path/to/reflect/db
|
|
52
|
+
|
|
53
|
+
# Install with custom port
|
|
54
|
+
npx reflect-mcp install --port 4000
|
|
55
|
+
|
|
56
|
+
# Check if service is running
|
|
57
|
+
npx reflect-mcp status
|
|
58
|
+
|
|
59
|
+
# Remove auto-start
|
|
60
|
+
npx reflect-mcp uninstall
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Tools Available
|
|
64
|
+
|
|
65
|
+
- `get_graphs` - List all Reflect graphs
|
|
66
|
+
- `get_backlinks` - Get backlinks for a note
|
|
67
|
+
- `get_daily_notes` - Get recent daily notes
|
|
68
|
+
- `get_daily_note_by_date` - Get daily note for specific date
|
|
69
|
+
- `get_backlinked_notes` - Get notes with most backlinks
|
|
70
|
+
- `get_tags` - Get all tags with usage counts
|
|
71
|
+
- `get_notes_with_tag` - Get notes with a specific tag
|
|
72
|
+
- `get_note` - Get a note by title
|
|
73
|
+
- `create_note` - Create a new note
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
|
78
|
+
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -3,54 +3,212 @@
|
|
|
3
3
|
* Reflect MCP Server - CLI Entry Point
|
|
4
4
|
*
|
|
5
5
|
* Run with: npx reflect-mcp <db-path>
|
|
6
|
+
* Install: npx reflect-mcp install <db-path>
|
|
6
7
|
*/
|
|
7
8
|
import { startReflectMCPServer } from "./server.js";
|
|
8
|
-
import { DEFAULT_DB_PATH } from "./utils.js";
|
|
9
|
+
import { DEFAULT_DB_PATH, expandPath } from "./utils.js";
|
|
10
|
+
import * as fs from "fs";
|
|
11
|
+
import * as path from "path";
|
|
12
|
+
import * as os from "os";
|
|
13
|
+
import { execSync } from "child_process";
|
|
9
14
|
const REFLECT_CLIENT_ID = "55798f25d5a24efb95e4174fff3d219e";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const LAUNCH_AGENT_LABEL = "com.reflect-mcp";
|
|
16
|
+
const LAUNCH_AGENT_DIR = path.join(os.homedir(), "Library/LaunchAgents");
|
|
17
|
+
const LAUNCH_AGENT_PATH = path.join(LAUNCH_AGENT_DIR, `${LAUNCH_AGENT_LABEL}.plist`);
|
|
18
|
+
// Get the command and arguments
|
|
19
|
+
const args = process.argv.slice(2);
|
|
20
|
+
const command = args[0];
|
|
21
|
+
// Handle commands
|
|
22
|
+
if (command === "install") {
|
|
23
|
+
install(args.slice(1));
|
|
24
|
+
}
|
|
25
|
+
else if (command === "uninstall") {
|
|
26
|
+
uninstall();
|
|
27
|
+
}
|
|
28
|
+
else if (command === "status") {
|
|
29
|
+
status();
|
|
30
|
+
}
|
|
31
|
+
else if (command === "--help" || command === "-h") {
|
|
32
|
+
showHelp();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Default: run the server
|
|
36
|
+
runServer(args);
|
|
37
|
+
}
|
|
38
|
+
function showHelp() {
|
|
39
|
+
console.log(`
|
|
40
|
+
Reflect MCP Server - Connect your Reflect notes to Claude
|
|
41
|
+
|
|
42
|
+
Usage:
|
|
43
|
+
reflect-mcp [db-path] [--port <port>] Run the server
|
|
44
|
+
reflect-mcp install [db-path] Install as auto-start service
|
|
45
|
+
reflect-mcp uninstall Remove auto-start service
|
|
46
|
+
reflect-mcp status Check service status
|
|
22
47
|
|
|
23
48
|
Arguments:
|
|
24
|
-
db-path
|
|
25
|
-
|
|
49
|
+
db-path Path to Reflect SQLite database
|
|
50
|
+
(default: ${DEFAULT_DB_PATH})
|
|
26
51
|
|
|
27
52
|
Options:
|
|
28
|
-
--port <port>
|
|
29
|
-
--help, -h Show this help message
|
|
53
|
+
--port <port> Port to run server on (default: 3000)
|
|
30
54
|
|
|
31
55
|
Examples:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
reflect-mcp install # Install with default db path
|
|
57
|
+
reflect-mcp install ~/my/reflect/db # Install with custom db path
|
|
58
|
+
reflect-mcp uninstall # Remove auto-start
|
|
59
|
+
reflect-mcp # Run server manually
|
|
35
60
|
`);
|
|
36
|
-
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
function install(installArgs) {
|
|
64
|
+
let dbPath = DEFAULT_DB_PATH;
|
|
65
|
+
let port = 3000;
|
|
66
|
+
// Parse install arguments
|
|
67
|
+
for (let i = 0; i < installArgs.length; i++) {
|
|
68
|
+
if (installArgs[i] === "--port" && installArgs[i + 1]) {
|
|
69
|
+
port = parseInt(installArgs[++i]);
|
|
37
70
|
}
|
|
38
|
-
else if (!
|
|
39
|
-
|
|
40
|
-
dbPath = args[i];
|
|
71
|
+
else if (!installArgs[i].startsWith("--")) {
|
|
72
|
+
dbPath = installArgs[i];
|
|
41
73
|
}
|
|
42
74
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
const expandedDbPath = expandPath(dbPath);
|
|
76
|
+
const nodePath = process.execPath;
|
|
77
|
+
const cliPath = process.argv[1];
|
|
78
|
+
console.log("📦 Installing Reflect MCP Server as auto-start service...\n");
|
|
79
|
+
// Create Launch Agent directory if needed
|
|
80
|
+
if (!fs.existsSync(LAUNCH_AGENT_DIR)) {
|
|
81
|
+
fs.mkdirSync(LAUNCH_AGENT_DIR, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
// Stop existing service if running
|
|
84
|
+
try {
|
|
85
|
+
execSync(`launchctl stop ${LAUNCH_AGENT_LABEL} 2>/dev/null`, { stdio: "ignore" });
|
|
86
|
+
execSync(`launchctl unload ${LAUNCH_AGENT_PATH} 2>/dev/null`, { stdio: "ignore" });
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Ignore errors - service might not exist yet
|
|
90
|
+
}
|
|
91
|
+
// Create plist content
|
|
92
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
93
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
94
|
+
<plist version="1.0">
|
|
95
|
+
<dict>
|
|
96
|
+
<key>Label</key>
|
|
97
|
+
<string>${LAUNCH_AGENT_LABEL}</string>
|
|
98
|
+
<key>ProgramArguments</key>
|
|
99
|
+
<array>
|
|
100
|
+
<string>${nodePath}</string>
|
|
101
|
+
<string>${cliPath}</string>
|
|
102
|
+
<string>${expandedDbPath}</string>
|
|
103
|
+
<string>--port</string>
|
|
104
|
+
<string>${port}</string>
|
|
105
|
+
</array>
|
|
106
|
+
<key>RunAtLoad</key>
|
|
107
|
+
<true/>
|
|
108
|
+
<key>KeepAlive</key>
|
|
109
|
+
<true/>
|
|
110
|
+
<key>StandardErrorPath</key>
|
|
111
|
+
<string>/tmp/reflect-mcp.log</string>
|
|
112
|
+
<key>StandardOutPath</key>
|
|
113
|
+
<string>/tmp/reflect-mcp.log</string>
|
|
114
|
+
</dict>
|
|
115
|
+
</plist>`;
|
|
116
|
+
// Write plist file
|
|
117
|
+
fs.writeFileSync(LAUNCH_AGENT_PATH, plist);
|
|
118
|
+
console.log(`✅ Created: ${LAUNCH_AGENT_PATH}`);
|
|
119
|
+
// Load and start the service
|
|
120
|
+
try {
|
|
121
|
+
execSync(`launchctl load ${LAUNCH_AGENT_PATH}`);
|
|
122
|
+
execSync(`launchctl start ${LAUNCH_AGENT_LABEL}`);
|
|
123
|
+
console.log("✅ Service installed and started!\n");
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.error("❌ Failed to start service:", error);
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
console.log(`🚀 Reflect MCP Server will now auto-start on login`);
|
|
130
|
+
console.log(` Server: http://localhost:${port}`);
|
|
131
|
+
console.log(` Database: ${expandedDbPath}`);
|
|
132
|
+
console.log(` Logs: tail -f /tmp/reflect-mcp.log\n`);
|
|
133
|
+
console.log(`📋 Add to Claude Desktop config (~/.config/claude/claude_desktop_config.json):`);
|
|
134
|
+
console.log(`{
|
|
135
|
+
"mcpServers": {
|
|
136
|
+
"reflect": {
|
|
137
|
+
"command": "npx",
|
|
138
|
+
"args": ["-y", "mcp-remote", "http://localhost:${port}/mcp"]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}`);
|
|
142
|
+
}
|
|
143
|
+
function uninstall() {
|
|
144
|
+
console.log("🗑️ Removing Reflect MCP Server auto-start service...\n");
|
|
145
|
+
try {
|
|
146
|
+
execSync(`launchctl stop ${LAUNCH_AGENT_LABEL} 2>/dev/null`, { stdio: "ignore" });
|
|
147
|
+
execSync(`launchctl unload ${LAUNCH_AGENT_PATH} 2>/dev/null`, { stdio: "ignore" });
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Ignore errors
|
|
151
|
+
}
|
|
152
|
+
if (fs.existsSync(LAUNCH_AGENT_PATH)) {
|
|
153
|
+
fs.unlinkSync(LAUNCH_AGENT_PATH);
|
|
154
|
+
console.log(`✅ Removed: ${LAUNCH_AGENT_PATH}`);
|
|
155
|
+
}
|
|
156
|
+
console.log("✅ Service uninstalled. Server will no longer auto-start.");
|
|
157
|
+
}
|
|
158
|
+
function status() {
|
|
159
|
+
console.log("📊 Reflect MCP Server Status\n");
|
|
160
|
+
// Check if plist exists
|
|
161
|
+
if (fs.existsSync(LAUNCH_AGENT_PATH)) {
|
|
162
|
+
console.log(`✅ Launch Agent installed: ${LAUNCH_AGENT_PATH}`);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
console.log("❌ Launch Agent not installed");
|
|
166
|
+
console.log(" Run: reflect-mcp install");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
// Check if service is running
|
|
170
|
+
try {
|
|
171
|
+
const result = execSync(`launchctl list | grep ${LAUNCH_AGENT_LABEL}`, { encoding: "utf-8" });
|
|
172
|
+
if (result.includes(LAUNCH_AGENT_LABEL)) {
|
|
173
|
+
const parts = result.trim().split(/\s+/);
|
|
174
|
+
const pid = parts[0];
|
|
175
|
+
const exitCode = parts[1];
|
|
176
|
+
if (pid !== "-") {
|
|
177
|
+
console.log(`✅ Service running (PID: ${pid})`);
|
|
178
|
+
}
|
|
179
|
+
else if (exitCode === "0") {
|
|
180
|
+
console.log("⚠️ Service stopped (last exit: success)");
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
console.log(`❌ Service stopped (last exit code: ${exitCode})`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
console.log("❌ Service not loaded");
|
|
189
|
+
}
|
|
190
|
+
console.log(`\n📝 Logs: tail -f /tmp/reflect-mcp.log`);
|
|
191
|
+
}
|
|
192
|
+
function runServer(serverArgs) {
|
|
193
|
+
let dbPath = DEFAULT_DB_PATH;
|
|
194
|
+
let port = 3000;
|
|
195
|
+
for (let i = 0; i < serverArgs.length; i++) {
|
|
196
|
+
if (serverArgs[i] === "--port" && serverArgs[i + 1]) {
|
|
197
|
+
port = parseInt(serverArgs[++i]);
|
|
198
|
+
}
|
|
199
|
+
else if (!serverArgs[i].startsWith("--")) {
|
|
200
|
+
dbPath = serverArgs[i];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
startReflectMCPServer({
|
|
204
|
+
clientId: REFLECT_CLIENT_ID,
|
|
205
|
+
port,
|
|
206
|
+
dbPath,
|
|
207
|
+
}).then(() => {
|
|
208
|
+
console.log(`Reflect MCP Server running on http://localhost:${port}`);
|
|
209
|
+
console.log(`Database: ${dbPath}`);
|
|
210
|
+
}).catch((err) => {
|
|
211
|
+
console.error("Failed to start server:", err);
|
|
212
|
+
process.exit(1);
|
|
213
|
+
});
|
|
214
|
+
}
|
package/dist/pkcehandler.d.ts
CHANGED
package/dist/pkcehandler.js
CHANGED
|
@@ -281,6 +281,16 @@ export class PKCEOAuthProxy {
|
|
|
281
281
|
}
|
|
282
282
|
return data;
|
|
283
283
|
}
|
|
284
|
+
// Get first valid token (for stdio mode where we don't have specific token ID)
|
|
285
|
+
getFirstValidToken() {
|
|
286
|
+
const now = new Date();
|
|
287
|
+
for (const [id, token] of this.tokens) {
|
|
288
|
+
if (token.expiresAt > now) {
|
|
289
|
+
return token;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
284
294
|
// Cleanup expired transactions and tokens
|
|
285
295
|
startCleanup() {
|
|
286
296
|
this.cleanupInterval = setInterval(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reflect-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"dev": "tsx src/cli.ts",
|
|
17
17
|
"start": "node dist/cli.js",
|
|
18
|
-
"prepublishOnly": "npm run build"
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"postinstall": "npm rebuild better-sqlite3 || true"
|
|
19
20
|
},
|
|
20
21
|
"keywords": [
|
|
21
22
|
"mcp",
|
|
@@ -35,7 +36,8 @@
|
|
|
35
36
|
"node": ">=18"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
40
|
+
"better-sqlite3": "^11.10.0",
|
|
39
41
|
"fastmcp": "^3.25.4",
|
|
40
42
|
"zod": "^4.1.13"
|
|
41
43
|
},
|