A small MCP (Model Context Protocol) server that lets AI tools search a local SQLite "work history", with a server-side rule that controls which sources the AI is allowed to see.
This is a practice build. It is inspired by the idea behind Screenpipe (a local memory layer for AI agents) and is not affiliated with it. The data here is fake, seeded by a script.
- An AI tool (Claude Desktop, Cursor, or the MCP Inspector) sends a tool call to the MCP server.
- The MCP server runs a parameterized query against a local SQLite database.
- Matching rows come back to the AI tool as results.
seed.pyfills the database with sample events. It runs separately from the server.
| Tool | What it does |
|---|---|
search_events(query_text, limit) |
Keyword search over event text, newest first. Capped at 25 rows. |
get_recent(minutes) |
Events from the last N minutes, newest first. Capped at 25 rows. |
Each event has a timestamp (ts, Unix seconds), a source (browser, terminal, editor) and some text.
The server only returns rows whose source is in ALLOWED_SOURCES (set near the top of server.py). The rule is applied inside the SQL WHERE clause, so the AI cannot ask its way around it.
ALLOWED_SOURCES = ("browser", "terminal")With that setting, events from the editor source are invisible to any caller. Other safety basics:
- All values go through SQL placeholders (
?), never string formatting, to prevent SQL injection. - Results are capped at 25 rows per call.
Requires Python 3 and Node.js (for the Inspector). In PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python seed.py
npx @modelcontextprotocol/inspector python server.pyRun these from the project folder. server.py opens events.db by relative path, so it needs to start in the same folder as the database. If the Inspector shows an error about a missing table, run python seed.py again.
To reset the sample data at any time, re-run python seed.py. It drops and recreates the table.
Use absolute paths, and fully restart the client afterward.
Claude Desktop: add this to %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"work-memory": {
"command": "C:\\full\\path\\to\\project\\.venv\\Scripts\\python.exe",
"args": ["C:\\full\\path\\to\\project\\server.py"]
}
}
}Claude Code:
claude mcp add work-memory -- C:\full\path\to\project\.venv\Scripts\python.exe C:\full\path\to\project\server.pyserver.py MCP server and tools
seed.py creates and fills events.db with sample data
requirements.txt dependencies
docs/ architecture diagram
events.db is generated by seed.py and is not committed.
- Per-agent policies instead of one global allow-list (deny by default for unknown agents)
- An audit log recording every call and every denial
- Rate limits to stop an agent from dumping the whole history by looping
- A short threat model describing what is protected and from whom
