Skip to main content
Glama
silent-law

silent-law

by lechiffre1

Silent Law — § 309 BGB Statutory Compliance Checker

A neuro-symbolic MCP server that checks German AGB (Allgemeine Geschäftsbedingungen) clauses against all 16 mandatory prohibitions in § 309 BGB, determines voidness (Nichtigkeit), and identifies the statutory substitution rule that replaces each void clause.

The Problem

Legal AI tools check what contracts say. They don't check what mandatory law does to contracts.

Under German law, § 309 BGB contains 16 bright-line prohibitions that automatically void non-compliant clauses in standard terms (AGB). When a clause is void, the statute doesn't just delete it — it substitutes a specific statutory provision in its place. A warranty limited to 6 months doesn't just "fail" — it's replaced by the full 24-month statutory period under § 438 BGB, retroactively, across every contract that used it.

No widely available legal AI tool checks for this systematically. They operate at Layer 1 (what does the contract say?) but are blind to Layer 2 (what does mandatory law do to the contract?).

Silent Law fills that gap.

Related MCP server: wanhe-compliance

Architecture

Three stations, strict handoff between each:

Station 1 — LLM Extraction: Reads a German AGB clause (messy natural language) and converts it into a structured data card: clause type, parameters, regime (B2C/B2B), goods condition, confidence score. The LLM is a translator, not a judge. Temperature=0 required for reproducibility.

Station 2 — Pydantic Schema Boundary: Validates the data card before it reaches the validator. Missing fields, malformed data, unexpected types — all rejected. This is the security boundary. LLM output is untrusted input. The schema enforces required parameters per clause type (e.g., a warranty clause must have limitation_period_months and goods_condition).

Station 3 — Deterministic Validator: Pure Python if/then logic. Checks the structured data against the 16 statutory prohibitions. Same input → same output, every time. No AI involved. When it says VOID, it provides the exact statutory citation, the threshold crossed, and the substitution rule.

Three-Ring Design

┌─────────────────────────────────────────────────┐
│  Outer Ring: Integration Layer                  │
│  Claude Skills / Plugins / Platform Connectors  │
├─────────────────────────────────────────────────┤
│  Middle Ring: Deployment Wrappers               │
│  wrappers/mcp_server.py  (~50 lines plumbing)  │
├─────────────────────────────────────────────────┤
│  Inner Ring: Model-Agnostic Python Core         │
│  silent_law/                                    │
│  ├── validation/ (models, validators, checker)  │
│  ├── knowledge/  (prohibitions.json, subs.json) │
│  ├── extraction/ (LLM prompt templates)         │
│  └── reporting/  (output formatting)            │
└─────────────────────────────────────────────────┘
  • Inner ring: Model-agnostic Python core (silent_law/). Never imports transport layers. Works with any LLM, any deployment target.

  • Middle ring: Deployment wrappers (~50 lines each). Currently MCP server (wrappers/mcp_server.py). Future: REST API, Azure Functions.

  • Outer ring: Integration layer. Claude skills/plugins, platform connectors.

Verdicts

Verdict

Meaning

When

VOID

Clause violates a bright-line prohibition. Automatic, deterministic.

Statutory threshold crossed

VALID

Clause checked against all relevant prohibitions and passed.

All checks passed. Audit trail lists every check performed

INDICATIVE_VIOLATION

B2B context — same violation would be VOID in B2C. Strong indicator of § 307 failure.

B2B regime detected

NEEDS_REVIEW

Extraction uncertain, parameter missing, or evaluative question beyond scope.

Confidence < 0.75, missing required param, or § 307 territory

These correspond to the ComplianceStatus enum in silent_law/validation/models.py.

Quick Start

Requirements: Python ≥ 3.10, uv package manager.

# Clone the repository
git clone https://github.com/jasper-michieka/silent-law-mcp.git
cd silent-law-mcp

# Install dependencies
uv sync --dev

# Run tests (151 tests covering all 16 prohibitions)
uv run pytest tests/ -v

# Start MCP server (stdio mode — for Claude Desktop, Claude Code, Cursor)
uv run wrappers/mcp_server.py

# Start MCP server (HTTP mode — for browser/inspector)
uv run wrappers/mcp_server.py --http

Dependencies (from pyproject.toml):

  • mcp[cli]>=1.0.0 — FastMCP server framework

  • pydantic>=2.0.0 — Schema validation boundary

MCP Client Configuration

Add to your MCP client config (.mcp.json, Claude Desktop config, or Cursor settings):

