<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SendNF</title>
    <description>The latest articles on DEV Community by SendNF (@sendnf).</description>
    <link>https://dev.to/sendnf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4256312%2Ff1089983-b33a-4bc6-ac49-c04ce59e83f6.png</url>
      <title>DEV Community: SendNF</title>
      <link>https://dev.to/sendnf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sendnf"/>
    <language>en</language>
    <item>
      <title>Letting an AI agent issue Brazilian invoices without letting it issue them alone</title>
      <dc:creator>SendNF</dc:creator>
      <pubDate>Fri, 20 Nov 2026 20:05:45 +0000</pubDate>
      <link>https://dev.to/sendnf/letting-an-ai-agent-issue-brazilian-invoices-without-letting-it-issue-them-alone-102c</link>
      <guid>https://dev.to/sendnf/letting-an-ai-agent-issue-brazilian-invoices-without-letting-it-issue-them-alone-102c</guid>
      <description>&lt;p&gt;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&lt;br&gt;
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&lt;br&gt;
official XML layout that rejects almost anything that is slightly off. It is a good problem for an AI agent, and a risky one:&lt;br&gt;
an invoice that is issued cannot simply be deleted. It has to be cancelled with the tax authority.&lt;/p&gt;

&lt;p&gt;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.&lt;br&gt;
Here is how we split the work between the agent and the human, and why.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Reads first, writes later
&lt;/h2&gt;

&lt;p&gt;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&lt;br&gt;
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.&lt;br&gt;
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.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Preview is its own tool
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;preview_nfse&lt;/code&gt;, &lt;code&gt;preview_nfce&lt;/code&gt; and &lt;code&gt;preview_nfe&lt;/code&gt; build the document and validate it against the official layout&lt;br&gt;
without sending it. They return totals and a list of problems, each with a guide. The agent can loop on this: read the&lt;br&gt;
problem, fix the field, preview again. Because the preview never transmits, a wrong guess costs nothing.&lt;/p&gt;

&lt;p&gt;There is also &lt;code&gt;validate_dps&lt;/code&gt;, which checks a DPS XML (the national service invoice request) against the official XSD and explains each&lt;br&gt;
error in Portuguese with the field, the cause and the fix. It validates the layout only. It does not call the city or the&lt;br&gt;
tax authority, and it does not promise the invoice will be accepted.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. A person approves before issuing
&lt;/h2&gt;

&lt;p&gt;The issuing tools (&lt;code&gt;issue_nfse&lt;/code&gt;, &lt;code&gt;issue_nfce&lt;/code&gt;, &lt;code&gt;issue_nfe&lt;/code&gt;) are separate from the preview tools, and in the MCP the&lt;br&gt;
server holds the issue until a person approves. This lock lives on the server, not in the prompt, and it is on by default.&lt;br&gt;
While the lock is on, even a confused or manipulated agent cannot issue on its own. The agent can also call &lt;code&gt;create_note_draft&lt;/code&gt;, which&lt;br&gt;
leaves a draft waiting for approval and returns a link where the person reviews it.&lt;/p&gt;

&lt;p&gt;A conversation looks like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You:&lt;/strong&gt; Issue the invoice for Acme: R$ 1,500 of software development, for October.&lt;br&gt;
&lt;strong&gt;Agent:&lt;/strong&gt; Found code 01.01.01. Pre-issued and checked against the layout. Acme Tecnologia, R$ 1,500.00, ISS 2%.&lt;br&gt;
You are in production. Shall I issue it?&lt;br&gt;
&lt;strong&gt;You:&lt;/strong&gt; Go ahead.&lt;br&gt;
&lt;strong&gt;Agent:&lt;/strong&gt; Issued: NFS-e no. 1042 authorized. PDF and XML sent to the client.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  4. Sandbox keys
&lt;/h2&gt;

&lt;p&gt;Keys that start with &lt;code&gt;nt_test_&lt;/code&gt; run in sandbox mode: the document goes through the same flow with no fiscal value&lt;br&gt;
and no charge. Keys that start with &lt;code&gt;nt_live_&lt;/code&gt; issue real invoices. We suggest connecting with a test key first and&lt;br&gt;
running the whole conversation before switching.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Retries must not duplicate
&lt;/h2&gt;

&lt;p&gt;For NF-e the issue tool takes a &lt;code&gt;reference&lt;/code&gt;, so repeating a call does not create a second invoice. Agents retry, so any&lt;br&gt;
tool that writes to the outside world needs a key like this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http sendnf https://api.sendnf.com/mcp \
  --header &lt;span class="s2"&gt;"Authorization: Bearer nt_test_..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Claude Desktop you add it as a custom connector with the same URL and sign in with your SendNF account. Cursor takes&lt;br&gt;
the URL and the header in &lt;code&gt;mcp.json&lt;/code&gt;. The server is listed in the official MCP Registry as &lt;code&gt;io.github.sendnf/sendnf&lt;/code&gt;,&lt;br&gt;
and the manifest and tool list are on GitHub: &lt;a href="https://github.com/sendnf/sendnf-mcp" rel="noopener noreferrer"&gt;https://github.com/sendnf/sendnf-mcp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You need a SendNF account to get a key. Sandbox mode costs nothing; real invoices are on paid plans that start at&lt;br&gt;
R$ 47.90 per month. Step-by-step setup for each client (in Portuguese): &lt;a href="https://sendnf.com/mcp/" rel="noopener noreferrer"&gt;https://sendnf.com/mcp/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What we would tell anyone building a similar server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Make the dangerous step a different tool, and put the lock on the server.&lt;/li&gt;
&lt;li&gt;Give the agent a preview that cannot send anything.&lt;/li&gt;
&lt;li&gt;Return errors in plain language with the field that failed. Agents fix what they can read.&lt;/li&gt;
&lt;li&gt;Offer a sandbox key from day one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Originally published on Medium. SendNF: &lt;a href="https://sendnf.com/mcp/" rel="noopener noreferrer"&gt;https://sendnf.com/mcp/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>api</category>
      <category>brazil</category>
    </item>
  </channel>
</rss>
