Skip to main content
Glama
Norway Legislation MCP Server

Norway Legislation MCP Server

by cyanheads
README.md
<div align="center">
  <h1>@cyanheads/norway-legislation-mcp-server</h1>
  <p><b>Read Norwegian laws and regulations, resolve citations, search provisions, and trace amendments via MCP. STDIO or Streamable HTTP.</b>
  <div>8 Tools</div>
  </p>
</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/norway-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/norway-legislation-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/norway-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/norway-legislation-mcp-server/releases/latest/download/norway-legislation-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=norway-legislation-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvbm9yd2F5LWxlZ2lzbGF0aW9uLW1jcC1zZXJ2ZXIiXX0=) [![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%22norway-legislation-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fnorway-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

Search Norwegian laws and regulations by title or body text, resolve citations to specific published records, read provisions, and follow the source evidence for regulations and amendments. The server builds a local SQLite mirror of Lovdata’s public bulk data. It needs no Lovdata account or API key.

### Tools

| Tool | Description |
|:---|:---|
| `norlaw_lookup_citation` | Resolve up to 25 citations to records and verify provision addresses where possible |
| `norlaw_get_document` | Read document metadata and an outline, or select a provision, chapter, or sibling range |
| `norlaw_get_provision` | Read up to 10 provisions from one record, with source links, change notes, and available variants |
| `norlaw_search_documents` | Find documents by title and metadata filters |
| `norlaw_search_text` | Search indexed body text and get ranked excerpts with source locators |
| `norlaw_find_regulations` | Find regulations based on an Act, directly or through one delegation decision |
| `norlaw_list_amendments` | Trace amending acts using provision notes and structured gazette evidence |
| `norlaw_list_reference` | Look up document kinds, vocabulary, addresses, status rules, coverage, freshness, and attribution |

## Capability reference

- **Resolve and read.** Start with `norlaw_lookup_citation` for a Lovdata URL, identifier, journal number, short title, or Norwegian legal citation. It usually prefers the consolidated edition, while an announcement identifier selects its gazette record. Explicit edition or language requests keep that scope. Use the returned `recordId` and the full locator to read the exact source node. A sentence address without explicit source markup can be returned as unverified.
- **Browse an instrument.** `norlaw_get_document` defaults to the outline. A selected part or same-group sibling range returns complete Markdown up to 64 KiB. Larger selections return an outline with exact locators. Use `norlaw_get_provision` with the returned `recordId` and full locator for an oversized node. If a source build changes, retrieve a fresh outline or hit before reusing its locator.
- **Search titles or text.** `norlaw_search_documents` ANDs normalized title terms across titles, short titles, and abbreviations. It excludes amending acts by default and sorts by document date, newest first. `norlaw_search_text` accepts words, quoted phrases, suffix `*`, grouping, and uppercase `AND`, `OR`, and binary `NOT`. Hits are paged globally by rank and grouped by document in the response. Both searches default to consolidated records with status `current` (in force or partly pending). Searching only `local_regulation` defaults to promulgated records. Promulgated searches default to any status.
- **Follow authority and amendments.** `norlaw_find_regulations` defaults to current consolidated results and can include local announcements with `includeLocal: true`. Paths cite the records that supplied each link. `norlaw_list_amendments` includes pending acts by default and excludes withdrawn acts by default. Section filters use source evidence. Gazette history starts in 2001, and the availability of structured amendment targets varies by act.
- **Page and check coverage.** The four list/search tools that take `limit` and `offset` default to 25 results at offset 0. Full-text search applies up to 200 hits per page. Document search, regulations, and amendments apply up to 500 results per page. Each page reports its total, requested and applied limits, and any `nextOffset`. Use `norlaw_list_reference` with `topic: "coverage"` or `"freshness"` to see which package builds the server can query.

## Features

- **Two editions.** Consolidated records are Lovdata’s editorial text at the indexed build. Promulgated records are Norsk Lovtidend announcements, including published corrections and withdrawals where available. Gazette commencement evidence describes the announcement. Use the consolidated edition for current applicability, and check the reported source date and status basis.
- **Local reads.** After import, tool calls query SQLite without contacting Lovdata. Coverage includes consolidated laws and central regulations, plus Gazette department I and II announcements from 2001. Source languages are preserved.
- **Built on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core)** for MCP transport, validation, and observability.

## Getting started

Use Node.js 24 or later for npm and Claude Desktop. Source builds require Bun 1.4.4 or later.

### MCP client configuration

Use this entry for clients that accept an `mcpServers` map, or use the Cursor or VS Code install link above.

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

### Claude Desktop

Download and open [the Desktop extension](https://github.com/cyanheads/norway-legislation-mcp-server/releases/latest/download/norway-legislation-mcp-server.mcpb). The extension’s **Mirror directory** setting is optional.

### First sync

The server starts accepting MCP connections while a background worker downloads and indexes the packages. First import transfers about 125 MB compressed and parses about 1.3 GB of markup. A December 2026 build containing 67,919 source records used 10.7 GB for SQLite and its full-text index. Allow additional space for downloads, the write-ahead log, and overlapping generations during a refresh.

Use `norlaw_list_reference` with `topic: "freshness"` to check progress. Queries return retryable `mirror_not_ready` when required builds are unavailable. Some searches can return partial results with the missing coverage called out. The worker checks Lovdata on startup and every four hours after a successful sync. If a refresh fails, it keeps the last successful build and reports stale coverage and freshness information.

## Configuration

| Variable | Default | Purpose |
|:---|:---|:---|
| `NORLAW_MIRROR_DIR` | OS cache directory | Writable local directory for the SQLite mirror. Use an absolute path in client configuration. |
| `MCP_TRANSPORT_TYPE` | `stdio` | Set to `http` for Streamable HTTP. |
| `MCP_HTTP_HOST` | `127.0.0.1` | Listener address for HTTP. The Docker image listens on all container interfaces. |
| `MCP_HTTP_PORT` | `3010` | Listener port for HTTP. |
| `MCP_HTTP_ENDPOINT_PATH` | `/mcp` | Streamable HTTP endpoint path. |
| `MCP_AUTH_MODE` | `none` | HTTP authentication mode. See [.env.example](.env.example) for additional settings. |
| `MCP_LOG_LEVEL` | `info` | Minimum log level. |
| `MCP_USAGE_REPORTING` | `false` | Opt in to anonymous framework usage reporting. |

The default cache path is `~/Library/Caches/norway-legislation-mcp-server` on macOS, `%LOCALAPPDATA%/norway-legislation-mcp-server` on Windows (under `~/AppData/Local` if unset), and under `XDG_CACHE_HOME` or `~/.cache` on Linux. Keep the database and its accompanying files on a local filesystem. Set `NORLAW_MIRROR_DIR` in a manual client’s `env` or use the plugin setting where available. The Codex plugin inherits the variable from the environment that launches Codex.

## Running the server

### npm

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

Streamable HTTP accepts MCP connections at `http://127.0.0.1:3010/mcp`. A successful `/healthz` response confirms the process is serving HTTP. For dataset readiness, use the freshness tool.

### Source

```sh
git clone https://github.com/cyanheads/norway-legislation-mcp-server.git
cd norway-legislation-mcp-server
bun install
bun run build
bun run dist/index.js
```

Use `node dist/index.js` to run the compiled build with Node. Set `MCP_TRANSPORT_TYPE=http` before either invocation for Streamable HTTP.

### Docker

```sh
docker run --rm -p 127.0.0.1:3010:3010 \
  -v norlaw-mirror:/usr/src/app/.mirror \
  ghcr.io/cyanheads/norway-legislation-mcp-server:latest
```

The image sets `NORLAW_MIRROR_DIR=/usr/src/app/.mirror`. Mount a volume there to retain the index when replacing the container. If mounting a host directory, give the container’s `bun` user write access.

## Development guide

Run `bun run devcheck` and `bun run test` after changes. Tool definitions are in `src/mcp-server/tools/definitions/`, SQLite and synchronization are in `src/mirror/`, and source parsing and normalization are in `src/domain/`. See the [project tree](docs/tree.md) for the rest of the layout.

## Contributing

File bugs and feature requests in [GitHub Issues](https://github.com/cyanheads/norway-legislation-mcp-server/issues). See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for development and contribution guidelines.

## License and data attribution

The server code is licensed under [Apache-2.0](LICENSE).

Contains data under the Norwegian licence for Open Government data (NLOD) distributed by [Lovdata](https://api.lovdata.no/). The data is licensed under [NLOD 2.0](https://data.norge.no/nlod/no/2.0). The server converts source markup to Markdown and derives status and amendment fields. Results carry source attribution and package coverage.