japan-legislation-mcp-server
by cyanheads
README.md
<div align="center">
<h1>@cyanheads/japan-legislation-mcp-server</h1>
<p><b>Search Japanese national laws, read provisions by date, and trace amendments via MCP. STDIO or Streamable HTTP.</b>
<div>8 Tools</div>
</p>
</div>
<div align="center">
[](./CHANGELOG.md) [](./LICENSE) [](https://github.com/users/cyanheads/packages/container/package/japan-legislation-mcp-server) [](https://modelcontextprotocol.io/) [](https://www.npmjs.com/package/@cyanheads/japan-legislation-mcp-server) [](https://bun.sh/)
</div>
<div align="center">
[](https://github.com/cyanheads/japan-legislation-mcp-server/releases/latest/download/japan-legislation-mcp-server.mcpb) [](https://cursor.com/en/install-mcp?name=japan-legislation-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvamFwYW4tbGVnaXNsYXRpb24tbWNwLXNlcnZlciJdfQ==) [](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22japan-legislation-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fjapan-legislation-mcp-server%22%5D%7D)
[](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
</div>
---
## Overview
Search Japan’s Constitution, Acts, cabinet orders, ministerial ordinances, and rules in the original Japanese. The corpus covers national legislation. Prefectural and municipal 条例 fall outside it. Historical date selection begins on 2017-04-01, which includes the version then in force for laws already in effect. Repealed or expired laws may still have a last published text. Scheduled revisions carry the `UnEnforced` status.
出典:[e-Gov法令検索](https://laws.e-gov.go.jp/). This server reformats Japanese legal text from the Digital Agency’s [e-Gov Law API v2](https://laws.e-gov.go.jp/api/2/swagger-ui/) under the [e-Gov Law Search terms](https://laws.e-gov.go.jp/terms). For English reference translations, see the Ministry of Justice’s [Japanese Law Translation](https://www.japaneselawtranslation.go.jp/en/).
### Tools
| Tool | Description |
|:---|:---|
| `jplaw_search_laws` | Search by Japanese title, abbreviation, subject, promulgation, or amendment dates |
| `jplaw_search_text` | Search Japanese statutory text and preview matches grouped by law and revision |
| `jplaw_lookup_citation` | Resolve law numbers or Japanese citations and parse provision addresses |
| `jplaw_get_law` | Browse a revision outline, read selected text, and find official downloads |
| `jplaw_get_provision` | Read up to ten articles, paragraphs, or items in one revision |
| `jplaw_list_revisions` | Trace amendment history and find exact revision IDs |
| `jplaw_find_subordinate_laws` | Find possible implementing orders, ordinances, and rules with supporting evidence |
| `jplaw_list_reference` | Look up law types, category codes, identifiers, query syntax, and coverage |
## Capability reference
### `jplaw_search_laws` <sub>tool</sub>
- Start with `{"title":"個人情報保護法"}`. Use `law_types`, `categories`, `law_num_era`, and `law_num_year` to narrow the catalog. Get the accepted codes from `jplaw_list_reference`.
- The inclusive ranges `promulgation_from` and `promulgation_to` filter the law’s own promulgation date. The `amendment_promulgation_from` and `amendment_promulgation_to` or `amendment_enforcement_from` and `amendment_enforcement_to` pairs filter the amendment in the selected `asof` view.
- `status` defaults to `in_force`. Use `all` or filter for `Repeal`, `Expire`, `Suspend`, or `LossOfEffectiveness`. `sort` accepts `law_number` (default), `promulgated`, or `amended`.
- Up to 500 results per page. Pass `page.next_offset` back as `offset` with the same filters and sort.
### `jplaw_search_text` <sub>tool</sub>
- Try `{"keyword":"個人情報 第三者提供","sections":["mainprovision"],"limit":10}`. The `keyword` expression uses a space for AND, `|` for OR, `!` for NOT, and `*` and `?` as wildcards.
- Use `law_types`, `categories`, `asof`, and `sections` to narrow matches. Section values are `mainprovision`, `supplprovision`, `amendsupplprovision`, `caption`, `enactstatement`, and `relatedarticlenum`.
- Up to 1,000 snippets per page. Continue at `next_offset` even when a filtered page shows zero matches. Any `upstream_total_count` counts matches before section filtering. Follow up with a pinned law read for complete text.
### `jplaw_lookup_citation` <sub>tool</sub>
- Supply 1–25 `citations`, for example `["平成15年法律第57号","個人情報保護法第二十七条第一項"]`. Exact Japanese titles, abbreviations, and e-Gov law IDs also work, as do Gregorian law-number years and kanji numerals.
- Each citation resolves separately. For ambiguous results, select a returned law ID. Confirm parsed provision addresses with `jplaw_get_provision` in the relevant revision.
### `jplaw_get_law` <sub>tool</sub>
- `{"law":"個人情報保護法"}` opens the outline. Pass `part: "第二十七条"`, a Japanese structure path, or a canonical selector from that revision for text. Use `part: "全部"` for whole-law text and `include_amendment_suppl: true` to include amending supplementary provisions there.
- Use `asof` (YYYY-MM-DD) or `law_revision_id` to select a version. The revision ID can identify the law by itself. Results include pinned links to available attachments and document downloads.
- The paged outline and text return complete units. Continue with `next_offset` as `offset`, keeping `part`, `include_amendment_suppl` and the returned `law_revision_id` fixed. If `revision.updated` changes, start again at zero because an upstream correction can change the document without changing its revision ID.
### `jplaw_get_provision` <sub>tool</sub>
- Try `{"law":"個人情報保護法","asof":"2024-04-01","provisions":["第二十七条第一項"]}`. Pass up to ten addresses using Japanese 条/項/号 (including branches such as 第二十七条の二), supplementary notation such as 附則第二条, or structured coordinates.
- Version selection works the same way as in `jplaw_get_law`. Results distinguish found, deleted, and unresolved provisions. For large provisions returned as an outline, follow the child addresses or pass the canonical selector to `jplaw_get_law`.
### `jplaw_list_revisions` <sub>tool</sub>
- Pass `{"law":"平成15年法律第57号"}` to see versions in e-Gov’s newest-first order. Filter by `statuses`, or by inclusive `enforcement_from`/`enforcement_to` and `promulgation_from`/`promulgation_to` ranges.
- Pass `page.next_offset` as `offset` to continue. Copy the chosen `law_revision_id` into a law or provision read to retrieve that exact version.
### `jplaw_find_subordinate_laws` <sub>tool</sub>
- Pass the exact title, number, abbreviation, or law ID of an Act, for example `{"law":"個人情報保護法"}`. `status` defaults to `in_force`. Use `all` to include inactive candidates and `next_offset` to page through the unique instruments.
- Title extensions such as 施行令 or 施行規則 and enactment-statement matches are evidence to inspect. e-Gov does not provide a formal parent relationship.
### `jplaw_list_reference` <sub>tool</sub>
- Omit `topic` to list topics, or choose `law_types`, `categories`, `law_numbers`, `identifiers`, `provision_addresses`, `keyword_syntax`, `coverage`, or `upstream_errors`. This tool 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.
- Date and revision selection for Japanese law text, including supplementary provisions and appendices
- Revision-specific source links and explicit continuation offsets
- Catalog snapshots refresh after two hours. Revision lists and parsed law documents are cached for up to five minutes, and text reads check the source update timestamp.
- Search and browse calls default to `offset: 0` and `limit: 25`. A null continuation offset marks the end of the list.
## Getting started
Run it locally with Claude Code:
```sh
claude mcp add japan-legislation-mcp-server -- npx -y @cyanheads/japan-legislation-mcp-server
```
For other clients, add this to the MCP config file:
```json
{
"mcpServers": {
"japan-legislation-mcp-server": {
"command": "npx",
"args": ["-y", "@cyanheads/japan-legislation-mcp-server"]
}
}
}
```
For a client using Bun, use `"command": "bunx"` with `"args": ["@cyanheads/japan-legislation-mcp-server"]`. e-Gov access needs 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 bind address. | `127.0.0.1` |
| `MCP_HTTP_PORT` | HTTP server port. | `3010` |
| `MCP_HTTP_ENDPOINT_PATH` | Streamable HTTP endpoint path. | `/mcp` |
| `MCP_SESSION_MODE` | HTTP session mode (`stateless`, `stateful`, or `auto`). | `stateless` |
| `MCP_AUTH_MODE` | Authentication mode (`none`, `jwt`, or `oauth`). | `none` |
| `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `warning`, `error`, etc.). | `info` |
| `OTEL_ENABLED` | Enable [OpenTelemetry](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry). | `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 to build and Node.js v24+ for the built entry point.
```sh
git clone https://github.com/cyanheads/japan-legislation-mcp-server.git
cd japan-legislation-mcp-server
bun install
bun run rebuild
bun run start:http
```
Connect a Streamable HTTP client to `http://127.0.0.1:3010/mcp`, or use `bun run start:stdio` to launch the built server as a stdio process.
### Docker
```sh
docker run --rm -p 127.0.0.1:3010:3010 ghcr.io/cyanheads/japan-legislation-mcp-server:latest
```
The image uses HTTP and stateless sessions by default. For stdio, set `MCP_TRANSPORT_TYPE=stdio` and use `docker run -i`. To build locally, run `docker build -t japan-legislation-mcp-server .`.
## Project structure
| Directory | Purpose |
|:---|:---|
| `src/mcp-server/tools/definitions` | Eight read-only MCP tools. |
| `src/services/egov` | e-Gov transport, upstream schemas, and reference data. |
| `src/services/catalog` | Catalog search, exact law resolution, and revision history. |
| `src/services/law` | XML parsing, provision addressing, and revision text. |
| `src/services/keyword` | Snippet search and filtered continuation. |
| `tests/` | Contract and service tests. |
See the [file tree](./docs/tree.md) for the full layout.
## Development guide
See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules.
## 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.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues