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

evals: verify MCP auth never opens the recording database

louisb7758c9c225e
diff --git a/evals/coding-agent/README.md b/evals/coding-agent/README.md
index dbd09d47c..3040d00b7 100644
--- a/evals/coding-agent/README.md
+++ b/evals/coding-agent/README.md
@@ -9,7 +9,7 @@ This is an agent eval suite, not a unit-test suite. Every case contains:
- saved prompt, transcript, candidate patch, grader output, runtime fingerprint, and result;
- repeated-trial reporting with success rate, `pass@k`, and `pass^k`.
-The current app corpus contains 56 git-mined regressions. See
+The current app corpus contains 57 git-mined regressions. See
[DESIGN.md](./DESIGN.md) for the Anthropic guidance, source contract, and
history-mining workflow. The companion website manifest uses this same harness.
@@ -439,3 +439,24 @@ event ports; title generation is stubbed to prevent model/native execution.
This proves the selected delayed-read ordering, not native persistence, failures
or races within the settings writer, the complete rendered chat UI, real model
selection or enforced agent isolation. No model trial is implied.
+
+## MCP live database boundary
+
+`mcp-live-database-boundary` builds the real historical MCP entrypoint and drives
+its stdio tools through the SDK against a loopback API. A child-process preload
+models CLI failures/results and records selected filesystem/subprocess effects.
+Missing credentials and invalid CLI output must never reach the database; five
+preserved paths cover environment precedence, the legacy key and three CLI
+discovery routes. Repeated calls verify request credentials and visible results.
+
+Run `bun test evals/coding-agent/calibrate-mcp-db-boundary.test.js` with MCP
+dependencies installed. Controls reject the historical fallback, an unused fix,
+SQLite access without an existence probe, swallowed direct reads, lost CLI
+recovery and blanket denial; equivalent helper naming passes. Missing entrypoint
+is retained as a build error rather than intended regression evidence.
+
+Only the entrypoint is the historical oracle. This does not grade instruction
+wording or prove model compliance, native database locking, OS-wide filesystem
+isolation, real CLI/keychain discovery, package publication or other platforms.
+The observed IO ports are synthetic, not a universal access sandbox. Product
+startup tests with supplied credentials do not exercise the missing-key fallback.
diff --git a/evals/coding-agent/calibrate-mcp-db-boundary.test.js b/evals/coding-agent/calibrate-mcp-db-boundary.test.js
new file mode 100644
index 000000000..a479f41bd
--- /dev/null
+++ b/evals/coding-agent/calibrate-mcp-db-boundary.test.js
@@ -0,0 +1,32 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import {afterAll,expect,test} from 'bun:test';
+import {execFileSync,spawnSync} from 'node:child_process';
+import {cpSync,mkdirSync,mkdtempSync,readFileSync,rmSync,symlinkSync,writeFileSync} from 'node:fs';
+import {join,resolve} from 'node:path';
+import {tmpdir} from 'node:os';
+const repo=resolve(import.meta.dir,'../..'),pkg='packages/screenpipe-mcp',index=pkg+'/src/index.ts';
+const item=JSON.parse(readFileSync(join(import.meta.dir,'cases.json'),'utf8')).cases.find(c=>c.id==='mcp-live-database-boundary');
+const show=ref=>execFileSync('git',['show',`${ref}:${index}`],{cwd:repo,encoding:'utf8'}),fixed=show(item.oracle_ref),broken=show(item.base_ref);
+const root=mkdtempSync(join(tmpdir(),'mcp-db-calibration-')),template=join(root,'template');mkdirSync(template);
+execFileSync('tar',['-xf','-','-C',template],{input:execFileSync('git',['archive',item.base_ref,pkg],{cwd:repo,maxBuffer:64*1024*1024})});
+afterAll(()=>rmSync(root,{recursive:true,force:true}));
+function grade(name,source,extra){
+ const cwd=join(root,name);cpSync(template,cwd,{recursive:true});
+ if(source===null)rmSync(join(cwd,index));else writeFileSync(join(cwd,index),source);
+ if(extra)writeFileSync(join(cwd,index+'.unused.ts'),extra);
+ for(const f of item.grader.fixtures)writeFileSync(join(cwd,f.destination_path),readFileSync(join(import.meta.dir,f.local_path)));
+ symlinkSync(join(repo,pkg,'node_modules'),join(cwd,pkg,'node_modules'),'dir');
+ return spawnSync(process.execPath,['run','test','--','src/eval-db-boundary.test.ts'],{cwd:join(cwd,pkg),encoding:'utf8',timeout:45000,env:{PATH:process.env.PATH,HOME:cwd,BUN_BIN:process.execPath,CI:'true',NO_COLOR:'1',SCREENPIPE_DISABLE_TELEMETRY:'1'}});
+}
+function fails(r){expect(r.error).toBeUndefined();expect(r.signal).toBeNull();expect(r.status).toBe(1);expect(r.stderr).toContain('AssertionError');expect(r.stderr).not.toContain('Could not resolve');}
+function replace(s,a,b){expect(s.split(a)).toHaveLength(2);return s.replace(a,b);}
+test('parent reaches the forbidden database boundary and preserves five auth paths',()=>{const r=grade('parent',broken);fails(r);expect(r.stdout).toContain('2 failed | 5 passed');expect(r.stderr).toContain('sqlite3');});
+test('reference preserves all seven running-process outcomes',()=>{const r=grade('reference',fixed);expect(r.status).toBe(0);expect(r.stdout).toContain('7 passed');});
+test('equivalent auth helper naming passes',()=>expect(grade('renamed',fixed.replaceAll('discoverApiKey','resolveLocalKey').replaceAll('ensureApiKey','getLocalKey')).status).toBe(0));
+test('unused correct source cannot rescue the broken running entrypoint',()=>fails(grade('unused',broken,fixed)));
+test('removing the existence probe cannot conceal a direct SQLite command',()=>{const r=grade('no-probe',replace(broken,'if (fs.existsSync(dbPath)) {','if (true) {'));fails(r);expect(r.stderr).toContain('sqlite3');});
+test('direct database file reads are rejected even when their exception is swallowed',()=>fails(grade('read',replace(fixed,'const home = os.homedir();','const home = os.homedir(); try { fs.readFileSync(path.join(home, ".screenpipe", "db.sqlite")); } catch {}'))));
+test('removing supported CLI recovery is rejected',()=>fails(grade('no-cli',replace(fixed,'const home = os.homedir();','return ""; const home = os.homedir();'))));
+test('blanket keyless requests fail preserved access',()=>fails(grade('deny',replace(fixed,'function ensureApiKey(): Promise<string> {','function ensureApiKey(): Promise<string> { return Promise.resolve("");'))));
+test('missing entrypoint is a build failure, not an intended behavioral contrast',()=>{const r=grade('missing',null);expect(r.status).toBe(1);expect(r.stderr).toMatch(/Could not resolve|ModuleNotFound|not found/);expect(r.stderr).not.toContain('AssertionError');});
diff --git a/evals/coding-agent/cases.json b/evals/coding-agent/cases.json
index cdcedf395..2b6c5b657 100644
--- a/evals/coding-agent/cases.json
+++ b/evals/coding-agent/cases.json
@@ -1,7 +1,7 @@
{
"schema_version": 1,
"suite": "screenpipe-app-coding-agent-regressions",
- "dataset_version": "2026-09-20.7",
+ "dataset_version": "2026-09-20.8",
"suite_type": "regression",
"owner": "screenpipe engineering",
"policy": {
@@ -1842,6 +1842,49 @@
],
"command": "cd apps/screenpipe-app-tauri && \"${BUN_BIN:-bun}\" test ../../evals/coding-agent/graders/local-preset-preservation.test.js"
}
+ },
+ {
+ "id": "mcp-live-database-boundary",
+ "name": "Keep MCP authentication outside the live recording database",
+ "source": {
+ "kind": "git_regression",
+ "fix_commit": "a43b9757f3133a842bbe0d7764fff97e31f199c9"
+ },
+ "base_ref": "c92d8e5fd67b724846f2b9db5cf32a17fe58f4a5",
+ "oracle_ref": "a43b9757f3133a842bbe0d7764fff97e31f199c9",
+ "oracle_paths": [
+ "packages/screenpipe-mcp/src/index.ts"
+ ],
+ "tags": [
+ "regression",
+ "escaped-failure",
+ "mcp",
+ "recording",
+ "data-integrity",
+ "authentication"
+ ],
+ "prompt": "The MCP authentication discovery fallback can bypass Screenpipe and read the live recording database when environment credentials and CLI discovery fail. Keep database ownership inside Screenpipe: the MCP process must not probe, open, copy or mutate db.sqlite or its WAL/shared-memory companions, or spawn an external SQLite client to recover credentials. With missing credentials or invalid CLI output, keep MCP initialization and tool listing available, surface the backend authentication failure clearly, and never invent a key or report recording results as success. Preserve local environment-key precedence over the legacy environment key, support the legacy key, and preserve successful discovery through the bundled CLI, node-adjacent npx and PATH-based npx. Repeated search calls should reuse discovery and send the resolved credential to the configured Screenpipe API. Verify observable tool responses, authenticated requests and forbidden filesystem/subprocess effects using synthetic inputs; do not access real recordings or credentials.",
+ "agent_timeout_seconds": 1200,
+ "grader_dependency_links": [
+ {
+ "source_path": "packages/screenpipe-mcp/node_modules",
+ "destination_path": "packages/screenpipe-mcp/node_modules"
+ }
+ ],
+ "grader": {
+ "timeout_seconds": 180,
+ "fixtures": [
+ {
+ "local_path": "graders/mcp-db-boundary.fixture.ts",
+ "destination_path": "packages/screenpipe-mcp/src/eval-db-boundary.test.ts"
+ },
+ {
+ "local_path": "graders/mcp-db-boundary.preload.cjs",
+ "destination_path": "packages/screenpipe-mcp/src/eval-db-boundary.preload.cjs"
+ }
+ ],
+ "command": "cd packages/screenpipe-mcp && SCREENPIPE_DISABLE_TELEMETRY=1 \"${BUN_BIN:-bun}\" run test -- src/eval-db-boundary.test.ts"
+ }
}
]
}
diff --git a/evals/coding-agent/graders/mcp-db-boundary.fixture.ts b/evals/coding-agent/graders/mcp-db-boundary.fixture.ts
new file mode 100644
index 000000000..552eb52ec
--- /dev/null
+++ b/evals/coding-agent/graders/mcp-db-boundary.fixture.ts
@@ -0,0 +1,50 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import { beforeAll, expect, it } from 'vitest';
+import { Client } from '@modelcontextprotocol/sdk/client/index.js';
+import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
+import { execFileSync } from 'node:child_process';
+import { mkdtempSync, mkdirSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { resolve, join } from 'node:path';
+import { createServer } from 'node:http';
+const pkg=resolve(__dirname,'..');
+beforeAll(()=>execFileSync(process.env.BUN_BIN || 'bun',['run','build'],{cwd:pkg,timeout:120000}),130000);
+async function scenario(mode:string, env:Record<string,string>={}, expectedKey='') {
+ const home=mkdtempSync(join(tmpdir(),'mcp-db-boundary-'));mkdirSync(join(home,'.screenpipe'));
+ const requests:{url:string;auth:string|undefined}[]=[];let trace='';
+ const server=createServer((req,res)=>{requests.push({url:req.url||'',auth:req.headers.authorization});res.setHeader('content-type','application/json');
+ if (!expectedKey || req.headers.authorization!==`Bearer ${expectedKey}`) {res.statusCode=403;res.end(JSON.stringify({error:'authentication required'}));}
+ else res.end(JSON.stringify({data:[{type:'OCR',content:{text:'synthetic-recording-witness',timestamp:'2026-08-28T12:00:00Z',app_name:'Fixture',window_name:'Synthetic'}}],pagination:{total:1,offset:0}}));
+ });
+ await new Promise<void>(resolve=>server.listen(0,'127.0.0.1',resolve));const address=server.address();if(!address || typeof address==='string') throw new Error('fixture bind failed');
+ const client=new Client({name:'database-boundary-grader',version:'1.0.0'});
+ const transport=new StdioClientTransport({command:process.execPath,args:['--require',join(pkg,'src/eval-db-boundary.preload.cjs'),join(pkg,'dist/index.js')],env:{HOME:home,USERPROFILE:home,PATH:'',SCREENPIPE_DISABLE_TELEMETRY:'1',SCREENPIPE_API_URL:`http://127.0.0.1:${address.port}`,SCREENPIPE_BUN_PATH:join(home,'synthetic-bun'),EVAL_AUTH_MODE:mode,...env},stderr:'pipe'});
+ transport.stderr?.on('data',(chunk)=>{trace+=chunk.toString();});
+ try {
+ await client.connect(transport);
+ const tools=(await client.listTools()).tools;expect(tools.some(t=>t.name==='search-content')).toBe(true);
+ const results=[];
+ for(let i=0;i<2;i++) results.push(await client.callTool({name:'search-content',arguments:{q:'witness',start_time:'2026-08-28T00:00:00Z',limit:1}}));
+ await client.close();
+ const ports=trace.split('\n').filter(l=>l.startsWith('EVAL_PORT ')).map(l=>JSON.parse(l.slice(10)));
+ expect(ports.filter(p=>p.kind==='unexpected-command')).toEqual([]);
+ expect(ports.filter(p=>p.kind==='database-io' || p.kind==='database-probe' || (p.kind==='command' && /sqlite3/i.test(p.value)))).toEqual([]);
+ const searches=requests.filter(r=>r.url.startsWith('/search?'));expect(searches).toHaveLength(2);
+ if(expectedKey){
+ expect(searches.map(r=>r.auth)).toEqual([`Bearer ${expectedKey}`,`Bearer ${expectedKey}`]);
+ for(const result of results){expect(result.isError).not.toBe(true);expect(JSON.stringify(result.content)).toContain('synthetic-recording-witness');}
+ }else{
+ expect(requests.every(r=>!r.auth || r.auth==='Bearer ')).toBe(true);
+ for(const result of results) expect(result.isError).toBe(true);
+ expect(trace).toContain('SCREENPIPE_LOCAL_API_KEY');
+ }
+ expect(trace).not.toContain('sp-synthetic-database-key');
+ return ports;
+ } finally {await client.close();await new Promise<void>(resolve=>{server.close(()=>resolve());server.closeAllConnections();});rmSync(home,{recursive:true,force:true});}
+}
+it('missing credentials and failed CLI never fall back to the recording database',()=>scenario('missing'),15000);
+it('invalid CLI output never enables database fallback or authenticated success',()=>scenario('invalid-cli'),15000);
+it('explicit local credentials win over the legacy environment key',async()=>{const p=await scenario('missing',{SCREENPIPE_LOCAL_API_KEY:'sp-synthetic-local',SCREENPIPE_API_KEY:'sp-synthetic-legacy'},'sp-synthetic-local');expect(p.filter(p=>p.kind==='command')).toEqual([]);},15000);
+it('legacy environment credentials remain supported',async()=>{const p=await scenario('missing',{SCREENPIPE_API_KEY:'sp-synthetic-legacy'},'sp-synthetic-legacy');expect(p.filter(p=>p.kind==='command')).toEqual([]);},15000);
+for(const mode of ['bundled','adjacent','path']) it(`${mode} CLI credentials preserve authenticated search and one discovery across calls`,async()=>{const p=await scenario(mode,{},'sp-synthetic-cli-key');expect(p.filter(p=>p.kind==='command')).toHaveLength(1);},15000);
diff --git a/evals/coding-agent/graders/mcp-db-boundary.preload.cjs b/evals/coding-agent/graders/mcp-db-boundary.preload.cjs
new file mode 100644
index 000000000..78c6f576c
--- /dev/null
+++ b/evals/coding-agent/graders/mcp-db-boundary.preload.cjs
@@ -0,0 +1,37 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+// Synthetic ports for the child process only. Never run a real CLI or SQLite.
+const fs = require('node:fs');
+const cp = require('node:child_process');
+const path = require('node:path');
+const { promisify } = require('node:util');
+const mode = process.env.EVAL_AUTH_MODE;
+const report = (kind, value) => process.stderr.write('EVAL_PORT '+JSON.stringify({kind,value})+'\n');
+const isDatabase = value => /(?:^|[\\/])db\.sqlite(?:-wal|-shm)?$/.test(String(value));
+const exists = fs.existsSync;
+fs.existsSync = function(value) {
+ if (isDatabase(value)) { report('database-probe',String(value)); return true; }
+ if (String(value)===process.env.SCREENPIPE_BUN_PATH) return mode==='bundled' || mode==='invalid-cli';
+ if (/[/\\](?:bun(?:\.exe)?|npx(?:\.cmd)?)$/.test(String(value))) return mode==='adjacent' && path.basename(String(value)).startsWith('npx');
+ return exists.call(this,value);
+};
+for (const name of ['readFileSync','openSync','copyFileSync','unlinkSync','writeFileSync','createReadStream']) {
+ const original=fs[name];
+ fs[name]=function(...args) { if (isDatabase(args[0]) || (name==='copyFileSync' && isDatabase(args[1]))) {report('database-io',{name,path:String(args[0])});throw new Error('Synthetic database port is forbidden');} return original.apply(this,args); };
+}
+async function command(file,args=[]) {
+ const text=[file,...args].join(' ');report('command',text);
+ if (/sqlite3/i.test(String(file))) return {stdout:'0000|'+Buffer.from('sp-synthetic-database-key').toString('base64'),stderr:''};
+ if (mode==='bundled' && file===process.env.SCREENPIPE_BUN_PATH) return {stdout:'sp-synthetic-cli-key\n',stderr:''};
+ if (mode==='adjacent' && Array.isArray(args) && path.basename(String(file)).startsWith('npx')) return {stdout:'sp-synthetic-cli-key\n',stderr:''};
+ if (mode==='path' && String(file)==='npx screenpipe@latest auth token') return {stdout:'sp-synthetic-cli-key\n',stderr:''};
+ if (mode==='invalid-cli') return {stdout:'not-a-screenpipe-key\n',stderr:''};
+ throw new Error('Synthetic CLI unavailable');
+}
+for (const name of ['exec','execFile']) {
+ const replacement=function(file,...args) { const callback=args.at(-1);command(file,Array.isArray(args[0])?args[0]:[]).then(r=>callback(null,r.stdout,r.stderr),e=>callback(e)); };
+ replacement[promisify.custom]=(file,args)=>command(file,Array.isArray(args)?args:[]);
+ cp[name]=replacement;
+}
+for (const name of ['execSync','execFileSync','spawn','spawnSync','fork']) cp[name]=function(...args) {report('unexpected-command',{name,args});throw new Error('Unmodeled subprocess is forbidden');};
+require('node:module').syncBuiltinESMExports();