How to Set Up a SQLite MCP Server With Claude Code
Spencer Pauly
•4 min read
A customer emailed asking whether their data had actually synced or whether something was silently failing on their device. I knew we had a conflict table. I knew it had timestamps. I did not know the exact query off the top of my head, and I definitely didn't want to go write it from scratch while a customer was waiting for an answer. I wanted to ask in plain English, get the row count, and reply. This is the setup that made that possible.
We'll connect your SQLite database (via Turso or a libSQL endpoint) to Claude Code through QueryBear. About fifteen minutes.
Even with a read-only libSQL token, handing your endpoint directly to an AI agent means no per-table visibility control, no column masking, and no audit trail. QueryBear sits in between: SQL parser rejects anything that isn't a SELECT, you choose exactly which tables are visible, you block individual columns, and every query is logged. See the SQLite MCP Server guide for the full security picture.
Choose SQLite (Turso/libSQL). Paste your Turso URL, which looks like libsql://your-db-name.turso.io, and your auth token.
Under "Allowed tables," pick the tables you want Claude to see. In a sync-heavy app this might be sync_events, devices, conflicts, and a few others.
Under "Blocked columns," add anything sensitive: auth tokens, user secrets, anything you'd be unhappy seeing printed in a terminal.
Save. QueryBear connects over HTTP and confirms the schema is accessible.
Install the QueryBear MCP server in Claude Code
In your terminal:
claude mcp add --transport http querybear https://mcp.querybear.com/mcp
Claude Code walks you through OAuth. After that, three tools are available in every Claude Code session: list_connections, get_schema, and run_query. All three proxy through QueryBear; none of them talk directly to your Turso endpoint.
Ask your first question
Open a Claude Code session. Ask something in plain English:
I asked: "Which sync conflicts are still unresolved in the last 24 hours?"
Claude Code generated this query and ran it through QueryBear:
SELECT id, device_id, conflict_type, created_atFROM sync_conflictsWHERE resolved_at IS NULL AND created_at >= datetime('now', '-24 hours')ORDER BY created_at DESC;
Got back 7 rows. The whole round trip took under a second.
Claude calls get_schema first, then writes the query using SQLite's datetime('now', '-24 hours') syntax, then calls run_query. If the query hits a table not on the allowlist or a blocked column, QueryBear returns a readable rejection before anything reaches Turso.
A Claude Code-specific tip
Some questions come up on a schedule, like "any unresolved conflicts right now?" If you're checking that after every deploy or every customer complaint, save the query once. In QueryBear, after running a query you're happy with, click "Save as tool" and give it a name you'll actually remember, like unresolved-conflicts.
In Claude Code:
Use the unresolved-conflicts tool.
Claude calls it directly. Same query, same column order, every time. No drift in how it phrases the WHERE clause. For on-call situations especially, it's worth setting these up before you need them.