---
title: "SQL database | FluxOS MCP documentation"
description: "Read the schema of a Postgres, MySQL, or SQL Server database and generate MCP tools per table, with a client filter, bound parameters, and optional RLS isolation."
url: "https://www.fluxosmcp.com/en/docs/origens/sql"
lang: "en-US"
---

Documentation

# SQL database

The FluxOS MCP dashboard is currently in Portuguese. Screen labels appear here as you will see them, with the English meaning alongside.

Use this source to expose tables from a **PostgreSQL**, **MySQL**, or **SQL Server** database as MCP tools, without writing SQL.

## What gets imported

FluxOS MCP connects with the system’s credential and reads the **catalog**: tables, views, columns, primary keys, and foreign keys. The database’s own schemas (`pg_catalog`, `information_schema`, `sys`, and so on) are ignored. Table data is not read during the import.

**Saved SQL queries** found in the system’s `config.queries` are imported too. Today that is done through the API, when creating or editing the system; the registration screen has no editor for them.

## What you need on hand

- The **connection URL** (`postgres://usuario:senha@host:5432/banco`, `mysql://…`, or `sqlserver://…`) or the separate fields (driver, host, port, database, user, password, SSL mode).
- A **service user with the minimum permissions**: only the tables you want to expose and only the operations you need. The platform does not replace the database’s permissions.
- The **column that identifies the client** in each table (for example `cliente_id`).
- The database must be reachable from the FluxOS MCP installation. Internal network addresses are blocked unless the installation allows them.

## Step by step on screen

1. Under **Sistemas → Novo sistema** (Systems → New system), choose **Banco SQL** (SQL database). If you want, restrict the **schemas** and **tables** (comma-separated; empty means all the visible ones). Under **Conexão com o banco** (Database connection), choose a connection or create a new one.
2. In **Nova conexão SQL** (New SQL connection), enter the URL or the fields and use **Testar conexão** (Test connection) before saving. The URL is kept in the vault; the system stores only the reference.
![New SQL connection](https://www.fluxosmcp.com/_astro/20-sql-conexao.CkZCs6al_ZKXb45.webp)
3. **Criar e importar** (Create and import), then **Ler schema** (Read schema).
![Read schema](https://www.fluxosmcp.com/_astro/21-sql-ler-schema.C6oyfp9N_1bTo3l.webp)
4. Choose the tools, the client filter for each one, and the destination server.
![Proposed tools for the database](https://www.fluxosmcp.com/_astro/22-sql-ferramentas-propostas.B7_3HEdP_Ciwa5.webp)

## How tables become MCP tools

Up to five tools are proposed for each table (views only get the query one):

| Tool      | Generated name            | Type  | Notes                                                                                                           |
| --------- | ------------------------- | ----- | --------------------------------------------------------------------------------------------------------------- |
| Query     | consultar\_<tabela>       | Read  | Arguments igual, filtros, ordenarPor, direcao, limite, and offset                                               |
| Get by id | buscar\_<tabela>\_por\_id | Read  | Only exists with a single-column primary key                                                                    |
| Insert    | inserir\_<tabela>         | Write | One property per writable column; the required ones are those that do not accept null and have no default value |
| Update    | atualizar\_<tabela>       | Write | With a simple primary key: id and valores. Without one: filtros and valores                                     |
| Delete    | excluir\_<tabela>         | Write | With a simple primary key: id. Without one: filtros (at least one)                                              |

Details:

- Filters accept the operators `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `like`, `ilike`, `in`, `isNull`, and `notNull`, combined with AND, on columns the schema reports. Binary and JSON columns cannot be used as filters.
- Generated columns and always-generated identity columns are not writable.
- The query returns `{rows, rowCount, truncated}`. The default limit and the cap are both **200 records** per call; `truncated: true` means there are more (use `offset` to paginate).
- Decimal values come back as text (`"250.00"`).
- When the same table name appears in different schemas, the schema becomes part of the tool name.
- All values are **bound as parameters**; nothing is concatenated into the SQL. The block only builds queries with tables and columns that the imported schema contains.

### Client filter

When you choose a client column on a table:

- every read, update, and delete gets `WHERE <coluna> = <identificador do cliente da chave>` (the column equals the identifier of the key’s client);
- every insert fills in the column with that identifier;
- the column disappears from the arguments the AI sees.

The value always comes from the access key, never from the arguments. We verified this with a real call: a key for client `CLI-001` received only that client’s rows, an attempt to filter by another client was refused because that argument does not exist, and an insert wrote `cliente_id = CLI-001` on its own.

Tables without a client column only publish if they are marked as **Globais** (Global), or if isolation is handled by RLS (below).

### Extra isolation with database RLS

If the system has `config.tenantContext` (the name of a _setting_, such as `app.tenant_id`), the block tells the database who the client is before each query, inside a transaction, and the database’s own row-level security (RLS) policies filter as well. It works on PostgreSQL and SQL Server; **MySQL has no RLS** and the combination is refused. During the import, FluxOS MCP checks table by table whether RLS applies to the credential’s user and shows a warning when it does not. The full technical guide, with the commands for each database, is in `docs/isolamento-sql.md` in the repository.

## Limits and precautions

- **Review the client filter on every tool.** The screen preselects the first column in the list. Columns that look like client columns (`cliente_id`, `tenant_id`, `empresa`, and similar) come first, but on a table with none of them the first option will be some other column (in our tests, `id`). Switch to **Global** if the table is public.
- **Only reads come selected.** Insert, update, and delete are left deselected and are exposed as destructive.
- **Saved queries** require the `:cliente` parameter in order to publish. Publishing confirms that the query uses it, not that it uses it correctly: **human review is still mandatory**. Each query is a single statement and runs in a read-only transaction when the database allows it and the query is a read.
- **Time and volume:** a query has a default timeout of 30 seconds.
- **Use a service user** that is not a superuser, has no `BYPASSRLS`, and does not own the tables, if you plan to use RLS.
- **MySQL and SQL Server:** SQL generation for these databases has been tested, but real queries have not been run against them yet. Our end-to-end test was done with PostgreSQL.
- The table list of a large database can be long: use the **Schemas** and **Tabelas** (Tables) fields to narrow it down.
