Skip to content

How It Works

Saeed Yari edited this page Dec 2, 2026 · 1 revision

How It Works

Architecture

flowchart LR
    subgraph package["privacy-mcp: read-only, offline"]
        meta[("meta.json<br/>groups, consent profiles,<br/>US routing")] --> registry["registry.py<br/>routing, inheritance,<br/>transfers, comparison"]
        records[("jurisdictions/*.json<br/>one record per law,<br/>sources + last_verified")] --> registry
        tools["server.py<br/>4 tools, 1 resource<br/>advisory_only on every result"] --> registry
        tools --> security["security.py<br/>input caps, audit log"]
    end
    client["MCP client"] <-- "stdio" --> tools
Loading
  • server.py registers the tools and the resource. Every tool goes through one decorator that checks the input limits, adds advisory_only, the disclaimer and the registry version to the result, turns invalid input into a clear error, and writes the audit log.
  • registry.py loads the data once, resolves codes, applies inheritance and consent profiles, and does the transfer evaluation and the comparison.
  • data/ holds the registry: meta.json and one JSON file per group of jurisdictions.

The registry

meta.json holds the schema version (1.0.0), the last_updated date, the country groups used in transfer rules (@EU, @EEA, @US_COUNTRIES_OF_CONCERN), the four consent profiles and the routing rule that makes US ask for a state.

Each jurisdiction record has the identity fields (code, name, region, phase, status, framework, regulator), the obligations (consent_model, lawful_bases_required, dsar_sla_days, breach_notification_hours, dpo_mandatory_conditions, mandatory_disclosures, mandatory_ui_controls, sensitive_data_consent, children_age_threshold, max_penalty, each with notes), a consent block, a transfer block and the audit fields (effective_date, source_url, sources, last_verified). The full schema is in CONTRIBUTING.md.

  • Inheritance: EU member states have "inherits": "EU" and list only what national law changes.
  • Consent: a record names a profile and overrides only the tracking types where it differs.
  • US states use "transfer": {"same_as": "US-FEDERAL"}, since state privacy laws don't restrict transfers.

A test checks every record on every change: required fields and types, allowed values, https sources, dates against the status, consent profiles and overrides, every code and group a transfer rule refers to, inheritance, and that each roadmap phase is complete.

Transfer evaluation

evaluate_cross_border_transfer applies the origin's rules in this order:

  1. Same code: not a cross-border transfer (adequate).
  2. The destination is prohibited for this data category: prohibited.
  3. The destination is prohibited only for other data categories: restricted, with the prohibition as a warning.
  4. Same country, and the origin doesn't restrict domestic transfers: adequate. Quebec, DIFC and ADGM do restrict them, so their transfers to the rest of the country are evaluated like any other.
  5. The destination is on the origin's adequate list (a code, a group such as @EEA, or * for laws that only restrict named countries, such as India's DPDP Act and US federal law): adequate.
  6. The destination is adequate only under a condition (for example the EU-US Data Privacy Framework): conditional, with that mechanism first.
  7. Otherwise: restricted, with the origin's mechanisms in order.

Risk: low for adequate and conditional; for restricted, the origin's base risk (medium by default, high where government approval is needed, as in China), one level higher for sensitive or children's data; high for prohibited and partly prohibited destinations.

Comparison

compare_jurisdictions resolves each code like the other tools and takes the strictest value per field: the strictest consent model and sensitive-data consent (notice < opt-out < opt-in < explicit opt-in), the shortest DSAR and breach deadlines that are set, the highest children's age, opt-in per tracking type if any jurisdiction needs it, GPC if any needs it, and the union of DPO conditions and mandatory UI controls. Each strictest value lists the jurisdictions that set it.

Security model

  • Read-only and offline: the server writes no files, makes no network calls and starts no subprocesses. A test fails if its code imports networking or subprocess modules or opens a file for writing.
  • No user data: the inputs are jurisdiction codes, a data category and a tracking type.
  • Validated input: each text parameter is capped at 40 characters and lists at 30 items, and a code must match the ISO format before any lookup.
  • Advisory on every result: every tool result and the registry index carry advisory_only: true and a disclaimer that tells the assistant the result is operational guidance, not legal advice.
  • Docker: the image runs as a non-root user and needs no network, no writable filesystem and no mounted folders.

Configuration

Variable Default Effect
PRIVACY_MCP_AUDIT_LOG unset Set to 1 to log one JSON line per tool call to stderr: tool name, status, error type and latency. Never inputs or results.

Clone this wiki locally