Guides · For agents
Let an AI agent count a Postgres or MySQL table without write access
Put the connection string in an environment variable, turn databases on for Sift, and your agent can ask for counts and totals from a table. Sift opens the database read-only, runs at most one SELECT, and hands back numbers, not rows.
Turn it on
Live databases are off until you turn them on. Add two lines to Sift's entry in your MCP config: the switch, and a variable holding the connection string.
{
"mcpServers": {
"sift": {
"command": "npx",
"args": ["-y", "@heyife/siftdata@0.8.2"],
"env": {
"SIFT_ALLOW_DATABASES": "1",
"BILLING_DB": "postgres://readonly_user:password@host:5432/billing"
}
}
}
}
For MySQL, use a MySQL connection string and the type mysql. Use a database user that can only read.
Ask your agent
With Sift connected (setup takes three steps), paste this and swap in your own table and variable names.
Use Sift on the Postgres table public.subscriptions, connection env:BILLING_DB. Count the rows where status is active and plan is Pro, and total the mrr column.
What Sift sends back
These numbers come from a test copy of the table in a DuckDB database file. Database tables always run on Sift's DuckDB engine, and the same rows saved as a CSV give the same answer.
What Sift refuses
What to do next
- Give a table, or one SELECT query when you need a join or a filter in the database first.
- sift_profile and sift_match take the same source, so your agent can profile the table or match it, read-only.
- For a DuckDB file, use the type duckdb and its path instead. No switch is needed, as nothing goes over the network.
Questions
No. Sift opens the database read-only and refuses any query that is not a single SELECT. Use a read-only database user as well.
No. The connection string sits in an environment variable in your MCP config. The agent only names it, as env:BILLING_DB. A connection string typed into the call is refused.
A live database is the one thing Sift reaches over the network, so it stays off until you set SIFT_ALLOW_DATABASES. The first connection also downloads DuckDB's Postgres or MySQL extension.