Skip to main content
Glama
prbretas

mcp-frete-tributario

by prbretas

mcp-frete-tributario

Servidor MCP (Model Context Protocol) para simulação e cálculo da carga tributária de frete durante o período de transição da Reforma Tributária brasileira (LC 214/2025 — 2026 a 2033).

Node.js TypeScript MCP SDK License: MIT


Sumário


Related MCP server: brazil-invoice-mcp

O que é este projeto

Este é um servidor MCP escrito em TypeScript que expõe quatro ferramentas de IA para calcular, consultar e simular o impacto tributário de operações de frete no Brasil durante a transição da Reforma Tributária (2026–2033).

Ele pode ser plugado a qualquer cliente MCP — Claude Desktop, Cursor, VS Code + Kiro, Amazon Q, ou qualquer agente que suporte o protocolo — e permite que um assistente de IA responda perguntas como:

  • "Qual será a carga tributária de um frete de R$ 5.000 de SP para RJ em 2029?"

  • "Como os tributos de frete mudam ao longo da transição?"

  • "Quanto a empresa com CNPJ 12.345.678/0001-95 paga de imposto no frete hoje?"


Contexto: Reforma Tributária e o Setor de Frete

A Lei Complementar 214/2025 institui o IBS (Imposto sobre Bens e Serviços) e a CBS (Contribuição sobre Bens e Serviços), que substituirão progressivamente ICMS, ISS, PIS e COFINS entre 2026 e 2033. Para o transporte de cargas, isso representa uma das maiores mudanças fiscais das últimas décadas:

Ano

ICMS

ISS

PIS

COFINS

IBS

CBS

2026

12,0%

2,0%

0,65%

3,00%

0,10%

0,10%

2027

12,0%

2,0%

0,65%

3,00%

0,10%

0,10%

2028

9,6%

1,6%

0,52%

2,40%

3,20%

2,40%

2029

7,2%

1,2%

0,39%

1,80%

6,40%

4,80%

2030

4,8%

0,8%

0,26%

1,20%

9,60%

7,20%

2031

2,4%

0,4%

0,13%

0,60%

12,80%

9,60%

2032

0,0%

0,0%

0,00%

0,00%

16,00%

12,00%

2033

0,0%

0,0%

0,00%

0,00%

16,00%

12,00%

Este servidor encapsula esse cronograma e permite que agentes de IA raciocinem sobre ele de forma estruturada.


Arquitetura

Cliente MCP (Claude Desktop / Cursor / Kiro)
        │  stdio (JSON-RPC)
        ▼
┌─────────────────────────────────────────────┐
│            mcp-frete-tributario             │
│                                             │
│  src/index.ts  ◄── bootstrap & validação   │
│       │                                     │
│  ┌────▼──────────────────────────────────┐  │
│  │            4 Tools MCP                │  │
│  │  calcular_carga_tributaria_frete      │  │
│  │  consultar_cronograma_transicao       │  │
│  │  simular_impacto_rota                 │  │
│  │  listar_empresas_cadastradas          │  │
│  └───────────────────┬───────────────────┘  │
│                      │                      │
│  ┌───────────────────▼───────────────────┐  │
│  │           Camada de dados             │  │
│  │  cronograma-reforma.json (alíquotas)  │  │
│  │  empresas.json (banco simulado)       │  │
│  └───────────────────┬───────────────────┘  │
│                      │                      │
│  ┌───────────────────▼───────────────────┐  │
│  │         Serviço externo               │  │
│  │  BrasilAPI — consulta CNPJ → UF       │  │
│  └───────────────────────────────────────┘  │
└─────────────────────────────────────────────┘

O servidor usa o transporte stdio do MCP SDK, o que significa que o cliente MCP o inicializa como subprocesso e se comunica via stdin/stdout com JSON-RPC 2.0.


Pré-requisitos

  • Node.js >= 20.0.0

  • npm >= 9.0.0


Instalação

git clone https://github.com/prbretas/mcp-transportation.git
cd mcp-transportation
npm install
npm run build

O script build compila o TypeScript para dist/ e copia os arquivos de dados para data/.


Como usar

1. Executar diretamente

npm start

O servidor ficará aguardando conexão via stdio. Normalmente você não o executa diretamente — ele é iniciado pelo cliente MCP.

2. Desenvolvimento com watch

npm run dev

Compila em modo watch. Reinicie o servidor manualmente após cada rebuild.

3. Verificação de tipos

npm run typecheck

