senado-br-mcp 3.22.0 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/dataset/release.js +38 -0
- package/dist/server.js +13 -2
- package/dist/tools/deep-research.js +1 -1
- package/dist/tools/senadores.js +89 -18
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -390,10 +390,10 @@ Used by Groups A, E, F, H, I, J, K, L, M, N. The `.json` suffix is appended auto
|
|
|
390
390
|
| Upstream path | Used by |
|
|
391
391
|
|---------------|---------|
|
|
392
392
|
| `/senador/lista/atual` | `senado_listar_senadores` |
|
|
393
|
-
| `/senador/lista/legislatura/{legislatura}` | `senado_listar_senadores` (param `legislatura`) |
|
|
393
|
+
| `/senador/lista/legislatura/{legislatura}` | `senado_listar_senadores` (param `legislatura`; `emExercicio` crossed with `/senador/lista/atual`) |
|
|
394
394
|
| `/senador/{codigo}` (+ `/mandatos`) | `senado_obter_senador` (biografia + mandatos via chamada extra) |
|
|
395
395
|
| `/senador/{codigo}/licencas`, `/comissoes`, `/cargos`, `/historicoAcademico`, `/filiacoes`, `/profissao` | `senado_senador_historico` (`tipo` enum) |
|
|
396
|
-
| `/senador/afastados` | `senado_senadores_afastados` |
|
|
396
|
+
| `/senador/afastados` | `senado_senadores_afastados`, `senado_listar_senadores` (`emExercicio: false`) |
|
|
397
397
|
| `/senador/{codigo}/apartes` | `senado_discursos_senador` (`tipo=apartes`) |
|
|
398
398
|
| `/comissao/lista/colegiados` | `senado_listar_comissoes` (+ sigla-to-code resolution) |
|
|
399
399
|
| `/comissao/{codigo}` | `senado_obter_comissao` (`secao=resumo`; numeric code, not sigla) |
|
|
@@ -576,7 +576,7 @@ In addition to the `provenance` envelope, `structuredContent` carries a top-leve
|
|
|
576
576
|
|
|
577
577
|
**Out-of-band mirror in `_meta`.** The same `provenance` and `attribution` are also mirrored on the result's `_meta` under namespaced keys (`com.sidneybissoli.senado/provenance` and `com.sidneybissoli.senado/attribution`). The MCP spec keeps `_meta` for metadata *about* a result that should not steer the model, which is where the still-incubating trust/attribution work from #711 (split into an experimental extensions track, not yet in core) points; mirroring there gives audit and UI consumers the provenance without reading the model-facing data channel, at no model-token cost, while `structuredContent` keeps it visible so the model can cite the source. The mirror survives the ChatGPT-app profile minimizer (which only strips `structuredContent.meta`).
|
|
578
578
|
|
|
579
|
-
**Field-level granularity.** Most tools are single-source, so one envelope suffices. The few that merge reads in one response fill `field_sources` — a list of `{ fields, source_url, dataset_id, data_vintage, retrieved_at, served_from_cache }` attributing specific output fields to their real origin, and the block's `retrieved_at` is the oldest of them. `served_from_cache` is `true`/`false` for reads through the server cache and `null` where the notion does not apply (the bundled org-chart snapshot, the e-Cidadania corpus in D1). The merging tools (since 3.18.2): `senado_obter_materia` `secao=detalhe` (`/processo/{id}` + `ementa` from `/processo` + `relator` from `/processo/relatoria`), `senado_obter_senador` and the Deep Research `fetch` of a senator (biography + `mandatos`/`emExercicio` from `/senador/{codigo}/mandatos`), `senado_reunioes_comissao` over a window that crosses the year (one read per year), `senado_servidores` with `subordinadasA` (payroll + org-chart snapshot), `senado_suprimento_fundos` statistics on `atos-concessao` (acts + beneficiary names from the supridos registry), `senado_ecidadania_obter_evento` (live detail + `comentarios` from the corpus) and `senado_ecidadania_sugerir_tema_enquete` (consultas and ideias corpora). **Only a read that becomes a field of the answer is a sub-source**: a read that only resolves or checks an identifier (a committee acronym → its code, the parent check in `senado_contratacao_detalhe`) is left out, otherwise a cached lookup table would make the whole answer claim to be as old as it. `attribution` always lists every distinct underlying `source_url`.
|
|
579
|
+
**Field-level granularity.** Most tools are single-source, so one envelope suffices. The few that merge reads in one response fill `field_sources` — a list of `{ fields, source_url, dataset_id, data_vintage, retrieved_at, served_from_cache }` attributing specific output fields to their real origin, and the block's `retrieved_at` is the oldest of them. `served_from_cache` is `true`/`false` for reads through the server cache and `null` where the notion does not apply (the bundled org-chart snapshot, the e-Cidadania corpus in D1). The merging tools (since 3.18.2): `senado_obter_materia` `secao=detalhe` (`/processo/{id}` + `ementa` from `/processo` + `relator` from `/processo/relatoria`), `senado_obter_senador` and the Deep Research `fetch` of a senator (biography + `mandatos`/`emExercicio` from `/senador/{codigo}/mandatos`), `senado_reunioes_comissao` over a window that crosses the year (one read per year), `senado_servidores` with `subordinadasA` (payroll + org-chart snapshot), `senado_suprimento_fundos` statistics on `atos-concessao` (acts + beneficiary names from the supridos registry), `senado_ecidadania_obter_evento` (live detail + `comentarios` from the corpus), `senado_listar_senadores` with `legislatura` (since 3.24.0: the legislature list + `emExercicio` from `/senador/lista/atual`) and `senado_ecidadania_sugerir_tema_enquete` (consultas and ideias corpora). **Only a read that becomes a field of the answer is a sub-source**: a read that only resolves or checks an identifier (a committee acronym → its code, the parent check in `senado_contratacao_detalhe`) is left out, otherwise a cached lookup table would make the whole answer claim to be as old as it. `attribution` always lists every distinct underlying `source_url`.
|
|
580
580
|
|
|
581
581
|
`retrieved_at` fidelity is provided by the cache layer (`cachedFetchWithMeta`), which persists the fetch timestamp alongside the value, so it reflects the real upstream extraction even on a cache hit. Two exceptions report an honest live timestamp instead: the e-Cidadania **list** tools (read from D1) use the corpus's `lastScrapedAt` — the true age of the stored data, or the live scrape instant when the corpus is empty or stale and the list falls back to the portal (since 3.18.3; before, the stale corpus's instant leaked into the live answer) — while e-Cidadania **detail** tools, scraped live, use the fetch time and a level-3 canonical item URL. The only path that falls back to the build-time default is the in-code static reference catalog (`senado_tabelas_referencia` `tipos-materia`), which has no upstream extraction instant.
|
|
582
582
|
|
|
@@ -625,7 +625,7 @@ The frozen NDJSON is **not** committed (built from the sovereign D1 corpus on de
|
|
|
625
625
|
|
|
626
626
|
| Tool | Description |
|
|
627
627
|
|------|-------------|
|
|
628
|
-
| `senado_listar_senadores` | Lista senadores em exercício
|
|
628
|
+
| `senado_listar_senadores` | Lista senadores em exercício, fora de exercício (`emExercicio: false`) ou por legislatura, com filtros `nome` (busca parcial sem acento), `uf` e `partido` |
|
|
629
629
|
| `senado_obter_senador` | Detalhe biográfico de um senador: bio, mandatos, partido, contato |
|
|
630
630
|
| `senado_votacoes_senador` ⊕ | Como um senador votou em cada matéria (via v3 `/votacao`) |
|
|
631
631
|
| `senado_senador_historico` | Histórico funcional via `tipo` enum: licencas, comissoes, cargos, historico-academico, filiacoes, profissoes |
|
package/dist/dataset/release.js
CHANGED
|
@@ -125,6 +125,44 @@ export function formatSha256Sums(files) {
|
|
|
125
125
|
.map((f) => `${f.sha256} ${f.file}`)
|
|
126
126
|
.join("\n") + "\n");
|
|
127
127
|
}
|
|
128
|
+
const DOI_RE = /^10\.\d{4,}\/\S+$/;
|
|
129
|
+
/** DOI com forma válida e que não é o placeholder (que tem forma de DOI). */
|
|
130
|
+
const doiReal = (doi) => DOI_RE.test(doi) && doi !== DOI_PLACEHOLDER;
|
|
131
|
+
/**
|
|
132
|
+
* Deriva os DOIs de um rascunho Zenodo ainda não publicado. O version-DOI é o reservado
|
|
133
|
+
* (`prereserve_doi`); o concept-DOI vem da deposição ou, no 1º release (concept ainda sem DOI
|
|
134
|
+
* cunhado), de `conceptrecid` sob o mesmo prefixo do version-DOI. Lança se faltar algum: o freeze
|
|
135
|
+
* NÃO pode seguir com placeholder quando o Zenodo está ligado — o `release.json` de um release
|
|
136
|
+
* publicado é imutável (dataset-v1.0.0 saiu com "PENDENTE" porque os DOIs vinham depois).
|
|
137
|
+
*/
|
|
138
|
+
export function doisDaDeposicao(dep) {
|
|
139
|
+
const versionDoi = dep.metadata?.prereserve_doi?.doi ?? "";
|
|
140
|
+
if (!doiReal(versionDoi)) {
|
|
141
|
+
throw new Error(`deposição sem version-DOI reservado válido (prereserve_doi="${versionDoi}").`);
|
|
142
|
+
}
|
|
143
|
+
let conceptDoi = dep.conceptdoi ?? "";
|
|
144
|
+
if (!conceptDoi && dep.conceptrecid) {
|
|
145
|
+
conceptDoi = `${versionDoi.slice(0, versionDoi.lastIndexOf("."))}.${dep.conceptrecid}`;
|
|
146
|
+
}
|
|
147
|
+
if (!doiReal(conceptDoi)) {
|
|
148
|
+
throw new Error(`deposição sem concept-DOI derivável (conceptdoi="${dep.conceptdoi ?? ""}", conceptrecid="${dep.conceptrecid ?? ""}").`);
|
|
149
|
+
}
|
|
150
|
+
return { conceptDoi, versionDoi };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Confere que um `release.json` leva exatamente os DOIs reservados da deposição para onde vai.
|
|
154
|
+
* Devolve a lista de problemas (vazia = confere). Trava do envio: um manifesto congelado antes da
|
|
155
|
+
* reserva, ou de outra deposição, não sobe.
|
|
156
|
+
*/
|
|
157
|
+
export function conferirDoisDoManifesto(manifest, dois) {
|
|
158
|
+
const problemas = [];
|
|
159
|
+
for (const campo of ["conceptDoi", "versionDoi"]) {
|
|
160
|
+
if (manifest[campo] !== dois[campo]) {
|
|
161
|
+
problemas.push(`${campo} do release.json = "${String(manifest[campo])}", reservado = "${dois[campo]}"`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return problemas;
|
|
165
|
+
}
|
|
128
166
|
/**
|
|
129
167
|
* Deriva a `metadata` de uma deposição Zenodo a partir do `.zenodo.json` committado + a versão/DOI
|
|
130
168
|
* do release corrente. PURO: o driver faz o PUT. `version` sempre vem do release (não do arquivo),
|
package/dist/server.js
CHANGED
|
@@ -98,8 +98,19 @@ export function createServer(env, ctx, options = {}) {
|
|
|
98
98
|
// `retrieval`. `provenance` é objeto com uma fonte e LISTA quando a chamada passa
|
|
99
99
|
// várias (o índice do Deep Research), então os dois.
|
|
100
100
|
const outputSchema = z.looseObject({
|
|
101
|
-
provenance: z
|
|
102
|
-
|
|
101
|
+
provenance: z
|
|
102
|
+
.union([ConciseBlockSchema, z.array(ConciseBlockSchema).min(1)])
|
|
103
|
+
.describe("Bloco de proveniência do portfólio (projeção concise): source, source_url, data_vintage, " +
|
|
104
|
+
"retrieved_at (horário de Brasília), citation, license, revision e retrieval; field_sources " +
|
|
105
|
+
"só quando a resposta funde recortes, derived e derivation_note só nos modos de estatísticas. " +
|
|
106
|
+
"retrieval é o diagnóstico da ida à origem nesta chamada — requisições, tentativas com " +
|
|
107
|
+
"retentativas, anomalias superadas (timeout, network, rate_limited, http_5xx, http_4xx, " +
|
|
108
|
+
"malformed_body) e unstable (true quando algo precisou ser repetido) —, ou null quando não " +
|
|
109
|
+
"foi medido. Lista de blocos quando a chamada consulta várias fontes (índice do search)."),
|
|
110
|
+
attribution: z
|
|
111
|
+
.array(z.string())
|
|
112
|
+
.describe("URLs de origem dos dados (as source_url distintas dos blocos de proveniência, incluindo as de " +
|
|
113
|
+
"field_sources), para linkar a citação"),
|
|
103
114
|
});
|
|
104
115
|
const registerTool = server.registerTool.bind(server);
|
|
105
116
|
const analytics = env.SENADO_ANALYTICS;
|
|
@@ -100,7 +100,7 @@ async function construirIndice(baseUrl) {
|
|
|
100
100
|
cachedFetchWithMeta("senado_listar_senadores", { path: PATH_SENADORES }, CACHE_SEMI_STATIC, () => upstreamFetch(PATH_SENADORES, {}, baseUrl)),
|
|
101
101
|
cachedFetchWithMeta("senado_listar_comissoes", {}, CACHE_SEMI_STATIC, () => upstreamFetch(PATH_COLEGIADOS, {}, baseUrl)),
|
|
102
102
|
]);
|
|
103
|
-
const senadores = extractParlamentares(sen.value).map(parseSenadorResumo);
|
|
103
|
+
const senadores = extractParlamentares(sen.value).map((p) => parseSenadorResumo(p, true));
|
|
104
104
|
const comissoes = ensureArray(com.value?.ListaColegiados?.Colegiados?.Colegiado).map(parseComissaoItem);
|
|
105
105
|
return {
|
|
106
106
|
index: createIndex([...entradasSenadores(senadores), ...entradasComissoes(comissoes)]),
|
package/dist/tools/senadores.js
CHANGED
|
@@ -11,9 +11,18 @@ import { cachedFetchWithMeta } from "../cache/manager.js";
|
|
|
11
11
|
import { upstreamFetch } from "../throttle/upstream.js";
|
|
12
12
|
import { errorFrom, ensureArray, normalizeText, safeInt } from "../utils/validation.js";
|
|
13
13
|
import { digArrayRoot, digObjectRoot } from "../utils/upstream-parse.js";
|
|
14
|
-
import { leituraDoCache, provenanceFor, resultWithProvenance, toBrasiliaIso } from "../utils/provenance.js";
|
|
14
|
+
import { derivado, leituraDoCache, provenanceFor, resultWithProvenance, toBrasiliaIso, withFieldSources } from "../utils/provenance.js";
|
|
15
15
|
import { CACHE_SEMI_STATIC, CACHE_DYNAMIC, CACHE_ON_DEMAND } from "../types.js";
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* `emExercicio` is NOT read from the record: none of the three list endpoints carries
|
|
18
|
+
* a usable flag. The participation lives inside `Mandato` and only says titular/suplente
|
|
19
|
+
* — and a suplente in `/senador/lista/atual` IS seated (11 of 81 on 30/10/2026). Until
|
|
20
|
+
* 3.x the field read a top-level `DescricaoParticipacao`/`DataFim` that never exists, so
|
|
21
|
+
* it came out `true` for everyone, including the 163 suplentes of legislature 57.
|
|
22
|
+
* The caller states it from WHICH official list the record came (see
|
|
23
|
+
* `resumosDaListagem`); `null` when it is not known.
|
|
24
|
+
*/
|
|
25
|
+
export function parseSenadorResumo(parlamentar, emExercicio = null) {
|
|
17
26
|
const id = parlamentar.IdentificacaoParlamentar || parlamentar;
|
|
18
27
|
const m = parlamentar.Mandato || {};
|
|
19
28
|
return {
|
|
@@ -23,9 +32,68 @@ export function parseSenadorResumo(parlamentar) {
|
|
|
23
32
|
partido: m.Partido?.SiglaPartido || id.SiglaPartidoParlamentar || null,
|
|
24
33
|
uf: m.UfParlamentar || id.UfParlamentar || "",
|
|
25
34
|
foto: id.UrlFotoParlamentar || null,
|
|
26
|
-
emExercicio
|
|
35
|
+
emExercicio,
|
|
27
36
|
};
|
|
28
37
|
}
|
|
38
|
+
export const PATH_SENADORES_ATUAIS = "/senador/lista/atual";
|
|
39
|
+
export const PATH_SENADORES_AFASTADOS = "/senador/afastados";
|
|
40
|
+
/**
|
|
41
|
+
* The official list `senado_listar_senadores` reads. "Em exercício" is a state of TODAY:
|
|
42
|
+
* without `legislatura`, `true` (default) is `/senador/lista/atual` and `false` is
|
|
43
|
+
* `/senador/afastados` (licensed titulars + suplentes out of the seat — measured 30/10/2026:
|
|
44
|
+
* 81 and 44, disjoint). With `legislatura`, the legislature list is crossed with
|
|
45
|
+
* `/senador/lista/atual` (`cruzaComAtual`).
|
|
46
|
+
*/
|
|
47
|
+
export function fonteDaListagem(params) {
|
|
48
|
+
if (params.legislatura) {
|
|
49
|
+
return { path: `/senador/lista/legislatura/${params.legislatura}`, dataset_id: `legislatura=${params.legislatura}`, cruzaComAtual: true };
|
|
50
|
+
}
|
|
51
|
+
return params.emExercicio === false
|
|
52
|
+
? { path: PATH_SENADORES_AFASTADOS, dataset_id: "afastados", cruzaComAtual: false }
|
|
53
|
+
: { path: PATH_SENADORES_ATUAIS, dataset_id: "lista/atual", cruzaComAtual: false };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Summaries with `emExercicio` stated from the list they came from. With `legislatura`,
|
|
57
|
+
* it is membership in `/senador/lista/atual` (`codigosEmExercicio`), and an explicit
|
|
58
|
+
* `emExercicio` filters on it; omitted, the whole legislature comes back.
|
|
59
|
+
*/
|
|
60
|
+
export function resumosDaListagem(parlamentares, params, codigosEmExercicio) {
|
|
61
|
+
if (!params.legislatura || !codigosEmExercicio) {
|
|
62
|
+
const emExercicio = params.legislatura ? null : params.emExercicio !== false;
|
|
63
|
+
return parlamentares.map((p) => parseSenadorResumo(p, emExercicio));
|
|
64
|
+
}
|
|
65
|
+
const resumos = parlamentares.map((p) => {
|
|
66
|
+
const r = parseSenadorResumo(p);
|
|
67
|
+
return { ...r, emExercicio: codigosEmExercicio.has(r.codigo) };
|
|
68
|
+
});
|
|
69
|
+
return params.emExercicio === undefined
|
|
70
|
+
? resumos
|
|
71
|
+
: resumos.filter((s) => s.emExercicio === params.emExercicio);
|
|
72
|
+
}
|
|
73
|
+
/** Server-side cross of a legislature list with the current one (contract v1.3 `derived`). */
|
|
74
|
+
export const NOTA_DERIVACAO_EM_EXERCICIO = "Situação de exercício de cada senador da legislatura determinada pelo servidor, cruzando a lista da legislatura com a lista oficial dos senadores em exercício hoje.";
|
|
75
|
+
/**
|
|
76
|
+
* Provenance of `senado_listar_senadores`. A plain list (atual/afastados) restates the
|
|
77
|
+
* source. With `legislatura`, `emExercicio` comes from a second reading (`atual`), which
|
|
78
|
+
* becomes a field source, and the block is marked derived.
|
|
79
|
+
*/
|
|
80
|
+
export function provenanceDaListagem(baseUrl, params, principal, atual) {
|
|
81
|
+
const fonte = fonteDaListagem(params);
|
|
82
|
+
const prov = provenanceFor("SENADO_LEGIS", baseUrl, fonte.path, {
|
|
83
|
+
dataset_id: fonte.dataset_id,
|
|
84
|
+
retrieved_at: principal.fetchedAt,
|
|
85
|
+
});
|
|
86
|
+
if (!atual)
|
|
87
|
+
return prov;
|
|
88
|
+
return derivado(withFieldSources(prov, [
|
|
89
|
+
{
|
|
90
|
+
fields: ["emExercicio"],
|
|
91
|
+
source_url: `${baseUrl.replace(/\/$/, "")}${PATH_SENADORES_ATUAIS}`,
|
|
92
|
+
dataset_id: "lista/atual",
|
|
93
|
+
...leituraDoCache(atual),
|
|
94
|
+
},
|
|
95
|
+
]), NOTA_DERIVACAO_EM_EXERCICIO);
|
|
96
|
+
}
|
|
29
97
|
/**
|
|
30
98
|
* Match a party filter tolerantly (OBS-6). The upstream stores the official sigla
|
|
31
99
|
* ("PODEMOS"), so an exact match against a common short form ("PODE") silently
|
|
@@ -290,20 +358,27 @@ export function provenanceSenadorDetalhe(baseUrl, codigoSenador, leitura) {
|
|
|
290
358
|
});
|
|
291
359
|
}
|
|
292
360
|
export function registerSenadoresTools(server, baseUrl) {
|
|
361
|
+
// One cache entry per official list: `emExercicio: false` shares the afastados
|
|
362
|
+
// entry with `senado_senadores_afastados`.
|
|
363
|
+
const lerListaOficial = (path) => path === PATH_SENADORES_AFASTADOS
|
|
364
|
+
? cachedFetchWithMeta("senado_senadores_afastados", {}, CACHE_SEMI_STATIC, () => upstreamFetch(path, {}, baseUrl))
|
|
365
|
+
: cachedFetchWithMeta("senado_listar_senadores", { path }, CACHE_SEMI_STATIC, () => upstreamFetch(path, {}, baseUrl));
|
|
293
366
|
// A1. senado_listar_senadores (filtro `nome` substitui a antiga busca por nome)
|
|
294
|
-
server.tool("senado_listar_senadores", "Use para pedidos como 'liste os senadores em exercício', 'senadores atuais', 'lista atual de senadores' ou filtros por UF/partido. Lista senadores em exercício ou de uma legislatura específica, com filtros opcionais por `nome`, `uf` e `partido`. Retorna `{ count, senadores }`, cada item com `codigo`, `nome`, `nomeCompleto`, `partido`, `uf`, `foto` e `emExercicio`, mais proveniência oficial
|
|
295
|
-
emExercicio: z.boolean().optional().
|
|
367
|
+
server.tool("senado_listar_senadores", "Use para pedidos como 'liste os senadores em exercício', 'senadores atuais', 'lista atual de senadores' ou filtros por UF/partido. Lista senadores em exercício, fora de exercício ou de uma legislatura específica, com filtros opcionais por `nome`, `uf` e `partido`. Retorna `{ count, senadores }`, cada item com `codigo`, `nome`, `nomeCompleto`, `partido`, `uf`, `foto` e `emExercicio`, mais proveniência oficial da lista lida. `emExercicio` é a situação de HOJE: sem `legislatura`, `true` (padrão) lista os em exercício (titulares e suplentes que assumiram a vaga) e `false` lista os fora de exercício (titulares licenciados e suplentes fora da vaga — a mesma lista de `senado_senadores_afastados`); com `legislatura`, omitido traz a legislatura inteira e `true`/`false` filtra pela situação de hoje. `nome` faz correspondência parcial ignorando acentos/maiúsculas (use quando você só tem o nome e precisa do `codigo`); `uf`/`partido` filtram localmente. Use o `codigo` em `senado_obter_senador` ou `senado_votacoes_senador`.", {
|
|
368
|
+
emExercicio: z.boolean().optional().describe("Situação de hoje: true = em exercício (padrão sem `legislatura`), false = fora de exercício. Com `legislatura`, omitido = todos"),
|
|
296
369
|
legislatura: z.number().int().min(1).optional().describe("Número da legislatura (ex: 57 para 2023-2027)"),
|
|
297
370
|
nome: z.string().optional().describe("Nome ou parte do nome (busca parcial, sem acento)"),
|
|
298
371
|
uf: z.string().max(2).optional().describe("Sigla do estado (ex: SP, RJ, MG)"),
|
|
299
372
|
partido: z.string().optional().describe("Sigla do partido (ex: PT, PL, MDB); tolera formas curtas como PODE→PODEMOS"),
|
|
300
373
|
}, async (params) => {
|
|
301
374
|
try {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
|
|
375
|
+
const fonte = fonteDaListagem(params);
|
|
376
|
+
const principal = await lerListaOficial(fonte.path);
|
|
377
|
+
const atual = fonte.cruzaComAtual ? await lerListaOficial(PATH_SENADORES_ATUAIS) : null;
|
|
378
|
+
const codigosEmExercicio = atual
|
|
379
|
+
? new Set(extractParlamentares(atual.value).map((p) => parseSenadorResumo(p).codigo))
|
|
380
|
+
: null;
|
|
381
|
+
let senadores = resumosDaListagem(extractParlamentares(principal.value), params, codigosEmExercicio);
|
|
307
382
|
if (params.nome) {
|
|
308
383
|
senadores = senadores.filter((s) => matchesNome(s, params.nome));
|
|
309
384
|
}
|
|
@@ -314,10 +389,7 @@ export function registerSenadoresTools(server, baseUrl) {
|
|
|
314
389
|
if (params.partido) {
|
|
315
390
|
senadores = senadores.filter((s) => matchesPartido(s.partido, params.partido));
|
|
316
391
|
}
|
|
317
|
-
const prov =
|
|
318
|
-
dataset_id: params.legislatura ? `legislatura=${params.legislatura}` : "lista/atual",
|
|
319
|
-
retrieved_at: fetchedAt,
|
|
320
|
-
});
|
|
392
|
+
const prov = provenanceDaListagem(baseUrl, params, principal, atual);
|
|
321
393
|
return resultWithProvenance({ count: senadores.length, senadores }, prov);
|
|
322
394
|
}
|
|
323
395
|
catch (e) {
|
|
@@ -435,10 +507,9 @@ export function registerSenadoresTools(server, baseUrl) {
|
|
|
435
507
|
// A7. senado_senadores_afastados
|
|
436
508
|
server.tool("senado_senadores_afastados", "Lista os senadores atualmente afastados (fora de exercício). Retorna `{ count, senadores }`, cada item com `codigo`, `nome`, `nomeCompleto`, `partido`, `uf`, `foto` e `emExercicio` (sempre `false`). Não requer parâmetros. Atenção: é a lista BRUTA do upstream, sem recorte de legislatura — pode conter registros históricos (ex.: senadores falecidos) e inconsistências pontuais com o detalhe do parlamentar; também não traz o vínculo titular↔suplente (para saber quem assumiu a vaga, consulte os mandatos em `senado_obter_senador`). Use `codigo` em `senado_obter_senador` para o detalhe; para os senadores em exercício (e busca por nome) use `senado_listar_senadores`.", {}, async () => {
|
|
437
509
|
try {
|
|
438
|
-
const { value: response, fetchedAt } = await
|
|
439
|
-
const senadores = extractParlamentares(response).map(parseSenadorResumo)
|
|
440
|
-
|
|
441
|
-
const prov = provenanceFor("SENADO_LEGIS", baseUrl, "/senador/afastados", {
|
|
510
|
+
const { value: response, fetchedAt } = await lerListaOficial(PATH_SENADORES_AFASTADOS);
|
|
511
|
+
const senadores = extractParlamentares(response).map((p) => parseSenadorResumo(p, false));
|
|
512
|
+
const prov = provenanceFor("SENADO_LEGIS", baseUrl, PATH_SENADORES_AFASTADOS, {
|
|
442
513
|
retrieved_at: fetchedAt,
|
|
443
514
|
});
|
|
444
515
|
return resultWithProvenance({ count: senadores.length, senadores }, prov);
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "senado-br-mcp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
4
4
|
"description": "MCP server for Brazilian Senate open data — runs hosted on Cloudflare Workers or locally via npx (stdio)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"@cloudflare/workers-types": "^5.20260830.1",
|
|
82
82
|
"@modelcontextprotocol/client": "^2.0.0",
|
|
83
83
|
"@sbissoli/mcp-evals": "^0.2.1",
|
|
84
|
-
"@sbissoli/mcp-live-source": "^0.
|
|
84
|
+
"@sbissoli/mcp-live-source": "^0.4.0",
|
|
85
85
|
"@sbissoli/mcp-surface": "^0.6.0",
|
|
86
86
|
"@types/node": "^26.5.1",
|
|
87
|
-
"agents": "^0.
|
|
87
|
+
"agents": "^0.30.0",
|
|
88
88
|
"exceljs": "^4.4.0",
|
|
89
89
|
"tsx": "^4.23.13",
|
|
90
90
|
"typescript": "^7.0.2",
|