Skip to main content
Glama
denmark-legislation-mcp-server

denmark-legislation-mcp-server

by cyanheads
README.md
<div align="center">
  <h1>@cyanheads/denmark-legislation-mcp-server</h1>
  <p><b>Search Danish legislation, read provisions, and trace amendments in Retsinformation via MCP. STDIO or Streamable HTTP.</b></p>
  <div>8 Tools</div>
</div>

<div align="center">

[![Version](https://img.shields.io/badge/Version-0.1.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/denmark-legislation-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^2.4.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/denmark-legislation-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/denmark-legislation-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^7.0.2-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.4.4-blueviolet.svg?style=flat-square)](https://bun.sh/)

</div>

<div align="center">

[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/denmark-legislation-mcp-server/releases/latest/download/denmark-legislation-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=denmark-legislation-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvZGVubWFyay1sZWdpc2xhdGlvbi1tY3Atc2VydmVyIl19) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22denmark-legislation-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fdenmark-legislation-mcp-server%22%5D%7D)

[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)

</div>

---

## Overview

Danish legislation, administrative decisions, Folketing documents, and Ombudsman opinions from Retsinformation. Search in Danish, resolve citations to European Legislation Identifiers (ELIs), read the source text, and follow published changes. Runs over stdio or Streamable HTTP and uses public Retsinformation endpoints without an API key.

### Tools

| Tool | Description |
|:---|:---|
| `dklaw_search_documents` | Find documents by Danish terms, exact popular title, ministry, type, CELEX, or date |
| `dklaw_get_provisions` | Read provisions, chapters, annexes, or document text |
| `dklaw_get_document` | Get document metadata, links, and an outline with text selectors |
| `dklaw_list_versions` | Trace a law's consolidations or an executive order's amendments |
| `dklaw_get_relations` | Follow amendment, implementation, decision, and other source links |
| `dklaw_lookup_citation` | Resolve citations, ELIs, accession numbers, and exact popular titles |
| `dklaw_track_changes` | List publications or source-reported changes over a date window |
| `dklaw_list_reference` | Look up filters, accepted syntax, and source coverage |

## Capability reference

### `dklaw_search_documents` <sub>tool</sub>

- Combine optional `query`, `popular_title`, `ministry`, `document_types`, `classification`, `celex`, `year_from`, `year_to`, and `published_from` filters. `status: "current"` is the default. Use `"all"` to include historical records. Sort by `"relevance"` (default) or `"newest"`.
- Pages start at `page: 0` and return `total`, `applied_filters`, and `next_page`. The default `limit` is 25, capped at 100. Narrow broad queries by filters or dates to stay within the upstream 10,000-row search window.
- When a search misses, try Danish terms, relax filters, or pass a known citation to `dklaw_lookup_citation`.

---

### `dklaw_get_provisions` <sub>tool</sub>

- Requires `document`. Defaults to `version: "current"` to follow verified consolidation links. Use `"as_given"` for the cited revision.
- Send `provisions` such as `["§ 4, stk. 2, nr. 1", "Bilag 1"]` to read the first 10 addresses. Resubmit `remaining_provisions` with the same document and version. Large or ambiguous matches return `kind: "outline"` with selectors. Legacy HTML can return `kind: "legacy_text"` for the body when exact addressing is unavailable.
- Omit `provisions` to read a `selector` or start at `"body"`. The default `limit` is 12,000 Unicode code points and callers can request a larger positive limit. Continue with the returned selector, canonical ELI, `version: "as_given"`, and `page.next_offset` as `offset`. On `selector_changed`, refresh the outline or restart at the first body page.

---

### `dklaw_get_document` <sub>tool</sub>

- Requires `document` and defaults to `version: "as_given"`. Use `"current"` to follow verified consolidation links. Set `include: ["bill_history"]` for available parliamentary history and the publisher's historical cause.
- Returns metadata, source format links, pending amendments, and an outline with selectors for provisions, sections, annexes, commencement blocks, and the body. If source metadata is available but the outline is unavailable, follow its guidance or open a source link.

---

### `dklaw_list_versions` <sub>tool</sub>

- Requires `document`. Lists a law's source timeline newest first or an executive order's direct amendments. An amending act can return `unsupported_document_type` with targets whose timelines can be requested.
- Continue with `next_offset` (default `limit` 25, capped at 100). Read `coverage` for timeline gaps or partial ELI coverage. If fallback discovery is in progress, repeat the call with the same document.

---

### `dklaw_get_relations` <sub>tool</sub>

- Requires `document` and follows links from that revision. Omit `relation` for all groups, or select a group such as `changed_by`, `consolidates`, `subordinate`, or `commenced_by`. `status: "all"` includes historical subordinate rules and available unclassified `basis_for` links.
- Returns source-backed relations with `coverage` and `next_offset` (default `limit` 25, capped at 100). Use `relation: "basis_for"` with `status: "all"` when the source lacks a more specific group.

---

### `dklaw_lookup_citation` <sub>tool</sub>

- Send a nonempty `citations` array of Retsinformation ELI paths or URLs, accessions, exact popular titles, or dated citations such as `lov nr. 502 af 23. maj 2018 § 1`. Resolves the first 25 in order. Resubmit `remaining_citations` to continue.
- Each row resolves the cited revision, with a separately identified `current_consolidation` and a normalized `provision` when available. Per-item misses report `reason` and `guidance`. An ambiguous title also returns candidates.

---

### `dklaw_track_changes` <sub>tool</sub>

- Requires inclusive Copenhagen dates `from` and `to` in `YYYY-MM-DD`. Both modes accept `medium` and use `next_offset` (default `limit` 25, capped at 100). Default `kind: "published"` uses publication dates and accepts `document_types`. If counts drift and the tool returns `window_changed`, restart at offset zero.
- `kind: "changed"` reports the latest event per document in the rolling Atom feed and accepts `reasons`. By default it includes content changes, combined metadata and content changes, and removals. Daily harvest fallback can provide partial coverage and reports `coverage.date_basis: "harvest_window_end"`.
- Read `coverage` before interpreting `total`. Use `"published"` for older publication windows beyond the change feed. Publication paging narrows the upstream 10,000-row window by date and surfaces the source limit if a single day's rows still exceed it.

---

### `dklaw_list_reference` <sub>tool</sub>

- Requires one `topic` from `document_types`, `ministries`, `media`, `identifiers`, `provisions`, `status`, `change_reasons`, or `coverage`. Runs offline.
- Returns `entries` and a `source` link. Use it for accepted filter values, citation or address syntax, historical status codes, and corpus and feed coverage. Danish court case law is covered separately by Domsdatabasen.

## Features

Built on [@cyanheads/mcp-ts-core](https://github.com/cyanheads/mcp-ts-core) with stdio and Streamable HTTP, configurable HTTP auth, structured logging, and optional OpenTelemetry.

- `current_text` reflects the publisher's current or historical flag. Read the separate `in_force` metadata where available, and check commencement clauses and `pending_amendments` to assess applicability.
- LexDania XML provides structured text and selectors. Earlier records can be available as legacy HTML, with source links preserved.
- Source URLs, coverage notes, per-item guidance, and explicit continuation fields support citation, recovery, and paging.

**Kilde: Retsinformation (Civilstyrelsen).** This is an independent integration. Civilstyrelsen permits commercial and noncommercial reuse of open data, including copying and adaptation. Keep protected contributions such as photographs with the relevant regulation when reproducing them, and keep requests proportionate to the service. [Civilstyrelsen open data terms](https://www.retsinformation.dk/static/api.html)

## Getting started

Add it to Claude Code with Node.js 24 or later installed.

```sh
claude mcp add denmark-legislation-mcp-server -- npx -y @cyanheads/denmark-legislation-mcp-server
```

For other clients, add this to your MCP configuration file.

```json
{
  "mcpServers": {
    "denmark-legislation-mcp-server": {
      "command": "npx",
      "args": ["-y", "@cyanheads/denmark-legislation-mcp-server"]
    }
  }
}
```

## Configuration

| Variable | Default | Description |
|:---|:---|:---|
| `MCP_TRANSPORT_TYPE` | `stdio` | Set to `http` for Streamable HTTP |
| `MCP_HTTP_HOST` | `127.0.0.1` | HTTP bind address |
| `MCP_HTTP_PORT` | `3010` | HTTP port |
| `MCP_HTTP_ENDPOINT_PATH` | `/mcp` | HTTP MCP endpoint |
| `MCP_SESSION_MODE` | `stateless` | HTTP session mode |
| `MCP_AUTH_MODE` | `none` | HTTP authentication mode (`none`, `jwt`, or `oauth`) |
| `MCP_LOG_LEVEL` | `info` | Minimum log level |
| `MCP_USAGE_REPORTING` | `false` | Opt in to daily and shutdown tool-call summaries |

See [`.env.example`](.env.example) for additional framework settings.

## Running the server

Start a local Streamable HTTP endpoint at `http://127.0.0.1:3010/mcp`.

```sh
MCP_TRANSPORT_TYPE=http npx -y @cyanheads/denmark-legislation-mcp-server
```

Run the container with the MCP port published to loopback.

```sh
docker run --rm -p 127.0.0.1:3010:3010 ghcr.io/cyanheads/denmark-legislation-mcp-server:0.1.1
```

Peer containers on the same Docker network can reach the server's HTTP port.

Build from source with Bun 1.4.4 or later and Node.js 24 or later.

```sh
git clone https://github.com/cyanheads/denmark-legislation-mcp-server.git
cd denmark-legislation-mcp-server
bun install
bun run build
bun run start:stdio
```

## Project structure

| Path | Purpose |
|:---|:---|
| `src/index.ts` | Server entry point and tool registration |
| `src/mcp-server/tools/definitions/` | Tool schemas and handlers |
| `src/services/` | Retsinformation clients, document parsing, version graphs, and reference tables |
| `tests/` | Tool and source-adapter tests |

## Development guide

See [CLAUDE.md](CLAUDE.md) for server conventions and [docs/tree.md](docs/tree.md) for the complete layout. Run `bun run devcheck` and `bun run test` to verify changes.

## Contributing

Report bugs and request features through [GitHub Issues](https://github.com/cyanheads/denmark-legislation-mcp-server/issues).

## License

[Apache-2.0](LICENSE)