Querido Diário MCP Server

io.github.lucaspmgomess由 GitHub 账号 lucaspmgomess 发布v0.1.0更新于 Oct 24, 2026

Unofficial, read-only MCP server for the public Querido Diário API (Brazilian municipal gazettes)

概览

AI 生成的概览

本地只读 MCP 服务器,让助手通过公开的 Querido Diário 查询巴西市镇并检索已收录的市政官方公报。

可以做什么
按名称或州解析巴西市镇,获取其 7 位 IBGE 地区编号,或按精确编号获取单个市镇。对已收录的市政公报做全文检索,可按市镇、发布日期范围、分页和排序筛选,并支持必含词、排除词和精确短语等简单查询语法。返回结构化结果,便于汇总、筛选或与其他工具结合使用。
适用场景
适合在巴西市政官方公报中查找某公司、个人或话题的提及,或先把城市名称对应到 IBGE 地区编号再检索。它是范围很窄的只读检索工具,不是通用网页或文档抓取工具。
运行要求
以 PyPI 包形式通过 stdio 在本地运行;需要 Python 3.12+ 和 uv,由 MCP 客户端用 uvx 命令启动。无需 API 密钥或账户。需要访问公开的 Querido Diário API;可选环境变量 QD_API_BASE_URL 可覆盖 API 基础地址,普通用户无需设置。
安装前请注意
非官方社区项目,未获 Open Knowledge Brasil 认可,且处于 beta 阶段。它只读取公开 API,不抓取公报链接、不下载 PDF、不做 OCR,也不写入数据。检索词和城市查询会发送给第三方 Querido Diário API;设置 QD_API_BASE_URL 会改为访问其他端点。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Querido Diário MCP Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Querido Diário MCP Server

[PyPI] [Python] [CI] [MCP Registry] [License: MIT]

A local-first Model Context Protocol server that gives AI clients structured, read-only access to Brazilian municipal official gazettes indexed by Querido Diário.

No API key · Runs locally · Read-only · No telemetry · Open source

🇧🇷 Versão em português

The package is published on PyPI and the MCP Registry.

What it does

Querido Diário provides searchable municipal official gazettes through a public API. This server exposes a small, typed MCP interface on top of that API so an MCP client can:

  • resolve Brazilian municipalities and their IBGE territory IDs;
  • search indexed official gazettes by text, municipality and date range;
  • receive structured results that are easier for agents to inspect and combine with other tools.

The server runs as a local stdio subprocess and only performs read-only HTTPS requests to the public Querido Diário API.

Quick start

Requires Python 3.12+ and uv.

No repository clone is required:

bash
uvx querido-diario-mcp-server

This starts the MCP server on stdio. It is intended to be launched by an MCP client rather than used as an interactive terminal application.

Client configuration

All supported clients use the same command:

text
uvx querido-diario-mcp-server

Claude Desktop / Claude Code

json
{  "mcpServers": {    "querido-diario": {      "command": "uvx",      "args": ["querido-diario-mcp-server"]    }  }}

Use this in claude_desktop_config.json for Claude Desktop or a project-level .mcp.json for Claude Code.

Cursor

json
{  "mcpServers": {    "querido-diario": {      "command": "uvx",      "args": ["querido-diario-mcp-server"]    }  }}

Add it to .cursor/mcp.json or your global Cursor MCP configuration.

Codex CLI

toml
[mcp_servers.querido-diario]command = "uvx"args = ["querido-diario-mcp-server"]

Other MCP clients that support local stdio servers can launch the same command.

Tools

The server intentionally exposes a small, read-only tool surface.

ToolPurpose
search_citiesSearch Brazilian municipalities by name and resolve the 7-digit IBGE territory ID. Supports an optional state filter.
get_cityFetch one municipality by its exact 7-digit IBGE territory ID.
search_gazettesFull-text search over indexed gazettes with municipality, publication date, pagination and sorting filters.

search_gazettes uses the simple-query-string syntax supported by the upstream search API. Examples include +required, -excluded and "exact phrase".

Example

A user can ask:

text
Find mentions of ACME Ltda in Porto Alegre gazettesfrom January through July 2026.

An MCP client can then execute:

