{
  "markdown": "# Portuguese Law MCP Server\n\n<!-- ANSVAR-CTA-BEGIN -->\n> **The Portuguese law corpus is now served through the Ansvar Gateway.** Connect your AI assistant (Claude, Copilot, Cursor, custom MCP client) to `https://gateway.ansvar.eu/mcp` — one OAuth connection, free tier available, covering this corpus plus EU regulations, national law across dozens of audited jurisdictions (Europe + the US), and CVE/security intelligence, every result with a verbatim source citation. Start at https://ansvar.eu/docs/quickstart\n\n### Connect\n\n**Claude Code** (one line):\n\n```bash\nclaude mcp add ansvar --transport http https://gateway.ansvar.eu/mcp\n```\n\n**Claude Desktop / Cursor** — add to `claude_desktop_config.json` (or `mcp.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"ansvar\": {\n      \"type\": \"url\",\n      \"url\": \"https://gateway.ansvar.eu/mcp\"\n    }\n  }\n}\n```\n\n**Claude.ai** — Settings → Connectors → Add custom connector → paste `https://gateway.ansvar.eu/mcp`\n\nFirst request opens an OAuth signup flow (setup details: [ansvar.eu/docs/quickstart](https://ansvar.eu/docs/quickstart)). After signup, your client is bound to your account; tier (free / premium / team / company) determines fan-out, quota, and which downstream MCPs are reachable.\n\n---\n\n## Self-host this MCP\n\nYou can also clone this repo and build the corpus yourself. The schema,\nfetcher, and tool implementations all live here. What is not in the repo is\nthe pre-built database — TDM and standards-licensing constraints on the\nupstream sources mean we host the corpus on Ansvar infrastructure rather\nthan redistribute it as a public artifact.\n\nBuild your own: run this repo's ingestion script (entry-point varies per\nrepo — typically `scripts/ingest.sh`, `npm run ingest`, or `make ingest`;\ncheck the repo root).\n<!-- ANSVAR-CTA-END -->\n\n\n**The Diário da República alternative for the AI age.**\n\n[![MCP Registry](https://img.shields.io/badge/MCP-Registry-blue)](https://registry.modelcontextprotocol.io)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![GitHub stars](https://img.shields.io/github/stars/Ansvar-Systems/portuguese-law-mcp?style=social)](https://github.com/Ansvar-Systems/portuguese-law-mcp)\n[![CI](https://github.com/Ansvar-Systems/portuguese-law-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Ansvar-Systems/portuguese-law-mcp/actions/workflows/ci.yml)\n[![Daily Data Check](https://github.com/Ansvar-Systems/portuguese-law-mcp/actions/workflows/check-updates.yml/badge.svg)](https://github.com/Ansvar-Systems/portuguese-law-mcp/actions/workflows/check-updates.yml)\n[![Database](https://img.shields.io/badge/database-pre--built-green)](docs/EU_INTEGRATION_GUIDE.md)\n[![Provisions](https://img.shields.io/badge/provisions-81%2C012-blue)](docs/EU_INTEGRATION_GUIDE.md)\n\nQuery **1,130 Portuguese statutes** -- from the Lei n.º 58/2019 (proteção de dados pessoais) and Código Penal to the Código Civil, Código do Trabalho, Decreto-Lei n.º 7/2004 (comércio eletrónico), and more -- directly from Claude, Cursor, or any MCP-compatible client.\n\nIf you're building legal tech, compliance tools, or doing Portuguese legal research, this is your verified reference database.\n\nBuilt by [Ansvar Systems](https://ansvar.eu) -- Stockholm, Sweden\n\n---\n\n## Why This Exists\n\nPortuguese legal research means navigating dre.pt (Diário da República Eletrónico), tracking Leis, Decretos-Lei, Portarias, and Despachos across multiple ministries, and cross-referencing EU transpositions. Whether you're:\n\n- A **lawyer** validating citations in a brief or contract\n- A **compliance officer** checking RGPD implementation or Código do Trabalho requirements\n- A **legal tech developer** building tools on Portuguese law\n- A **researcher** tracing EU directives through to Portuguese legislation\n\n...you shouldn't need dozens of browser tabs and manual PDF cross-referencing. Ask Claude. Get the exact provision. With context.\n\nThis MCP server makes Portuguese law **searchable, cross-referenceable, and AI-readable**.\n\n---\n\n## Example Queries\n\nOnce connected, just ask naturally -- in Portuguese or English:\n\n- *\"O que diz a Lei n.º 58/2019 (proteção de dados pessoais) sobre o consentimento?\"*\n- *\"O Código Penal está em vigor? Quais são as disposições sobre criminalidade informática?\"*\n- *\"Pesquisa por 'proteção de dados pessoais' na legislação portuguesa\"*\n- *\"Quais as diretivas europeias que a Lei n.º 58/2019 implementa?\"*\n- *\"Que diz o Código Civil sobre responsabilidade contratual?\"*\n- *\"Encontre as disposições do Código do Trabalho sobre teletrabalho\"*\n- *\"Quais as leis portuguesas que implementam o RGPD?\"*\n- *\"Which Portuguese laws implement the GDPR?\"*\n- *\"Compare NIS2 implementation requirements across Portuguese statutes\"*\n\n---\n\n## What's Included\n\n| Category | Count | Details |\n|----------|-------|---------|\n| **Statutes** | 1,130 statutes | Portuguese Leis, Decretos-Lei, Códigos, and Portarias |\n| **Provisions** | 81,012 sections | Full-text searchable with FTS5 |\n| **Preparatory Works** | 297,024 documents | Propostas de lei and parliamentary debates (Premium) |\n| **Database Size** | ~76 MB | Optimized SQLite, portable |\n| **Daily Updates** | Automated | Freshness checks against dre.pt |\n\n**Verified data only** -- every citation is validated against official sources (dre.pt). Zero LLM-generated content.\n\n---\n\n## See It In Action\n\n### Why This Works\n\n**Verbatim Source Text (No LLM Processing):**\n- All statute text is ingested from dre.pt (Diário da República Eletrónico) official sources\n- Provisions are returned **unchanged** from SQLite FTS5 database rows\n- Zero LLM summarization or paraphrasing -- the database contains regulation text, not AI interpretations\n\n**Smart Context Management:**\n- Search returns ranked provisions with BM25 scoring (safe for context)\n- Provision retrieval gives exact text by lei/decreto-lei identifier + artigo/número\n- Cross-references help navigate without loading everything at once\n\n**Technical Architecture:**\n```\ndre.pt API → Parse → SQLite → FTS5 snippet() → MCP response\n               ↑                      ↑\n        Provision parser       Verbatim database query\n```\n\n### Traditional Research vs. This MCP\n\n| Traditional Approach | This MCP Server |\n|---------------------|-----------------|\n| Search dre.pt by número de diploma | Search by plain Portuguese: *\"proteção de dados pessoais\"* |\n| Navigate multi-artigo statutes manually | Get the exact provision with context |\n| Manual cross-referencing between diplomas | `build_legal_stance` aggregates across sources |\n| \"Este diploma está em vigor?\" → manual check | `check_currency` tool → answer in seconds |\n| Find EU basis → dig through EUR-Lex | `get_eu_basis` → linked EU directives instantly |\n| Check dre.pt for updates | Daily automated freshness checks |\n| No API, no integration | MCP protocol → AI-native |\n\n**Traditional:** Search dre.pt → Download PDF → Ctrl+F → Cross-reference with proposta de lei → Check EUR-Lex → Repeat\n\n**This MCP:** *\"Qual o artigo da Lei 58/2019 sobre consentimento e qual a diretiva europeia que lhe dá base?\"* → Done.\n\n---\n\n## Available Tools (13)\n\n### Core Legal Research Tools (8)\n\n| Tool | Description |\n|------|-------------|\n| `search_legislation` | FTS5 search on 81,012 provisions with BM25 ranking |\n| `get_provision` | Retrieve specific provision by lei/decreto-lei identifier + artigo |\n| `validate_citation` | Validate citation against database (zero-hallucination check) |\n| `build_legal_stance` | Aggregate citations from statutes and preparatory works |\n| `format_citation` | Format citations per Portuguese conventions (full/short/pinpoint) |\n| `check_currency` | Check if statute is in force, amended, or repealed |\n| `list_sources` | List all available statutes with metadata and data provenance |\n| `about` | Server info, capabilities, dataset statistics, and coverage summary |\n\n### EU Law Integration Tools (5)\n\n| Tool | Description |\n|------|-------------|\n| `get_eu_basis` | Get EU directives/regulations for Portuguese statute |\n| `get_portuguese_implementations` | Find Portuguese laws implementing EU act |\n| `search_eu_implementations` | Search EU documents with Portuguese implementation counts |\n| `get_provision_eu_basis` | Get EU law references for specific provision |\n| `validate_eu_compliance` | Check implementation status (requires EU MCP) |\n\n---\n\n## EU Law Integration\n\nPortugal is an EU member state since 1986. Portuguese law extensively implements EU directives, particularly in data protection, financial services, consumer rights, and environmental law.\n\n| Metric | Value |\n|--------|-------|\n| **EU Member Since** | 1986 |\n| **GDPR Implementation** | Lei n.º 58/2019 |\n| **NIS2 Implementation** | Lei n.º 65/2021 (cybersecurity) |\n| **Data Authority** | Comissão Nacional de Proteção de Dados (CNPD) |\n| **EUR-Lex Integration** | Automated metadata fetching |\n\n### Key Portuguese EU Implementations\n\n- **GDPR** (2016/679) → Lei n.º 58/2019 (proteção de dados pessoais)\n- **NIS2 Directive** (2022/2555) → Lei n.º 65/2021 and subsequent updates\n- **AI Act** (2024/1689) → Portuguese implementation in progress\n- **eIDAS** (910/2014) → Decreto-Lei n.º 290-D/99 and updates\n- **AML Directive** (2015/849) → Lei n.º 83/2017 (combate ao branqueamento)\n- **Consumer Rights Directive** (2011/83) → Decreto-Lei n.º 24/2014\n\n> **Note on statute types:** Portuguese law uses a legislative hierarchy -- Lei (Parliament), Decreto-Lei (Government), Portaria (Ministry), Despacho (Department). The database covers the primary levels (Lei and Decreto-Lei) most relevant for compliance research.\n\nSee [EU_INTEGRATION_GUIDE.md](docs/EU_INTEGRATION_GUIDE.md) for detailed documentation.\n\n---\n\n## Data Sources & Freshness\n\nAll content is sourced from authoritative Portuguese legal databases:\n\n- **[dre.pt - Diário da República Eletrónico](https://dre.pt/)** -- Official Portuguese law database\n- **[EUR-Lex](https://eur-lex.europa.eu/)** -- Official EU law database (metadata only)\n\n### Data Provenance\n\n| Field | Value |\n|-------|-------|\n| **Authority** | Imprensa Nacional - Casa da Moeda (INCM) |\n| **Retrieval method** | dre.pt API |\n| **Language** | Portuguese |\n| **License** | Portuguese public data (open government) |\n| **Coverage** | 1,130 statutes (Leis, Decretos-Lei, Códigos, Portarias) |\n| **Last ingested** | 2026-02-25 |\n\n### Automated Freshness Checks (Daily)\n\nA [daily GitHub Actions workflow](.github/workflows/check-updates.yml) monitors all data sources:\n\n| Source | Check | Method |\n|--------|-------|--------|\n| **Statute amendments** | dre.pt API date comparison | All 1,130 statutes checked |\n| **New diplomas** | dre.pt Diário da República feed | Diffed against database |\n| **EU reference staleness** | Git commit timestamps | Flagged if >90 days old |\n\n---\n\n## Security\n\nThis project uses multiple layers of automated security scanning:\n\n| Scanner | What It Does | Schedule |\n|---------|-------------|----------|\n| **CodeQL** | Static analysis for security vulnerabilities | Weekly + PRs |\n| **Semgrep** | SAST scanning (OWASP top 10, secrets, TypeScript) | Every push |\n| **Gitleaks** | Secret detection across git history | Every push |\n| **Trivy** | CVE scanning on filesystem and npm dependencies | Daily |\n| **Docker Security** | Container image scanning + SBOM generation | Daily |\n| **Socket.dev** | Supply chain attack detection | PRs |\n| **OSSF Scorecard** | OpenSSF best practices scoring | Weekly |\n| **Dependabot** | Automated dependency updates | Weekly |\n\nSee [SECURITY.md](SECURITY.md) for the full policy and vulnerability reporting.\n\n---\n\n## Important Disclaimers\n\n### Legal Advice\n\n> **THIS TOOL IS NOT LEGAL ADVICE**\n>\n> Statute text is sourced from official dre.pt publications. However:\n> - This is a **research tool**, not a substitute for professional legal counsel\n> - **Court case coverage is limited** -- do not rely solely on this for case law research\n> - **Verify critical citations** against primary sources (dre.pt) for court filings\n> - **EU cross-references** are extracted from Portuguese statute text, not EUR-Lex full text\n> - **Portarias and Despachos** (ministerial orders) are only partially covered -- check relevant ministry websites for complete guidance\n\n**Before using professionally, read:** [DISCLAIMER.md](DISCLAIMER.md) | [PRIVACY.md](PRIVACY.md)\n\n### Client Confidentiality\n\nQueries go through the Claude API. For privileged or confidential matters, use on-premise deployment. See [PRIVACY.md](PRIVACY.md) for Ordem dos Advogados compliance guidance.\n\n---\n\n## Documentation\n\n- **[EU Integration Guide](docs/EU_INTEGRATION_GUIDE.md)** -- Detailed EU cross-reference documentation\n- **[EU Usage Examples](docs/EU_USAGE_EXAMPLES.md)** -- Practical EU lookup examples\n- **[Security Policy](SECURITY.md)** -- Vulnerability reporting and scanning details\n- **[Disclaimer](DISCLAIMER.md)** -- Legal disclaimers and professional use notices\n- **[Privacy](PRIVACY.md)** -- Client confidentiality and data handling\n\n---\n\n## Development\n\n### Setup\n\n```bash\ngit clone https://github.com/Ansvar-Systems/portuguese-law-mcp\ncd portuguese-law-mcp\nnpm install\nnpm run build\nnpm test\n```\n\n### Running Locally\n\n```bash\nnpm run dev                                       # Start MCP server\nnpx @anthropic/mcp-inspector node dist/index.js   # Test with MCP Inspector\n```\n\n### Data Management\n\n```bash\nnpm run ingest                     # Ingest statutes from dre.pt\nnpm run build:db                   # Rebuild SQLite database\nnpm run drift:detect               # Run drift detection\nnpm run check-updates              # Check for amendments and new statutes\nnpm run census                     # Generate coverage census report\n```\n\n### Performance\n\n- **Search Speed:** <100ms for most FTS5 queries\n- **Database Size:** ~76 MB (efficient, portable)\n- **Reliability:** 100% ingestion success rate\n\n---\n\n## More Ansvar MCPs\n\nFull fleet coverage at [ansvar.eu/coverage](https://ansvar.eu/coverage).\n## Contributing\n\nContributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\nPriority areas:\n- Court case law expansion (Supremo Tribunal de Justiça, Tribunal Constitucional)\n- EU regulation cross-reference expansion\n- Portaria and Despacho coverage\n- Historical statute versions and amendment tracking\n\n---\n\n## Roadmap\n\n- [x] Core statute database with FTS5 search\n- [x] Full corpus ingestion (1,130 statutes, 81,012 provisions)\n- [x] EU law integration tools\n- [x] Vercel Streamable HTTP deployment\n\n- [x] Daily freshness checks\n- [ ] Court case law expansion (STJ, Tribunal Constitucional)\n- [ ] Historical statute versions (amendment tracking)\n- [ ] Portaria and Despacho coverage\n- [ ] English translations for key statutes\n\n---\n\n## Citation\n\nIf you use this MCP server in academic research:\n\n```bibtex\n@software{portuguese_law_mcp_2026,\n  author = {Ansvar Systems AB},\n  title = {Portuguese Law MCP Server: Production-Grade Legal Research Tool},\n  year = {2026},\n  url = {https://github.com/Ansvar-Systems/portuguese-law-mcp},\n  note = {1,130 Portuguese statutes with 81,012 provisions and EU law cross-references}\n}\n```\n\n---\n\n## License\n\nApache License 2.0. See [LICENSE](./LICENSE) for details.\n\n### Data Licenses\n\nAnsvar attribution code: **`Portuguese-CDADC-Art-7-and-8`**. Basis:\n**cross-reference** between CDADC (Codigo do Direito de Autor e dos\nDireitos Conexos) Art. 8 and Art. 3(1)(c).\n\n- **Statutes & Legislation:** Imprensa Nacional - Casa da Moeda via\n  Diario da Republica (`dre.pt` / `diariodarepublica.pt`). Reused under\n  CDADC Art. 8 + Art. 3(1)(c).\n- **EU Metadata:** EUR-Lex (EU public-domain notice).\n\n### Coverage scope (cross-reference construction)\n\nPortugal's statutory-PD basis is a **cross-reference** — it requires two\narticles read together:\n\n- **Art. 8 (CDADC):** carves official documents from copyright protection.\n- **Art. 3(1)(c) (CDADC):** defines what counts as an \"official document\"\n  for the carve-out — legislative acts, administrative regulations,\n  court decisions, and other official texts.\n\n**Why this is NOT Art. 7 alone:** Art. 7 covers only news reports\n(`notícias do dia`), petitions (`petições`), and discourses\n(`discursos`). It does NOT cover statutes. Treating Art. 7 as the\nstatutory-PD basis is a common misreading. The correct construction is\nArt. 8 + Art. 3(1)(c).\n\nSee `docs/audits/2026-05-17-eu-copyright-statutory-works-batch-2-HU-LU-PT-RO-GR.md`\nin the Ansvar architecture-documentation repo for the verbatim Art. 8\nand Art. 3(1)(c) text and the cross-reference analysis.\n\n---\n\n## About Ansvar Systems\n\nWe build AI-accelerated compliance and legal research tools for the European market. This MCP server started as our internal reference tool for Portuguese law -- turns out everyone building compliance tools for the Iberian and Lusophone market has the same research frustrations.\n\nSo we're open-sourcing it. Navigating 1,130 diplomas in the Diário da República shouldn't require a law degree.\n\n**[ansvar.eu](https://ansvar.eu)** -- Stockholm, Sweden\n\n---\n\n<p align=\"center\">\n  <sub>Built with care in Stockholm, Sweden</sub>\n</p>\n",
  "bytes": 17094,
  "sha": "075dcf06dc923ab637c2900af293a9f045e80256895acd2cceafda8ee548886d",
  "repo_slug": "ansvar-systems/portuguese-law-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_eu_ansvar_portuguese_law_mcp_fcdd1cf0/readme"
}