Skip to main content
Glama
fidsouzarv

mcp-nfs-emissor

by fidsouzarv

mcp-nfs-emissor

Servidor MCP (Desktop Extension .mcpb) que emite NFS-e de comissão de afiliado da Shopee a partir do CSV mensal. Roda 100% local via stdio — o CSV, o certificado A1 e a emissão nunca saem da máquina.

Estado atual: scaffold. Estrutura, configs, servidor MCP e testes estão de pé; a tool listar_saidas é funcional e as outras 6 são stubs (isError). A lógica de negócio (parse/agregação/emissão) e os providers reais chegam nas próximas fases — ver docs/plugin-claude-mvp/.

Requisitos

  • Node.js >= 18 (testado no 24)

  • pnpm

Related MCP server: mcp-nfse-nacional

Scripts

pnpm install       # instala dependências
pnpm dev           # roda o servidor em dev (tsx), stdio
pnpm build         # compila para dist/ (entry_point do .mcpb = dist/server.js)
pnpm typecheck     # checagem de tipos sem emitir
pnpm test          # testes de integração (vitest, transporte in-memory)

Tools (catálogo — fase-2 §5)

Tool

Estado

configurar_prestador

stub

carregar_csv

stub

previsualizar_emissao

stub

emitir_nfse

stub

consultar_status

stub

reprocessar_falhas

stub

listar_saidas

funcional

Documentação

  • Fonte de verdade do plugin: docs/plugin-claude-mvp/ (fases 1–4 + decisões).

  • Plano do scaffold: docs/emissores-nf/plan-scaffold-mcp-01.md.

  • Contexto fiscal e mapeamento do CSV: docs/emissores-nf/.

Segurança

Segredos (token do provedor, senha do .pfx) chegam por user_config → env, guardados no Keychain/Credential Manager do SO. O .pfx fica fora do bundle (referenciado por caminho). Nada de segredo é versionado — ver .gitignore e .env.example.

Licença

MIT

Available Tools

7 tools
carregar_csvCarregar CSVA
Read-only

Lê um CSV mensal da Shopee (respeitando aspas no campo Endereço do Vendedor), filtra pedidos com Status válido {Pendente, Concluído} e comissão ≠ 0, e AGREGA por ID da Loja somando a comissão. Retorna a lista de vendedores (uma futura NFS-e por loja) e as contagens do funil. NÃO emite nada.

ParametersJSON Schema
NameRequiredDescriptionDefault
competenciaNoCompetência AAAA-MM (opcional).
caminhoArquivoYesCaminho do .csv em entradas/.

TDQS

A3.9/5.0
Behavior4/5

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

Annotations declare readOnlyHint=true, and the description confirms no emission, adding that it respects quotes in the address field, filters by status and commission, and aggregates. This provides useful behavioral context beyond the annotations, though it does not cover error conditions or file format details.

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?

The description is concise (two sentences) and front-loaded with the main action. It packs essential details without wordiness. Minor improvement could be clearer separation of input/output, but overall efficient.

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?

Given the tool's complexity and the presence of full schema coverage and no output schema, the description covers the primary behavior, processing logic, and return values. It could mention error handling or format validation, but for a read-only data loading tool, it is sufficiently complete.

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% with descriptions for both parameters. The tool description does not add significant meaning beyond the schema; it mentions the month concept but does not directly link to the 'competencia' parameter. Baseline of 3 is appropriate.

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?

The description clearly states the tool reads a monthly CSV from Shopee, applies specific filters (valid status and non-zero commission), aggregates by store ID, and returns the list of sellers and funnel counts. It explicitly distinguishes itself from siblings by emphasizing it does not emit anything, making its purpose clear and unique among the sibling tools.

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

Usage Guidelines3/5

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

The description implies the tool is used to load CSV data before emission, but it does not explicitly state when to use it versus alternatives, nor does it provide exclusions. The context from sibling tools helps, but the description itself lacks direct guidance on usage scenarios.

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

configurar_prestadorConfigurar prestadorA