text
1. search_cities(city_name="Porto Alegre")   -> territory_id: "4314902"
2. search_gazettes(       query='"ACME Ltda"',       territory_ids=["4314902"],       published_since="2026-01-01",       published_until="2026-07-31",   )

The result is returned as structured tool output for the client to summarize, filter or combine with other tools.

Architecture

text
MCP client   |   | stdio / MCP   vserver.py   |   | validated tool arguments   vclient.py   |   | typed read-only HTTPS requests   vQuerido Diário public API

The implementation keeps the protocol boundary separate from the HTTP integration:

text
src/querido_diario_mcp_server/    __init__.py   package version and CLI entry point    config.py     environment-driven configuration    errors.py     integration error hierarchy    models.py     typed Pydantic domain models    client.py     async HTTP client with no MCP dependency    server.py     MCP lifespan, validation and tool definitions

A single httpx.AsyncClient connection pool is created for the server lifecycle and reused across tool calls. The HTTP client can be tested independently of MCP, while integration tests exercise the real MCP server in process.

Design principles

  • Read-only by design. The integration only calls a fixed set of upstream GET endpoints.
  • Local-first. There is no hosted middleware, proprietary backend or account requirement.
  • Typed boundaries. API responses and MCP outputs use explicit Pydantic models.
  • Small tool surface. The server exposes only the operations required to discover cities and search gazettes.
  • Explicit failures. Upstream failures are converted to concise MCP tool errors rather than raw tracebacks or HTML responses.
  • No arbitrary URL fetching. Tool callers cannot turn the server into a generic HTTP or SSRF primitive.
  • No telemetry. The server does not collect usage data.

Security

The server never automatically follows gazette URLs returned by the upstream API and does not accept arbitrary target URLs from tool callers. Territory IDs, dates, pagination and sort options are validated before use.

For vulnerability reporting and the supported security scope, see SECURITY.md.

Configuration

VariableDefaultPurpose
QD_API_BASE_URLhttps://api.queridodiario.org.brBase URL for the Querido Diário API. Can be overridden for local or staging environments.

Normal users do not need to set any environment variables.

Development

Clone the repository only if you want to contribute or work on the implementation:

bash
git clone https://github.com/lucaspmgomess/querido-diario-mcp-server.gitcd querido-diario-mcp-serveruv sync

Run the same checks enforced by CI:

bash
uv run ruff check .uv run ruff format --check .uv run pyrightuv run pytest --cov

Run the server from the checkout:

bash
uv run querido-diario-mcp-server

Inspect the MCP tools interactively:

bash
uv run mcp dev src/querido_diario_mcp_server/server.py:mcp

Test strategy

Unit tests mock the HTTP boundary with httpx.MockTransport, so the automated suite does not depend on the public API.

Coverage includes:

  • successful city and gazette searches;
  • query serialization and repeated territory IDs;
  • date ranges, pagination and sorting;
  • empty result sets;
  • 4xx and 5xx upstream failures;
  • malformed responses;
  • connection errors and timeouts;
  • MCP tool discovery, schemas and structured outputs;
  • validation errors and upstream failures at the MCP boundary.

Manual smoke-test scripts are available for validating the real production API and the full MCP-to-API path:

bash
uv run python scripts/smoke_test_api.pyuv run python scripts/smoke_test_mcp.py

Project status

The project is currently in beta. The MCP tool surface is intentionally small and changes are kept conservative. Release history is documented in CHANGELOG.md.

The following are intentionally outside the current scope:

  • arbitrary URL fetching;
  • automatic PDF or full-text download;
  • OCR;
  • write operations;
  • crawling and background jobs;
  • built-in LLM summarization;
  • a web interface.

Relationship to Querido Diário

This is a community-built, unofficial project.

Querido Diário is maintained by Open Knowledge Brasil and its community. This repository is not an official Open Knowledge Brasil project, is not endorsed or maintained by the organization, and only consumes the project's public API.

Relevant upstream repositories:

Additional notes about upstream endpoint history are kept in docs/upstream-api-history.md.

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md for the development workflow, project scope and review checklist.

License

MIT

来源:README.md,提交 eba1c33

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分