Which server to choose
It depends on the type of database, but the principle is one.
- SQLite (a database that's a single file on the computer): the simplest and most private case, suited to those who keep data locally.
- PostgreSQL or MySQL ("real" databases, often on a server): for larger or corporate archives.
- There are servers that cover several types at once (like DBHub), useful if you have different databases.
For someone starting out who wants to keep everything private, a local SQLite database with a read-only server is the safest choice.
How to do it
- Get the database access details. For a SQLite file, the file's path. For PostgreSQL/MySQL, the connection string (address, port, database name, user).
- Add the server to the configuration file. The working syntax (example with a local SQLite database, read-only):
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "@executeautomation/database-server", "--sqlite", "/Users/yourname/data/archive.db"]
}
}
}
The last value is the path to your database file. For other types of database, the same server accepts a connection string in place of the path: check the server's page for the exact form.
- Give read-only access. Configure the server so it can only read (
SELECT-type queries), so the AI can't modify or delete data. It's the single measure that makes everything else safe. - Restart and query in plain English. Ask the assistant: "which are the 5 clients who spent the most this year?". The server translates the question into a query, runs it and gives you the answer.
A concrete example
Laura runs a small shop and keeps the orders in a SQLite file exported from her management system. She wants to understand the trend but doesn't know how to write queries. She connects the database server to that file, read-only, and restarts the assistant.
Then she asks in plain English: "compare this quarter's revenue with the same one last year and tell me which categories grew." The AI queries the real database and answers with the real numbers, not invented. Laura didn't write SQL and didn't upload anything online: the file stayed on her computer, the AI only read it. The analyses she used to ask her accountant for she now does on her own.
When it does NOT work (and how to fix it)
If the AI invents the numbers instead of reading them
If it answered "from memory" without querying the database, the data would be unreliable. Ask explicitly "query the database and show me the query you used." Seeing the query confirms that the answer comes from the real data, and lets you notice right away if it misunderstood the question.
If the database is online and contains sensitive data
Connecting a production database with client data exposes sensitive information. Work on a copy, keep read-only, and give the AI only the tables that are needed. For third parties' personal data, consider whether it's appropriate to let it see them at all.
If you grant write permissions by mistake
An AI with write access to a database can, by mistake, modify or delete data. The rule is clear-cut: read-only, always, barring a specific reason. If you need it to write, do it on a test copy, never on the real archive.
A tip from someone who really uses it
Create a copy of the database just for the AI, with the tables you need inside and no excess confidential data. You connect that one, read-only. That way you query your data without the risk of touching the real archive and without exposing more than necessary. The dedicated copy is the same logic as the restricted folder for files: you give access to a box, not to the whole warehouse.
Frequently asked questions
Do I have to know how to write SQL to use it?
No, and that's the beauty of it: you ask the questions in plain English and the server translates them into queries on its own. Knowing a bit of SQL (the language for querying databases) helps you check what it did, but it isn't needed to start. Ask and read the answer.
Does it also work with data from Google Sheets or Excel?
For spreadsheets there are MCP servers dedicated to Excel, more suited than those for databases. If your data is in a spreadsheet, that type of server is preferable; the database server is for structured archives like SQLite or PostgreSQL.
Does my database's data get uploaded online?
If the database is on your computer, the server reads it locally and the data isn't uploaded anywhere. The portion of data you let it see in the answers, however, passes through the AI assistant: the file stays yours, but what you ask it to analyze transits through the model anyway.