Grava os dados fixos do afiliado (prestador/emitente) em config/prestador.json para reutilizar nas emissões. Use antes da primeira emissão ou para corrigir CNPJ/IM/LC116/ISS. O emitente é exclusivamente PJ (CNPJ 14 dígitos; CPF é recusado). Nunca grava token nem senha.

ParametersJSON Schema
NameRequiredDescriptionDefault
cnpjYesCNPJ do prestador, 14 dígitos, sem máscara. SÓ CNPJ (PJ).
aliquotaIssNoAlíquota ISS (%).
codigoLC116NoCódigo de serviço LC 116 (ex.: 17.06 — promoção de vendas).17.06
razaoSocialNo
municipioIbgeYesCódigo IBGE (7 dígitos) do município de emissão do afiliado.
regimeTributarioNo
inscricaoMunicipalYesInscrição Municipal (cadastrar sem formatação; pode ter letras).

TDQS

A4.6/5.0
Behavior5/5

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

The description discloses that the tool writes to a specific file, does not save tokens or passwords, and that the emitter must be a legal entity (CNPJ) with CPF rejected. These details go beyond the annotations (readOnlyHint=false) to add safety and constraint context.

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?

The description is two sentences, front-loading the purpose and usage. Every sentence adds distinct information without redundancy: first sentence states the action and location, second provides usage timing and limitations.

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 configuration tool with 7 parameters (3 required) and no output schema, the description covers main purpose, timing, and a critical safety note (no token/password). It lacks details on error handling or prerequisites but overall provides sufficient context.

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

Parameters4/5

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

With schema coverage at 71%, the description adds value by reinforcing that CNPJ must be 14 digits and exclusively for legal entities, and that CPF is refused. This enriches the schema's parameter descriptions. Remaining parameters are adequately covered by 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?

The description clearly states the tool saves fixed data of the affiliate to config/prestador.json for reuse in emissions. It specifies the verb 'Grava' and the resource 'dados fixos do afiliado'. It distinguishes from siblings by its focus on configuration before emission.

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?

The description explicitly advises 'Use antes da primeira emissão ou para corrigir CNPJ/IM/LC116/ISS', providing clear context for when to use. It does not explicitly mention when not to use, but the sibling tools cover different operations, making it implicit.

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

consultar_statusConsultar statusB
Read-only

Consulta no provedor o status atual das notas de uma competência (útil quando a emissão é assíncrona: processando → autorizada/rejeitada). Atualiza o resumo.csv.

ParametersJSON Schema
NameRequiredDescriptionDefault
idLojaNoConsulta apenas esta loja.
protocoloNoConsulta por protocolo específico.
competenciaYes

TDQS

B3.3/5.0
Behavior3/5

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

Description adds that it updates 'resumo.csv', which is a side effect beyond the readOnlyHint annotation. This provides useful behavioral context, but the contradiction with the annotation reduces confidence.

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?

Two sentences, front-loaded with purpose, concise with no unnecessary words.

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

Completeness3/5

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

Description states purpose and a side effect, but lacks explanation of output format or how to interpret results, which is expected for a query tool without output schema.

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

Parameters2/5

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

Schema covers 2 of 3 parameters with descriptions, but the required 'competencia' has only a pattern. Description mentions 'competência' but does not explain its meaning (e.g., month/year format) or elaborate on optional parameters.

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

Purpose4/5

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

Description clearly states it queries the provider for current status of invoices for a competency, and gives context about async emission. It distinguishes from sibling tools implicitly by focusing on status checking, but does not explicitly differentiate.

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

Usage Guidelines3/5

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

Description indicates usefulness when emission is asynchronous, providing state transition example. However, it does not specify when not to use or list alternatives.

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

emitir_nfseEmitir NFS-eA
Idempotent

Emite as NFS-e da competência (uma por loja) chamando o provedor. Exige confirmar: true. Respeita o modo (dry-run não envia; sandbox usa mock; producao emite de verdade e exige certificado A1, mas só via configuração do host). Idempotente por (idLoja + competência): não reemite quem já foi autorizada. Processa em BLOCOS e retorna progresso; salva PDFs/XMLs e atualiza o resumo.csv.

