Skip to main content
Glama
fxbarros

MCP-DOE-PI

by fxbarros

Servidor MCP que permite ao Claude Desktop consultar o Diário Oficial do Estado do Piauí (diario.pi.gov.br/doe) em linguagem natural: lista edições, busca por conteúdo nos atos publicados e lê o texto integral de qualquer ato sem baixar PDF.

⚙️ Como funciona

O portal do DOE-PI é um front DataTables/jQuery sobre três APIs internas que respondem a POST form-urlencoded, sem autenticação e sem Cloudflare:

Endpoint

Função

Api/listardiarios.json

lista edições (filter_numero, filter_data em yyyy-mm-dd)

Api/buscaavancada.json

busca por palavras-chave no conteúdo (filter_texto)

Api/visualizarnota.json

texto integral do ato em HTML (uuid)

GET nesses endpoints retorna 500 — o método precisa ser POST.

Related MCP server: MCP-PJe-TJMA

🛠️ As 4 ferramentas

Ferramenta

O que faz

listar_edicoes

edições com link do PDF; filtros por data (yyyy-mm-dd) e número

buscar_conteudo

palavras-chave no texto dos atos; retorna o uuid_ato de cada resultado (filtro de ano aplicado localmente)

ler_ato

texto integral do ato pelo uuid, direto da base do portal — sem baixar PDF

baixar_edicao

baixa o PDF diagramado para ~/Downloads (para citação formal ou juntada)

📋 Limitações conhecidas

  • O acervo do portal começa na edição 240/2022 (14/12/2022).

  • A busca normaliza acentos e aceita casamento parcial de palavras — confira o campo palavras_encontradas de cada resultado.

  • A busca devolve tudo de uma vez (sem paginação); termos muito comuns demoram alguns segundos.

🧰 Requisitos

  • macOS (ou Linux) com uv instalado

  • Claude Desktop instalado

  • Python 3.12+ (o uv cuida do ambiente automaticamente)

📦 Instalação

1) Clonar

git clone https://github.com/fxbarros/MCP-DOE-PI.git
cd MCP-DOE-PI
uv sync

2) Registrar o MCP no Claude Desktop

No claude_desktop_config.json (menu Configurações → Desenvolvedor → Editar config), adicione:

"doe-pi": {
  "command": "/Users/SEU_USUARIO/.local/bin/uv",
  "args": ["--directory", "/caminho/para/MCP-DOE-PI", "run", "doe-pi-mcp"]
}

3) Reiniciar o Claude Desktop

As quatro ferramentas passam a aparecer no ícone de conector do DOE-PI.

💬 Exemplos de uso

  • "Liste as edições do DOE-PI de 15/07/2026."

  • "Busque 'desapropriação de utilidade pública' no Diário Oficial do Estado em 2025."

  • "Leia o inteiro teor daquele decreto de crédito suplementar."

  • "Baixe o PDF da edição 134 para eu juntar no processo."

🏗️ Estrutura do projeto

MCP-DOE-PI/
├── README.md
├── pyproject.toml
├── docs/assets/banner.svg      # marca dos projetos MCP do autor
├── src/doe_pi_mcp/
│   ├── server.py               # servidor MCP (4 tools)
│   └── doe_client.py           # cliente HTTP + conversor HTML→texto (lxml)
└── tests/
    └── test_limpar_html.py     # testes offline do conversor de notas

🔬 Notas de implementação

  • O HTML das notas é convertido em texto com lxml (não regex); tabelas — comuns em decretos orçamentários — são renderizadas linha a linha com células separadas por |, preservando a relação código/valor.

  • O transporte httpx faz retry automático de conexão (3 tentativas) contra instabilidades do portal.

  • A busca (buscaavancada.json) não pagina nem filtra por data no servidor: o cliente puxa o acervo inteiro e faz o recorte de ano/limite localmente.

🔒 Segurança e responsabilidade

  • Somente leitura: este MCP apenas consulta o Diário Oficial — nunca publica, altera ou remove nada.

  • Sem credenciais: o portal é público; nada de login, token ou secret.

  • Não inventa resultados: se o portal cair ou ficar lento, as ferramentas retornam um erro explícito instruindo o modelo a avisar o usuário, em vez de alucinar atos.

  • Uso responsável: nada de scraping massivo; respeite o termo de uso do portal.

  • Contingência anti-bot: hoje o portal não tem Cloudflare nem exige TLS de navegador. Se isso mudar (como ocorreu com o SCON/STJ), o caminho de migração é o StealthySession/FetcherSession(impersonate="chrome") do Scrapling, mantendo o mesmo cliente de parsing.

📝 Licença e créditos

Uso pessoal e profissional, sem garantias — use por sua conta e risco, respeitando as regras do portal. Construído por Fábio Ximenes Barros com ajuda do Claude, usando httpx e lxml.

Available Tools

4 tools
baixar_edicaoA