{
  "mcpServers": {
    "silent-law": {
      "command": "uv",
      "args": ["--directory", "/path/to/silent-law-mcp", "run", "wrappers/mcp_server.py"]
    }
  }
}

MCP Tools

Tool

Purpose

check_clause

Check a single AGB clause against relevant § 309 prohibitions

check_contract

Extract and check all clauses in a contract (two-phase: extraction prompts → deterministic validation)

explain_prohibition

Return full detail on a specific § 309 Nr. X prohibition

get_substitution_rule

What the law substitutes for a void clause under § 306 Abs. 2 BGB

How It Works

  1. Input: A German AGB clause (e.g., "Mängelansprüche verjähren in 6 Monaten.")

  2. Station 1: The calling LLM extracts structured parameters using the extraction prompts (temperature=0). Output: {contract_type: "Kaufvertrag", limitation_period_months: 6, goods_condition: "new"}

  3. Station 2: Pydantic validates the schema. Missing fields, wrong types, or adversarial payloads are rejected.

  4. Station 3: Deterministic validator checks: 6 months < 24-month minimum (§ 438 BGB for new goods). Verdict: VOID under § 309 Nr. 8a lit. ff BGB.

  5. Output: Structured result with statutory citation, substitution rule (§ 438 Abs. 1 Nr. 3 BGB — 24 months applies), and full audit trail including checks_performed, knowledge_base_version, and disclaimer.

Knowledge Base

16 prohibitions encoded in silent_law/knowledge/prohibitions.json, versioned (schema_version: "1.0.0"). Each prohibition includes:

  • Statutory basis (e.g., § 309 Nr. 8a BGB)

  • Sub-provisions with threshold conditions and extraction hints

  • Applicable regime (B2C direct, B2B with Indizwirkung)

  • Cross-references to related BGB sections

Substitution mappings in silent_law/knowledge/substitutions.json. Each entry specifies the replacing statute, practical effect (DE/EN), and substituting statutes under § 306 Abs. 2 BGB.

Built entirely on open data from gesetze-im-internet.de.

The 16 Prohibitions

§ 309 Nr.

Topic

Key Threshold

1

Short-term price increases

4 months

2

Extension of time (Nachfrist)

Context-dependent

3

Set-off prohibition

Undisputed claims

4

Warning/deadline requirements

Statutory requirement

5

Lump-sum damages

Typical expected damage

6

Contractual penalty

Non-acceptance / late payment

7

Liability exclusion

Personal injury, gross fault

8a

Defect rights (sales)

24 months B2C new / 12 months used

8b

Defect rights (works)

12 months minimum

9

Contract duration

2yr initial / 1yr extension / 3mo notice

10

Party substitution

Withdrawal right required

11

Agent liability

Statutory limits

12

Burden of proof

User's sphere

13

Form requirements

Schriftform maximum

14

Deemed receipt

Actual receipt required

15

Assignment exclusion

Monetary claims protected

16

Retention rights

§ 273 BGB

Regime Toggle

Regime

Behavior

B2C_AGB (default)

§ 309 violations → VOID with substitution rules

B2B

Same matches → INDICATIVE_VIOLATION (Indizwirkung under § 310 Abs. 1 BGB). No substitution rules. § 307 balancing test note appended.

individual

§ 309 does not apply — skip validation entirely

Empirical Results

Phase 1–2: Core Validation

  • 4 test cases A/B tested against vanilla ChatGPT. Deterministic precision on bright-line checks. Correct deferral (NEEDS_REVIEW) on ambiguous cases.

  • 10 cross-model validated clauses (Gemini-drafted, GPT-executed, Claude-architected). 100% routing accuracy with functional meta-prompt. 40% failure rate with naive semantic classification — solved by evaluating economic effect, not surface vocabulary.

AGB-DE Benchmark (755 clauses)

Dataset: Braun & Matthes (ACL 2024), 3,764 expert-annotated German AGB clauses. Test split: 755 clauses, 37 void (4.9% prevalence).

Metric

Silent Law

Vanilla GPT

Best Published ML

F1

0.167

0.118

0.54

DMR

0.27

0.919

~0.43 (est.)

Interpretation: F1 is low because Silent Law checks § 309 only; the dataset labels voids across ALL statutes (§ 305c, § 307, § 308, § 309). This is a scope mismatch, not an architectural failure. The Dangerous Miss Rate (0.27 vs 0.919) validates the safety architecture: when Silent Law says VALID, it's far more trustworthy than vanilla GPT.

This is an iteration diagnostic. Statute annotation of the 37 void clauses to compute § 309-scoped F1 is pending.

Stress Tests (22 adversarial clauses)

Category

Result

Correct verdicts

16/21 (76%)

