Brazil has several invoice types, and each one has its own rules. A service invoice is an NFS-e. A sale to a consumer is
an NFC-e. A sale of goods between companies is an NF-e, model 55. Behind the names sit tax codes, city systems and an
official XML layout that rejects almost anything that is slightly off. It is a good problem for an AI agent, and a risky one:
an invoice that is issued cannot simply be deleted. It has to be cancelled with the tax authority.
At SendNF we built a remote MCP server (44 tools) so that Claude (the client we tested), Cursor and other MCP clients can prepare these documents.
Here is how we split the work between the agent and the human, and why.
1. Reads first, writes later
25 of the 44 tools are read-only. An agent can look up a company by CNPJ (the Brazilian company tax ID), search the national service
code list (LC 116) to find the six-digit code, and ask how to get hard-to-find data such as a city registration number.
None of that changes anything. An agent that only reads cannot cause a tax problem, so we let it do as much as it wants here.
2. Preview is its own tool
preview_nfse, preview_nfce and preview_nfe build the document and validate it against the official layout
without sending it. They return totals and a list of problems, each with a guide. The agent can loop on this: read the
problem, fix the field, preview again. Because the preview never transmits, a wrong guess costs nothing.
There is also validate_dps, which checks a DPS XML (the national service invoice request) against the official XSD and explains each
error in Portuguese with the field, the cause and the fix. It validates the layout only. It does not call the city or the
tax authority, and it does not promise the invoice will be accepted.
3. A person approves before issuing
The issuing tools (issue_nfse, issue_nfce, issue_nfe) are separate from the preview tools, and in the MCP the
server holds the issue until a person approves. This lock lives on the server, not in the prompt, and it is on by default.
While the lock is on, even a confused or manipulated agent cannot issue on its own. The agent can also call create_note_draft, which
leaves a draft waiting for approval and returns a link where the person reviews it.
A conversation looks like this:
You: Issue the invoice for Acme: R$ 1,500 of software development, for October.
Agent: Found code 01.01.01. Pre-issued and checked against the layout. Acme Tecnologia, R$ 1,500.00, ISS 2%.
You are in production. Shall I issue it?
You: Go ahead.
Agent: Issued: NFS-e no. 1042 authorized. PDF and XML sent to the client.
4. Sandbox keys
Keys that start with nt_test_ run in sandbox mode: the document goes through the same flow with no fiscal value
and no charge. Keys that start with nt_live_ issue real invoices. We suggest connecting with a test key first and
running the whole conversation before switching.
5. Retries must not duplicate
For NF-e the issue tool takes a reference, so repeating a call does not create a second invoice. Agents retry, so any
tool that writes to the outside world needs a key like this.
Connect it
claude mcp add --transport http sendnf https://api.sendnf.com/mcp \
--header "Authorization: Bearer nt_test_..."
In Claude Desktop you add it as a custom connector with the same URL and sign in with your SendNF account. Cursor takes
the URL and the header in mcp.json. The server is listed in the official MCP Registry as io.github.sendnf/sendnf,
and the manifest and tool list are on GitHub: https://github.com/sendnf/sendnf-mcp.
You need a SendNF account to get a key. Sandbox mode costs nothing; real invoices are on paid plans that start at
R$ 47.90 per month. Step-by-step setup for each client (in Portuguese): https://sendnf.com/mcp/
What we would tell anyone building a similar server
- Make the dangerous step a different tool, and put the lock on the server.
- Give the agent a preview that cannot send anything.
- Return errors in plain language with the field that failed. Agents fix what they can read.
- Offer a sandbox key from day one.
Originally published on Medium. SendNF: https://sendnf.com/mcp/
Top comments (0)