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). 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).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ChaveNFYesChave 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.
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 (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

TableJSON 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 apenas quando o evento e autorizado (cStat 135) e o documento e NF-e (modelo 55). 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
    • 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"
      +  ]
      +}
  2. 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"
      +]
  3. First observed

TDQS

A3.9/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false, and openWorldHint=true, so the irreversible write nature is covered structurally. The description adds the genuinely useful SEFAZ 24h post-authorization window, but says nothing about permissions, idempotency, or what happens if the window has passed.

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

Conciseness4/5

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

Four dense sentences, front-loaded with the action and its supported document types, with no filler. Slightly crowded by packing the NFS-e branch and the SEFAZ deadline into the same block, but every sentence carries operational information.

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?

With an output schema present, return values need no explanation, and the description covers document routing, required inputs, and the critical time constraint. Missing only ancillary context such as authorization requirements or consequences of cancellation after the deadline.

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% and every parameter is already documented in detail, including the cross-parameter branching for TipoDocumento. The description largely restates that routing logic (TipoDocumento=1 → NumeroNFSe, otherwise chave) rather than adding syntax or format detail beyond 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?

States a specific verb (Cancela) and resource (documento fiscal autorizado), and enumerates the exact document types covered (NF-e, NFC-e, NFS-e, CT-e, MDF-e, DC-e). This clearly separates it from siblings like evento_inutilizar and evento_carta_correcao, which act on unused numbers or corrections rather than authorized documents.

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 invocation conditions: supply the 44-digit chave plus a justification of at least 15 characters, and use TipoDocumento=1 with NumeroNFSe for NFS-e. It also flags the real-world SEFAZ 24-hour deadline that gates whether the call can succeed, though it never explicitly contrasts itself with sibling event tools.

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.