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 `screenpipe auth token` CLI
Louis Beaumonta0d7434f6a1a
diff --git a/crates/screenpipe-connect/screenpipe-mcp/src/index.ts b/crates/screenpipe-connect/screenpipe-mcp/src/index.tsindex 7af7793b0..70785c544 100644--- a/crates/screenpipe-connect/screenpipe-mcp/src/index.ts+++ b/crates/screenpipe-connect/screenpipe-mcp/src/index.ts@@ -28,36 +28,20 @@ for (let i = 0; i < args.length; i++) {const SCREENPIPE_API = `http://localhost:${port}`;-// Auto-discover API key: env var > store.bin > auth.json+// Discover API key: env var > `screenpipe auth token` CLIfunction discoverApiKey(): string {- // 1. Env var (set by pipes or user)const envKey = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY;if (envKey) return envKey;- // 2. Read from store.bin (Tauri desktop app encrypted settings)+ // Ask the running screenpipe CLI for the tokentry {- const os = require("os");- const fs = require("fs");- const path = require("path");- const storePath = path.join(os.homedir(), ".screenpipe", "store.bin");- if (fs.existsSync(storePath)) {- const content = fs.readFileSync(storePath, "utf-8");- const parsed = JSON.parse(content);- const key = parsed?.settings?.apiKey || parsed?.state?.settings?.apiKey;- if (key) return key;- }- } catch {}-- // 3. Legacy auth.json- try {- const os = require("os");- const fs = require("fs");- const path = require("path");- const authPath = path.join(os.homedir(), ".screenpipe", "auth.json");- if (fs.existsSync(authPath)) {- const parsed = JSON.parse(fs.readFileSync(authPath, "utf-8"));- if (parsed?.token) return parsed.token;- }+ const { execSync } = require("child_process");+ const token = execSync("screenpipe auth token", {+ timeout: 5000,+ encoding: "utf-8",+ stdio: ["pipe", "pipe", "pipe"],+ }).trim();+ if (token) return token;} catch {}return "";