AG

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.

Quick Install
npx -y @pdmtt/brlaw_mcp_server

Overview

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):

git clone https://github.com/pdmtt/brlaw_mcp_server.git
cd brlaw_mcp_server
docker-compose up -d

Run locally (Python/FastAPI example):

git clone https://github.com/pdmtt/brlaw_mcp_server.git
cd brlaw_mcp_server
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# configure environment variables (see .env.example)
uvicorn app.main:app --host 0.0.0.0 --port 8080

Example .env configuration:

# .env
PORT=8080
DATA_DIR=./data
VECTOR_DB_URL=postgresql://user:pass@localhost:5432/vectordb
INTO_OPENAI_API_KEY=YOUR_OPENAI_KEY
INGEST_SOURCES=planalto,stf,stj,camara
LOG_LEVEL=info

Environment variables (summary):

VariablePurpose
PORTHTTP server port (default 8080)
DATA_DIRLocal path for documents and indices
VECTOR_DB_URLConnection string for vector storage (optional)
INGEST_SOURCESComma-separated list of sources to index
LOG_LEVELLogging 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

  1. 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.
  2. 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.
  3. 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.
  4. 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:

curl -X POST "http://localhost:8080/mcp" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "legal-research-agent-1",
    "input": {
      "type": "search",
      "query": "direito administrativo licitação responsabilidade civil",
      "max_results": 5,
      "semantic": true
    }
  }'

Example (truncated) response structure:

{
  "context": [
    {
      "id": "doc-12345",
      "title": "Lei nº 8.666/1993",
      "snippet": "...regulates public procurement...",
      "source": "Planalto",
      "url": "https://www.planalto.gov.br/ccivil_03/leis/L8666cons.htm",
      "score": 0.92
    }
  ],
  "status": "ok"
}

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

Tags:search