Baixa o PDF oficial (diagramado) de uma edição do DOE-PI para ~/Downloads. Use apenas quando o usuário precisar do documento em si (juntada, citação formal); para leitura, prefira ler_ato.

Args: url_pdf: URL do PDF, obtida em listar_edicoes (campo pdf) ou buscar_conteudo (campo pdf_edicao). nome_arquivo: nome de destino opcional; padrão é o nome original.

ParametersJSON Schema
NameRequiredDescriptionDefault
url_pdfYes
nome_arquivoNo

TDQS

A4.8/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden and discloses the key side effect (saving the PDF to ~/Downloads) and default naming behavior. It does not cover error handling, overwrite behavior, or return values, but these are less critical for a download tool and the core behavior is well explained.

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 highly concise, front-loading the purpose and usage guidance in the first sentence, followed by a clear and compact Args section. Every sentence adds value, with no redundant or filler content.

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 low complexity (2 params, no output schema, no annotations), the description covers purpose, when to use, alternatives, parameter semantics, and source of required data. It is complete enough for an agent to correctly select and invoke the tool without additional information.

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

Parameters5/5

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

Even though the schema has 0% description coverage, the description thoroughly explains both parameters: `url_pdf` (source and how to obtain it) and `nome_arquivo` (optional, default behavior). This goes beyond the schema and effectively compensates for the lack of structured descriptions.

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 a specific verb ('Baixa') and clearly identifies the resource (official PDF of a DOE-PI edition) and destination (~/Downloads). It also distinguishes itself from siblings by noting that for reading, one should prefer `ler_ato`.

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?

Explicitly states when to use this tool ('apenas quando o usuário precisar do documento em si') and provides a clear alternative (`ler_ato` for reading). It also indicates where to obtain the required `url_pdf` from sibling tools (`listar_edicoes` or `buscar_conteudo`).

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

buscar_conteudoA

Busca palavras-chave no TEXTO dos atos publicados no DOE-PI (leis, decretos, portarias, editais, nomeações, avisos etc.).

Cada resultado traz o uuid_ato — use a tool ler_ato com ele para obter o texto integral do ato SEM baixar o PDF.

Args: termo: palavras-chave. Acentos são normalizados pelo servidor e a busca com várias palavras aceita casamento parcial — confira o campo palavras_encontradas de cada resultado. ano: se informado, restringe aos atos publicados nesse ano (filtro aplicado localmente; a API não filtra por data). limite: máximo de resultados retornados (padrão 20). O campo total_encontrado informa quantos existem no acervo.

Cobertura: todo o acervo do portal (dez/2022 em diante).

ParametersJSON Schema
NameRequiredDescriptionDefault
anoNo
termoYes
limiteNo

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals several important traits: accent normalization by the server, partial matching for multi-word searches, the `ano` filter being applied locally (not server-side), and the fact that results include `uuid_ato` instead of full text. This goes beyond a simple 'search' description and helps the agent anticipate behavior.

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 well-structured and concise. It opens with a clear purpose, then uses a compact list for arguments, and ends with a coverage note. Every sentence provides valuable information without redundancy. It is appropriately sized for the tool's complexity.

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?

Despite having no output schema or annotations, the description covers essential context: what the tool does, what each parameter means, what the results contain (uuid_ato, palavras_encontradas, total_encontrado), how to proceed with `ler_ato`, and the coverage scope. This is complete enough for an agent to select and invoke the tool correctly.

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

Parameters5/5

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

The input schema provides only types and defaults (0% description coverage). The description compensates fully by explaining each parameter: `termo` (keywords, accent normalization, partial matching), `ano` (year restriction, local filter), and `limite` (max results, default 20, with `total_encontrado` field). This adds substantive meaning 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's function: 'Busca palavras-chave no TEXTO dos atos publicados no DOE-PI' (searches keywords in the text of published acts). It also lists the types of acts covered (leis, decretos, etc.) and distinguishes itself from siblings by explaining that it returns `uuid_ato` to be used with `ler_ato` for full text.

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 provides clear context for use: search text content, then use `ler_ato` with the returned `uuid_ato` to get the full text. It also notes that the `ano` filter is applied locally because the API does not filter by date, which helps set expectations. However, it does not explicitly contrast with sibling tools like `listar_edicoes` or `baixar_edicao`, so a perfect score is not warranted.

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

ler_atoA

Retorna o texto integral de um ato publicado no DOE-PI, em texto plano, direto da base do portal — sem precisar baixar o PDF da edição.

Args: uuid: identificador do ato, obtido no campo uuid_ato dos resultados de buscar_conteudo.

Atenção: o texto vem da base de notas do portal, não do PDF diagramado. Para citação formal ou juntada, baixe a edição com baixar_edicao.

ParametersJSON Schema
NameRequiredDescriptionDefault
uuidYes

TDQS