Ferramentas MCP disponíveis

calcular_carga_tributaria_frete

Calcula a carga tributária completa de um frete para um ano específico da transição, comparando o novo regime (IBS + CBS) com o antigo (ICMS + PIS + COFINS).

Parâmetros:

Campo

Tipo

Obrigatório

Descrição

valorFrete

number

Valor do frete em BRL (deve ser > 0)

ufOrigem

string (2 chars)

UF de origem (ex: "SP")

ufDestino

string (2 chars)

UF de destino (ex: "RJ")

ano

number

Ano da transição (2026 a 2033)

ncm

string

Código NCM da mercadoria (futuro)

Exemplo de resposta:

{
  "aliquotaNominal": 0.20,
  "valorIBS": 1.00,
  "valorCBS": 1.00,
  "totalNovoRegime": 2.00,
  "valorICMS": 120.00,
  "valorPIS": 6.50,
  "valorCOFINS": 30.00,
  "totalAntigoRegime": 156.50
}

consultar_cronograma_transicao

Retorna as alíquotas de todos os tributos para um ano específico da transição, com totais calculados.

Parâmetros:

Campo

Tipo

Obrigatório

Descrição

ano

number

Ano da transição (2026 a 2033)

Exemplo de resposta:

{
  "ano": 2029,
  "icms": 7.2,
  "iss": 1.2,
  "pis": 0.39,
  "cofins": 1.80,
  "ibs": 6.40,
  "cbs": 4.80,
  "totalNovoRegime": 11.20,
  "totalAntigoRegime": 10.59
}

simular_impacto_rota

Simula o impacto tributário de uma rota de frete a partir dos CNPJs de origem e destino. As UFs são resolvidas automaticamente via BrasilAPI — nenhum dado de UF precisa ser informado manualmente.

Parâmetros:

Campo

Tipo

Obrigatório

Descrição

cnpjOrigem

string

CNPJ da empresa de origem (14 dígitos)

cnpjDestino

string

CNPJ da empresa de destino

valorFrete

number

Valor do frete em BRL

Exemplo de resposta:

{
  "ufOrigem": "SP",
  "ufDestino": "RJ",
  "razaoSocialOrigem": "Logística Paulista S.A.",
  "razaoSocialDestino": "Rio Frete e Logística Ltda",
  "anoCorrente": 2026,
  "aliquotaNominal": 0.20,
  "valorIBS": 10.00,
  "valorCBS": 10.00,
  "totalNovoRegime": 20.00,
  "valorICMS": 1200.00,
  "valorPIS": 65.00,
  "valorCOFINS": 300.00,
  "totalAntigoRegime": 1565.00
}

Nota: Esta ferramenta faz chamadas reais à BrasilAPI. CNPJs devem ser de empresas existentes e a API deve estar acessível.


listar_empresas_cadastradas

Lista todas as empresas no banco de dados simulado. Não recebe parâmetros.

Exemplo de resposta:

{
  "empresas": [
    {
      "razaoSocial": "Transportes Sul Ltda",
      "cnpj": "12345678000195",
      "uf": "RS",
      "valorUltimoFrete": 1850.00
    }
  ],
  "totalEmpresas": 7
}

Dados incluídos

cronograma-reforma.json

Tabela com as alíquotas reais de cada tributo para os anos de 2026 a 2033, baseada na LC 214/2025 e nas estimativas do Ministério da Fazenda.

empresas.json

Banco de dados simulado com 7 empresas transportadoras distribuídas pelos estados brasileiros (RS, SP, BA, MT, AM, MG, RJ), no mesmo formato do sistema SCTEC.


Testes

O projeto usa Vitest com testes unitários (example-based) e property-based tests com fast-check.

# Rodar todos os testes
npm test

# Modo watch
npm run test:watch

Cobertura de testes:

Arquivo

Testes unitários

Property-based

calcularCargaTributaria

consultarCronograma

simularImpactoRota

listarEmpresas

utils

index (bootstrap)


Configuração no cliente MCP

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "frete-tributario": {
      "command": "node",
      "args": ["/caminho/absoluto/para/mcp-transportation/dist/index.js"]
    }
  }
}

Kiro / Cursor (mcp.json)

{
  "mcpServers": {
    "frete-tributario": {
      "command": "node",
      "args": ["/caminho/absoluto/para/mcp-transportation/dist/index.js"]
    }
  }
}

Substitua /caminho/absoluto/para/mcp-transportation pelo caminho real no seu sistema. No Windows, use barras duplas ou barras normais: C:\\Users\\seu-usuario\\....


