---
title: "Tutorial: an AI assistant for your finance team | FluxOS MCP Blog"
description: "From the ERP database to three questions the assistant can answer: open receivables, overdue customers, and receipts by month. Read-only, built on database views."
url: "https://www.fluxosmcp.com/en/blog/tutorial-an-ai-assistant-for-your-finance-team"
lang: "en-US"
---

[Blog](https://www.fluxosmcp.com/en/blog) · Nov 25, 2026 · FluxOS MCP Team

# Tutorial: an AI assistant for your finance team

[Leia este artigo em português](https://www.fluxosmcp.com/blog/tutorial-um-assistente-de-ia-para-o-time-financeiro)

Every Monday, someone in finance stops what they are doing to answer the same questions: how much are we owed, who is late, how much came in last month. The information is in the ERP database. What’s missing is a way to ask without opening a report.

In this tutorial you build, from start to finish, an MCP server with three tools for the finance team. It is the second of the [five use cases](https://www.fluxosmcp.com/en/blog/5-mcp-use-cases-for-businesses), put into practice.

The approach rests on one central idea: **the assistant does not query the ERP tables; it queries views prepared for it.** You will see why.

## What you need

- A team account on FluxOS MCP.
- Access to a PostgreSQL, MySQL, or SQL Server database that holds the receivables.
- Someone who can create views and a user in the database (usually the DBA or whoever maintains the ERP).
- An AI assistant that accepts remote MCP servers.

The example uses a simplified table. Adapt the names to yours:

```sql
titulos (id, empresa_id, sacado, documento, valor, emissao, vencimento, pago_em)

```

`empresa_id` identifies which company the receivable belongs to. If you serve a single company, it has one value; if your system serves several, this is the column that keeps each company’s data apart.

## Step 1: why views, and not the tables

The FluxOS MCP database import reads the tables and proposes tools for each one. That works, but for finance there are three problems with exposing the receivables table directly:

- **The business rule is left to the assistant.** Does “overdue” mean past due and unpaid? Does the due date itself count? If the tool only lists receivables, the model decides, on every question.
- **Sums are left to the assistant.** “How much are we owed” means adding up dozens of rows. Leaving the math to the model is asking for a wrong number.
- **Too many fields leave the database.** The real table has dozens of columns that finance does not need to see in a conversation.

A **view** is a query saved in the database that behaves like a read-only table. In it, the rule and the sum are written in SQL, reviewed once, the same for everyone. And the import treats views as tables: for each view, it proposes a query tool.

## Step 2: create the three views

Ask whoever maintains the database to create these three views (the example is PostgreSQL; on another database, the date syntax changes a little).

**Open receivables**, with the days overdue already calculated:

```sql
CREATE VIEW fin.titulos_em_aberto AS
SELECT empresa_id, sacado, documento, valor, vencimento,
       GREATEST(current_date - vencimento, 0) AS dias_em_atraso
FROM fin.titulos
WHERE pago_em IS NULL;

```

**Overdue customers**, already grouped and summed:

```sql
CREATE VIEW fin.sacados_em_atraso AS
SELECT empresa_id, sacado,
       count(*) AS titulos_vencidos,
       sum(valor) AS total_vencido,
       max(current_date - vencimento) AS maior_atraso_dias
FROM fin.titulos
WHERE pago_em IS NULL AND vencimento < current_date
GROUP BY empresa_id, sacado;

```

**Receipts by month**:

```sql
CREATE VIEW fin.recebimentos_por_mes AS
SELECT empresa_id,
       to_char(pago_em, 'YYYY-MM') AS mes,
       count(*) AS titulos_pagos,
       sum(valor) AS total_recebido
FROM fin.titulos
WHERE pago_em IS NOT NULL
GROUP BY empresa_id, to_char(pago_em, 'YYYY-MM');

```

Notice that all three keep the `empresa_id` column. That column is what guarantees each company sees only its own numbers.

## Step 3: a read-only user

Create a database user that can read the three views and nothing else:

```sql
CREATE ROLE assistente_fin LOGIN PASSWORD 'troque-esta-senha';
GRANT USAGE ON SCHEMA fin TO assistente_fin;
GRANT SELECT ON fin.titulos_em_aberto, fin.sacados_em_atraso, fin.recebimentos_por_mes TO assistente_fin;

```

This user cannot see the receivables table or anything else in the ERP. Even if something goes wrong in every other layer, the database lets nothing out beyond the views. The platform adds protections; it does not replace the database’s own.

## Step 4: connect the database

In **Credenciais** (Credentials), create a **Nova conexão SQL** (New SQL connection):

- **Nome** (Name): Finance, read-only
- **Como informar a conexão** (How to provide the connection): connection URL, in the format `postgres://assistente_fin:SENHA@HOST:5432/BANCO`

Click **Testar conexão** (Test connection) and, once you see “Conexão OK” (Connection OK), click **Salvar conexão** (Save connection). The password goes into an encrypted vault; the rest of the system stores only the reference.

Then, in **Sistemas → Novo sistema** (Systems → New system):

- **Nome:** ERP Finance
- **Tipo de origem** (Source type): Banco SQL (SQL database)
- **Schemas:** `fin`
- **Conexão com o banco** (Database connection): Finance, read-only

Click **Criar e importar** (Create and import).

## Step 5: import the three tools

In the **Origem** (Source) step, click **Ler schema** (Read schema). The import reads the views (not the data) and proposes a query tool for each one:

- `consultar_titulos_em_aberto`
- `consultar_sacados_em_atraso`
- `consultar_recebimentos_por_mes`

For each one, make two adjustments.

**Choose the client filter: `empresa_id`.** From then on, the server adds the filter to every query, using the identifier of the company that owns the key, and the column disappears from the arguments. The assistant does not even know it exists.

**Rewrite the description.** The description the import proposes is technical (“Lista registros da visão…”, that is, “Lists records from the view…”). Replace it with:

- `consultar_titulos_em_aberto`: “Use for questions about receivables that have not been paid yet: how much is due this week, which of a customer’s receivables are open. Each receivable includes the payer (sacado), document, amount, due date, and days overdue (zero if it is not yet due).”
- `consultar_sacados_em_atraso`: “Use to find out which customers have late payments and how much they owe. Each row is a customer, with the number of past-due receivables, the total past due, and the longest delay in days. For the biggest debtors, sort by total\_vencido descending.”
- `consultar_recebimentos_por_mes`: “Use to find out how much was received in a month or to compare months. Each row is a month in YYYY-MM format, with the number of receivables paid and the total received.”

The descriptions explain what each number means. That is what keeps the assistant from confusing “past due” with “open”.

In the **Resumo** (Summary) step, create a new server, “Financeiro”, with the address `financeiro`, and click **Criar 3 ferramentas** (Create 3 tools).

## Step 6: what the assistant can ask for

Each query tool already comes with filters, sorting, and pagination, which the assistant uses on its own:

- **igual**: filter by exact value, such as `sacado = "Padaria Central"`;
- **filtros**: comparisons, such as `dias_em_atraso` greater than 30 or `vencimento` between two dates;
- **ordenarPor** and **direcao**: for example, `total_vencido` descending;
- **limite** and **offset**: pagination, with at most 200 records per call.

You do not need to configure any of this. But it is good to know, because it explains how a question like “the five biggest debtors” becomes a single call.

## Step 7: publish and hand over the key

1. In **Servidores MCP** (MCP servers), open “Financeiro” and click **Publicar** (Publish).
2. In **Clientes** (Clients), open the company (or create one, with the identifier it has in the ERP).
3. On the **Chaves** (Keys) tab, click **Nova chave** (New key), choose the “Financeiro” server, and set low limits to start, such as 20 per minute and 500 per day.
4. Copy the key right away: it is shown only once.

Connect the team’s assistant using the address on the **Conexão** (Connection) tab and the key. The connection articles cover each assistant, such as [Claude Code](https://www.fluxosmcp.com/en/blog/how-to-connect-claude-code-to-your-mcp-server) or [Cursor and VS Code](https://www.fluxosmcp.com/en/blog/how-to-connect-cursor-and-vs-code-to-your-mcp-server).

## Step 8: the Monday questions

- “How much are we owed over the next 15 days?”
- “Which customers are more than 30 days overdue? Sort by amount.”
- “How much did we receive in October, compared with September?”
- “Which of Padaria Central’s receivables are open?”

For the first, the assistant filters open receivables by due date and adds up the result. For the second, it uses the overdue view, already summed. For the third, it compares two rows of the receipts view. In none of these cases did it need to know what “overdue” means: the view already knew.

## Before you trust the numbers

Financial numbers have to match. Before handing this to the team:

- **Compare with the official report.** Ask the assistant and the ERP report the same questions, for three different dates. A difference is almost always a rule: issue date versus due date, a partially paid receivable, a canceled one that was never taken out of the total.
- **Fix the view, not the description.** If the rule is wrong, correct the view’s SQL. The description explains; the view decides.
- **Test with another company.** If your system serves several, create a key for a second company and confirm that one company’s numbers do not show up for the other.

## What stays out, for now

- **Nothing that changes data.** Settling a receivable, renegotiating, issuing a boleto (a Brazilian bank payment slip): those are write tools, which call for a different level of care. Start with reads and add the rest later, one at a time.
- **Personal data.** If the payers are individuals, name and document number are personal data. See [MCP and LGPD](https://www.fluxosmcp.com/en/blog/mcp-and-lgpd-what-changes-when-ai-accesses-personal-data) (Brazil’s data protection law, comparable to GDPR) before you open access.
- **Heavy analysis.** Projected cash flow, delinquency by cohort: these become new views, written and reviewed by someone on the team. The assistant does well with what the view already calculates.

## The same playbook for other areas

Swap the views and the rest of the tutorial stays the same:

- **Customer support:** order status, latest delivery, a customer’s invoices.
- **Inventory:** stock by warehouse, items below minimum, open purchase orders.
- **Sales:** customer history, stalled proposals, list price.

Views with the rule built in, a user that can only read the views, a client filter, and descriptions that explain each number. Before you hand it over, go through the [production checklist](https://www.fluxosmcp.com/en/blog/checklist-is-your-mcp-server-ready-for-production).
