How to Set Up a SQLite MCP Server With Windsurf

I was debugging a mobile sync issue and someone asked if any devices had gone quiet, as in, no sync in over 48 hours. We use Turso for our edge SQLite database. I had Windsurf open, the code right in front of me, and I figured I'd just ask Cascade instead of writing a throwaway script. It worked. That's the workflow this post sets up.
QueryBear supports SQLite through Turso and libSQL endpoints, so we'll use that. The title says SQLite and the body will explain what the connection actually looks like.
Part of the SQLite MCP Server guide.
What you'll need
- A SQLite database on Turso/libSQL (a
libsql://...turso.ioURL plus an auth token) - A QueryBear account (free tier works)
- Windsurf installed
Why route through a gateway
Giving an agent your raw Turso URL and token is the same as giving it full read-write access to your database. A gateway like QueryBear sits in between: it rejects DML and DDL at the parser level, enforces a table allowlist, blocks columns you've flagged as sensitive, and applies row limits and timeouts. Your credentials stay inside QueryBear. See the SQLite MCP Server guide for the full picture.
Connect QueryBear to your SQLite database
- Open the QueryBear dashboard and click "New connection."
- Select SQLite/Turso. Paste your libSQL URL (looks like
libsql://your-db.turso.io) and your Turso auth token. QueryBear connects over HTTP using the libSQL client. - Under "Allowed tables," select the tables Cascade should be able to see. For a sync-heavy app this might be
devices,sync_events,users,feature_flags. - Under "Blocked columns," add anything sensitive: auth tokens stored in the DB, private keys, PII you'd rather not surface. Save.
Install the QueryBear MCP server in Windsurf
In Windsurf, open Settings, then "MCP Servers," then "Add custom server." Paste:
{
"mcpServers": {
"querybear": {
"serverUrl": "https://mcp.querybear.com/mcp"
}
}
}Windsurf uses serverUrl, not url. That's different from Cursor's config format. Easy to miss if you're working from a generic MCP guide.
Save and let the connection reload. QueryBear should appear in Cascade's tool list in the side panel.
Ask your first question
In Cascade, ask:
"Find devices that haven't synced in over 48 hours."
Cascade calls get_schema, sees the devices table, and generates this:
SELECT device_id, device_name, user_id, last_sync_at
FROM devices
WHERE last_sync_at < datetime('now', '-48 hours')
OR last_sync_at IS NULL
ORDER BY last_sync_at ASC;The OR last_sync_at IS NULL covers devices that have never synced at all, which is often the case you care most about. Got back 8 devices in about half a second.
One SQLite thing worth knowing: SQLite uses dynamic typing. If last_sync_at was stored as a plain text string in a non-ISO format, the datetime() comparison might not behave the way you expect. If results look wrong, ask Cascade to show you a sample of raw values from that column first.
A Windsurf-specific tip
Cascade chains MCP calls automatically. A follow-up like "now show me the users who own those devices and when they last logged in" will trigger another get_schema lookup and a second run_query with a join, without you having to prompt it to check the schema. It keeps context between calls in the same session.
If results seem stale after you've modified your QueryBear configuration, Windsurf may be serving a cached schema. Hit cmd-shift-R to force a refresh before the next query.
Using a different tool?
- Claude Code
- Claude Cowork
- Cursor
- ChatGPT
- Codex
- Gemini