ParametersJSON Schema
NameRequiredDescriptionDefault
modoNoSobrepõe NFS_MODO apenas para dry-run/sandbox. Produção NUNCA vem por argumento — só do host.
offsetNoRetoma a partir do índice N.
confirmarYesTrava de segurança: precisa ser true para prosseguir.
apenasLojasNoRestringe a emissão a estes IDs de loja.
competenciaYes
tamanhoBlocoNoNotas por chamada (default ~100).

TDQS

A4.6/5.0
Behavior5/5

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

Annotated with openWorldHint and idempotentHint. Description adds significant context: confirmation requirement, mode effects (mock in sandbox, certificate in production), idempotency key, block processing, side effects (saves PDFs/XMLs, updates CSV). No contradictions with annotations.

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 dense sentences covering purpose, behavior, and key constraints. No redundancy; every sentence adds value.

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?

Covers emission, modes, idempotency, block processing, and side effects. Mentions return progress but lacks detailed output structure. Without output schema, this is a minor gap; overall sufficient for a complex tool.

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

Parameters4/5

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

Schema covers 5 of 6 parameters (competencia missing description). Description adds meaning: confirmar as safety lock, modo override constraints, offset resume, apenasLojas restriction, tamanhoBloco default. Complements schema well.

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?

Description clearly states the purpose: emit NFS-e for a given period (competência) per store. It differentiates from sibling tools like preview or status, and specifies the verb 'emite' and resource 'NFS-e'.

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?

Provides guidance on when to use (actual emission), required confirmation flag, mode behaviors (dry-run, sandbox, production), idempotency, and block processing. However, explicit contrast with preview tool could be stronger.

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

listar_saidasListar saídasA
Read-only

Lista as competências (pastas AAAA-MM) já processadas em saidas/ e quantas notas cada uma tem. Read-only; use para ver o histórico antes de reprocessar.

ParametersJSON Schema
NameRequiredDescriptionDefault
competenciaNoFiltra por competência AAAA-MM; vazio lista todas

Output Schema

ParametersJSON Schema
NameRequiredDescription
competenciasYes

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true. The description adds behavioral details: it lists competências and note counts, mentions the directory 'saidas/', and implies no side effects. No contradictions.

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?

Two sentences: first describes what the tool does, second gives usage guidance and safety. Efficient and front-loaded, every word serves a purpose.

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?

Given the tool's simplicity (1 optional param, read-only, has output schema), the description fully covers purpose, usage, and behavior. No gaps.

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

Parameters4/5

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

Schema coverage is 100% with a clear pattern and description. The description adds context by mentioning 'processadas em saidas/' and the format 'AAAA-MM', which goes beyond the schema's description. It also implies 'vazio lista todas' without restating it.

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?

The description clearly states the verb 'Lista' (lists), the resource 'competências (pastas AAAA-MM) já processadas em saidas/', and the result 'quantas notas cada uma tem'. It distinguishes itself from sibling tools by specifying its read-only nature and use case before reprocessing.

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?

Explicitly says 'use para ver o histórico antes de reprocessar', providing clear when-to-use guidance. It also states 'Read-only' implying safe usage. While it doesn't explicitly list when not to use, the context is sufficient given the sibling tools.

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

previsualizar_emissaoPrevisualizar emissãoA
Read-only

DRY-RUN: monta a tabela do que SERÁ emitido (tomador, valor, discriminação, código de serviço) para a competência já carregada, sem enviar ao provedor. Use para o usuário conferir e confirmar antes de emitir.

ParametersJSON Schema
NameRequiredDescriptionDefault
limiteNoLimita a quantidade de linhas retornadas.
competenciaYesCompetência AAAA-MM já carregada.

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already indicate readOnlyHint=true. The description adds behavioral context: it only works for a competência that has been loaded ('já carregada'), and it does not send data to the provider. No contradictions found.

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?

The description is two sentences, front-loaded with 'DRY-RUN' for immediate clarity. Every sentence adds value: first states what it does, second states when to use it. No filler.

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?

Given no output schema, the description lists key return fields (tomador, valor, discriminação, código de serviço). It mentions the prerequisite of an already loaded competência. The limite parameter is covered by the schema. Some may want pagination details, but overall sufficient for a preview tool.

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%, with both competencia and limite having descriptions. The description adds context that competencia must be 'já carregada', but this is implicit from the schema's description. No additional parameter details 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?

