Skip to main content
Glama

Cancelar documento fiscal

evento_cancelar
Destructive

Cancela um documento fiscal autorizado (NF-e, NFC-e, NFS-e, CT-e, MDF-e, DC-e, NFCom). Informe a chave de 44 dígitos e a justificativa (mínimo 15 caracteres). Para NFS-e use TipoDocumento=1 e informe NumeroNFSe ao invés de chave. Prazo SEFAZ NF-e: 24h após autorização (algumas UFs mais). NFCom: até 120h após o último dia do mês da autorização.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "ChaveNF": "<ChaveNF>",
      "Justificativa": "<Justificativa>",
      "TipoAmbiente": "<TipoAmbiente>",
      "TipoDocumento": "<TipoDocumento>"
    },
    "name": "evento_cancelar"
  }
}

Input Schema

NameRequiredDescriptionDefault
ChaveNFYesChave de acesso de 44 dígitos da NF-e/NFC-e/CT-e/MDF-e/DC-e/NFCom a cancelar. Obrigatório quando TipoDocumento = 0 (documentos NFe-family). Para NFS-e (TipoDocumento = 1) use NumeroNFSe.
DataEventoNoData do evento de cancelamento do documento (Caso não for enviado é considerada a data e hora atual)
NumeroNFSeNoNúmero da NFS-e a ser cancelada
TipoAmbienteYesAmbiente do documento original (DEVE bater com o ambiente onde a nota foi emitida). IMPORTANTE: passe explicitamente. Se a nota foi emitida em homologação (testes), use 2. Valores: 1 - Produção; 2 - Homologação
JustificativaYesMotivo do cancelamento. MÍNIMO 15 caracteres, MÁXIMO 1000. NÃO use texto genérico como "cancelamento" ou "erro" - descreva o motivo real (ex: "Erro no valor unitário do produto X"). Obrigatório para TipoDocumento = 0 (NFe-family).
TipoDocumentoYesTipo do documento fiscal a cancelar. Valores: 0 - NF-e, NFC-e, CT-e, MDF-e, DC-e, NFCom (usa ChaveNF de 44 dígitos); 1 - NFS-e (usa NumeroNFSe + CodCancelamentoNFSe + TipoAmbiente)
NumeroProtocoloNoNúmero do protocolo de autorização original do documento (obrigatório quando a nota foi emitida por OUTRO sistema externo). Se o documento foi emitido pelo próprio BrasilNFe, o protocolo é localizado automaticamente.
NumeroSequencialNoNúmero sequencial do evento
CodCancelamentoNFSeNoCódigo do motivo de cancelamento da NFS-e (Padrão 1) Valores: 1 - Erro na emissão; 2 - Serviço não prestado; 3 - Duplicidade da nota; 9 - Outros
CpfCnpjRemetenteDCeNoCPF ou CNPJ do Usuário Emitente (Remetente) da DC-e original. Obrigatório no cancelamento de DC-e quando a nota não está cadastrada no sistema (caso esteja, o valor é lido da própria NotaFiscal).

Output Schema

