senado-br-mcp 1.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Sidney da Silva Pereira Bissoli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,408 @@
1
+ # senado-br-mcp
2
+
3
+ MCP server for Brazilian Federal Senate open data (legislators, bills, votes, committees).
4
+
5
+ Servidor MCP (Model Context Protocol) que permite acesso estruturado aos dados abertos do Senado Federal do Brasil, democratizando o acesso a informações legislativas através de conversas com IA.
6
+
7
+ ## Features
8
+
9
+ - **33 tools** for accessing Senate data
10
+ - Real-time data from official API
11
+ - **e-Cidadania integration**: citizen participation data via web scraping
12
+ - Structured JSON responses
13
+ - Error handling with actionable suggestions
14
+ - TypeScript with full type safety
15
+ - **Two access modes:** stdio (npm) and HTTP remote
16
+
17
+ ## Two Ways to Use
18
+
19
+ | Mode | Installation | Best For |
20
+ |------|--------------|----------|
21
+ | **stdio/npm** | `npx senado-br-mcp` | Technical users, local usage |
22
+ | **HTTP remote** | None required | Non-technical users, cloud access |
23
+
24
+ Both modes provide access to the same 33 tools.
25
+
26
+ ---
27
+
28
+ ## Option 1: stdio/npm (Local)
29
+
30
+ ### Installation
31
+
32
+ **Using npx (Recommended):**
33
+ ```bash
34
+ npx senado-br-mcp
35
+ ```
36
+
37
+ **Global Installation:**
38
+ ```bash
39
+ npm install -g senado-br-mcp
40
+ senado-br-mcp
41
+ ```
42
+
43
+ **From Source:**
44
+ ```bash
45
+ git clone https://github.com/SidneyBissoli/senado-br-mcp.git
46
+ cd senado-br-mcp
47
+ npm install
48
+ npm run build
49
+ npm start
50
+ ```
51
+
52
+ ### Claude Desktop Configuration
53
+
54
+ Add to your `claude_desktop_config.json`:
55
+
56
+ **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
57
+ **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
58
+
59
+ ```json
60
+ {
61
+ "mcpServers": {
62
+ "senado-br-mcp": {
63
+ "command": "npx",
64
+ "args": ["-y", "senado-br-mcp"]
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Option 2: HTTP Remote (Cloud)
73
+
74
+ No installation required. Connect directly via URL.
75
+
76
+ ### Claude Desktop Configuration
77
+
78
+ In Claude Desktop settings, go to **"Add Custom Connector"** and enter:
79
+
80
+ - **Name:** senado-br-mcp
81
+ - **URL:** `https://senado-br-mcp.up.railway.app/mcp`
82
+
83
+ ### Endpoints
84
+
85
+ | Endpoint | Description |
86
+ |----------|-------------|
87
+ | `GET /` | Server info and documentation |
88
+ | `GET /health` | Health check |
89
+ | `GET /stats` | Usage statistics |
90
+ | `POST /mcp` | MCP protocol endpoint |
91
+
92
+ ### Rate Limiting
93
+
94
+ The HTTP server has a monthly request limit to stay within free tier:
95
+ - Alerts are sent at 50%, 80%, and 100% usage
96
+ - When limit is reached, use the npm version instead
97
+ - Limit resets on the 1st of each month
98
+
99
+ ## Available Tools
100
+
101
+ ### Senators (Senadores)
102
+
103
+ | Tool | Description |
104
+ |------|-------------|
105
+ | `senado_listar_senadores` | List senators in office or by legislature. Filters: state (UF), party |
106
+ | `senado_obter_senador` | Get detailed info about a senator (biography, mandates, committees) |
107
+ | `senado_buscar_senador_por_nome` | Search senators by name |
108
+ | `senado_votacoes_senador` | List how a senator voted. Filters: year, date range |
109
+
110
+ ### Legislative Matters (Matérias)
111
+
112
+ | Tool | Description |
113
+ |------|-------------|
114
+ | `senado_buscar_materias` | Search bills by type (PEC, PL, PLP, MPV), number, year, keyword, author |
115
+ | `senado_obter_materia` | Get bill details (summary, author, status, rapporteur) |
116
+ | `senado_tramitacao_materia` | Get bill's procedural history |
117
+ | `senado_textos_materia` | Get bill texts (original, substitute, final) with download URLs |
118
+ | `senado_votos_materia` | Get voting results for a bill |
119
+
120
+ ### Votes (Votações)
121
+
122
+ | Tool | Description |
123
+ |------|-------------|
124
+ | `senado_listar_votacoes` | List plenary votes by year. Filters: month, date range |
125
+ | `senado_obter_votacao` | Get vote details with nominal votes by senator |
126
+ | `senado_votacoes_recentes` | Get recent votes (last N days) |
127
+
128
+ ### Committees (Comissões)
129
+
130
+ | Tool | Description |
131
+ |------|-------------|
132
+ | `senado_listar_comissoes` | List committees. Filters: type (permanent, temporary, CPI), active |
133
+ | `senado_obter_comissao` | Get committee details (president, vice-president, purpose) |
134
+ | `senado_membros_comissao` | List committee members with roles |
135
+ | `senado_reunioes_comissao` | List committee meetings with agenda |
136
+
137
+ ### Agenda
138
+
139
+ | Tool | Description |
140
+ |------|-------------|
141
+ | `senado_agenda_plenario` | Get plenary session schedule with voting agenda |
142
+ | `senado_agenda_comissoes` | Get committee meeting schedule |
143
+
144
+ ### Lookup/Auxiliary (Auxiliares)
145
+
146
+ | Tool | Description |
147
+ |------|-------------|
148
+ | `senado_legislatura_atual` | Get current legislature info (number, period, dates) |
149
+ | `senado_tipos_materia` | List valid bill types (PEC, PL, PLP, MPV, etc.) |
150
+ | `senado_partidos` | List parties with senator count |
151
+ | `senado_ufs` | List states with senator count |
152
+
153
+ ### e-Cidadania (Citizen Participation)
154
+
155
+ Tools for accessing e-Cidadania data - the Senate's citizen participation platform.
156
+
157
+ #### Public Consultations (Consultas Públicas)
158
+
159
+ | Tool | Description |
160
+ |------|-------------|
161
+ | `senado_ecidadania_listar_consultas` | List public consultations with citizen voting on pending bills |
162
+ | `senado_ecidadania_obter_consulta` | Get consultation details including votes, author, and comments |
163
+ | `senado_ecidadania_consultas_polarizadas` | Get polarized consultations (~50/50 votes) - useful for identifying divisive issues |
164
+ | `senado_ecidadania_consultas_consensuais` | Get consensual consultations (>85% one way) - identifies broad agreement |
165
+
166
+ #### Legislative Ideas (Ideias Legislativas)
167
+
168
+ | Tool | Description |
169
+ |------|-------------|
170
+ | `senado_ecidadania_listar_ideias` | List citizen-proposed legislative ideas |
171
+ | `senado_ecidadania_obter_ideia` | Get idea details including full description and conversion to bill |
172
+ | `senado_ecidadania_ideias_populares` | Get most supported legislative ideas |
173
+
174
+ #### Interactive Events (Eventos Interativos)
175
+
176
+ | Tool | Description |
177
+ |------|-------------|
178
+ | `senado_ecidadania_listar_eventos` | List interactive events (hearings, confirmations, livestreams) |
179
+ | `senado_ecidadania_obter_evento` | Get event details including agenda, guests, and video link |
180
+ | `senado_ecidadania_eventos_populares` | Get events with most citizen comments and questions |
181
+
182
+ #### Analysis Tools
183
+
184
+ | Tool | Description |
185
+ |------|-------------|
186
+ | `senado_ecidadania_sugerir_tema_enquete` | AI-assisted analysis to suggest topics for monthly surveys based on participation metrics |
187
+
188
+ > **Note:** e-Cidadania tools use web scraping with rate limiting and caching. If the e-Cidadania website is temporarily unavailable, API tools (senators, bills, votes) remain operational.
189
+
190
+ ## Usage Examples
191
+
192
+ ### List senators from São Paulo
193
+
194
+ ```
195
+ Use senado_listar_senadores with uf: "SP"
196
+ ```
197
+
198
+ ### Search for Constitutional Amendments in 2024
199
+
200
+ ```
201
+ Use senado_buscar_materias with sigla: "PEC", ano: 2024
202
+ ```
203
+
204
+ ### Get recent votes
205
+
206
+ ```
207
+ Use senado_votacoes_recentes with dias: 7
208
+ ```
209
+
210
+ ### Find a senator by name
211
+
212
+ ```
213
+ Use senado_buscar_senador_por_nome with nome: "Randolfe"
214
+ ```
215
+
216
+ ### Get CCJ committee members
217
+
218
+ ```
219
+ Use senado_membros_comissao with sigla: "CCJ"
220
+ ```
221
+
222
+ ### Get polarized public consultations
223
+
224
+ ```
225
+ Use senado_ecidadania_consultas_polarizadas with minimoVotos: 5000
226
+ ```
227
+
228
+ ### Get most supported citizen ideas
229
+
230
+ ```
231
+ Use senado_ecidadania_ideias_populares with limite: 5
232
+ ```
233
+
234
+ ### Find upcoming interactive events
235
+
236
+ ```
237
+ Use senado_ecidadania_listar_eventos with status: "agendado"
238
+ ```
239
+
240
+ ## Response Format
241
+
242
+ All tools return structured JSON responses:
243
+
244
+ ### Success Response
245
+
246
+ ```json
247
+ {
248
+ "success": true,
249
+ "data": { ... },
250
+ "metadata": {
251
+ "fonte": "Senado Federal - Dados Abertos",
252
+ "dataConsulta": "2024-01-15T10:30:00Z",
253
+ "endpoint": "/senador/lista/atual"
254
+ }
255
+ }
256
+ ```
257
+
258
+ ### Error Response
259
+
260
+ ```json
261
+ {
262
+ "success": false,
263
+ "error": {
264
+ "code": "SENADOR_NAO_ENCONTRADO",
265
+ "message": "Senator with code 99999 was not found",
266
+ "suggestion": "Use senado_buscar_senador_por_nome to find the correct code"
267
+ }
268
+ }
269
+ ```
270
+
271
+ ## Development
272
+
273
+ ### Prerequisites
274
+
275
+ - Node.js 18+
276
+ - npm
277
+
278
+ ### Setup
279
+
280
+ ```bash
281
+ npm install
282
+ ```
283
+
284
+ ### Build
285
+
286
+ ```bash
287
+ # Build stdio version (npm package)
288
+ npm run build
289
+
290
+ # Build HTTP server version
291
+ npm run build:server
292
+
293
+ # Build both
294
+ npm run build:all
295
+ ```
296
+
297
+ ### Development Mode
298
+
299
+ ```bash
300
+ # stdio mode
301
+ npm run dev
302
+
303
+ # HTTP server mode
304
+ npm run dev:server
305
+ ```
306
+
307
+ ### Type Check
308
+
309
+ ```bash
310
+ npm run typecheck
311
+ ```
312
+
313
+ ### Test with MCP Inspector
314
+
315
+ ```bash
316
+ npm run inspect
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Self-Hosting HTTP Server
322
+
323
+ You can host your own HTTP server instance.
324
+
325
+ ### Local
326
+
327
+ ```bash
328
+ npm run build:server
329
+ npm run start:server
330
+ # Server runs on http://localhost:3000
331
+ ```
332
+
333
+ ### Railway
334
+
335
+ 1. Fork this repository
336
+ 2. Connect Railway to your GitHub
337
+ 3. Deploy (auto-detects configuration from `railway.json`)
338
+ 4. Set environment variables:
339
+ - `MONTHLY_REQUEST_LIMIT` (default: 10000)
340
+ - `ALERT_WEBHOOK_URL` (optional, for notifications)
341
+
342
+ ### Environment Variables
343
+
344
+ | Variable | Description | Default |
345
+ |----------|-------------|---------|
346
+ | `PORT` | Server port | 3000 |
347
+ | `MONTHLY_REQUEST_LIMIT` | Monthly request limit | 10000 |
348
+ | `ALERT_WEBHOOK_URL` | Webhook for alerts | - |
349
+ | `LOG_LEVEL` | Logging level | info |
350
+
351
+ ## Data Sources
352
+
353
+ ### Official API
354
+ - **API**: [Senado Federal - Dados Abertos](https://legis.senado.leg.br/dadosabertos)
355
+ - **Documentation**: https://legis.senado.leg.br/dadosabertos/docs/
356
+ - **Format**: JSON
357
+ - **Authentication**: None (public data)
358
+
359
+ ### e-Cidadania (Web Scraping)
360
+ - **Website**: [e-Cidadania](https://www12.senado.leg.br/ecidadania)
361
+ - **Content**: Public consultations, legislative ideas, interactive events
362
+ - **Method**: HTML scraping with rate limiting (1 req/sec) and caching (15min-24h)
363
+ - **Fallback**: If e-Cidadania is unavailable, API tools continue working
364
+
365
+ ## Bill Types (Tipos de Matéria)
366
+
367
+ | Code | Name | Description |
368
+ |------|------|-------------|
369
+ | PEC | Proposta de Emenda à Constituição | Constitutional Amendment |
370
+ | PL | Projeto de Lei | Ordinary Law Bill |
371
+ | PLP | Projeto de Lei Complementar | Complementary Law Bill |
372
+ | MPV | Medida Provisória | Provisional Measure |
373
+ | PDL | Projeto de Decreto Legislativo | Legislative Decree Bill |
374
+ | PRS | Projeto de Resolução do Senado | Senate Resolution Bill |
375
+ | PLC | Projeto de Lei da Câmara | Chamber of Deputies Bill |
376
+
377
+ ## License
378
+
379
+ MIT
380
+
381
+ ## Author
382
+
383
+ Sidney da Silva Pereira Bissoli
384
+
385
+ ## Repository
386
+
387
+ https://github.com/SidneyBissoli/senado-br-mcp
388
+
389
+ ## Contributing
390
+
391
+ Contributions are welcome! Please feel free to submit a Pull Request.
392
+
393
+ ## Changelog
394
+
395
+ ### 1.1.0
396
+
397
+ - Added e-Cidadania integration (11 new tools)
398
+ - Web scraping infrastructure with rate limiting and caching
399
+ - Public consultations analysis (polarized/consensual)
400
+ - Legislative ideas tracking
401
+ - Interactive events monitoring
402
+ - Survey topic suggestion tool
403
+
404
+ ### 1.0.0
405
+
406
+ - Initial release
407
+ - 22 tools for Senate data access
408
+ - Senators, bills, votes, committees, agenda, and lookup tools