# fedlex-Engine

> The own build over the Confederation's public Fedlex endpoint: SR numbers, versions, article texts — every answer with provenance. The first built area.

## What it does {#was}

The fedlex server reads federal law where the Confederation publishes it: over the public SPARQL endpoint fedlex.data.admin.ch/sparqlendpoint and the Akoma Ntoso versions in the same filestore. 35 tools — resolve an SR number, list the versions of an act, read an article in its wording, check a quote against the norm text that was read, build the canonical citation — and every answer carries its provenance and the moment it was really retrieved. The data knowledge came before the server: 123 rules from two rulebooks, and for each one a conformance table says whether this server honours it, contradicts it or merely happens not to be tested. A test parses that table: a row claiming «honoured» must name a test that exists and actually runs — «it looks right» is untested, never honoured. What it refuses to do: it invents no text, a cached act is never served in place of an answer the graph refused, and it makes at most one polite request at a time to the federal host — two a second, beyond that a typed refusal rather than a queue.


## Run it yourself {#betreiben}

**You need:**

- Rust (stable via rustup) and Git; every command runs from the root of the corpus checkout.

From the root of the corpus checkout, line by line:

```bash
cargo run --locked --manifest-path mcp/gateway/Cargo.toml -- --root . --http 8700 --fedlex-fixtures mcp/servers/fedlex/tests/fixtures --lindas-fixtures mcp/servers/lindas/tests/fixtures
```

Then you should see:

```text
gateway on 127.0.0.1:8700
```

The server speaks MCP over stdin/stdout and has no network address of its own; the simplest start is behind the gateway with fixtures. Directly: cargo run --locked --manifest-path mcp/servers/fedlex/Cargo.toml -- --fixtures mcp/servers/fedlex/tests/fixtures, then an MCP client connects over stdio.


## Test {#testen}

```bash
cargo test --locked --manifest-path mcp/servers/fedlex/Cargo.toml
```

- **Recorded fixtures:** `mcp/servers/fedlex/tests/fixtures`
- Runs without network: every answer comes from the repository, the result is the same every run.

## Call {#ansteuern}

- **Public:** *not yet* — No public endpoint: zone, route and deployment are not switched on.
- **Local:** über das Gateway: POST http://127.0.0.1:8700/tool/fedlex.<werkzeug>

### Contracts

- **Tool contract v1** `mcp/servers/fedlex/TOOLSET-v1.md`
- **Rulebook** `docs/reference/fedlex-data-rules.md`
- **Engine manifest** `mcp/servers/fedlex/engine.manifest.json`

### The fedlex rows of the tool list

```bash
curl -s http://127.0.0.1:8700/tools
```

Response (excerpt):

```json
[{"id":"directory.get","domain":"directory","summary":"The directory envelope (v0.2, authority: manifest). …","weight":1}, … 52 rows]
```

## Contribute {#mitwirken}

Changes go through merge requests and the same gates as the association's own: formatting, Clippy without warnings, tests, seal and drift checks. Security reports, in confidence, to admin@openhelvetia.swiss.

The base tier costs nothing; what the operation lives on is under [About us, Financing](../../../about/financing/index.html).

## Module card {#steckbrief}

State, evidence, download and dependencies are on the infrastructure page: [fedlex-Engine](../../../directory/building-blocks/fedlex-engine/index.html).

---

Source: generated from public/web/modules.json
