Skip to main content
Glama

Encerrar MDF-e

mdfe_encerrar
Destructive

Encerra um MDF-e já autorizado (evento tipo 3). Obrigatório ao final de cada transporte. Sem encerramento, novos MDF-e podem ser bloqueados pela SEFAZ.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chaveYesChave de acesso de 44 dígitos do MDF-e a encerrar.
protocoloNoProtocolo de autorização do MDF-e original. Opcional - se omitido, o sistema localiza pela chave.
tipoAmbienteYesAmbiente do MDF-e original (DEVE bater com o ambiente onde o manifesto foi emitido). IMPORTANTE: passe explicitamente. ATENÇÃO: encerramento é DEFINITIVO - revise os dados antes. Valores: 1 - Produção; 2 - Homologação
numeroSequencialNoNúmero sequencial do evento. Se omitido, o sistema usa o próximo disponível.

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. Changed8 schema fields changed
    • changedInput schema / properties / numeroSequencial / type
      Previous value: -"integer"New value: +[
      +  "integer",
      +  "null"
      +]
    • changedInput schema / properties / protocolo / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "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

A4.2/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and openWorldHint=true, so the safety profile is covered. The description adds regulatory consequence (new manifests blocked by SEFAZ without closure), which is real context beyond the annotations, though it does not itself restate irreversibility.

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?

Three short sentences, each earning its place: what it does, when it is required, and the consequence of skipping it. The purpose is front-loaded.

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 and rich annotations, the description need not explain returns or safety. It covers purpose, obligation, and consequence adequately, though it says nothing about error/duplicate-closure behavior for an operation the schema calls definitive.

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 coverage is 100% and the enum/default for tipoAmbiente plus the optional protocolo fallback are all documented in the schema itself. The description adds no parameter-level syntax or format detail, so the baseline of 3 applies.

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+resource ('Encerra um MDF-e já autorizado') and pins the domain event type ('evento tipo 3'), which separates it from mdfe_emitir and evento_cancelar without opening either 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 clear when-to-use context: it is mandatory at the end of every transport, and omitting it can cause SEFAZ to block new MDF-e. It stops short of naming a sibling alternative or an explicit when-not-to-use case.

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.