Estrutura de pastas

mcp-transportation/
├── src/
│   ├── index.ts                    # Bootstrap: carrega dados, registra tools, inicia servidor
│   ├── types.ts                    # Interfaces TypeScript compartilhadas
│   ├── utils.ts                    # halfUp() e UF_VALIDAS
│   ├── tools/
│   │   ├── calcularCargaTributaria.ts
│   │   ├── consultarCronograma.ts
│   │   ├── simularImpactoRota.ts
│   │   └── listarEmpresas.ts
│   ├── services/
│   │   └── brasilApiService.ts     # Integração com BrasilAPI (CNPJ → UF)
│   ├── data/
│   │   ├── cronograma-reforma.json
│   │   └── empresas.json
│   └── __tests__/
│       ├── fixtures/               # Dados de fixture para testes
│       ├── server/                 # Testes de bootstrap
│       └── tools/                  # Testes por ferramenta
├── data/                           # Cópia dos JSONs gerada pelo build (usada em runtime)
├── dist/                           # JavaScript compilado
├── package.json
├── tsconfig.json
├── vitest.config.ts
└── README.md

Contribuindo

  1. Fork o repositório

  2. Crie uma branch: git checkout -b feature/minha-feature

  3. Faça commit das mudanças: git commit -m "feat: descrição"

  4. Push para a branch: git push origin feature/minha-feature

  5. Abra um Pull Request


Origem do projeto

Este projeto foi desenvolvido como projeto de estudo durante uma aula sobre agentes de IA, com foco em Model Context Protocol (MCP), TypeScript, e aplicação real à Reforma Tributária brasileira. O domínio de negócio (tributação de frete, IBS/CBS, cronograma de transição) é diretamente relevante para sistemas TMS como o Protheus da TOTVS.


Documentação gerada em julho de 2026.

Available Tools

4 tools
calcular_carga_tributaria_freteA

Calcula a carga tributária de um frete para um ano da transição tributária (2026–2033), comparando novo regime (IBS/CBS) com antigo regime (ICMS/PIS/COFINS).

ParametersJSON Schema
NameRequiredDescriptionDefault
anoYes
ncmNo
ufOrigemYes
ufDestinoYes
valorFreteYes

TDQS

A3.5/5.0
Behavior3/5

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

No annotations are provided, so the description carries the transparency burden. It states the calculation and comparison but does not disclose behavioral details such as idempotency, data persistence, authentication requirements, or rate limits. The description is not contradictory but lacks depth.

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?

A single sentence that is direct and front-loaded with the core action. No redundant words. Every part contributes to the purpose.

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

Completeness2/5

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

Given 5 parameters, no output schema, and no annotations, the description is too brief. It does not specify the return format (e.g., numeric value, comparison table), nor does it explain how input parameters like UF or NCM affect the calculation. The tool's complexity demands more context.

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 description coverage is 0%, yet the description only mentions 'ano' and the regime comparison. It does not explain 'valorFrete', 'ufOrigem', 'ufDestino', or the optional 'ncm' parameter. The description adds minimal semantic value beyond the parameter names.

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 calculates the tax burden of freight, specifying the year range (2026–2033) and the comparison between new and old tax regimes. It distinguishes from sibling tools by focusing on freight tax calculation, not schedules, company lists, or route simulations.

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 use for freight tax calculation but does not explicitly mention when to use this tool versus the siblings or provide exclusion criteria. No guidance on prerequisites or alternatives.

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

consultar_cronograma_transicaoA

Consulta os percentuais de cada tributo (ICMS, ISS, PIS, COFINS, IBS, CBS) para um determinado ano da Reforma Tributária (2026–2033).

ParametersJSON Schema
NameRequiredDescriptionDefault
anoYes

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description must carry the burden. It discloses that the tool consults percentages for listed taxes and the year range, but doesn't mention error handling, authentication, or side effects. Adequate for a simple read operation but lacks depth.

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 a single sentence that is clear and to the point. Every word adds value, with no unnecessary 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?

Given the tool's simplicity (one parameter, no output schema), the description is fairly complete. It states what is returned (percentages of each tax) and the valid year range. However, it could mention behavior for invalid years or return format.

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?