Conservative deferrals (NEEDS_REVIEW on valid)

3/21

Over-triggers (VOID on non-contractual text)

1/21

Edge cases (debatable classification)

1/21

Dangerous misses (VALID on void)

0/21

Zero false negatives on prohibited clauses across all adversarial tests.

See EVALUATION.md for full methodology and analysis.

Known Limitations

  • Covers § 309 BGB only (16 of ~80 AGB-law provisions). §§ 305c, 307, 308 are not checked. The pre-routing classifier routes out-of-scope clauses to NEEDS_REVIEW.

  • Extraction quality depends on the calling LLM. Temperature=0 is required but cannot be enforced by the MCP server — the calling client is responsible.

  • Confidence threshold (0.75) is uncalibrated. Set provisionally; proper calibration requires 50+ annotated clauses.

  • Conservative on nuanced liability clauses: compliant clauses with cap + carve-out structure tend to return NEEDS_REVIEW rather than VALID.

  • Cannot distinguish contractual terms from informational text (e.g., safety warnings may over-trigger).

  • No § 307/§ 308 evaluative checks (Tier 2/3 — roadmap item).

Project Structure

silent-law-mcp/
├── silent_law/                 # Inner ring: model-agnostic Python core
│   ├── __init__.py             # Package root, version 0.1.0
│   ├── validation/
│   │   ├── models.py           # Pydantic schemas, enums, REQUIRED_PARAMETERS
│   │   ├── validators.py       # 16 deterministic prohibition checkers
│   │   └── checker.py          # Orchestration: routing, regime handling, aggregation
│   ├── knowledge/
│   │   ├── prohibitions.json   # All 16 § 309 prohibitions (schema_version: 1.0.0)
│   │   ├── substitutions.json  # Statutory substitution rules per § 306 Abs. 2 BGB
│   │   └── loader.py           # JSON loading and lookup functions
│   ├── extraction/
│   │   └── prompts.py          # LLM extraction prompt templates (12 prompts)
│   └── reporting/
│       └── formatter.py        # Output formatting (JSON + plain text audit reports)
├── wrappers/                   # Middle ring: deployment wrappers
│   └── mcp_server.py           # FastMCP server (4 tools, stdio + HTTP)
├── tests/
│   ├── test_validation.py      # 141 tests (all 16 prohibitions, regimes, edge cases)
│   ├── test_validators.py      # 10 core validator tests
│   └── contracts/              # 6 synthetic German AGB contract fixtures
├── benchmark/                  # AGB-DE benchmark scripts and results
├── pyproject.toml              # Build config (hatchling), deps, pytest settings
├── LICENSE                     # Apache 2.0
├── SECURITY.md                 # Trust architecture
└── EVALUATION.md               # Empirical evaluation (3 phases)

Security

LLM output is treated as untrusted input. Pydantic schema boundary prevents prompt injection, schema poisoning, and hallucinated parameters from reaching the validation layer. See SECURITY.md.

License

Apache 2.0. See LICENSE.

Author

Jasper Michieka — Kenyan-trained advocate (2019), German LL.M. in Digitalization and Law (Universität Würzburg, 2023–2025).

Citation

If you use Silent Law in academic work:

@software{michieka2026silentlaw,
  author = {Michieka, Jasper},
  title = {Silent Law: Neuro-Symbolic Compliance Checking for § 309 BGB},
  year = {2026},
  url = {https://github.com/jasper-michieka/silent-law-mcp},
  license = {Apache-2.0}
}

Disclaimer

Silent Law is a statutory compliance flag, not legal advice. Every verdict includes a statutory citation and audit trail. The system assumes clauses are pre-formulated standard terms (AGB) within the meaning of § 305 Abs. 1 BGB. Individually negotiated clauses are not subject to § 309. Consult a qualified attorney for specific legal matters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to check Chinese commercial content for advertising-law prohibited terms, AI-generated-content labeling requirements, and 17-item organizational compliance self-assessment, returning each hit with its location, cited legal basis, and revision suggestion. Runs fully offline with a deterministic rule engine and zero external dependencies.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Deterministic compliance audit for cross-border e-commerce listings (Amazon, Temu, TikTok Shop): banned words, promo words, absolute claims, certification and trademark risks, and 2026 AI content disclosure. Versioned YAML rule packs, three-level obfuscation-resistant matching, exit-code CI gate and SARIF output. No LLM involved in judging.
      4
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables users to search enacted German statutes and case law across first-instance, appellate, and supreme/constitutional courts, retrieve full documents as Markdown, and verify statutory and case citations against official registries.
      6
      MIT