Skip to content

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

fix: add API auth to MCP server

Louis Beaumont792caded4bc9
diff --git a/crates/screenpipe-connect/screenpipe-mcp/src/index.ts b/crates/screenpipe-connect/screenpipe-mcp/src/index.ts
index 9c9357cc2..ea9006caa 100644
--- a/crates/screenpipe-connect/screenpipe-mcp/src/index.ts
+++ b/crates/screenpipe-connect/screenpipe-mcp/src/index.ts
@@ -27,6 +27,7 @@ for (let i = 0; i < args.length; i++) {
}
const SCREENPIPE_API = `http://localhost:${port}`;
+const API_KEY = process.env.SCREENPIPE_LOCAL_API_KEY || process.env.SCREENPIPE_API_KEY || "";
// Read version from package.json (single source of truth)
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -531,6 +532,7 @@ async function fetchAPI(
...options,
headers: {
"Content-Type": "application/json",
+ ...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}),
...options.headers,
},
});