screenpipe-mcp 0.15.0 → 0.16.1
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/index.js +26 -31
- package/package.json +2 -1
- package/src/index.ts +24 -32
package/dist/index.js
CHANGED
|
@@ -53,18 +53,28 @@ for (let i = 0; i < args.length; i++) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
const SCREENPIPE_API = `http://localhost:${port}`;
|
|
56
|
-
// Discover API key: env var >
|
|
56
|
+
// Discover API key: env var > screenpipe JS lib > npx via process.execPath > npx on PATH
|
|
57
57
|
function discoverApiKey() {
|
|
58
58
|
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
59
59
|
if (envKey)
|
|
60
60
|
return envKey;
|
|
61
|
-
const { execSync } = require("child_process");
|
|
62
|
-
const os = require("os");
|
|
63
|
-
const fs = require("fs");
|
|
61
|
+
const { execFileSync, execSync } = require("child_process");
|
|
64
62
|
const path = require("path");
|
|
65
|
-
//
|
|
63
|
+
// Use the screenpipe npm package's JS API — resolves the bundled native
|
|
64
|
+
// binary directly, no PATH dependency, no subprocess spawning of npx.
|
|
66
65
|
try {
|
|
67
|
-
const
|
|
66
|
+
const { getApiKey } = require("screenpipe");
|
|
67
|
+
const token = getApiKey();
|
|
68
|
+
if (token)
|
|
69
|
+
return token;
|
|
70
|
+
}
|
|
71
|
+
catch { }
|
|
72
|
+
// Fallback: use the current Node binary to run npx (no PATH dependency).
|
|
73
|
+
// Claude Code and other MCP hosts may strip PATH, making bare `npx` unfindable.
|
|
74
|
+
// process.execPath is the absolute path to the Node binary running this MCP.
|
|
75
|
+
try {
|
|
76
|
+
const npxPath = path.join(path.dirname(process.execPath), "npx");
|
|
77
|
+
const token = execFileSync(npxPath, ["screenpipe@latest", "auth", "token"], {
|
|
68
78
|
timeout: 15000,
|
|
69
79
|
encoding: "utf-8",
|
|
70
80
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -73,32 +83,17 @@ function discoverApiKey() {
|
|
|
73
83
|
return token;
|
|
74
84
|
}
|
|
75
85
|
catch { }
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
else {
|
|
86
|
-
bundledBunPaths.push("/usr/lib/screenpipe/bun", "/opt/screenpipe/bun");
|
|
87
|
-
}
|
|
88
|
-
for (const bunPath of bundledBunPaths) {
|
|
89
|
-
try {
|
|
90
|
-
if (fs.existsSync(bunPath)) {
|
|
91
|
-
const token = execSync(`"${bunPath}" x screenpipe@latest auth token`, {
|
|
92
|
-
timeout: 15000,
|
|
93
|
-
encoding: "utf-8",
|
|
94
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
95
|
-
}).trim();
|
|
96
|
-
if (token)
|
|
97
|
-
return token;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
catch { }
|
|
86
|
+
// Last resort: npx on PATH
|
|
87
|
+
try {
|
|
88
|
+
const token = execSync("npx screenpipe@latest auth token", {
|
|
89
|
+
timeout: 15000,
|
|
90
|
+
encoding: "utf-8",
|
|
91
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
92
|
+
}).trim();
|
|
93
|
+
if (token)
|
|
94
|
+
return token;
|
|
101
95
|
}
|
|
96
|
+
catch { }
|
|
102
97
|
return "";
|
|
103
98
|
}
|
|
104
99
|
const API_KEY = discoverApiKey();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screenpipe-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "MCP server for screenpipe - search your screen recordings and audio transcriptions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
34
|
+
"screenpipe": "latest",
|
|
34
35
|
"ws": "^8.19.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -28,19 +28,28 @@ for (let i = 0; i < args.length; i++) {
|
|
|
28
28
|
|
|
29
29
|
const SCREENPIPE_API = `http://localhost:${port}`;
|
|
30
30
|
|
|
31
|
-
// Discover API key: env var >
|
|
31
|
+
// Discover API key: env var > screenpipe JS lib > npx via process.execPath > npx on PATH
|
|
32
32
|
function discoverApiKey(): string {
|
|
33
33
|
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
34
34
|
if (envKey) return envKey;
|
|
35
35
|
|
|
36
|
-
const { execSync } = require("child_process");
|
|
37
|
-
const os = require("os");
|
|
38
|
-
const fs = require("fs");
|
|
36
|
+
const { execFileSync, execSync } = require("child_process");
|
|
39
37
|
const path = require("path");
|
|
40
38
|
|
|
41
|
-
//
|
|
39
|
+
// Use the screenpipe npm package's JS API — resolves the bundled native
|
|
40
|
+
// binary directly, no PATH dependency, no subprocess spawning of npx.
|
|
42
41
|
try {
|
|
43
|
-
const
|
|
42
|
+
const { getApiKey } = require("screenpipe");
|
|
43
|
+
const token = getApiKey();
|
|
44
|
+
if (token) return token;
|
|
45
|
+
} catch {}
|
|
46
|
+
|
|
47
|
+
// Fallback: use the current Node binary to run npx (no PATH dependency).
|
|
48
|
+
// Claude Code and other MCP hosts may strip PATH, making bare `npx` unfindable.
|
|
49
|
+
// process.execPath is the absolute path to the Node binary running this MCP.
|
|
50
|
+
try {
|
|
51
|
+
const npxPath = path.join(path.dirname(process.execPath), "npx");
|
|
52
|
+
const token = execFileSync(npxPath, ["screenpipe@latest", "auth", "token"], {
|
|
44
53
|
timeout: 15000,
|
|
45
54
|
encoding: "utf-8",
|
|
46
55
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -48,32 +57,15 @@ function discoverApiKey(): string {
|
|
|
48
57
|
if (token) return token;
|
|
49
58
|
} catch {}
|
|
50
59
|
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
} else {
|
|
62
|
-
bundledBunPaths.push("/usr/lib/screenpipe/bun", "/opt/screenpipe/bun");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
for (const bunPath of bundledBunPaths) {
|
|
66
|
-
try {
|
|
67
|
-
if (fs.existsSync(bunPath)) {
|
|
68
|
-
const token = execSync(`"${bunPath}" x screenpipe@latest auth token`, {
|
|
69
|
-
timeout: 15000,
|
|
70
|
-
encoding: "utf-8",
|
|
71
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
72
|
-
}).trim();
|
|
73
|
-
if (token) return token;
|
|
74
|
-
}
|
|
75
|
-
} catch {}
|
|
76
|
-
}
|
|
60
|
+
// Last resort: npx on PATH
|
|
61
|
+
try {
|
|
62
|
+
const token = execSync("npx screenpipe@latest auth token", {
|
|
63
|
+
timeout: 15000,
|
|
64
|
+
encoding: "utf-8",
|
|
65
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
66
|
+
}).trim();
|
|
67
|
+
if (token) return token;
|
|
68
|
+
} catch {}
|
|
77
69
|
|
|
78
70
|
return "";
|
|
79
71
|
}
|