The description clearly states the tool performs a dry-run, assembling a table of what will be issued (tomador, valor, discriminação, código de serviço) for a given competência, without sending to the provider. This distinguishes it clearly from sibling tools like emitir_nfse (actual emission) and consultar_status.

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?

The description explicitly says 'Use para o usuário conferir e confirmar antes de emitir,' indicating the primary use case is before issuance. It also notes it's a dry-run without sending to provider. However, it does not explicitly state when not to use it or provide alternatives, so it's slightly below maximum.

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

reprocessar_falhasReprocessar falhasA
Idempotent

Reemite APENAS as notas com status rejeitada/erro da competência, reaproveitando os dados já carregados. Exige confirmar: true. Também processa em blocos. Para rejeitada, corrija a causa (config/LC116/alíquota) antes.

ParametersJSON Schema
NameRequiredDescriptionDefault
confirmarYesTrava de segurança: precisa ser true para prosseguir.
competenciaYes
tamanhoBlocoNo

TDQS

A4.1/5.0
Behavior4/5

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

Description adds behavioral context beyond annotations: requires confirm=true, processes in blocks, and suggests pre-correction for rejected notes. Annotations already indicate mutation (readOnlyHint=false) and idempotency (idempotentHint=true), which aligns. Minor gap: not stating what happens if confirmar is false.

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?

Two sentences, front-loaded with main purpose, uses emphasis appropriately. Every sentence adds value with no waste.

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

Completeness3/5

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

Given 3 parameters and no output schema, the description covers basic operation but leaves gaps: não explica o parâmetro 'tamanhoBloco' nem o comportamento de 'processa em blocos' em detalhes. Could be more explicit about return or side effects.

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 33% (only confirmar has a description). The description adds that confirmar must be true and hints at block processing for tamanhoBloco, but does not clarify competencia or tamanhoBloco defaults/values. Marginal improvement over 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?

The description clearly states it reissues only notes with rejected/error status from the period, reusing loaded data. This is specific and differentiates from siblings like emitir_nfse (emission) or carregar_csv (loading).

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?

The description explicitly says when to use: only for notes with rejected/error status, and advises to correct the cause for rejected notes before calling. It does not explicitly name alternatives but implies not to use for other statuses.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 7 tool updatesv0.1.0
    • First observedcarregar_csv
    • First observedconfigurar_prestador
    • First observedconsultar_status
    • First observedemitir_nfse
    • First observedlistar_saidas
    • First observedprevisualizar_emissao
    • First observedreprocessar_falhas

TDQS

A4.1/5.0

Scored across 7 tools

Disambiguation5/5

Each tool addresses a distinct step in the NFS-e emission workflow: configuration, CSV loading, dry-run preview, actual emission, status checking, reprocessing failures, and listing historical outputs. There is no functional overlap.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in Portuguese (e.g., configurar_prestador, carregar_csv), using lowercase with underscores throughout. No naming style conflicts are present.

Tool Count5/5

With 7 tools, the server covers all essential phases of batch NFS-e generation from setup to post-processing. The count is neither sparse nor excessive for the domain.

Completeness4/5

The tool set covers the core workflow (config, load, preview, emit, check status, reprocess failures, list history). A minor gap is the lack of a tool for individual note viewing or manual adjustment, but the overall lifecycle is well-supported.

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Model Context Protocol (MCP) server for Brazilian Electronic Invoicing (NF-e / NFC-e, modelo 55/65, schema 4.00). Provides CPF/CNPJ validation tools, with NF-e/NFC-e generation and SEFAZ integration planned.
    22
    Apache 2.0
  • A
    license
    A
    quality
    D
    maintenance
    MCP server for querying Brazilian electronic service invoices (NFSe) from the national portal. Allows AI agents to authenticate with digital certificates and search, detail, and download PDFs of issued NFSe.
    3
    42 npm
    16
    ISC
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables consulting Brazilian electronic invoices (NFE) from official Receita Federal sources through a read-only MCP tool.
    MIT