The input schema has zero description coverage for the 'ano' parameter. The description adds meaning by specifying that it is for a year in the 2026–2033 range and that it is part of the 'Reforma Tributária'. This is helpful context 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 uses the specific verb 'Consulta' and identifies the resource as 'percentuais de cada tributo (ICMS, ISS, PIS, COFINS, IBS, CBS)'. It clearly distinguishes this tool from siblings (e.g., calcular_carga_tributaria_frete) by focusing on querying the transition schedule for a given year.

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 usage for a year between 2026–2033 and focuses on tax percentages, but does not explicitly state when to use this tool over alternatives or provide exclusions. No guidance on prerequisites or context.

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

listar_empresas_cadastradasA

Lista todas as empresas cadastradas no banco simulado, retornando dados de CNPJ, UF e último frete.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It specifies the return fields (CNPJ, UF, último frete) but omits details like authentication requirements, performance characteristics, or what happens if no companies exist. The description is adequate but not fully transparent.

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 a single sentence that is front-loaded with the action and resource, followed by output details. Every word contributes meaning without redundancy.

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 simple list operation with no parameters and no output schema, the description provides sufficient context: what it lists and what data it returns. However, it lacks details on potential ordering or pagination, which would improve completeness.

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?

There are no parameters (schema coverage 100%), so the baseline is 4. The description adds value by specifying the fields returned, which compensates for the lack of an output 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 action (listar todas as empresas), the resource (empresas cadastradas), and the specific data returned (CNPJ, UF, último frete). This distinguishes it from sibling tools which deal with tax, timelines, and route simulation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, nor any mention of prerequisites or limitations. It simply states what it does without contextual usage advice.

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

simular_impacto_rotaC

Simula o impacto tributário de uma rota de frete informando os CNPJs de origem e destino — as UFs são resolvidas automaticamente via BrasilAPI.

ParametersJSON Schema
NameRequiredDescriptionDefault
cnpjOrigemYes
valorFreteYes
cnpjDestinoYes

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations, the description carries full burden. It reveals one behavioral trait: UFs are resolved automatically via BrasilAPI. However, it does not disclose whether the tool is read-only, destructive, or if it has rate limits, error behavior, or prerequisites like CNPJ validity. This is insufficient for an agent to safely invoke the tool.

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?

Description is a single sentence – concise and front-loaded. No superfluous words. However, it could afford to be slightly longer to cover parameter details and usage guidance without losing conciseness.

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

Completeness2/5

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

Given no output schema or annotations, and a moderately complex tool (external API call, tax impact calculation), the description is incomplete. It does not explain output structure, error handling, or what 'impacto tributário' means operationally. The agent lacks key information for correct invocation and result interpretation.

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 has 0% description coverage, so description must compensate. It mentions CNPJs and implicitly valorFrete but does not explain CNPJ format (14 digits), that valorFrete can be number or string with decimal, or that the tool automatically resolves UFs (already stated). The added value beyond schema is minimal.

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 simulates tax impact of a freight route using origin/destination CNPJs. The verb 'simula' and resource 'rota de frete' are specific. However, it does not differentiate from sibling tools like 'calcular_carga_tributaria_frete', leaving ambiguity about when to choose this one.

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 implies use for tax impact simulation given CNPJs and freight value. It provides no explicit guidance on when not to use this tool or alternatives (e.g., 'calcular_carga_tributaria_frete' for different scenarios). Usage context is implied but not fully clarified.

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

TDQS

A3.7/5.0
Disambiguation5/5

Each tool targets a distinct operation (calculate, consult, list, simulate) with no overlap. Clear differentiation.

Naming Consistency5/5

All tools follow a consistent verb_noun pattern in Portuguese (e.g., calcular_carga, consultar_cronograma), making it predictable.

Tool Count5/5

Four tools is appropriate for the niche domain of freight tax transition simulation, covering essential operations without bloat.

Completeness4/5

Covers core workflows: calculation, schedule lookup, company listing, and route simulation. Minor gap: no tool to add/update companies, but core functionality is complete.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP Server for accessing 36 Brazilian public data sources and 1 agent, enabling AI agents to query government data on economy, legislation, transparency, judiciary, elections, environment, health, and more.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    MCP server that lets AI agents issue Brazilian NFS-e service invoices via Focus NFe, with tools for creating, querying, and canceling invoices.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    MCP server that exposes Brazilian tax infrastructure as tools, resources, and prompts, enabling AI agents to emit and manage fiscal documents (NF-e, NFC-e, NFS-e, CT-e, MDF-e, DC-e) through natural language.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/prbretas/mcp-transportation'

If you have feedback or need assistance with the MCP directory API, please join our Discord server