Metadata-Version: 2.5
Name: zerez-client
Version: 0.1.1
Summary: Python client and CLI for ZEREZ, the German central register of unit and component certificates (zerez.net)
Project-URL: Homepage, https://github.com/the78mole/zerez-mcp
Project-URL: Source, https://github.com/the78mole/zerez-mcp
Project-URL: Issues, https://github.com/the78mole/zerez-mcp/issues
Project-URL: Changelog, https://github.com/the78mole/zerez-mcp/releases
Author: Daniel Glaser
License-Expression: MIT
License-File: LICENSE
Keywords: graphql,grid-code,inverter,mcp,unit-certificate,vde-ar-n-4105,vde-ar-n-4110,vde-ar-n-4120,zerez
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Natural Language :: German
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2.3; extra == 'mcp'
Description-Content-Type: text/markdown

# zerez-mcp

[![CI](https://github.com/the78mole/zerez-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/the78mole/zerez-mcp/actions/workflows/ci.yml)
[![Release](https://github.com/the78mole/zerez-mcp/actions/workflows/pypi.yml/badge.svg)](https://github.com/the78mole/zerez-mcp/actions/workflows/pypi.yml)
[![PyPI](https://img.shields.io/pypi/v/zerez-client?label=zerez-client)](https://pypi.org/project/zerez-client/)
[![Python versions](https://img.shields.io/pypi/pyversions/zerez-client)](https://pypi.org/project/zerez-client/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/the78mole/zerez-mcp/badge)](https://scorecard.dev/viewer/?uri=github.com/the78mole/zerez-mcp)
[![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)

A typed Python client and command line tool for **ZEREZ**, the German central register of unit
and component certificates (*Zentrales Register für Einheiten- und Komponentenzertifikate*,
<https://www.zerez.net/units-and-certificates>). Look up a unit by its ZEREZ ID and get its
certificate, grid codes and technical data (power, currents, short-circuit and flicker values),
or search the register by manufacturer, model, category, energy source or power.

The same calls are available as an **MCP server** for assistants such as Claude (stdio, see below).

- **Search units** like the table on zerez.net (`search_units`), with text, category, energy
  source, norm, status and power filters, or a raw GraphQL filter.
- **Unit details** by ZEREZ ID or UUID (`get_unit`): overview plus all publicly visible technical
  fields, discovered by schema introspection.
- **Certificates** by certificate code, unit ZEREZ ID, certificate number or UUID
  (`get_certificates`), with norms, software versions, documents, linked units and the revision
  chain (`get_certificate_chain`).
- **Download certificate documents** (PDF) with unique file names (`download_certificate_files`).
- **Explore the backend**: raw GraphQL queries and type introspection.

> This project is not affiliated with the operator of ZEREZ. It uses the same public, anonymous
> API as the zerez.net website. Please query it considerately.

## Installation

```bash
uv tool install zerez-client      # the `zerez` command
uvx --from zerez-client zerez …   # or run it without installing
uv add zerez-client               # as a library in a uv project
```

The PyPI package is `zerez-client`, the Python module `zerez`, the command `zerez`.

## Command line

The CLI output is German, like the labels on zerez.net.

```bash
zerez search Multiplus 5000                            # keywords, all must match
zerez search -m SMA --category INVERTER --norm 4105 --take 50
zerez search --energy PV_WITH_STORAGE --min-power 3 --max-power 10
zerez unit ZE-KAXY-Z16S-0001                           # overview and technical data
zerez unit ZE-KAXY-Z16S-0001 --all --json
zerez cert ZE-KAXY-Z16S --chain                        # certificate with revision chain
zerez download ZE-KAXY-Z16S -o ./pdf                   # certificate documents (PDF)
zerez norms
zerez schema UnitOverviewFilterInput                   # explore the schema
zerez query '{ unitOverview(take: 1) { totalCount } }' # raw GraphQL
```

`--json` works with every command.

## Library

```python
from zerez import ZerezClient

with ZerezClient() as z:
    page = z.search_units(manufacturer="Deye", take=10)
    unit = z.get_unit("ZE-KAXY-Z16S-0001")      # {"overview": ..., "technical": ...}
    certs = z.get_certificates("ZE-KAXY-Z16S")
```

## MCP server

The package contains an [MCP](https://modelcontextprotocol.io) server, so that assistants such as
Claude can query the register. It runs over **stdio** and needs the optional dependency `mcp`:

```bash
uv tool install 'zerez-client[mcp]'
zerez mcp                     # or: zerez-mcp
```

Claude Code:

```bash
claude mcp add zerez -- uvx --from 'zerez-client[mcp]' zerez-mcp
```

Claude Desktop (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "zerez": {
      "command": "uvx",
      "args": ["--from", "zerez-client[mcp]", "zerez-mcp"]
    }
  }
}
```

All tools are read-only:

| Tool | Purpose |
| --- | --- |
| `search_units` | search units by keywords (AND), manufacturer, model, category, energy source, grid code, status, power |
| `get_unit` | overview and technical data of a unit by ZEREZ ID or UUID |
| `get_certificates` | certificates with grid codes, software versions, documents and linked units |
| `get_certificate_chain` | revision and extension chain of a certificate |
| `get_document_links` | signed, short-lived download links of the certificate PDFs |
| `list_norms` | grid codes known to the register |

Raw GraphQL and schema introspection are not exposed as tools. An HTTP transport is planned.

## The ZEREZ backend

zerez.net is a single-page app on top of a **HotChocolate GraphQL gateway**:

```
POST https://app-zerez-weeu-gatewaysvc-prod-01.azurewebsites.net/graphql/
Content-Type: application/json
```

- Read queries work **without authentication**, and introspection is enabled.
- The overview table uses `unitOverview(skip, take, where, order)` (type `UnitOverview`).
- `unit(id: UUID!)` returns the technical data of a unit (type `Unit`, about 90 fields).
- `certificates(where, ...)` returns certificates with norms, software versions, documents and
  units. Selecting `certificateBridgeUnits { unit }` fails unless `unitId` is selected as well.
- `certificateFileStorageLocation` is a **signed, short-lived** path `api/PublicDownload/...`
  relative to the gateway that returns the PDF.
- Matrix and inertia parameters are released per role and are `null` for anonymous clients.
- Missing dates come back as `1900-01-01...`; the client turns them into `None`.
- Power values are in kW.

### ZEREZ ID

| Format | Meaning |
| --- | --- |
| `ZE-XXXX-XXXX-0001` | unit (`unitCode`) |
| `ZE-XXXX-XXXX` | certificate (`certificateCode`); its units append `-0001`, `-0002`, ... |

The first group of four is the code of the certificate holder (`tenantCode`).

## Development

zerez-mcp uses [uv](https://docs.astral.sh/uv/), Ruff, mypy (strict) and pytest.

```bash
uv sync
uv run pytest                       # unit tests against a mocked backend
uv run pytest -m live               # against the real ZEREZ backend
uv run pre-commit install           # once, sets up the Git hook
uv run pre-commit run --all-files
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for commit conventions.

## Releases

Every commit on `main` is released: the version is calculated from the Conventional Commit
message (`feat:` bumps the minor version, `!` the major version, everything else the patch
version), the commit must pass CI, then it is uploaded to PyPI with Trusted Publishing and
published as a [GitHub Release](https://github.com/the78mole/zerez-mcp/releases) with generated
notes. See [`pypi.yml`](.github/workflows/pypi.yml) and [CHANGELOG.md](CHANGELOG.md).

## License

zerez-mcp is licensed under the [MIT License](LICENSE).
