Skip to main content
Glama

explain_rejection

Read-onlyIdempotent

Explain why a rejected document was refused and what to change.

get_invoice_submissions has the authority's reply as sent; this reads it for someone who does not speak SEFAZ: the code, the message verbatim, what it means, the steps to fix it, the field at fault and, when there is one, a suggested value. Quote the code and the message to the user; they are what they will search for. A suggested value is confirmed with the user before reissue_invoice, never applied on its own.

transient means the authority was unavailable, not the data wrong. A document that is not rejected is refused (409). Read-only.

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": {
      "invoice_id": "<invoice_id>"
    },
    "name": "explain_rejection"
  }
}

Input Schema

NameRequiredDescriptionDefault
company_idNoUUID of the company acted for. Omit for a single company; else see list_authorized_companies. Send one, never both.
invoice_idYesThe local id of the rejected invoice, as list_invoices returns it. A rejected document has no access key.
company_tax_idNoCNPJ or CPF of the company acted for, never the recipient or a taxpayer looked up. Omit for a single company; else see list_authorized_companies. Send one, never both.

Output Schema

NameRequiredDescriptionDefault
codeNoThe authority's own rejection code.
fieldNoThe field to fix, when there is one.
stepsNoWhat to change, in order.
sourceNocatalogue (known code), official_rule (the authority's published rule) or authority (its message only).
statusNoknown (from the catalogue of rejection codes), generated (written for this case) or unknown.
actionsNoedit, retry, resend, company or certificate.
messageNoThe authority's message, verbatim.
relatedNoThe authorized document holding the same number, on a duplicate-number rejection.
authorityNo
suggestedNoA value for that field, when one can be suggested. Confirm it with the user before reissuing.
transientNoTrue when the authority was unavailable rather than the data wrong: reissuing unchanged may work.
comparisonNoSent versus related, per field.
invoice_idNo
explanationNoWhat it means, in plain words.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changed
    • addedOutput schema / $defs
      Added value: +{
      +  "ComparisonRow": {
      +    "additionalProperties": true,
      +    "description": "One field of the sent document beside the related one.",
      +    "properties": {
      +      "differs": {
      +        "anyOf": [
      +          {
      +            "type": "boolean"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "field": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "related": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "sent": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      }
      +    },
      +    "type": "object"
      +  },
      +  "RelatedDocument": {
      +    "additionalProperties": true,
      +    "description": "An authorized document the rejection points at.",
      +    "properties": {
      +      "access_key": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "amount": {
      +        "anyOf": [
      +          {
      +            "type": "number"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "client_name": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "id": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "issued_at": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "status": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      },
      +      "tax_id": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null
      +      }
      +    },
      +    "type": "object"
      +  }
      +}
    • addedOutput schema / properties / actions
      Added value: +{
      +  "description": "edit, retry, resend, company or certificate.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / comparison
      Added value: +{
      +  "description": "Sent versus related, per field.",
      +  "items": {
      +    "$ref": "#/$defs/ComparisonRow"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / related
      Added value: +{
      +  "anyOf": [
      +    {
      +      "$ref": "#/$defs/RelatedDocument"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "The authorized document holding the same number, on a duplicate-number rejection."
      +}
    • addedOutput schema / properties / source
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "catalogue (known code), official_rule (the authority's published rule) or authority (its message only)."
      +}
  2. Changed2 schema fields changed
    • changedInput schema / properties / company_id / description
      Previous value: -"UUID of the company acted for. Omit it if the connection covers a single company; else see list_authorized_companies. company_id or company_tax_id, never both."New value: +"UUID of the company acted for. Omit for a single company; else see list_authorized_companies. Send one, never both."
    • changedInput schema / properties / company_tax_id / description
      Previous value: -"CNPJ or CPF of the company acted for, never the recipient or a taxpayer looked up. Omit it if the connection covers a single company; else see list_authorized_companies. company_id or company_tax_id, never both."New value: +"CNPJ or CPF of the company acted for, never the recipient or a taxpayer looked up. Omit for a single company; else see list_authorized_companies. Send one, never both."
  3. Changed2 schema fields changed
    • changedInput schema / properties / company_id / description
      Previous value: -"UUID of the company this call acts for. Omit it when the connection covers a single company; with several it is required (see list_authorized_companies). Send company_id or company_tax_id, never both."New value: +"UUID of the company acted for. Omit it if the connection covers a single company; else see list_authorized_companies. company_id or company_tax_id, never both."
    • changedInput schema / properties / company_tax_id / description
      Previous value: -"CNPJ or CPF of the company this call acts for, never the recipient or a taxpayer being looked up. Omit it when the connection covers a single company; with several it is required (see list_authorized_companies). Send company_id or company_tax_id, never both."New value: +"CNPJ or CPF of the company acted for, never the recipient or a taxpayer looked up. Omit it if the connection covers a single company; else see list_authorized_companies. company_id or company_tax_id, never both."
  4. Added

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and closed-world scope, so the bar is lower, yet the description still adds real behavior: what the response contains (code, verbatim message, meaning, remediation steps, faulting field, optional suggested value), how to use it (quote code and message to the user), and a hard safety constraint that a suggested value is confirmed with the user before reissue_invoice and never auto-applied. It also disambiguates "transient" as authority unavailability rather than bad data, which prevents a wrong remediation path.

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?

Front-loaded with the purpose, then the sibling contrast, then the return contents, then the operating rules. Every sentence carries distinct information an agent needs; nothing restates the name, annotations, or schema.

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

Completeness5/5

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

An output schema exists, so return values need not be spelled out, yet the description still characterizes the payload and its intended use. Combined with a fully documented 3-parameter schema and safety annotations, an agent has everything needed to call it correctly and act on the result.

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 the schema already explains company_id/company_tax_id selection rules and that invoice_id is the local id from list_invoices with no access key. The description adds no parameter-level meaning beyond that, 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?

"Explain why a rejected document was refused and what to change" names a specific verb (explain) and a specific resource (a rejected document's refusal), and the second sentence explicitly contrasts it with get_invoice_submissions, which holds the raw authority reply. An agent can distinguish the two 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 Guidelines5/5

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

It routes the agent explicitly: use get_invoice_submissions for the reply as sent, use this tool to interpret it for someone who does not speak SEFAZ. It also states the precondition that a non-rejected document is refused with 409, so the agent knows the failure mode rather than misreading it as an error.

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.