screenpipe-mcp 0.14.1 → 0.15.0
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 +50 -0
- package/package.json +1 -1
- package/src/index.ts +53 -0
package/dist/index.js
CHANGED
|
@@ -53,6 +53,55 @@ 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 > npx screenpipe auth token > bundled bun
|
|
57
|
+
function discoverApiKey() {
|
|
58
|
+
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
59
|
+
if (envKey)
|
|
60
|
+
return envKey;
|
|
61
|
+
const { execSync } = require("child_process");
|
|
62
|
+
const os = require("os");
|
|
63
|
+
const fs = require("fs");
|
|
64
|
+
const path = require("path");
|
|
65
|
+
// Try npx first (works if user has Node installed)
|
|
66
|
+
try {
|
|
67
|
+
const token = execSync("npx screenpipe@latest auth token", {
|
|
68
|
+
timeout: 15000,
|
|
69
|
+
encoding: "utf-8",
|
|
70
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
71
|
+
}).trim();
|
|
72
|
+
if (token)
|
|
73
|
+
return token;
|
|
74
|
+
}
|
|
75
|
+
catch { }
|
|
76
|
+
// Try bundled bun inside the screenpipe app
|
|
77
|
+
const bundledBunPaths = [];
|
|
78
|
+
const platform = os.platform();
|
|
79
|
+
if (platform === "darwin") {
|
|
80
|
+
bundledBunPaths.push("/Applications/screenpipe.app/Contents/MacOS/bun");
|
|
81
|
+
}
|
|
82
|
+
else if (platform === "win32") {
|
|
83
|
+
bundledBunPaths.push(path.join(process.env.LOCALAPPDATA || "", "screenpipe", "bun.exe"), path.join(process.env.PROGRAMFILES || "", "screenpipe", "bun.exe"));
|
|
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 { }
|
|
101
|
+
}
|
|
102
|
+
return "";
|
|
103
|
+
}
|
|
104
|
+
const API_KEY = discoverApiKey();
|
|
56
105
|
// Read version from package.json (single source of truth)
|
|
57
106
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
58
107
|
const PKG_VERSION = require("../package.json").version;
|
|
@@ -523,6 +572,7 @@ async function fetchAPI(endpoint, options = {}) {
|
|
|
523
572
|
...options,
|
|
524
573
|
headers: {
|
|
525
574
|
"Content-Type": "application/json",
|
|
575
|
+
...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}),
|
|
526
576
|
...options.headers,
|
|
527
577
|
},
|
|
528
578
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -28,6 +28,58 @@ 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 > npx screenpipe auth token > bundled bun
|
|
32
|
+
function discoverApiKey(): string {
|
|
33
|
+
const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;
|
|
34
|
+
if (envKey) return envKey;
|
|
35
|
+
|
|
36
|
+
const { execSync } = require("child_process");
|
|
37
|
+
const os = require("os");
|
|
38
|
+
const fs = require("fs");
|
|
39
|
+
const path = require("path");
|
|
40
|
+
|
|
41
|
+
// Try npx first (works if user has Node installed)
|
|
42
|
+
try {
|
|
43
|
+
const token = execSync("npx screenpipe@latest auth token", {
|
|
44
|
+
timeout: 15000,
|
|
45
|
+
encoding: "utf-8",
|
|
46
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
47
|
+
}).trim();
|
|
48
|
+
if (token) return token;
|
|
49
|
+
} catch {}
|
|
50
|
+
|
|
51
|
+
// Try bundled bun inside the screenpipe app
|
|
52
|
+
const bundledBunPaths: string[] = [];
|
|
53
|
+
const platform = os.platform();
|
|
54
|
+
if (platform === "darwin") {
|
|
55
|
+
bundledBunPaths.push("/Applications/screenpipe.app/Contents/MacOS/bun");
|
|
56
|
+
} else if (platform === "win32") {
|
|
57
|
+
bundledBunPaths.push(
|
|
58
|
+
path.join(process.env.LOCALAPPDATA || "", "screenpipe", "bun.exe"),
|
|
59
|
+
path.join(process.env.PROGRAMFILES || "", "screenpipe", "bun.exe"),
|
|
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
|
+
}
|
|
77
|
+
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const API_KEY = discoverApiKey();
|
|
82
|
+
|
|
31
83
|
// Read version from package.json (single source of truth)
|
|
32
84
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
33
85
|
const PKG_VERSION: string = require("../package.json").version;
|
|
@@ -531,6 +583,7 @@ async function fetchAPI(
|
|
|
531
583
|
...options,
|
|
532
584
|
headers: {
|
|
533
585
|
"Content-Type": "application/json",
|
|
586
|
+
...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}),
|
|
534
587
|
...options.headers,
|
|
535
588
|
},
|
|
536
589
|
});
|