---
title: "From endpoint to workflow: a tool that looks up, decides, and answers | FluxOS MCP Blog"
description: "On the FluxOS MCP canvas, turn a company lookup into a tool that checks the company's status and returns only what matters. No code required."
url: "https://www.fluxosmcp.com/en/blog/from-endpoint-to-workflow-a-tool-that-looks-up-decides-and-answers"
lang: "en-US"
---

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

# From endpoint to workflow: a tool that looks up, decides, and answers

[Leia este artigo em português](https://www.fluxosmcp.com/blog/do-endpoint-ao-workflow-uma-ferramenta-que-consulta-decide-e-responde)

Importing an API is the fastest way to get an MCP tool. But an imported tool does exactly one thing: it calls the URL and returns whatever comes back.

Sometimes that is enough. Often it is not. BrasilAPI’s lookup for a CNPJ (Brazilian company tax ID), for example, returns more than forty fields, from share capital to the municipality code. The assistant receives all of it, spends attention on things that do not matter, and still has to figure out on its own that a company marked “BAIXADA” (deregistered) is a problem.

In FluxOS MCP, every tool is a **workflow**: a diagram of blocks connected on a canvas. In this tutorial you will open the workflow of an imported tool and teach it two things: to **decide** and to **summarize**.

## What we are going to build

A `verificar_empresa` tool that takes a CNPJ and:

- if the company is **active**, returns a five-field summary;
- if it **is not**, returns a text alert, ready for the assistant to pass along.

## What you need

The `consultar_cnpj` tool from the [Postman tutorial](https://www.fluxosmcp.com/en/blog/tutorial-turn-your-postman-collection-into-ai-tools). If you have not done it yet, it takes ten minutes and needs no key.

## Step 1: open the canvas

The FluxOS MCP dashboard is still in Portuguese, so on-screen labels appear here as they are, with the meaning in parentheses. In **Servidores MCP** (MCP servers), open the “Cadastro público” server. On the **Ferramentas** (Tools) tab, click **Canvas** on the `consultar_cnpj` row.

You will see three blocks in a row:

1. **Chamado via MCP** (Called via MCP): the trigger. It holds the tool’s name, description and arguments. This is where the CNPJ comes in.
2. **GET /cnpj/v1/{cnpj}**: the HTTP request to BrasilAPI.
3. **Responder ao MCP** (Respond to MCP): what goes back to the assistant. Right now it contains `{{ $json.body }}`, meaning the entire response body.

That `{{ ... }}` is an **expression**. `$json` means “whatever arrived from the previous block.” You will use it a lot.

## Step 2: run a test to get some data

Before changing anything, click **Executar teste** (Run test). Because the tool is called by a client, the **Testar como cliente** (Test as client) window opens. Pick any client and, under **Entrada (JSON)** (Input (JSON)), enter:

```json
{ "cnpj": "00000000000191" }

```

Click **Executar teste**. Now open the request block: the **Saída** (Output) column shows the real response, with `status`, `headers` and `body`. This is the list you will drag fields from in the next steps, instead of typing names from memory.

## Step 3: add the decision

Delete the connection between the request and **Responder ao MCP**. In the **Blocos** (Blocks) list on the left, find **Se (IF)** (If), under **Lógica** (Logic), and drag it onto the canvas. Connect the request’s output to it.

Open the block and, in **Regras** (Rules) mode, fill in one condition:

- left value: `{{ $json.body.descricao_situacao_cadastral }}`
- operator: **é igual a** (equals)
- right value: `ATIVA`

You can drag the `descricao_situacao_cadastral` field from the **Entrada** (Input) column onto the left value: the expression writes itself.

Rename the block to “Company active?”. The block has two outputs, **sim** (yes) and **não** (no). Each one will follow its own path.

## Step 4: the “sim” path returns a summary

Drag in an **Editar campos** (Edit fields) block, under **Dados** (Data), and connect the **sim** output to it. Check **Manter somente os campos definidos** (Keep only the defined fields) and create five fields:

- `empresa`: `{{ $json.body.razao_social }}`
- `situacao`: `{{ $json.body.descricao_situacao_cadastral }}`
- `cidade`: `{{ $json.body.municipio }}/{{ $json.body.uf }}`
- `atividade`: `{{ $json.body.cnae_fiscal_descricao }}`
- `aberta_em`: `{{ formatDate($json.body.data_inicio_atividade, "dd/MM/yyyy") }}`

Two details about the expressions:

- In `cidade`, two expressions and a slash in the same field become a single string: “BRASILIA/DF”.
- In `aberta_em`, the `formatDate` function converts the date from the API’s format (1966-08-01) to the Brazilian day/month/year format.

Rename the block to “Summary” and connect its output to the **Responder ao MCP** block that was already there. Open that block and **clear** the contents of the **Resposta** (Response) field: when empty, it returns what it received, which is now the summary.

## Step 5: the “não” path returns an alert

Drag in a second **Responder ao MCP** block, under **Integrações** (Integrations), and connect the **não** output to it. In the **Resposta** field, write:

```text
Warning: the company {{ $json.body.razao_social }} has had the registration status {{ $json.body.descricao_situacao_cadastral }} since {{ formatDate($json.body.data_situacao_cadastral, "dd/MM/yyyy") }}. Do not proceed with onboarding without checking with finance.

```

Rename it to “Respond with alert”.

Notice that the response here is **text**, not a list of fields. It is an instruction for the assistant, written by you, the person who knows the company’s rule. The assistant will pass the warning along instead of improvising an interpretation.

## Step 6: adjust the name and description

Open the **Chamado via MCP** trigger and rewrite the **Descrição** (Description):

> Use before onboarding or doing business with a company. Provide the CNPJ as 14 digits, numbers only. Returns a summary if the company is active, or an alert if it is not.

The description says **when to use it**, **what to provide** and **what comes back**. It is the text the assistant reads to decide.

The tool’s name is changed somewhere else: on the server page, with the edit button on the tool’s row. Change it from `consultar_cnpj` to `verificar_empresa`.

## Step 7: test both paths

Click **Executar teste** again, with the same CNPJ. The expected result:

```json
{
  "empresa": "BANCO DO BRASIL SA",
  "situacao": "ATIVA",
  "cidade": "BRASILIA/DF",
  "atividade": "Bancos múltiplos, com carteira comercial",
  "aberta_em": "01/08/1966"
}

```

Five fields, instead of more than forty.

To see the other path without hunting for the CNPJ of a closed company, temporarily change the condition’s right value to `BAIXADA` and run the test: the execution goes through **não** and you see the alert text. Then switch it back to `ATIVA`.

On the canvas, every execution shows the path it took. If something comes out differently than expected, open the block and compare **Entrada** and **Saída**.

## Step 8: publish

Click **Publicar v2** (Publish v2). The screen validates the diagram and tells you if anything blocks publishing. The published version is fixed: whatever you change afterward stays in draft until you publish again. If v2 causes trouble, **Histórico** (History) lets you roll production back to v1.

Finally, on the server page, click **Publicar alterações** (Publish changes).

## What changed for the assistant

Ask: “Can I onboard the supplier with CNPJ 00.000.000/0001-91?”

Before, it received forty fields and had to guess which ones matter. Now it receives five, or a clear warning. The decision about what counts as a company “with a problem” moved out of the assistant’s head and into your workflow, where it can be read, tested and audited.

## Going further

The canvas has other blocks that follow the same logic:

- **Switch (várias saídas)** (Switch (multiple outputs)), when the decision has more than two paths (active, suspended, deregistered, unfit).
- **Filtrar** (Filter), to sort and paginate lists before returning them.
- **Consulta SQL** (SQL query), to fetch data from a database.
- **Código (JavaScript)** (Code (JavaScript)), for the calculation no ready-made block can do.
- The **erro** (error) output on any block, to answer with something useful when the source API fails.

Two natural paths from here: using conditions to [limit what the AI can do](https://www.fluxosmcp.com/en/blog/no-code-business-rules-what-the-ai-can-and-cannot-do) and [combining two sources in the same answer](https://www.fluxosmcp.com/en/blog/one-tool-two-sources-database-and-api-in-the-same-response).
