MCP for AI apps
Updated
SayQL includes an MCP server, so AI assistants like Claude and Cursor can query your databases through the connections you saved in SayQL.
On Linux, use the .deb or .rpm for MCP. The AppImage opens from a new folder each time, so the path you give your AI app would stop working.
The assistant can list connections, list databases, describe the schema, and run a read-only query. The same read-only rules apply. Database passwords are never shared with the assistant. What it gets back from a query is up to you, per connection (below): by default counts and summaries, not your rows.
It can also list your saved scripts (with their SQL on connections where you allow all rows, with string literals masked on counts and masked rows, and by name only where it may see nothing), and, on connections where you allow all rows, export a read-only query to a CSV in your Downloads folder (up to 100,000 rows). Exported rows aren't sent to the assistant, only the file path, but it could open the file, so export follows the same setting.
Three more tools hand work to you in SayQL instead of doing it:
- Add connection opens SayQL's New connection dialog with the details filled in. You type the password in SayQL, test and save.
- Open query opens SQL in a new SayQL tab, unrun. You review it and click Run; SayQL asks before anything that changes data, and the results stay in SayQL.
- Open script opens one of your saved scripts, unrun.
The schema the assistant gets includes the database notes you saved, so it knows what codes mean and how tables relate.
Several companies? An AI app sees one workspace, or one group in it: add --workspace and --group to its setup. Without them it sees Personal only.
Never-send columns
Columns you marked never send in a connection's agent settings stay private over MCP too, and describe_schema marks them [never sent to AI]. Write an entry as table.column for one table, or column for that column in every table. A query that could read one in any form is refused before it runs: naming it (also in WHERE, ORDER BY or COUNT), a whole row as one value (row_to_json(c), c::text), * inside a subquery or CTE, a column alias list, a set operation that could rename it, a sort by its position (ORDER BY 3, ORDER BY +3), or MySQL's PROCEDURE ANALYSE(). When SayQL can't tell, it refuses and asks the assistant to name the columns it needs. A plain SELECT * runs, with those columns withheld. Their comments, enum values and CHECK constraints are left out of the schema the AI sees.
On PostgreSQL, SayQL also asks the database for the query's plan first (EXPLAIN, which doesn't run it), so it follows views and renamed columns to the table they come from. On MySQL, SQL Server and SQLite it reads the SQL, so a view that renames a never-send column isn't followed: add the view's column to the list too. Functions defined in your database that read such a column aren't followed on any database.
Whatever the setting, AI apps can't call functions that read the server's files or reach outside the database (pg_read_file, pg_ls_dir, large objects, dblink, the http extension (http_get, http_post…), Amazon RDS's aws_s3 and aws_lambda, load_file, OPENROWSET, and the like), even when the saved login could. A login with only the rights it needs is still the best protection.
Table usage
After each table, describe_schema says how much it is used, from the database's own statistics, so the assistant can tell a live table from an abandoned one, for example usage: 12.3k reads, 0 writes, last write 2026-03-12. One line above the tables gives the period the figures cover ("since 2026-01-01", or "since the server started on …"): the counters reset when the server restarts or fails over, and differ on each replica. They are counts and dates, never row values.
- PostgreSQL: reads (sequential and index scans), written rows and live rows from
pg_stat_user_tables, and when the table was last analyzed; the period starts when the database's statistics were reset, else when the server started. - SQL Server: seeks, scans and lookups as reads, updates as writes, and the last read and write, from the index usage statistics since the server started. A table with no entry wasn't used in that time.
- MySQL and MariaDB: read and write counts from
performance_schemawhen it's on and readable, and the last write time MySQL keeps. - SQLite keeps no such statistics, so nothing is shown.
It's one extra query per describe_schema, stopped after 5 seconds. If the database user can't read the statistics (or they're turned off), one line says usage statistics are unavailable.
Notes suggested by AI apps
When an assistant learns a lasting fact about a database (a table that's no longer used and what replaced it, what a status code means, how two tables relate), it can call suggest_note with the note (up to 300 characters) and its evidence (up to 600), such as "no references in api/ since commit a1b2c3; usage: 0 writes since 2026-01-01". Notes describe the database, never the data in it. Status codes and enum names (1=Pending, status IN (2,3)), SQL, file paths (migrations/2026_03_01_merge_orders.sql), dates, units and short commit hashes are fine; a note or evidence that looks like a value from your rows is refused: an email, a phone, card, ID or account number, a UUID or other long id, a number of six or more digits or with thousands separators, a money amount, or what looks like a person's name. The same check applies to notes you write and notes Investigate suggests.
A suggestion isn't a note until you accept it. A database's suggestions show under Notes → Suggested notes and fixes in the navigator, with a count; all of them are in Settings → AI apps → Suggestions, whose tab shows how many are waiting. The count is also on AI apps in the Settings sidebar and on the settings (gear) button, which opens straight to Suggestions while any are waiting. Each shows the app, the note and the evidence, with Accept (it's saved like a note you wrote, so the Ask box, Investigate and every AI app see it from then on) and Dismiss. Up to 50 suggestions wait per connection, a note already saved or suggested is refused, and each suggestion is in the agent activity log.
An assistant can also correct a note you saved. describe_schema lists the saved notes with a short id each, such as [n_1a2b3c4d]. A suggestion with replaces set to that id proposes new text for the note: it shows as Replaces: with the old text struck through, and Replace note changes the note's text. With remove: true as well, it proposes deleting the note, with why as its text: it shows as Remove note: and Remove note deletes it. Dismiss leaves the note as it is. Only notes of the same database can be named.
A suggestion can also carry a check: read-only SQL returning one row and one column, true while the note holds. Once accepted, SayQL runs it to keep the note honest (see How notes stay true). describe_schema marks each note with how sure SayQL is of it: checked, or may be out of date with the reason, such as a column it names that was dropped or renamed. Assistants are told the schema wins when a note disagrees with it. SayQL suggests fixes of its own too, signed SayQL, when a schema change breaks a note.
Audit: teach SayQL your database
Your code knows things your schema doesn't: which tables are retired, what a status code means, which columns join without a foreign key. The audit lets a coding agent that works in your project, such as Claude Code or Cursor, read the database through SayQL, check it against your code, and suggest notes for you to approve.
- Connect your coding agent (see Connect your coding agent).
- Run the audit in your project. How depends on the agent (see the table there). In Claude Code, type
/mcp__sayql__audit, followed by the connection's name (or id) when you have more than one, and optionally a database on the server:/mcp__sayql__audit Shop. Without a connection, the agent callslist_connections, picks the one your code uses, and asks you if it isn't clear. Apps that don't support MCP prompts can use Copy prompt on a connection in Settings → AI apps → Access (or Copy audit prompt in the navigator's Teach SayQL this database) and paste the instructions into the chat. - Approve what's right under Notes → Suggested notes and fixes or Settings → AI apps → Suggestions. Nothing changes until you accept a suggestion.
The instructions ask the agent to call describe_schema (with the usage figures and the notes already saved), search your code for where each table and column is used, and look for tables with no references and no writes in the usage period, the meaning of status codes and flags as your code defines them, relationships that aren't declared as foreign keys, and units and time zones. It reviews the saved notes against the code and suggests replacing or removing ones that look wrong or out of date. Each suggestion comes with its evidence (files, cited as source:path@commit when SayQL runs it, and usage figures), describes the schema and never your rows, may carry a check (a read-only query returning one row with one column, ok, true while the note holds), and the agent keeps to the 10 to 20 most useful notes, then summarizes what it suggested. The audit needs no rows; if the agent runs a query anyway, it gets only what you allow on that connection.
Run it again now and then, and after big changes: code moves on and notes go stale. The Last audit column in Settings → AI apps → Access shows when an app last fetched the audit prompt for each connection ("Never", "3 days ago"), and says Run an audit when it's never been run or not in the last 30 days. A copied prompt isn't counted, since SayQL can't tell when it's used. Fetching the prompt goes through the same blocking and approval as the tools, and is in the activity log.
Run an audit from SayQL
SayQL can start the audit for you: Run audit runs your installed Claude Code, read-only, over the database's code. Without Claude Code it runs SayQL's built-in OpenCode with your AI provider instead. The button is in Teach SayQL this database, on each connection in Settings → AI apps → Access next to Copy prompt, and on the Suggestions tab while none are waiting. Add the connection's knowledge sources (SayQL remembers them per connection) and press Start audit in the Run an audit dialog: SayQL fetches the repositories, reads the files and web pages again, runs Claude Code over the sources with the audit instructions for that connection, and shows what it does as it goes (Fetching backend…, Reading the schema, Searching for “legacy_orders” in backend:src, and Suggested a note: … once SayQL has taken the suggestion, or why it refused one). Cancel stops it and everything it started; a run stops by itself after 15 minutes. At the end you see how many notes it suggested, its summary (formatted as it wrote it) and Review suggestions. Open in Terminal starts the same run in your terminal instead, to watch it or answer it there.
It runs read-only, and SayQL enforces that with Claude Code's own options rather than asking nicely: --restricted and --tools Read,Grep,Glob leave only reading, searching and listing files (no shell commands, no file edits, no web), and only in the knowledge sources (the first is its working folder, the others are given with --add-dir), --strict-mcp-config gives the run SayQL's MCP server and no other, with only the tools the audit needs (list_connections, list_databases, describe_schema, suggest_note, run_query; every other SayQL tool is denied by name), --permission-mode dontAsk refuses anything else instead of asking, and the project's own hooks, settings and .mcp.json are left out. Your Claude Code setup isn't changed: SayQL's server is given to that one run. Its database access goes through SayQL like any AI app's, so it gets back only what you allow on that connection, blocked and approved apps apply, and its calls are in the activity log. A finished run counts as the connection's Last audit.
Knowledge sources
The audit reads every knowledge source of a connection: folders on your computer, git repositories on GitHub, GitLab, Bitbucket or any git server, files, and web pages. Add them under Knowledge sources in the Run an audit dialog or in the connection's Overview…: Add folder…, Add files…, Add web page…, or Add repository… with its https:// or SSH address (as its Clone button shows it), a branch (its default branch if you leave it empty) and a folder in it if only part of the repository matters. Each source has a short name, its folder or repository name, that the audit cites files by (backend:src/billing/refund.py@1a2b3c4). The list shows each source's kind, when it was last fetched or read and at which commit or version, or why it couldn't be; Refresh (↻) checks a folder or repository again, reads files and web pages again, and Remove forgets it. The folder you chose before this version becomes the connection's first source.
Files are documents and exports about the database: .md, .txt, .csv, .tsv, .json, .yaml, .sql, .html, .pdf and Word .docx, up to 50 in a source and 20 MB each. A scanned PDF is only images and has no text to read. SayQL reads each PDF in a separate process that it stops after 30 seconds, so a damaged PDF only gets a message saying SayQL can't read it. Web pages are public pages, such as docs or a data dictionary: one page, or with Also read the pages in its folder the pages it links to under the same address on the same site (https://docs.acme.com/data/…), up to 50 pages and 5 MB in all. SayQL reads them from your computer without cookies or sign-in, follows robots.txt when it reads more than one page, and refuses addresses on your computer or a private network. SayQL keeps their text in its own folder (repos, readable by you only) and reads them again each time the audit runs; if that fails, the audit reads the text from before and says so. The audit cites them as docs:billing/refunds.txt@ab12cd3, the version being a hash of their text. Documents can be out of date, so the audit is told to base notes on the code and the database, and to show you where a document disagrees with them instead of picking one.
Your sources stay on this computer. They go only to the AI you chose, when you run an audit, and never to SayQL's servers. The free app keeps up to 3 sources per connection. SayQL for teams keeps unlimited sources in sync for everyone.
SayQL fetches each repository with your own git every time the audit runs, so the notes reflect the latest code: your SSH keys and git's credential helper work as they do in a terminal. If git can't read a private repository that way, add a read-only token (a GitHub fine-grained token with read access to its contents, a GitLab project token with read_repository, a Bitbucket repository access token): SayQL keeps it in your keychain and gives it to git in its environment, never on the command line or in a file. For a server other than GitHub, GitLab or Bitbucket, enter the user name it expects with a token. Adding a repository checks that git can read it first (git ls-remote). The copy is kept in SayQL's own folder (repos, readable by you only) with the last 50 commits, and goes when you remove the source or the connection. Git runs without prompts, hooks or other programs from the repository, only over https and ssh, and checks symbolic links out as plain files, so a link can't lead the audit out of the copy. If a fetch fails, the audit reads the copy fetched before and says so. Code never goes to SayQL's servers. It needs git (on a Mac, xcode-select --install).
It uses your own Claude Code: its sign-in and subscription (or API key, or whatever else it's set up with), and its usage. SayQL never reads your Claude credentials. Model in the dialog picks what it runs on: Sonnet (the default, cheaper and enough to read code and suggest notes), Opus, or My Claude Code default (whatever claude uses when you start it). SayQL passes Claude Code's --model sonnet or --model opus, which follow the latest model of each, and remembers your choice; Open in Terminal uses it too. Either way the run counts against your Claude plan. SayQL starts it on your computer and reads what it prints; no code goes anywhere SayQL controls. It needs Claude Code 2.1.259 or later (claude update); SayQL finds it on your PATH and in the usual install folders (~/.local/bin, Homebrew, npm, nvm, Bun, Volta). If it isn't signed in, SayQL says so: run claude once in a terminal and sign in.
Paid by you, not SayQL. With Claude Code, the audit always runs on your own Claude Code sign-in (or however your Claude Code is set up): SayQL passes it no API key, token or endpoint, and never reads your Claude credentials. Paying for the audit with SayQL AI credits is off for now. SayQL AI credits still work for SayQL's own Ask box and Investigate (Settings → AI provider).
Other agents aren't offered yet because SayQL can't keep them read-only from the command line: the Codex CLI reads code by running shell commands (its read-only sandbox blocks writes, not commands), and Gemini CLI and Cursor CLI take their tool permissions from the project's own settings files too. Connect them as usual and use Copy audit prompt.
Without Claude Code: SayQL's built-in OpenCode
If Claude Code isn't installed (or is too old), Run audit uses SayQL's built-in OpenCode, an open-source coding agent, with the AI you chose in Settings → AI provider: SayQL AI credits, an Anthropic, OpenAI, Gemini, OpenRouter, Mistral, Groq or DeepSeek key, or a local model (Ollama, LM Studio, any OpenAI-compatible server). It uses that provider's agent model (else its expert or typing model); SayQL AI credits cover their own Claude models only, so another name there runs on Claude Sonnet 5.5. When both are there, Audit with in the dialog picks one. Your Claude plan works only through Claude Code.
What's downloaded. The first audit with it downloads OpenCode 1.19.5 (from github.com/anomalyco/opencode releases) and the ripgrep 15.1.0 it searches with (from github.com/BurntSushi/ripgrep), about 66 MB, once; the dialog says so on Download and start and shows the progress. Each file is checked against a SHA-256 pinned in SayQL before it's unpacked, and the copy (in SayQL's app data, runners/opencode/1.19.5) is checked again before every run. Nothing else is installed, and your own OpenCode, if you have one, isn't touched.
How it stays read-only. SayQL gives OpenCode its own agent whose rules deny everything first, then allow only reading, searching and listing files in the knowledge sources and SayQL's five audit tools. Shell commands, file edits, web fetches and subagents aren't offered to the model at all; .env files, keys, credentials, Terraform state and .git folders can't be read in any letter case (.ENV too), and searches skip them too (on Windows the agent reads and lists files but doesn't search their contents); folders outside the sources are refused, and SayQL won't start over a source with a symbolic link that leads out of the sources, since OpenCode would follow it (it names the link); and anything that would need approval is refused, since nobody can approve it. Each run gets an empty home and temp folder in SayQL's own cache, readable by you only and deleted afterwards, so your OpenCode settings, plugins and sign-ins, the project's opencode.json, .opencode folder and AGENTS.md, and any OPENCODE_* variables are all left out. It makes no update checks, doesn't fetch model lists or plugins, and talks only to your AI provider. If an administrator has installed an OpenCode policy on the computer, which OpenCode would apply over SayQL's rules, SayQL doesn't run it. Its database access goes through SayQL's MCP server like any AI app's, listed as OpenCode in Settings → AI apps, so blocking and approval apply. It runs inside SayQL only, not in a terminal.
Which AI sees what. The code and documents it reads, SayQL's schema and notes, and the audit instructions go to your AI provider, as they would with any coding agent. With SayQL AI credits that's through SayQL's service to Anthropic, which keeps token counts, never prompts or answers; with a local model nothing leaves your computer. The key goes to OpenCode in its environment only: never on its command line, in a file or in what SayQL shows.
Until a connection has been audited, the navigator shows Teach SayQL this database under the open database, with your coding agent to pick, its setup, how to run the audit in it for that connection and Copy audit prompt; its × hides it for good. The same steps show on the Suggestions tab while none are waiting.
Passwords and writes never go through MCP. SayQL brings its window to the front and marks what came from an AI app, e.g. From Claude (MCP).
What AI apps may see
In Settings → AI apps → Access, the Connections table has a row per saved connection. Choose what an AI app gets back from a query under What AI apps get back:
- Nothing (names and row counts only): only how many rows a query returned, and its column names.
- Counts and summaries (the default): the row count and, per column, its type, nulls and distinct values, and min and max only for a table's own number and date columns and for counts, sums, averages, minimums and maximums of them (not for computed expressions, which could carry text). No row values. The assistant answers with queries whose numbers answer the question, and can open SQL in SayQL when you want to see the rows yourself.
- Rows, masked: rows, with likely personal data (emails, phones, names, IDs) replaced by tokens such as
‹email-1›. When a query moves values in a way SayQL can't trace to their column (UNION,VALUES, column alias lists, JSON access, functions inFROM), all its text is masked. This is best effort: a free-text column can hold anything. - All rows: rows as they are, in pages of 100 by default and at most 1,000, and CSV export. For data you're happy to share with that app.
Columns marked never send stay out at every level, for AI apps and for Investigate alike (it's one list per connection). They show as chips in the same row; Edit opens a list of your tables to pick them from (the same list Investigate uses, without turning Investigate on or off). Database errors can quote values, so below All rows (and at All rows for a query on a table with never-send columns) the assistant gets a fixed description of the error instead of the database's message: a syntax error and where, a column or table that doesn't exist (named only when the name is in its own SQL), a value that couldn't be converted, and so on.
These levels decide what SayQL sends back, and they keep your rows from reaching an AI app by accident. They don't make a determined agent harmless: a row count or a sum is a fact about your rows, and an agent set on it can turn a value into a count (WHERE email LIKE 'a%'). Never send is the firm line: SayQL refuses any query that could read those columns. For data an AI app must not learn at all, mark it never send, or leave the connection out.
Agent activity and blocking an app
The Activity tab lists what AI apps did through SayQL on this computer: when, which app, the connection, the SQL, and whether it ran (with the row count) or was refused and why. Filter it by app, by connection, or to refused queries only, and click a row to see its full SQL. Listing connections, databases and scripts, reading the schema, and handing work to you (with the SQL an app opened for you) are listed too. It keeps the SQL and counts, never rows: errors are kept only in their fixed form, and suggested notes wait in SayQL rather than in the log. The log is a file in SayQL's folder; Clear the log deletes it.
On the Access tab, Apps lists each app SayQL has seen, with whether it's allowed or blocked, when it was last seen and a Block button. A blocked app is refused everything until you click Allow. A block goes by the name the app reports when it connects, which nothing checks: it stops an app like Cursor, not software on your computer that reports another name, so it isn't a security boundary.
To keep out apps you haven't chosen, turn on Only allow apps I've approved at the top of Apps. Turning it on approves every app already listed that isn't blocked, so the apps you use now keep working. After that, an app you haven't approved is refused everything, logged as refused (not approved), and listed as Waiting for approval with Approve and Block; the app is told to ask you to approve it under Settings → AI apps → Access. A blocked app stays blocked even if it was approved. Approval goes by the reported name too, so it keeps out unknown apps but isn't a security boundary against software that lies about its name.
Hand-offs from an app SayQL doesn't recognise show its reported name marked (unverified).
If SayQL's settings for AI apps can't be read (a damaged file), every request is refused until you open SayQL, which shows the problem; the MCP server never moves or rewrites SayQL's files.
For a company, govern agents centrally instead: on a SayQL server, an admin gives each agent its own key, the databases, tables and rows it may read, and what it may see. Private columns are withheld on the server, and every agent query is in the team's audit log.
How this compares with other database MCP servers and AI SQL clients: SayQL vs MCP Toolbox for Databases, SayQL vs Chat2DB, and all tools side by side.
Connect your coding agent
Open Settings → AI apps and, at the top of the Access tab, Connect an app (open and highlighted until an app has connected, one line after that). The first-run setup ends with a shortcut here too. Pick Your coding agent: it shows the exact command, link or config for that agent, with the path to sayql-mcp on your computer filled in. Teach SayQL this database has the same list. SayQL picks one for you to start with: the agent you chose last time, else one it finds installed (it only checks for the app or command, and runs nothing), else the app that last connected, else Claude Code.
| Agent | Connect | Run the audit |
|---|---|---|
| Claude Code | claude mcp add --scope user sayql -- <path> | Run audit in SayQL, or /mcp__sayql__audit |
| Cursor | Open in Cursor (Cursor asks first), or ~/.cursor/mcp.json | Type / in the Agent chat and pick SayQL's audit |
| VS Code (GitHub Copilot) | Open in VS Code, code --add-mcp, or MCP: Open User Configuration | /mcp.sayql.audit in Copilot Chat, in Investigate |
| Codex CLI | codex mcp add sayql -- <path>, or ~/.codex/config.toml | Paste the audit prompt |
| Gemini CLI | gemini mcp add -s user sayql <path>, or ~/.gemini/settings.json | /audit |
| GitHub Copilot CLI | copilot mcp add sayql -- <path>, or ~/.copilot/mcp-config.json | Paste the audit prompt |
| opencode | ~/.config/opencode/opencode.json or your project's opencode.json | /sayql:audit |
| Windsurf / Devin Desktop | ~/.config/devin/mcp_config.json (Windows: %APPDATA%\devin\mcp_config.json; older Windsurf: ~/.codeium/windsurf/mcp_config.json) | Paste the audit prompt into Cascade |
| Zed | context_servers in Zed's settings file | Paste the audit prompt |
| Cline, Roo Code | Their MCP settings file, opened from the extension | Paste the audit prompt |
| Continue | .continue/mcpServers/sayql.json in your project | Type / in the chat and pick SayQL's audit |
| Amp | amp mcp add sayql -- <path>, or ~/.config/amp/settings.json | Paste the audit prompt |
| JetBrains AI Assistant | Settings → Tools → AI Assistant → Model Context Protocol (MCP), add a STDIO server | Paste the audit prompt |
| Claude Desktop | claude_desktop_config.json (Settings → Developer → Edit Config), then quit and reopen it | Pick SayQL's audit from the menu that lists your connectors. It can't read your code on its own, so a coding agent audits better. |
| Other (any MCP app) | A stdio server that runs sayql-mcp (the usual mcpServers JSON) | Paste the audit prompt |
Paste the audit prompt means Copy audit prompt (on the card, in the audit dialog, or Copy prompt on a connection in Settings → AI apps → Access) and paste it into the agent's chat, started in your project. Those agents don't document MCP prompts, so this is the way that works everywhere. Only Claude Code, and SayQL's own built-in OpenCode, can be started by SayQL (Run audit), because they're the ones SayQL can keep read-only.
Something missing or unclear? Ask in Discussions.