Skip to main content
Glama
brazil-legislation-mcp-server

brazil-legislation-mcp-server

by cyanheads

Version License Docker MCP SDK npm TypeScript Bun

Install in Claude Desktop Install in Cursor Install in VS Code

Framework


Overview

Search the Senado Federal catalog for Brazilian federal norms and selected STF constitutional-review decisions. Resolve a citation such as Lei 13.709/2018 (LGPD), read a specific publication or provision, and trace the acts that changed it. Exact state and municipal LexML URNs can return bibliographic metadata. The sources are public and require no API key.

Tools

Tool

Purpose

brlaw_search_norms

Search Portuguese summaries and nicknames or browse a signature year.

brlaw_lookup_citation

Resolve citations, nicknames and LexML URNs in a batch.

brlaw_get_norm

Get norm metadata, publication IDs and change counts.

brlaw_get_text

Read an edition, available translation, article or section.

brlaw_get_changes

Trace later and earlier acts by act or provision.

brlaw_list_reference

Inspect citation syntax, source coverage, mirror state and Senado vocabularies.

Related MCP server: FREOA Verifica

Capability reference

For search, changes and vocabulary pages, limit defaults to 25 and clamps to 200. Continue with next_offset and optionally pass back page_token to check continuity. On page_changed, restart at offset 0 without the token.

brlaw_search_norms tool

  • Searches Portuguese ementas and nicknames with accent-insensitive matching. Filter by Senado types (including family expansion), number, and either signature year or ISO date bounds. The default sort is relevance with a query and newest without one. oldest is also available.

  • Send equal year bounds or two dates in one year, with no query, to browse live. Other searches require the initialized mirror. The response names the source and gives the live observation time or the mirror's coverage.

brlaw_lookup_citation tool

  • Resolves the first 25 citations in input order, preserving the rest in unprocessed. Include a type and year when available. Provision addresses such as Art. 26, § 1º, II can follow a citation.

  • Outcomes are found, ambiguous, not_found, outside_base, and unavailable. A found row gives the Senado ID for subsequent calls. outside_base covers exact non-federal LexML URNs. Some nickname lookups need the mirror.

brlaw_get_norm tool

  • Takes norm as a Senado ID, LexML URN, typed citation, or nickname. Returns the official summary, subject indexing, publications, text versions, and recorded change counts. Use a returned publication_id to select an edition.

  • include_lexml defaults to false. When enabled, it can add a bill of origin and doctrine references. Doctrine pages default to 10 rows and continue with lexml.doctrine.next_offset.

brlaw_get_text tool

  • Defaults to consolidated Portuguese text. The server tries Senado, Câmara and verified Planalto compilations, then the original. Choose version: "as_published" or an exact publication_id. Available Senado translations can be requested with language: "en" or "fr".

  • Choose articles or sections. Article selection processes up to 10 addresses and returns the rest for a follow-up. Text over 24,000 characters returns an outline. Use its section IDs with the same edition to retrieve complete sections. A repeated section ID returns same_as_selection, the one-based position of its first result in selections.

  • Results distinguish whole, outline, selected and unavailable. Read the served source, date and date basis before citing. An unknown compilation date means freshness is unknown. Dated later acts are recorded changes and do not establish legal effect. The Diário Oficial da União is authoritative.

brlaw_get_changes tool

  • Set direction to changed_by (default), changes or both. Use view: "by_act" (default) or "by_article". Filter by related-act signature dates, relation kinds, actions or act classes such as stf_ruling.

  • Includes recorded Portuguese relation labels, notes, and affected provisions where the source supplies them. Each item indicates whether the recorded action changes wording.

brlaw_list_reference tool

  • topic: "overview" (default) gives citation and provision examples, source credits, and index coverage. Choose types, publications, relations or actions for vocabulary rows and snapshot provenance.

  • Senado uses ADCon in type filters for the STF action cited as ADC. ADC in those filters stands for Ato Declaratório.

Features

Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.

  • Cross-year search uses a persistent SQLite FTS5 mirror of the Senado catalog. The November 30, 2026 sweep indexed 244,266 unique IDs across signature years 1808–2026. Use brlaw_list_reference for current local coverage and readiness.

  • Reformatted texts retain source links and publication notices. Source credits go to Senado Federal, Câmara dos Deputados, Presidência da República and LexML Brasil.

Getting started

For npm installs, use Node.js 24 or later with built-in SQLite. The portable .mcpb is a stdio bundle and declares the same Node floor for the runtime that the host uses to launch it.

claude mcp add brazil-legislation-mcp-server -- npx -y @cyanheads/brazil-legislation-mcp-server

For other clients, add this to the MCP config file:

