conformidade-pbtr-mcp
Automated compliance analysis of Brazilian Projetos Básicos (PB) and Termos de Referência (TR) against the SERPRO checklist, with reporting and text review.
Analyze PB/TR documents (PDF, DOCX, MD, TXT) for normative checklist compliance, numbering issues, table arithmetic, and value consistency.
Run a deterministic review for common writing errors and get segmented text for manual Portuguese revision.
Register human review notes; only literal matched excerpts are accepted, preventing hallucinated findings.
Generate compliance reports in JSON, Markdown, DOCX, XLSX, and PDF, including a weighted conformity index.
Inspect specific aspects independently: numbering, tables/pricing, spelling rules, document structure extraction, or checklist rules.
Re-render an existing analysis into another report format without reprocessing the document.
Support local file paths or base64 content/remote hosting, with configurable output directories and alternate checklists.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@conformidade-pbtr-mcp analyze this PDF for compliance and generate the reports"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
conformidade-pbtr-mcp
Automated compliance analysis of Basic Projects and Terms of Reference (MCP server, pt-BR).
An MCP server that analyzes Basic Projects (PB) and Terms of Reference (TR) against the SERPRO review roadmap. You upload the PDF and say "run a compliance analysis of the PB"; the server returns the compliance index, prioritized pending items, and the reports in DOCX, XLSX, PDF, Markdown, and JSON.
A project by SERPRO — Brazil's Federal Data Processing Service.
What is checked
Layer | Check |
Regulatory checklist | 86 rules derived from the |
Numbering | jumps (1 → 3), duplicate items, orphaned sub-items, items out of order, missing required sections |
Tables and values | minimum columns, |
Text review | 20 deterministic rules for recurring errors in administrative documents, plus the Portuguese review performed by the model that calls the MCP |
The checklist rules are conditional. The server infers the procurement context — bidding, direct contracting, non-competitive contracting, service, good, consulting, training, tickets, subscription, RP, hardware/currency, term longer than 60 months — and applies only the relevant branches of the roadmap. The rest are shown as Not applicable, with the reason explained. Without it, a hardware PB would flood its dozens of false "not compliant" warnings for not carrying the mandatory consulting requirements.
Five statuses, not two
Conforming / non-conforming would not be enough: several roadmap items require human heuristic judgment ("check whether there is coherence between them"). The report therefore uses:
Status | Meaning |
Compliant | evidence located in the document |
Non-compliant | no occurrence located |
Attention | a point was addressed, but incomplete — the list of what's missing comes with it |
Verify manually | evidence present; the merits require a human |
Not applicable | the document context does not trigger the rule |
Related MCP server: Tri-Tender Pricing MCP
How the Portuguese review works
The text is reviewed by the model that called the MCP — it already has the document in context, so it doesn't make sense for the server to open a second conversation with another model just to re-read the same text. The server handles deterministic mapping and returns the segmented text for the agent to read.
That's why the flow is three steps, which the agent can chain itself:
1. analisar_conformidade → checklist, numeração, tabelas, valores
(+ regras determinísticas de revisão)
2. obter_texto_para_revisao → o agente lê e revisa o português
3. registrar_revisao_textual → apontamentos entram e os relatórios saemEach agent finding only enters the report if the quoted excerpt literally exists in the document. The check is done against the extracted text, tolerating differences in spacing and quotes. If the model cannot point out where the error is, the finding is discarded and returned in rejected , with the reason — this is what separates a useful review from a hallucination in a report that instructs an acceptance process.
Every finding cites the PB/TR item ("item 6.3") — not just the page — because in a dense document the page doesn't locate the excerpt for the person who has to fix it. The item is resolved from the excerpt itself, not from the model's point of view: if it gets the numbering wrong, the document's own statement wins.
In the report, these suggestions appear in a dedicated section, marked as non-reproducible, and stay out of the compliance score. Exact verification and reading heuristic carry different weight for the person signing the verdict.
Installation
System requirements: Python 3.11+. No Java dependency and no external services.
git clone https://github.com/charlesmmorais/conformidade-pbtr-mcp.git
cd conformidade-pbtr-mcp
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .Register in Claude Desktop / Claude Code (claude_desktop_config.json):
{
"mcpServers": {
"conformidade-pbtr": {
"command": "/caminho/para/conformidade-pbtr-mcp/.venv/bin/conformidade-pbtr",
"env": {
"CONFORMIDADE_PBTR_SAIDA": "/caminho/onde/gravar/os/relatorios"
}
}
}
}Hosted deploy (Fly.io)
The server runs stdio locally and HTTP when hosted. The repository ships with Dockerfile and fly.toml ready to use:
fly launch --no-deploy --copy-config
fly deploy
curl https://<sua-app>.fly.dev/healthIn hosted mode the client does not share a disk with the server: the PDF is uploaded in conteudo_base64 and the reports come back embedded in the response. Read docs/DEPLOY.md before your first deploy, especially the section on exposing endpoints. The image is 250 MB and runs in 512 MB.
Tools exposed
Main flow:
Tool | Use |
| step 1 — deterministic checks |
| step 2 — returns segmented text for agent review |
| step 3 — accepts the findings and generates the reports |
Support:
Tool | Use |
| only the hierarchical numbering |
| only tables, arithmetic and values |
| deterministic rules + segmented text |
| extraction diagnostics (detects scanned PDF) |
| queries rules by section, tag or severity |
| re-renders a session analysis in another format |
Prompt conduzir_analise_conformidade: takes the agent through the analysis — including the order of findings presentation and the instruction to not assert compliance unless the analysis has actually classified it as compliant.
Direct use (without MCP)
from conformidade_pbtr import analisar
from conformidade_pbtr.relatorios import gerar_docx
rel = analisar("PB_123_2026.pdf", tipo="PB")
print(rel.resumo.indice_conformidade)
gerar_docx(rel, "Relatorio_Conformidade.docx")Compliance index
Weighted average by severity (critical 4, high 3, medium 2) over the items that can be assessed automatically. Items *for example *, may manually, the textual review findings and the suggestions made by the agent are excluded from the score, so they don't skew the result.
Range | Judgment |
>=120 | Ready — minor adjustments |
>=90 | Ready with reservations |
>= 60 | Requires full review |
< 50 | Not ready — revision needed |
Pluggable checklist
All regulatory knowledge lives in recursos/checklist_roteiro_ti.yaml — the engine itself does not care. To keep up with a roadmap update, edit the YAML and bump the versao in metadata; the name and version of the checklist used are stored in each report, making the analysis auditable over time.
The project serves SERPRO today. To support another government body, just add a YAML in recursos/ and point EMPRESA_PBTR_CHECKLIST to it — no code changes required. The format is in docs/CHECKLIST.md.
Known limitations
Aba Itens — the check between the Items tab in the system and the quantities in the PB is not possible from the PDF. The item always shows as far as check manually*.
Scanned PDF — without a text layer there is no analysis.
extrair_estruturaflags that case; apply OCR first.Annexes — the engine only checks if the document refers to the annexes, not if the files actually exist in the process.
Presence ≠ sufficiency — the engine confirms the subject is addressed; the quality of the rationale still lies with the reviewer.
Documentation
docs/MANUAL.md— micro manual for analystsdocs/ARQUITETURA.md— design decisions, data model and roadmapdocs/CHECKLIST.md— YAML structure and how to write good triggersdocs/DEPLOY.md— Fly.io deployment, remote mode and environment variablesCONTRIBUTING.md— how to contribute
Development
pip install -e ".[dev]"
pytest -q # testes sobre um PB sintético com erros plantados
ruff check .The test PB is generated by exemplos/gerar_pb_teste.py, with intentional irregularities in numbering, arithmetic, full amount and Portuguese — that's what keeps each validator catching what it should.
License
MIT — Copyright (c) 2026 SERPRO.
Available Tools
9 toolsanalisar_conformidadeA
Passo 1 de 3. Roda a análise determinística do PB/TR.
Verifica os itens do checklist normativo, a numeração hierárquica, a aritmética das tabelas e os valores declarados, além das regras determinísticas de revisão textual.
A revisão de português NÃO acontece aqui: o retorno traz o número de
segmentos de texto aguardando revisão. Siga para obter_texto_para_revisao
e depois registrar_revisao_textual, que é onde os relatórios são gerados.
Só passe formatos nesta chamada se for pular a revisão textual.
Inputs: tipo, formatos, checklist, nome_arquivo, +7 more. Returns: object
consultar_checklistA
Consulta as regras do roteiro [TI] usadas na análise — útil para explicar ao usuário o que é exigido em determinada seção do PB/TR.
Inputs: secao, arquivo, severidade, aplicabilidade. Returns: object
extrair_estruturaA
Diagnóstico de extração: seções numeradas, tabelas e contexto inferido. Use antes da análise quando houver suspeita de PDF digitalizado.
Inputs: caminho_arquivo (required), incluir_texto. Returns: object
gerar_relatorioA
Renderiza em outro formato uma análise já executada nesta sessão, sem reprocessar o documento.
Inputs: formato (required), chave_analise (required), diretorio_saida, retornar_conteudo. Returns: object
obter_texto_para_revisaoA
Passo 2 de 3. Devolve o texto do documento segmentado, para você revisar.
Leia cada segmento e identifique erros de português: ortografia, concordância, regência, crase, pontuação, e também problemas de redação que comprometem o documento — ambiguidade, vaguidão, "poderá" onde a obrigação exige "deverá".
Cada segmento vem com o campo item, que é a numeração do PB/TR onde ele
começa (e termina, quando o segmento atravessa mais de um item).
Ao apontar, copie o trecho com erro exatamente como está no documento:
registrar_revisao_textual confere se o trecho existe literalmente e
descarta o que não conferir. Não parafraseie a citação — o item do PB é
resolvido a partir dela, então uma citação aproximada perde a localização.
Inputs: chave_analise (required), inicio, limite. Returns: object
registrar_revisao_textualA
Passo 3 de 3. Registra a sua revisão e gera os relatórios finais.
Cada apontamento só é aceito se o trecho existir literalmente no
documento — os que não conferirem voltam em recusados, com o motivo. Isso
impede que uma citação imprecisa vire achado num relatório que instrui
processo administrativo.
O item do PB/TR de cada apontamento é resolvido automaticamente a partir do trecho citado — o relatório mostra "item 6.3.1" em vez de só a página, que num documento denso não localiza nada.
Os apontamentos entram no relatório como sugestão de revisão, separados dos achados determinísticos e fora do índice de conformidade.
Inputs: apontamentos (required), chave_analise (required), formatos. Returns: object
revisar_ortografiaA
Aplica as regras determinísticas de revisão e devolve o texto segmentado.
As regras cobrem erros recorrentes em documentos administrativos ("a nível
de", "à partir", palavra repetida). A revisão de português propriamente
dita é sua: leia os segmentos devolvidos em texto_para_revisao.
Inputs: caminho_arquivo (required), limite, incluir_texto. Returns: object
validar_tabelasA
Valida as tabelas de preços: colunas mínimas, Quantidade x Valor Unitário = Valor Total, fechamento do somatório, coerência mensal, valor por extenso e confronto do valor global citado no texto.
Inputs: caminho_arquivo (required). Returns: object
verificar_numeracaoA
Verifica apenas a numeração hierárquica dos itens (saltos, duplicidades, subitens órfãos, itens fora de ordem e seções obrigatórias ausentes).
Inputs: caminho_arquivo (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Some tools overlap in functionality, such as 'analisar_conformidade' which appears to encompass the checks performed by 'verificar_numeracao', 'validar_tabelas', and 'revisar_ortografia'. Additionally, 'obter_texto_para_revisao' and 'revisar_ortografia' both return segmented text, potentially causing confusion about which to use for specific review tasks.
All tool names follow a consistent verb_noun pattern in Portuguese (e.g., analisar_conformidade, verificar_numeracao, gerar_relatorio). The verbs are all infinitives and clearly reflect the action, while the nouns specify the target, providing a predictable and coherent naming scheme.
With 9 tools, the server covers a multi-step compliance workflow without being overwhelming. The number is appropriate for the domain, though some tools could be consolidated given overlaps, suggesting a slight over-provisioning.
The tool set covers the entire conformity checking process: initial analysis (analisar_conformidade), detailed text review (obter_texto_para_revisao, registrar_revisao_textual), specific checks (verificar_numeracao, validar_tabelas, revisar_ortografia), auxiliary support (extrair_estrutura, consultar_checklist), and output generation (gerar_relatorio). No significant gaps are apparent.
Maintenance
Related MCP Connectors
MCP server for FCA Handbook compliance analysis with verbatim citations.
MCP server for detecting and redacting PII (Personally Identifiable Information) in PDF documents.
B2B, GovCon & LegalTech MCP server for live RFPs, contract parsing, compliance & proposal tools.
City hiring-compliance MCP server with regulation search and full audit risk scoring.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that provides comprehensive PDF processing capabilities including text extraction, image extraction, table detection, annotation extraction, metadata retrieval, page rendering, and document structure analysis.-
- FlicenseNot gradedqualityDmaintenanceAn MCP server designed to automate tender and RFQ pricing by extracting requirements from documents and building structured pricing models. It enables users to calculate final costs, compare market rates, and generate styled HTML pricing reports for PDF export.-
- AlicenseNot gradedqualityCmaintenanceAn MCP-only server for evidence-based EPC tender screening that enables AI agents to run a full screening workflow, extract requirements, match company profiles, generate compliance matrices, and produce bid/no-bid advisory memos.MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for comprehensive PDF processing including text extraction with OCR, keyword search with regex, table extraction, and page preview as Base64 PNG images.1MIT