NameRequiredDescriptionDefault
ErrorNoMensagem de erro da operação. Vazia ("") quando foi bem-sucedida.
AvisosNoAvisos não bloqueantes. Pode vir preenchida mesmo em emissão bem-sucedida.
StatusNo1 - Evento Processado; 2 - Aguardando processamento do evento; 3 - Ocorreu um erro ao processar o evento
DsEventoNo
DsMotivoNo
Base64XmlNoXML do evento processado (procEventoNFe) em Base64. Preenchido quando o evento e autorizado (cStat 135) na Carta de Correcao da NF-e, na manifestacao do destinatario e no ECONF (NF-e e NFC-e). Nulo nos demais casos.
Base64FileNoPDF do documento auxiliar do evento (ex.: Carta de Correcao) em Base64. Preenchido apenas quando o evento e autorizado e a nota existe na base. Nulo nos demais casos.
DsAmbienteNo
NuProtocoloNo
NumeroSequencialNo
CodStatusRespostaSefazNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / ChaveNF / description
      Previous value: -"Chave de acesso de 44 dígitos da NF-e/NFC-e/CT-e/MDF-e/DC-e a cancelar. Obrigatório quando TipoDocumento = 0 (documentos NFe-family). Para NFS-e (TipoDocumento = 1) use NumeroNFSe."New value: +"Chave de acesso de 44 dígitos da NF-e/NFC-e/CT-e/MDF-e/DC-e/NFCom a cancelar. Obrigatório quando TipoDocumento = 0 (documentos NFe-family). Para NFS-e (TipoDocumento = 1) use NumeroNFSe."
    • changedInput schema / properties / TipoDocumento / description
      Previous value: -"Tipo do documento fiscal a cancelar. Valores: 0 - NF-e, NFC-e, CT-e, MDF-e, DC-e (usa ChaveNF de 44 dígitos); 1 - NFS-e (usa NumeroNFSe + CodCancelamentoNFSe + TipoAmbiente)"New value: +"Tipo do documento fiscal a cancelar. Valores: 0 - NF-e, NFC-e, CT-e, MDF-e, DC-e, NFCom (usa ChaveNF de 44 dígitos); 1 - NFS-e (usa NumeroNFSe + CodCancelamentoNFSe + TipoAmbiente)"
  2. Changed1 schema field changed
    • changedOutput schema / properties / Base64Xml / description
      Previous value: -"XML do evento processado (procEventoNFe) em Base64. Preenchido apenas quando o evento e autorizado (cStat 135) e o documento e NF-e (modelo 55). Nulo nos demais casos."New value: +"XML do evento processado (procEventoNFe) em Base64. Preenchido quando o evento e autorizado (cStat 135) na Carta de Correcao da NF-e, na manifestacao do destinatario e no ECONF (NF-e e NFC-e). Nulo nos demais casos."
  3. Changed2 schema fields changed
    • addedOutput schema / properties / Base64File
      Added value: +{
      +  "description": "PDF do documento auxiliar do evento (ex.: Carta de Correcao) em Base64. Preenchido apenas quando o evento e autorizado e a nota existe na base. Nulo nos demais casos.",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • addedOutput schema / properties / Base64Xml
      Added value: +{
      +  "description": "XML do evento processado (procEventoNFe) em Base64. Preenchido apenas quando o evento e autorizado (cStat 135) e o documento e NF-e (modelo 55). Nulo nos demais casos.",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
  4. Changed12 schema fields changed
    • changedInput schema / properties / CpfCnpjRemetenteDCe / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • removedInput schema / properties / DataEvento / format
      Removed value: -"date-time"
    • changedInput schema / properties / DataEvento / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedInput schema / properties / NumeroNFSe / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedInput schema / properties / NumeroProtocolo / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedInput schema / properties / NumeroSequencial / type
      Previous value: -"integer"New value: +[
      +  "integer",
      +  "null"
      +]
    • changedOutput schema / properties / Avisos / type
      Previous value: -"array"New value: +[
      +  "array",
      +  "null"
      +]
    • changedOutput schema / properties / DsAmbiente / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedOutput schema / properties / DsEvento / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedOutput schema / properties / DsMotivo / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedOutput schema / properties / Error / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedOutput schema / properties / NuProtocolo / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
  5. First observed

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true and openWorldHint=true, so the bar is lower; the description still adds real value with the legal cancellation deadlines and the 15-character minimum justification, which materially constrain the attempt. It does not, however, describe failure behavior when the window has expired, whether the action is reversible, or what the cancellation event returns — though the output schema carries the return shape.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four short sentences, front-loaded with the action and the required inputs, then the NFS-e exception, then the deadlines. Every clause carries operational information; nothing is padding or restatement of the title.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter, destructive, deadline-bound cancellation across seven document families, the description covers the two input paths and the time windows that determine feasibility, and both the rich schema and the output schema handle the remaining detail. It stops short of mentioning the protocol requirement for externally issued documents, which is the one precondition an agent could trip over.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description restates the key constraints (44-digit key, 15-character justification) and summarizes the TipoDocumento=0 vs 1 branching, but adds no semantics absent from the schema — NumeroProtocolo's 'externally issued' condition and CpfCnpjRemetenteDCe are covered only in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource — 'Cancela um documento fiscal autorizado' — and enumerates exactly which document types qualify (NF-e, NFC-e, NFS-e, CT-e, MDF-e, DC-e, NFCom). This distinguishes it from siblings such as evento_carta_correcao, evento_inutilizar, and evento_manifestar without the agent needing to open any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete operational windows that define when the tool is usable: SEFAZ NF-e 24h after authorization (some UFs longer) and NFCom up to 120h after the last day of the authorization month. It also routes NFS-e callers to TipoDocumento=1 with NumeroNFSe instead of ChaveNF. The gap is that it never names a sibling alternative (e.g., inutilização for unused numbers), so exclusions are implied only through deadlines.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.