A5/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden. It discloses that the text comes from the portal's notes database, not the typeset PDF, and that it returns plain text. This caveat is important for understanding the tool's output limitations and differentiates it from the PDF-based alternative.

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 succinct: one purpose statement, a short Args section, and a single caveat sentence. It is well-structured with clear labels ('Args', 'Atenção') and avoids redundant filler, making it easy to scan.

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?

For a simple read tool with no output schema and no annotations, the description covers the purpose, parameter source, data source caveat, and an alternative tool. It provides all essential information for an agent to select and invoke the tool correctly, including the nuance about formal use.

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

Parameters5/5

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

The input schema provides only the parameter name 'uuid' with no description (0% coverage). The description compensates by explaining that uuid is the act identifier from the `uuid_ato` field of `buscar_conteudo` results, adding critical provenance and context.

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 opens with a specific action: 'Retorna o texto integral de um ato publicado no DOE-PI, em texto plano, direto da base do portal' – clearly stating verb, resource, and output format. It distinguishes from siblings by contrasting with 'sem precisar baixar o PDF da edição' and referencing `buscar_conteudo` for obtaining the UUID.

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?

The description explicitly tells the user how to obtain the UUID ('obtido no campo `uuid_ato` dos resultados de `buscar_conteudo`) and when to use an alternative ('Para citação formal ou juntada, baixe a edição com `baixar_edicao`'). This provides clear when-to-use and when-not-to-use guidance.

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

listar_edicoesA

Lista edições do Diário Oficial do Estado do Piauí, da mais recente para a mais antiga, com o link do PDF de cada uma.

Args: data: filtra pela data de publicação, no formato yyyy-mm-dd (ex.: "2026-07-15"). Formato dd/mm/yyyy NÃO funciona. numero: filtra pelo número da edição (ex.: "134" — retorna a edição 134 de todos os anos do acervo, incluindo suplementares). quantidade: máximo de edições retornadas (padrão 20).

O acervo começa na edição 240/2022 (14/12/2022); diários anteriores não estão no portal.

ParametersJSON Schema
NameRequiredDescriptionDefault
dataNo
numeroNo
quantidadeNo

TDQS

A4.4/5.0
Behavior4/5

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

Despite having no annotations, the description discloses important behavioral details: ordering (most recent to oldest), archive scope (starts at edition 240/2022), and date format restrictions (only yyyy-mm-dd). These limitations go beyond basic expectations and help the agent understand the tool's boundaries.

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 front-loaded summary sentence clearly states the tool's purpose, followed by a structured Args block. While slightly detailed, every piece of information serves a purpose, and the formatting improves scannability. No redundant content was introduced.

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?

The description covers the tool's purpose, parameters, ordering, output link, and archive limitation. Since there is no output schema, it would benefit from explicitly stating the full item structure, but for a filtering/listing tool it is reasonably complete.

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

Parameters5/5

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

The input schema provides only names and types with zero coverage in its descriptions, but the description fully compensates by explaining each parameter's meaning, format, example values, default behavior, and edge cases (e.g., dd/mm/yyyy does not work; numero returns matches across all years). This adds substantial value 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 lists editions of the Piauí State Official Diary, ordered from most recent to oldest, with a PDF link for each. This distinguishes it from siblings like ler_ato (read act), baixar_edicao (download edition), and buscar_conteudo (search content) by defining the listing action and resource.

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 provides clear guidance on how to use the optional filters (data, numero, quantidade) with examples and defaults, but it does not explicitly mention when not to use this tool or when to prefer alternatives. The context is clear but lacks exclusions.

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. 4 tool updatesv0.1.0
    • First observedbaixar_edicao
    • First observedbuscar_conteudo
    • First observedler_ato
    • First observedlistar_edicoes

TDQS

A4.7/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: listing editions, searching acts, reading act text, and downloading PDFs. No overlap or ambiguity between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in Portuguese (ler_ato, baixar_edicao, listar_edicoes, buscar_conteudo), using lowercase and underscores throughout.

Tool Count5/5

The set of 4 tools is well-scoped for the server's purpose, covering the essential operations without unnecessary bloat or missing core functionality.

Completeness4/5

The tools cover the main workflows: browsing editions, searching acts, reading full text, and downloading PDFs. A minor gap is the lack of a direct way to list all acts within a specific edition, but search can compensate.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables querying the Brazilian PJe court system for TJMA (1st and 2nd degrees) via natural language, with automated login, expedient and deadline checks, document listing and download, and case searches.
    2
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables natural language querying of Brazil's Federal Justice 1st Region electronic court system (PJe-TRF1) for both 1st and 2nd degrees, allowing users to check pending expedients, deadlines, case details, and download documents via an automated login and read-only MCP server.
    2
    -
  • F
    license
    A
    quality
    C
    maintenance
    Enables natural language, read-only access to the SPA system of the Prefeitura Municipal de Teresina, allowing users to query process boxes, urgent deadlines, recent entries, triage briefings, and judicial documents via pure HTTP without a browser.
    12
    -