{
  "mcpServers": {
    "brazil-legislation-mcp-server": {
      "command": "npx",
      "args": ["-y", "@cyanheads/brazil-legislation-mcp-server"]
    }
  }
}

For local Streamable HTTP:

MCP_TRANSPORT_TYPE=http npx -y @cyanheads/brazil-legislation-mcp-server

Connect to http://127.0.0.1:3010/mcp. For Docker or a source build, see Running the server.

Configuration

Variable

Description

Default

BRLAW_DATA_DIR

Writable directory for the index and reference snapshot. Use the same directory for the CLI and server.

brazil-legislation-mcp-server in the per-user app data directory

MCP_TRANSPORT_TYPE

stdio or http.

stdio

MCP_HTTP_HOST

HTTP bind address.

127.0.0.1

MCP_HTTP_PORT

HTTP port.

3010

MCP_HTTP_ENDPOINT_PATH

HTTP MCP path.

/mcp

MCP_SESSION_MODE

HTTP session mode.

stateless

MCP_AUTH_MODE

none, jwt, or oauth.

none

MCP_LOG_LEVEL

Minimum log level.

info

OTEL_ENABLED

Enable OpenTelemetry.

false

See .env.example for common framework overrides.

Running the server

Initialize and refresh the index

Exact citations and single-year listings can use live Senado data from first launch. Initialize the mirror once for cross-year and text searches:

npx -y --package @cyanheads/brazil-legislation-mcp-server brazil-legislation-mirror init
npx -y --package @cyanheads/brazil-legislation-mcp-server brazil-legislation-mirror verify
npx -y --package @cyanheads/brazil-legislation-mcp-server brazil-legislation-mirror refresh

init resumes interrupted work. verify reports integrity and coverage. HTTP schedules a daily refresh for an initialized index. For stdio, run refresh to update the index and reference vocabularies. A refresh covers this year and the previous year, or all years when the last complete sweep is at least seven calendar days old. Keep the data directory across restarts.

Local development

Requires Bun v1.4.4 or higher for project scripts and Node.js 24 or later for the start scripts.

git clone https://github.com/cyanheads/brazil-legislation-mcp-server.git
cd brazil-legislation-mcp-server && bun install
cp .env.example .env
bun run rebuild
bun run start:http
# or bun run start:stdio

After building, the mirror commands are also available as node dist/mirror-cli.js init, refresh, and verify.

Docker

Initialize a named volume and use it again when starting the server:

docker run --rm -v brlaw-data:/usr/src/app/.mirror \
  ghcr.io/cyanheads/brazil-legislation-mcp-server:latest bun run dist/mirror-cli.js init
docker run --rm -p 127.0.0.1:3010:3010 -v brlaw-data:/usr/src/app/.mirror \
  ghcr.io/cyanheads/brazil-legislation-mcp-server:latest

The image defaults to HTTP with stateless sessions. Substitute refresh or verify in the lifecycle command as needed. For stdio, run with -i and -e MCP_TRANSPORT_TYPE=stdio in place of the port mapping. To build locally, run docker build -t brazil-legislation-mcp-server ..

Project structure

Directory

Purpose

src/mcp-server/tools

Six MCP tool contracts and handlers.

src/domain

Citation resolution, provision addresses, and change relationships.

src/services/senado

Norm records, publication retrieval and reference vocabularies.

src/services/mirror

Local SQLite mirror and reference refresh.

src/services/text

Edition selection, legal HTML parsing and text provenance.

src/services/lexml

Exact-URN ficha and doctrine metadata.

tests/

Contract and service tests.

Development guide

See CLAUDE.md for development guidelines and architectural rules. See docs/design.md for source mappings and mirror behavior.

Contributing

Issues are welcome. Run checks and tests before submitting:

bun run devcheck
bun run test

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables searching and reading federal statutes with linked legal and inline citations, listing published titles, and retrieving complete sections with bounded pagination through hosted HTTP or local stdio.
      3
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables verified retrieval of Brazilian primary legal sources — legislation, CVM and CMN/BCB norms, and case law — with reproducible evidence, checking whether a provision exists, whether a quoted passage is literal, which wording was in force on a given date, and whether the citations in a document resolve. Each result carries official URLs, capture timestamps and hashes, and the server abstains rather than asserting nonexistence when an official source cannot be reached.
      13
      AGPL 3.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables hybrid retrieval and reranking over public Brazilian legislation, returning answers with literal per-sentence citations verified by code through search, answer, health, and source-listing tools over stdio or HTTP.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables searching, reading, and citing Brazilian legislation from a local read-only corpus clone, with article-level retrieval, faceted counts, coverage gap checks, and signatory lookups.
      5
      MIT