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

docs: add raw SQL aggregation tips to SKILL.md and MCP guide

Louis Beaumontdc0c05a20121
diff --git a/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md b/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md
index 44dd5bb1e..afc37d1e3 100644
--- a/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md
+++ b/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md
@@ -204,3 +204,18 @@ Do NOT use markdown links or multi-line code blocks for videos.
- If asked about meetings, use `content_type=audio`.
- If asked about a specific app, always use the `app_name` filter.
- Combine multiple searches to build a complete picture (e.g., screen + audio for a meeting).
+- **For aggregation over large datasets**, use raw SQL instead of paginating through search results. The `/search` endpoint returns paginated results (default limit 20), so summarizing thousands of events requires raw SQL. Examples:
+
+```bash
+# Count accessibility events by app (last 24h)
+curl -X POST http://localhost:3030/raw_sql -H "Content-Type: application/json" \
+ -d '{"query": "SELECT app_name, COUNT(*) as count FROM accessibility WHERE timestamp > datetime(\"now\", \"-24 hours\") GROUP BY app_name ORDER BY count DESC"}'
+
+# Count input events by type and app (last 24h)
+curl -X POST http://localhost:3030/raw_sql -H "Content-Type: application/json" \
+ -d '{"query": "SELECT app_name, event_type, COUNT(*) as count FROM ui_events WHERE timestamp > datetime(\"now\", \"-24 hours\") GROUP BY app_name, event_type ORDER BY count DESC"}'
+
+# App usage summary from OCR frames (last 24h)
+curl -X POST http://localhost:3030/raw_sql -H "Content-Type: application/json" \
+ -d '{"query": "SELECT app_name, COUNT(*) as frames FROM frames WHERE timestamp > datetime(\"now\", \"-24 hours\") GROUP BY app_name ORDER BY frames DESC"}'
+```
diff --git a/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.md b/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.md
index 44dd5bb1e..afc37d1e3 100644
--- a/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.md
+++ b/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.md
@@ -204,3 +204,18 @@ Do NOT use markdown links or multi-line code blocks for videos.
- If asked about meetings, use `content_type=audio`.
- If asked about a specific app, always use the `app_name` filter.
- Combine multiple searches to build a complete picture (e.g., screen + audio for a meeting).
+- **For aggregation over large datasets**, use raw SQL instead of paginating through search results. The `/search` endpoint returns paginated results (default limit 20), so summarizing thousands of events requires raw SQL. Examples:
+
+```bash
+# Count accessibility events by app (last 24h)
+curl -X POST http://localhost:3030/raw_sql -H "Content-Type: application/json" \
+ -d '{"query": "SELECT app_name, COUNT(*) as count FROM accessibility WHERE timestamp > datetime(\"now\", \"-24 hours\") GROUP BY app_name ORDER BY count DESC"}'
+
+# Count input events by type and app (last 24h)
+curl -X POST http://localhost:3030/raw_sql -H "Content-Type: application/json" \
+ -d '{"query": "SELECT app_name, event_type, COUNT(*) as count FROM ui_events WHERE timestamp > datetime(\"now\", \"-24 hours\") GROUP BY app_name, event_type ORDER BY count DESC"}'
+
+# App usage summary from OCR frames (last 24h)
+curl -X POST http://localhost:3030/raw_sql -H "Content-Type: application/json" \
+ -d '{"query": "SELECT app_name, COUNT(*) as frames FROM frames WHERE timestamp > datetime(\"now\", \"-24 hours\") GROUP BY app_name ORDER BY frames DESC"}'
+```
diff --git a/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts b/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts
index ee3153071..ba2a4a031 100644
--- a/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts
+++ b/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts
@@ -281,6 +281,7 @@ Screenpipe captures four types of data:
1. Read screenpipe://context first to get current timestamps
2. Use content_type=input for "what did I type?" queries
3. Use content_type=accessibility for accessibility tree text
+4. For large aggregations (e.g. "what apps did I use today?"), paginate with offset or suggest the user run raw SQL via \`curl -X POST http://localhost:3030/raw_sql\` for efficient GROUP BY queries
## Timeline Deep Links
When showing search results to users, create clickable links to specific moments:
diff --git a/docs/mintlify/docs-mintlify-mig-tmp/pipes.mdx b/docs/mintlify/docs-mintlify-mig-tmp/pipes.mdx
index b05d217a0..8c9a062d0 100644
--- a/docs/mintlify/docs-mintlify-mig-tmp/pipes.mdx
+++ b/docs/mintlify/docs-mintlify-mig-tmp/pipes.mdx
@@ -53,7 +53,7 @@ curl "http://localhost:3030/search?limit=20&content_type=all&start_time=<ISO8601
### query parameters
- q: text search query (optional)
-- content_type: "vision" | "audio" | "input" | "accessibility" | "all" | "vision+audio+input" | "vision+input" | "audio+input"
+- content_type: "all" | "ocr" | "audio" | "input" | "accessibility"
- limit: max results (default 20)
- offset: pagination offset
- start_time / end_time: ISO 8601 timestamps
@@ -89,7 +89,7 @@ each result contains:
- timestamp: when it was captured
### input results (user actions)
-query via: curl "http://localhost:3030/ui-events?app_name=Slack&limit=50&start_time=<ISO8601>&end_time=<ISO8601>"
+query via: curl "http://localhost:3030/search?content_type=input&app_name=Slack&limit=50&start_time=<ISO8601>&end_time=<ISO8601>"
event types: text (keyboard input), click, app_switch, window_focus, clipboard, scroll
## secrets