Python MCP server and HTTP API for loading, validating, searching, and resolving German legal texts with source provenance.
Project description
legal-text-mcp-de
MCP-native research agent for German federal + state law, with HTTP API as secondary surface.
It is local or server-side infrastructure: no SaaS, no billing, no
accounts, no tenant model, and no legal advice. The runtime loads
either the committed fixture packages used by fast CI or a generated
production corpus package built outside Git. Official text comes from
gesetze-im-internet.de for German federal laws and from EUR-Lex /
Cellar for EU acts such as the GDPR.
No legal advice. This software returns text and structured metadata. It does not interpret the law, advise on it, or produce any legal conclusion. The maintainer assumes no liability for use in legal decision-making contexts.
Older internal documentation has been archived under docs-legacy/summary.md.
Status
| Lifecycle | Stable v2.0.0 GA — MCP-native domain server |
| Versioning | SemVer 2.0.0 (stability contract starts at v1.0.0) |
| Licence | Apache License 2.0 — see LICENSE and NOTICE |
| Upstream | Derived from floleuerer/deutsche-gesetze-mcp (MIT, preserved) |
Features
- MCP tools for listing laws, fetching norms, resolving citations, full-text search, and source provenance.
- HTTP API (FastAPI) over the same runtime, with structured
/health,/ready,/laws,/search, and OpenAPI endpoints. - Provenance-first design: every law and norm carries source URL, fetch timestamp, content hash, and the parser path it traversed.
- Two corpus modes: committed fixture packages for deterministic tests and CI, or a generated production package built from official sources at runtime.
- No editorial bundling: this repository ships tooling, not legal text. Texts are loaded from official sources at runtime.
Installation
Mode 1 — uvx + auto-download (default, easiest)
uvx legal-text-mcp-de
Server fetches the latest signed corpus bundle from GHCR on first run.
Mode 2 — Docker with pre-bundled corpus
docker run -p 8001:8001 ghcr.io/klein-business/legal-text-mcp-de-full:2.0.0
Mode 3 — Self-built corpus (compliance-sensitive)
git clone https://github.com/klein-business/legal-text-mcp-de
cd legal-text-mcp-de
uv run python -m prepare_data.build_corpus --output ./my-corpus.tar.zst --sources land:by,land:nrw
DATASET_PATH=./my-corpus.tar.zst uvx legal-text-mcp-de
Mode 4 — Public-hosted service
// claude_desktop_config.json
{
"mcpServers": {
"legal-de": {
"url": "https://mcp.klein.business/legal/de",
"transport": "streamable-http"
}
}
}
Quickstart
Run the MCP server with the committed fixture corpus
uv sync --all-groups
DATASET_PATH=tests/fixtures/normalized \
STRICT_STARTUP=true \
uv run legal-text-mcp-de
The default transport is streamable HTTP at
http://localhost:8001/mcp.
Run the HTTP API
DATASET_PATH=tests/fixtures/normalized \
STRICT_STARTUP=true \
uv run uvicorn legal_text_mcp_de.http_api:app --host 127.0.0.1 --port 8080
Docker
The Docker image does not bundle legal text data. Mount a validated
package at /data/legal-texts:
docker run --rm -p 8001:8001 \
-v /path/to/legal-text-package:/data/legal-texts:ro \
ghcr.io/klein-business/legal-text-mcp-de:2.0.0
MCP Resources
v2.0 exposes the corpus as read-only legal:// URIs that any MCP client can load directly into its LLM context. Examples:
legal://laws— paginated indexlegal://laws/bgb— BGB header + norm indexlegal://laws/bgb/norms/par:433— § 433 BGB as Markdownlegal://corpus/coverage— what's in the corpus
See docs/concepts/mcp-native.md for the full URI catalogue.
MCP Prompts (slash-commands)
Five curated workflows appear as slash-commands in MCP clients:
| Slash | Args | Purpose |
|---|---|---|
/rechtsfrage |
frage, rechtsgebiet? |
Answer a German legal question with exact norm citations |
/zitation-checken |
citation |
Resolve a citation (e.g. § 433 Abs. 1 BGB) + Stand-Datum |
/norm-erklaeren |
code, norm |
Plain-language explanation with cited cross-references |
/recherche |
topic |
Multi-step research using research_topic smart tool |
/dsgvo-check |
aktivitaet |
Walk through GDPR Art. 5, 6, 7, 9, 13, 14 against a processing activity |
Smart Tools
research_topic is a multi-step research tool that orchestrates 2 LLM-sampling calls per invocation:
- Corpus search for candidate norms
- LLM ranking of candidates by relevance
- Related-norms graph loading
- LLM synthesis of a structured research report
When the client lacks sampling support, the tool returns a degraded report with ranked candidates only.
Data Sources
| Source | Coverage | Reuse position |
|---|---|---|
gesetze-im-internet.de |
German federal laws | Public-domain-equivalent under §5 (1) UrhG |
EUR-Lex / Cellar (publications.europa.eu) |
EU acts (GDPR, AI Act, Data Act, …) | Reuse permitted under Commission Decision 2011/833/EU with attribution |
No text from these sources is committed to this repository. The generated-corpus pipeline fetches them at build time and stores provenance in a manifest.
MCP Tools
See the MCP tools reference for the full surface. Highlights:
list_laws(query?)— list loaded laws with optional metadata filter.get_law(code)— law metadata + normalised norm summaries.get_norm(code, norm)— return one structured norm.search_laws(query, codes?)— search normalised texts.resolve_citation(...)— resolve structured citations without legal interpretation.get_source_metadata(code?),get_source_limitations(...),get_corpus_coverage(),get_related_norms(code, norm).
MCP tools return JSON-compatible objects. They do not return double-serialised JSON strings.
HTTP API
| Method | Path | Purpose |
|---|---|---|
GET |
/health |
Liveness |
GET |
/ready |
Readiness |
GET |
/laws |
List laws |
GET |
/laws/{code} |
Law detail |
GET |
/laws/{code}/norms/{norm} |
Norm detail |
GET |
/laws/{code}/norms/{norm}/relationships |
Relationship metadata |
GET |
/corpus/coverage |
Corpus coverage summary |
GET |
/corpus/source-limitations |
Source limitations query |
GET |
/search |
Search |
GET |
/openapi.json |
OpenAPI document |
Article-plus-section paths must be URL-encoded:
/laws/egbgb/norms/art%3A246a%2Fpar%3A1
Documentation
Full documentation is published at klein-business.github.io/legal-text-mcp-de.
Quick links:
- Quickstart
- MCP tools
- HTTP API
- Operations: security, SBOM, cosign-verify, versioning, threat model
- Roadmap
Source-of-truth documents live in the repo: README.md, CHANGELOG.md, SECURITY.md, CONTRIBUTING.md, GOVERNANCE.md, NOTICE, LICENSE.
Development
uv sync --all-groups
PYTHONPATH=mcp uv run --group dev pytest mcp/tests -v
The full fixture-backed release gate:
PYTHONPATH=mcp uv run --group dev python scripts/verify_release.py
The public-flip readiness gate:
PYTHONPATH=mcp uv run --group dev python scripts/verify_pre_flip.py
Contributing
See CONTRIBUTING.md for guidelines, code of conduct, and security policy.
All contributions must comply with the Developer Certificate of Origin
(sign-off with git commit -s).
Verification (post-v2.0.0)
Each release is signed and accompanied by an SBOM and SLSA-3 provenance.
Cosign image signature
cosign verify ghcr.io/klein-business/legal-text-mcp-de:2.0.0 \
--certificate-identity-regexp 'https://github.com/klein-business/.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
See Verify with cosign for SBOM and SLSA attestation verification.
Licence and acknowledgements
This project is licensed under the Apache License 2.0. See NOTICE for required attribution.
Derived from floleuerer/deutsche-gesetze-mcp (Copyright (c) 2025 Florian Leuerer, MIT). Upstream licence terms are preserved in licenses/MIT-floleuerer.txt.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file legal_text_mcp_de-2.0.0.tar.gz.
File metadata
- Download URL: legal_text_mcp_de-2.0.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da2e2149ec578bab72ffe4b9555383de6cf5b14b94a0e83c9237448dc5c4eab8
|
|
| MD5 |
b7297d24fecfaa671169589a61f257f9
|
|
| BLAKE2b-256 |
9a078f403b6f674cf3c4acee47db2ed3952b9ab4b5013a5e5749f8ae0ece6f43
|
Provenance
The following attestation bundles were made for legal_text_mcp_de-2.0.0.tar.gz:
Publisher:
release.yml on klein-business/legal-text-mcp-de
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
legal_text_mcp_de-2.0.0.tar.gz -
Subject digest:
da2e2149ec578bab72ffe4b9555383de6cf5b14b94a0e83c9237448dc5c4eab8 - Sigstore transparency entry: 1563700942
- Sigstore integration time:
-
Permalink:
klein-business/legal-text-mcp-de@05d6a213af61a6a697d6c64e48118df55005a72a -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/klein-business
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@05d6a213af61a6a697d6c64e48118df55005a72a -
Trigger Event:
push
-
Statement type:
File details
Details for the file legal_text_mcp_de-2.0.0-py3-none-any.whl.
File metadata
- Download URL: legal_text_mcp_de-2.0.0-py3-none-any.whl
- Upload date:
- Size: 112.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
377512609ce7cd17213d9db8efc9904352b274e458ddaa5b5baddaa386790816
|
|
| MD5 |
4246422ce3f577701b19b095c7ca9a13
|
|
| BLAKE2b-256 |
08e7140774051d45e46378a730c1635f52e3585520b2bc0ae532cc8b39a909ed
|
Provenance
The following attestation bundles were made for legal_text_mcp_de-2.0.0-py3-none-any.whl:
Publisher:
release.yml on klein-business/legal-text-mcp-de
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
legal_text_mcp_de-2.0.0-py3-none-any.whl -
Subject digest:
377512609ce7cd17213d9db8efc9904352b274e458ddaa5b5baddaa386790816 - Sigstore transparency entry: 1563700984
- Sigstore integration time:
-
Permalink:
klein-business/legal-text-mcp-de@05d6a213af61a6a697d6c64e48118df55005a72a -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/klein-business
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@05d6a213af61a6a697d6c64e48118df55005a72a -
Trigger Event:
push
-
Statement type: