1. AI and MCP
  2. Issuing NF-e with the agent

With the MCP connected, you ask for the invoice in natural language and the agent calls the Treeunfe tools. Underneath, they use the same routes as the NF-e API. The connection operates in production. See Environment.

1

Check that the company is ready

get_nfe_checklist checks the certificate, the series and number settings, and the tax rules.

Is my company ready to issue NF-e?
2

Make sure the NCM has a tax rule

Issuance calculates the taxes from the tax rule that covers the item’s NCM.

Is there a tax rule for NCM 85176241 on a sale to GO?
3

Ask for the invoice

Give the customer, the items, and the operation. The agent fills the issuer with the company data and lets Treeunfe calculate the taxes (calculateTaxes: true).

Issue a sales NF-e for customer 11222333000181, with 2 units
of product PROD-001 at R$ 500.00 each, with no freight. Before sending,
show me the customer, the items, the CFOP, and the total so I can confirm.
4

Check the result

After issuing, the agent reads the invoice with get_nfe and, if it was authorized, gets the DANFE with get_nfe_danfe_url.

Was the invoice authorized? Give me the access key and the DANFE link.

Always ask the agent to show the data before issuing. The MCP operates in production: use a series and a number that have not been used yet, so the invoice is not rejected as a duplicate.

​
NF-e tools

ToolWhat it doesAPI route
get_nfe_checklistChecks whether the company is ready to issue.NF-e checklist
emit_nfeIssues a model 55 NF-e.Issue NF-e
list_nfeLists the company’s NF-e.List NF-e
get_nfeReads one NF-e and its status.Get NF-e
get_nfe_itemsLists the items with the calculated taxes.NF-e items
get_nfe_xmlReturns the invoice XML.NF-e XML
get_nfe_danfe_urlReturns the DANFE link of an authorized invoice.DANFE da NF-e
cancel_nfeCancels an authorized NF-e.Cancel NF-e
create_nfe_cceRegisters a correction letter.Issue CC-e
list_nfe_cceLists the invoice’s correction letters.Get CC-e
create_nfe_inutilizationInvalidates a number range.Inutilizar numeração
list_nfe_inutilizationsLists number invalidations.Listar inutilizações

​
Supporting tools

The agent also reaches the data issuance uses:

GroupTools
Company and settingsget_current_organization, get_settings_nfe, update_settings_nfe
Tax ruleslist_tax_rules, list_default_tax_rules, get_tax_rule, create_tax_rule, update_tax_rule, delete_tax_rule
Customerslist_customers, get_customer, create_customer, update_customer, delete_customer
Productslist_products, get_product, create_product, update_product, delete_product
Carrierslist_carriers, get_carrier, create_carrier, update_carrier, delete_carrier
Certificateget_current_certificate, upload_certificate, delete_certificate
CNPJ lookuplookup_cnpj_rfb
Webhookslist_webhooks, get_webhook, create_webhook, update_webhook, delete_webhook

​
Events

Cancel NF-e 006f917a-21a5-491d-90b4-f745d96385e7.
Justification: the amount on the invoice was wrong.
Register a correction letter on the last NF-e issued: the correct
delivery address is Rua das Flores, 100.
Invalidate numbers 15 through 20 of series 1. Justification: a system
failure skipped the numbering.

The rules are the same as the API: a justification of 15 to 255 characters on cancellation and number invalidation, and a correction of 15 to 1000 characters on the CC-e. See NF-e events.

Cancellation, CC-e, and number invalidation are sent to SEFAZ and cannot be undone. Confirm the invoice ID and the text before you authorize the agent.

​
Useful lookups

List the NF-e issued today, with number, customer, amount, and status.
Why was the last NF-e rejected? Show the reason and what to fix.
Show the taxes calculated on each item of NF-e 006f917a-21a5-491d-90b4-f745d96385e7.