polish-law-mcp
# polish-law-mcp
[English](#english) · [Polski](#polski)
---
## English
**An [MCP](https://modelcontextprotocol.io) server that lets AI assistants search and read Polish legal texts.**
It reads the data published in **[polish-law](https://github.com/MikolajKondej/polish-law)** (consolidated
statutes as Markdown and JSON, CC0, refreshed daily). That data is produced by
**[polish-law-toolkit](https://github.com/MikolajKondej/polish-law-toolkit)**.
| Repository | What it holds |
|---|---|
| [polish-law](https://github.com/MikolajKondej/polish-law) | the texts (data only) |
| [polish-law-toolkit](https://github.com/MikolajKondej/polish-law-toolkit) | the software that downloads and reads the texts |
| **polish-law-mcp** (this one) | the MCP server for AI clients |
> **The texts have no official force.** They are *teksty ujednolicone*: current but unofficial, prepared by the
> Chancellery of the Sejm, and extracted automatically from PDF files, so errors are expected. Always check
> the text published in Dziennik Ustaw (Journal of Laws). The server repeats this in every answer.
### Tools
| Tool | What it does |
|---|---|
| `list_kinds` | kinds of text available (today `unified`) and their size |
| `search_acts` | find acts by words in title or address, diacritics ignored |
| `get_act` | metadata: title, what the text is based on, source PDF, versions |
| `get_act_text` | the act as Markdown, in pages |
| `get_provision` | one provision by citation (`art. 1 ust. 3 pkt 1`) with its sub-units |
| `search_provisions` | provisions containing all given words, in one act or in all |
Every tool takes `kind` (default `unified`). The data repository keeps each kind of text in its own top-level folder
with the same layout, so kinds added there later work without changing the server (list them in `POLISH_LAW_KINDS`,
or, with a local clone, they are discovered).
### Install and use
```bash
pip install git+https://github.com/MikolajKondej/polish-law-mcp
```
Claude Desktop / any MCP client (stdio):
```json
{ "mcpServers": { "polish-law": { "command": "polish-law-mcp" } } }
```
Two ways to read the data:
* **Over HTTP (default).** Nothing to download: files are fetched from `raw.githubusercontent.com` when needed.
Searching inside provisions works within one act; searching all acts at once does not.
* **Local clone (faster, full search).** `git clone https://github.com/MikolajKondej/polish-law` and set
`POLISH_LAW_DATA_DIR=/path/to/polish-law`. Searching all ~800 acts then takes about 10 seconds.
| Variable | Meaning |
|---|---|
| `POLISH_LAW_DATA_DIR` | path to a local clone of polish-law |
| `POLISH_LAW_REPO`, `POLISH_LAW_REF` | repository (`owner/name`) and branch for HTTP mode; defaults `MikolajKondej/polish-law`, `main` |
| `POLISH_LAW_KINDS` | comma-separated kinds for HTTP mode; default `unified` |
### Tests
```bash
pip install -e '.[test]' && python -m pytest
```
Licence: [Apache 2.0](LICENSE) for the code. The texts are CC0 (see polish-law).
---
## Polski
**Serwer [MCP](https://modelcontextprotocol.io), dzięki któremu asystenci AI wyszukują i czytają polskie teksty
prawne.** Czyta dane z repozytorium **[polish-law](https://github.com/MikolajKondej/polish-law)** (teksty
ujednolicone ustaw jako Markdown i JSON, CC0, odświeżane codziennie). Dane wytwarza program
**[polish-law-toolkit](https://github.com/MikolajKondej/polish-law-toolkit)**.
| Repozytorium | Co zawiera |
|---|---|
| [polish-law](https://github.com/MikolajKondej/polish-law) | teksty (same dane) |
| [polish-law-toolkit](https://github.com/MikolajKondej/polish-law-toolkit) | program pobierający i odczytujący teksty |
| **polish-law-mcp** (to) | serwer MCP dla klientów AI |
> **Teksty nie mają mocy urzędowej.** To teksty ujednolicone: aktualne, ale nieurzędowe, opracowane przez Kancelarię
> Sejmu i odczytane automatycznie z plików PDF, więc mogą zawierać błędy. Zawsze sprawdź tekst ogłoszony w
> Dzienniku Ustaw. Serwer powtarza to w każdej odpowiedzi.
### Narzędzia
`list_kinds` (rodzaje tekstów), `search_acts` (akty po słowach z tytułu, bez względu na polskie znaki),
`get_act` (metadane i wersje), `get_act_text` (akt jako Markdown, stronami), `get_provision` (przepis po
cytacie, np. `art. 1 ust. 3 pkt 1`, razem z jednostkami podrzędnymi), `search_provisions` (przepisy ze wszystkimi
podanymi słowami, w jednym akcie albo we wszystkich). Każde narzędzie przyjmuje `kind` (domyślnie `unified`);
nowe rodzaje tekstów w repozytorium danych (osobne katalogi o tym samym układzie) działają bez zmian w serwerze.
### Instalacja i użycie
```bash
pip install git+https://github.com/MikolajKondej/polish-law-mcp
```
Konfiguracja klienta MCP: `{ "mcpServers": { "polish-law": { "command": "polish-law-mcp" } } }`.
Domyślnie serwer pobiera pliki przez HTTP z GitHuba (wyszukiwanie w treści działa w obrębie jednego aktu).
Żeby przeszukiwać wszystkie akty naraz (ok. 10 s), sklonuj `polish-law` i ustaw `POLISH_LAW_DATA_DIR`.
Zmienne: `POLISH_LAW_DATA_DIR`, `POLISH_LAW_REPO`, `POLISH_LAW_REF`, `POLISH_LAW_KINDS` (opis wyżej).
Licencja kodu: [Apache 2.0](LICENSE). Teksty: CC0 (zob. polish-law).
TDQS
Scored across 6 tools
Each tool has a clearly distinct target: list_kinds (corpus summary), search_acts (title lookup) vs search_provisions (content lookup), get_act (metadata) vs get_act_text (full paginated text) vs get_provision (single citation). The overlap between get_act_text and get_provision is explicitly resolved by the description's guidance to prefer get_provision when a citation is known.
Uniform snake_case verb_noun pattern throughout (list_kinds, search_acts, get_act, get_act_text, get_provision, search_provisions). The two verbs (list/get/search) map predictably onto summary/metadata vs. retrieval vs. lookup semantics.
Six tools is well within the ideal range and each earns its place: corpus overview, two search axes, metadata, bulk text, and single-provision retrieval. Nothing redundant and nothing feels missing at the count level.
The read-only retrieval lifecycle (discover kinds -> search acts -> act metadata -> text -> provision -> search inside provisions) is fully covered with no dead ends. Minor gaps remain: no table-of-contents/structure endpoint for long acts, no way to retrieve historical/specific versions despite metadata mentioning versions seen, and search_provisions is crippled without a local data clone.