finland-law-mcp-server
by cyanheads
README.md
<div align="center">
<h1>@cyanheads/finland-law-mcp-server</h1>
<p><b>Read Finnish statutes, amendments, court decisions, and government proposals from Finlex via MCP. STDIO or Streamable HTTP.</b>
<div>10 Tools</div>
</p>
</div>
<div align="center">
[](https://github.com/cyanheads/finland-law-mcp-server/releases) [](./LICENSE) [](https://github.com/users/cyanheads/packages/container/package/finland-law-mcp-server) [](https://modelcontextprotocol.io/) [](https://www.npmjs.com/package/@cyanheads/finland-law-mcp-server) [](https://www.typescriptlang.org/) [](https://bun.sh/)
</div>
<div align="center">
[](https://github.com/cyanheads/finland-law-mcp-server/releases/latest/download/finland-law-mcp-server.mcpb) [](https://cursor.com/en/install-mcp?name=finland-law-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvZmlubGFuZC1sYXctbWNwLXNlcnZlciJdfQ%3D%3D) [](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22finland-law-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Ffinland-law-mcp-server%22%5D%7D)
[](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
</div>
---
## Overview
Read Finnish and Swedish legal material from Finlex. Search by title or metadata, resolve citations, and follow statutes to amendments, court decisions, and preparatory works. The Statute Book contains the authentic as-enacted wording. Finlex consolidations are informational and can include adopted amendments before they take effect. For wording on a date, request an effective-date read and retain its evidence.
### Tools
| Tool | Description |
|:---|:---|
| `filaw_search_statutes` | Find consolidated or as-enacted statutes by title, keyword, year, or type |
| `filaw_search_decisions` | Find KKO and KHO decisions by court, collection, exact keyword, or year |
| `filaw_search_government_proposals` | Find government proposals by title or year |
| `filaw_lookup_citation` | Resolve legal citations and turn provision references into tool inputs |
| `filaw_get_statute` | Read an outline, a chapter, or commencement text and related sources |
| `filaw_get_provision` | Read selected provisions as enacted, on a date, or in an adopted snapshot |
| `filaw_list_amendments` | Trace commencement dates, transitional rules, and preparatory works |
| `filaw_get_decision` | Read KKO and KHO decisions or selected published sections |
| `filaw_get_government_proposal` | Read a proposal outline or section, or get the source PDF link |
| `filaw_list_reference` | Look up citation syntax, collection coverage, and accepted filters |
## Capability reference
The three search tools filter titles or metadata. Finlex Open Data has no full-text search. They accept `language` (`fin` by default, or `swe`), `start_year`, `end_year`, `published_since`, and `limit` (default 5, capped at 10 with a notice). Results are oldest first by year and number. Use `next_cursor` as `cursor` with the original query. Finlex supplies no total for these searches.
### `filaw_search_statutes` <sub>tool</sub>
- Search Finnish or Swedish title substrings or exact Finlex keyword labels. Use `statute_type` with slugs such as `act` or `decree`, also accepted as `laki` or `asetus`.
- `collection` defaults to `consolidated`. Use `as_enacted` for the Statute Book. `in_force` applies only to consolidated records.
- Results include canonical numbers, source URIs, and `has_text` so callers can identify title-only records.
### `filaw_search_decisions` <sub>tool</sub>
- Choose `court: "KKO"` (Supreme Court) or `"KHO"` (Supreme Administrative Court). The default `type` is `precedent`. Both courts support `other_decision`, and KHO also supports `summary_archive`.
- `keyword` matches exact Finlex labels. On an empty initial page, the server tries capitalizing a lowercase initial once and carries the resulting query into the continuation cursor.
### `filaw_search_government_proposals` <sub>tool</sub>
- `title` matches a case-insensitive substring, for example `työsopimuslain`. Results identify proposals by HE number, link affected statutes, and report XML, PDF-only, or unknown text availability.
### `filaw_lookup_citation` <sub>tool</sub>
- Resolve up to 25 `citations` per call. Accepted forms include `55/2001`, `SK 55/2001` (as enacted), `Työsopimuslaki`, `55/2001 7 luku 2 §`, `HE 157/2000`, and court numbers or ECLIs.
- Each citation returns its own outcome. Ambiguous numbers or titles return candidates. A resolved citation with a provision address provides input for `filaw_get_provision`.
### `filaw_get_statute` <sub>tool</sub>
- Omit `part` for the outline and metadata, including available decree, preparatory work, correction, and translation links. Use a chapter such as `7 luku` or `entry_into_force` for the corresponding text.
- Consolidated reads can select an `asof` date or an exact `version`, one at a time. The outline provides section selectors for `filaw_get_provision`. Translation links identify the last included amendment when Finlex records it.
### `filaw_get_provision` <sub>tool</sub>
- Select up to ten `provisions` from one statute. Use natural addresses such as `7 luku 2 §` or copy selectors from the statute outline.
- In the consolidated collection, `asof` requests wording effective on an ISO date and defaults to today in Europe/Helsinki when no `version` is supplied. An eight-digit `version` selects a served adoption snapshot, which may include prospective wording.
- Dated reads can return established fragments, candidate wording, and unresolved paths when snapshots or commencement evidence leave gaps. Use `filaw_list_amendments` to inspect the underlying amendments and transitional text.
### `filaw_list_amendments` <sub>tool</sub>
- Lists amending acts newest first, with recorded commencement and end dates, published commencement and transitional text, preparatory-work references, and the earliest served version where available. Filter by recorded start dates or current status in Europe/Helsinki. The response includes the date used for status.
- Pages default to 25 amendments and cap at 100. Continue with `next_offset` as `offset`.
### `filaw_get_decision` <sub>tool</sub>
- Read up to ten decisions. Use court numbers, numeric ECLIs, legacy KKO series such as `KKO 1975 I 1`, or structured `{ court, type, year, number }` selectors.
- Omit `sections` for all published body text. Select `introduction`, `background`, `arguments`, `motivation`, or `decision` to narrow the read. Results identify missing sections and summary-only coverage where applicable.
### `filaw_get_government_proposal` <sub>tool</sub>
- Use a proposal number such as `HE 157/2000`. Omit `part` for the heading outline and text sizes. Use a selector from the outline or an exact unique heading for section text.
- PDF-only proposals return metadata and the source PDF link. The server reads text supplied as XML.
### `filaw_list_reference` <sub>tool</sub>
- Returns citation and provision syntax, curated abbreviation mappings, statute types, court collections, language and history coverage, and pagination rules. Takes an empty object and works offline.
## Features
Built on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core): stdio and Streamable HTTP transports, pluggable auth (`none` / `jwt` / `oauth`), swappable storage (`in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`), structured logging with optional OpenTelemetry tracing.
- Finlex requests start at least one second apart, with up to three in flight. When the shared queue fills, the server returns a retry delay.
- A combined XML page above 16 MiB is fetched one document at a time. An individual expression above 8 MiB returns `finlex_response_too_large`. Read that expression directly on Finlex. Limits apply after decompression.
- Resolved expressions and latest-version aliases are cached for up to ten minutes, with up to 64 entries per cache and a 24 MiB source-size budget for parsed documents.
- Text returned in `content[]` preserves the data in `structuredContent`, including evidence, source links, and unresolved results.
## Getting started
```sh
claude mcp add finland-law-mcp-server -- npx -y @cyanheads/finland-law-mcp-server
```
For other clients, add this to the MCP config file:
```json
{
"mcpServers": {
"finland-law-mcp-server": {
"command": "npx",
"args": ["-y", "@cyanheads/finland-law-mcp-server"]
}
}
}
```
Finlex requires no API key. For Docker or a source build, see [Running the server](#running-the-server).
## Configuration
| Variable | Description | Default |
|:---|:---|:---|
| `MCP_TRANSPORT_TYPE` | Transport, `stdio` or `http` | `stdio` |
| `MCP_HTTP_HOST` | HTTP listen address | `127.0.0.1` |
| `MCP_HTTP_PORT` | HTTP server port | `3010` |
| `MCP_HTTP_ENDPOINT_PATH` | HTTP endpoint path | `/mcp` |
| `MCP_SESSION_MODE` | HTTP session mode, `stateless`, `stateful`, or `auto` | `auto`; example and Docker use `stateless` |
| `MCP_AUTH_MODE` | Authentication, `none`, `jwt`, or `oauth` | `none` |
| `MCP_LOG_LEVEL` | Log level | `info` |
| `LOGS_DIR` | Directory for log files | `<app-root>/logs` |
| `STORAGE_PROVIDER_TYPE` | Framework storage backend | `in-memory` |
| `OTEL_ENABLED` | Enable [OpenTelemetry](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry) | `false` |
| `MCP_USAGE_REPORTING` | Opt in to sending tool-call summaries to the maintainer | `false` |
See [`.env.example`](./.env.example) for common framework overrides.
## Running the server
### Local development
Requires [Bun v1.4.4](https://bun.sh/) or higher and Node.js v24+.
- **Clone and install**:
```sh
git clone https://github.com/cyanheads/finland-law-mcp-server.git
cd finland-law-mcp-server && bun install
cp .env.example .env # optional framework overrides
```
- **Build and run the production version**:
```sh
# One-time build
bun run rebuild
# Run the built server
bun run start:http
# or
bun run start:stdio
```
- **Run checks and tests**:
```sh
bun run devcheck # Lints, formats, type-checks, and more
bun run test # Runs the test suite
```
### Docker
```sh
docker run --rm -p 3010:3010 ghcr.io/cyanheads/finland-law-mcp-server:latest
```
The image defaults to HTTP transport, stateless session mode, and logs to `/var/log/finland-law-mcp-server`. To run it over stdio from an MCP client, use `"command": "docker"` with `"args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/finland-law-mcp-server:latest"]`. To build locally, `docker build -t finland-law-mcp-server .`; OpenTelemetry peer dependencies are installed by default — build with `--build-arg OTEL_ENABLED=false` to omit them.
## Project structure
| Directory | Purpose |
|:---|:---|
| `src/mcp-server/tools/definitions/` | Ten tool definitions and shared statute schemas |
| `src/services/finlex/` | Finlex transport, Akoma Ntoso parsing, document lookup, citations, and effective-date reconstruction |
| `tests/integration/` | Fixture-backed integration tests |
## Development guide
See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no `try/catch` in tool logic
- Use `ctx.log` for logging, `ctx.state` for storage
- Register new tools in the `createApp()` arrays in `src/index.ts`
- Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
## Contributing
Issues are welcome. Run checks and tests before submitting:
```sh
bun run devcheck
bun run test
```
## License
This project is licensed under the Apache 2.0 License. See the [LICENSE](./LICENSE) file for details.
Source material from [Finlex Open Data](https://www.finlex.fi/fi/avoin-data), published by Finland’s Ministry of Justice and Legal Register Centre under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). This server reformats the material.
This server cannot be deployed
Maintenance
ActivityNo data
ResponsivenessNo recent community issues