Skip to main content
Glama
gotoai

japan-law-util-mcp-server

by gotoai

japan-law-util-mcp-server

An MCP server for e-Gov法令検索's 法令API Version 2, the Digital Agency's API for Japanese national law: find a law, read its articles, search the text of every law, and pin any point in time.

e-Gov法令検索の法令API(Version 2)を使って、日本の法令の検索・条文の閲覧・全文の キーワード検索・施行時点の指定ができる MCP サーバーです。

Unofficial. This project is not affiliated with or endorsed by the Digital Agency (デジタル庁), which operates e-Gov法令検索. It is written against the published API specification.

Tools

Tool

What it does

load_guideline

The usage guideline for the whole tool set: how to find a law, how to read it by elm, the keyword search expressions, how to pin a point in time, what e-Gov法令検索 covers, and the conditions of use. It takes no arguments and always returns the whole guideline.

search_laws

Find laws by title, law number, type, subject category or promulgation date; paged.

search_law_text

Search the text of every law for a keyword or search expression; returns the laws it appears in with the matching sentences.

list_law_revisions

One law's amendment history: enforcement dates, amending laws, revision ids, and whether each revision is in force, not yet in force or repealed.

get_law_outline

One law's table of contents — parts, chapters, sections, articles with their captions, supplementary provisions and appendices — each with the elm that reads it.

read_law_text

A law's text as plain text, whole or the one part elm names, in pieces with next_offset to continue.

The server follows a skill-style layout. Its MCP instructions are one sentence saying what the tools are for and to call load_guideline first. Everything that concerns the tool set as a whole — including the conditions of use — lives in the guideline, and each tool's description covers only that tool. Agents that load many MCP servers keep only a short entry per server in their prompt, and read the guideline when they need it.

Reading a law

A law's text is addressed with the API's elm paths. get_law_outline returns the one to use for each entry, so the agent never has to build one:

MainProvision-Article_17            本則第十七条
MainProvision-Article_3_2           本則第三条の二
MainProvision-Chapter_4-Section_2   本則第四章第二節
SupplProvision[1]-Article_1         附則第一条
AppdxTable[1]                       別表第一

The law text arrives as the API's light JSON (json_format=light) and is rendered to plain text: captions, article and paragraph numbers, items, tables as |-separated rows, 振り仮名 resolved to the word itself. A whole act is tens of thousands of characters, so read_law_text returns it in pieces and the fetched law is cached for ten minutes.

The supplementary provisions of the laws that amended this one are left out unless include_amendment_supplements is true — an act can carry twenty of them. That choice decides which SupplProvision[n] each index names, so get_law_outline takes the same argument and the two have to agree.

Related MCP server: Houki e-Gov MCP Server

Run

Python 3.11 or later.

pip install -e .
japan-law-util-mcp-server --host 127.0.0.1 --port 8000      # Streamable HTTP at /mcp
japan-law-util-mcp-server --transport stdio                 # for clients that start it themselves

Behind a reverse proxy, accept the public host name as well; otherwise the server's DNS rebinding protection rejects requests whose Host is not localhost:

japan-law-util-mcp-server --host 127.0.0.1 --port 8000 --allowed-host demo.mcp.gotoai.com

When bound to a non-loopback address (for example --host 0.0.0.0 on a LAN), that protection is off; restrict access with a firewall or a proxy.

In Kari

Add a custom extension of type Streamable HTTP with the URL http://<host>:<port>/mcp. Give it an ASCII name such as japanlaw — the name becomes part of every tool name the agent sees.

Conditions of use

These are in the guideline the agent reads; they apply to anyone presenting the results:

  • Credit the source as 「出典:e-Gov法令検索(デジタル庁)」 with the law's URL.

  • Say so when the text has been summarised, excerpted or rearranged, and do not present the result as if the government had written it.

  • Where e-Gov法令検索 differs from the 官報, the 官報 prevails; confirm anything that matters against the law's own page.

  • Avoid excessive repeated access to the API.

e-Gov法令検索's content is published by the Digital Agency under the 公共データ利用規約(第1.0版); its own terms are at https://laws.e-gov.go.jp/terms/ and apply to whoever runs this server.

Coverage

e-Gov法令検索 holds national law only — 憲法・法律・政令・勅令・府令・省令・規則. It does not hold 告示・通達, treaties, local ordinances or case law. Its data starts from the text in force on 2017-04-01, covering acts and cabinet orders in force since 2015-08-01 and ministerial ordinances and rules since 2016-10-01, so amendment history before then is incomplete.

Development

pip install -e ".[dev]"
pytest                      # offline tests
JAPAN_LAW_LIVE=1 pytest     # also the live tests against the real API
ruff check src tests

License

MIT — see LICENSE.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables querying Japanese national laws and ordinances via the e-Gov Law API, allowing AI agents to access legal data through natural language questions.
    157 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to query Japanese public data (laws, corporations, statistics) from official government APIs, returning normalized English metadata with source attribution.
    1
    MIT