Agent-Driven Brazilian Law MCP Server
Explore agent-driven Brazilian law research using official sources on the MCP server by pdmtt for accurate, up-to-date legal insights.
npx -y @pdmtt/brlaw_mcp_serverOverview
This MCP (Model Context Protocol) server provides a focused environment for agent-driven research into Brazilian law using official public sources. It implements an MCP-compatible API that lets LLM-based agents query, search, and retrieve authoritative legal documents (laws, decrees, jurisprudence, bills) from government-maintained repositories and indexed corpora. The goal is to enable reproducible, up-to-date legal retrieval workflows for developers building assistants, research tools, or compliance utilities.
The project is designed for integrations with agent frameworks and LLMs: it supplies searchable context, document metadata, and optional semantic ranking so agents can combine retrieved evidence with generative reasoning. Because the source material is drawn from official portals (Planalto, STF, STJ, Câmara, Senado, etc.), the server helps teams keep results accurate and traceable.
Features
- MCP-compatible HTTP API for agent integrations
- Indexing and retrieval of official Brazilian legal sources (legislation, jurisprudence, bills)
- Full-text search plus optional semantic (vector) search for relevance ranking
- Document metadata (citations, publication dates, source URLs) included in responses
- Pluggable data ingestion pipeline for PDFs, HTML, and XML feeds
- Configurable storage backends (local file, vector DBs) and cache support
- Dockerized deployment and simple local run mode for development
- Audit-friendly responses: links to original official documents in results
Installation / Configuration
Clone the repository and run with Docker (recommended) or locally for development.
Quick start (Docker Compose):
Run locally (Python/FastAPI example):
# configure environment variables (see .env.example)
Example .env configuration:
PORT=8080
DATA_DIR=./data
VECTOR_DB_URL=
INTO_OPENAI_API_KEY=YOUR_OPENAI_KEY
INGEST_SOURCES=planalto,stf,stj,camara
LOG_LEVEL=info
Environment variables (summary):
| Variable | Purpose |
|---|---|
| PORT | HTTP server port (default 8080) |
| DATA_DIR | Local path for documents and indices |
| VECTOR_DB_URL | Connection string for vector storage (optional) |
| INGEST_SOURCES | Comma-separated list of sources to index |
| LOG_LEVEL | Logging verbosity |
Available Resources
This server focuses on official Brazilian legal sources and provides connectors and parsers for common formats:
- Official portals: Planalto, STF, STJ, Câmara dos Deputados, Senado Federal
- Document parsers: HTML extractor, PDF text extractor, XML feed handler
- Indexes: full-text inverted index and optional vector index for semantic search
- Metadata mapping: standardized fields for citation, date, original_url, jurisdiction
These resources let agents cite primary documents and include direct links to the original postings, improving traceability.
Use Cases
Legal research assistant:
- An agent queries the MCP server for “regras de aposentadoria Lei 8.213/91 atualizações” and receives ranked documents (laws, modificative measures, relevant jurisprudence) with source links and passage snippets for use in a generated answer.
Compliance monitoring:
- A compliance bot runs periodic searches for new legislation matching regulatory keywords. When new documents are detected in the ingestion pipeline, the agent is notified and can summarize impacts for stakeholders.
Precedent discovery for litigation:
- A litigator’s agent requests jurisprudence related to a statute; the MCP server returns court decisions (STJ/STF) that cite the statute along with citation metadata so the agent can assemble a precedent brief.
Bill tracking and legislative intelligence:
- Track bills in Câmara/Senado, retrieve their text and amendment history, and expose results to an agent tasked with summarizing legislative intent or drafting alerts.
Example: Agent Request (HTTP)
The server exposes an MCP-compatible HTTP endpoint (default: /mcp). Example request format (JSON) and curl call:
Example (truncated) response structure:
Notes:
- The exact endpoint and payload fields can be customized; check the repo README or configuration files for the concrete schema.
- Semantic search requires a vector store backend and embedding provider configured.
Getting Help & Contributing
For usage notes, issues, and contributions, see the GitHub repository: https://github.com/pdmtt/brlaw_mcp_server/. Issues and pull requests