YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: MCP discovers API key via npx, falls back to bundled bun
Louis Beaumont7e21c4c6b86a
diff --git a/crates/screenpipe-connect/screenpipe-mcp/src/index.ts b/crates/screenpipe-connect/screenpipe-mcp/src/index.tsindex 70785c544..3dd6b5848 100644--- a/crates/screenpipe-connect/screenpipe-mcp/src/index.ts+++ b/crates/screenpipe-connect/screenpipe-mcp/src/index.ts@@ -28,22 +28,53 @@ for (let i = 0; i < args.length; i++) {const SCREENPIPE_API = `http://localhost:${port}`;-// Discover API key: env var > `screenpipe auth token` CLI+// Discover API key: env var > npx screenpipe auth token > bundled bunfunction discoverApiKey(): string {const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;if (envKey) return envKey;- // Ask the running screenpipe CLI for the token+ const { execSync } = require("child_process");+ const os = require("os");+ const fs = require("fs");+ const path = require("path");++ // Try npx first (works if user has Node installed)try {- const { execSync } = require("child_process");- const token = execSync("screenpipe auth token", {- timeout: 5000,+ const token = execSync("npx screenpipe@latest auth token", {+ timeout: 15000,encoding: "utf-8",stdio: ["pipe", "pipe", "pipe"],}).trim();if (token) return token;} catch {}+ // Try bundled bun inside the screenpipe app+ const bundledBunPaths: string[] = [];+ const platform = os.platform();+ if (platform === "darwin") {+ bundledBunPaths.push("/Applications/screenpipe.app/Contents/MacOS/bun");+ } else if (platform === "win32") {+ bundledBunPaths.push(+ path.join(process.env.LOCALAPPDATA || "", "screenpipe", "bun.exe"),+ path.join(process.env.PROGRAMFILES || "", "screenpipe", "bun.exe"),+ );+ } else {+ bundledBunPaths.push("/usr/lib/screenpipe/bun", "/opt/screenpipe/bun");+ }++ for (const bunPath of bundledBunPaths) {+ try {+ if (fs.existsSync(bunPath)) {+ const token = execSync(`"${bunPath}" x screenpipe@latest auth token`, {+ timeout: 15000,+ encoding: "utf-8",+ stdio: ["pipe", "pipe", "pipe"],+ }).trim();+ if (token) return token;+ }+ } catch {}+ }+return "";}