egov-law-mcp
@codeagentjp/egov-law-mcp
Local stdio MCP server for searching Japanese laws and retrieving article text from e-Gov Law Search.
This server does not call an LLM. It only returns source-backed law data and e-Gov URLs so your MCP client (Claude Desktop, Claude Code, Cursor, or any other agent) can cite the original source.
Design choices were informed by reading Digital Agency's open-sourced Lawsy-Custom-BQ (released 2026-04-24 as part of the Gennai government AI OSS release). See the design notes at codeagent.jp.
Why another e-Gov MCP
There is an existing egov-law-mcp on npm by another author. This package differs in three ways:
find_related_laws— looks up enforcement orders (施行令) and regulations (施行規則) for a given base law name. Lawsy-Custom-BQ has the same step server-side; useful because definitions and delegated rules often live outside the parent act.Source attribution baked into every tool result — every response includes the law name, law ID, article number, and the canonical e-Gov URL, so the calling LLM cannot drop the citation.
Single-file
.mjs, no build step —bin/egov-law-mcp.mjsruns directly under Node 20+. Easier to audit, smaller install.
Related MCP server: Ask Google MCP Server
Status
MVP. The API surface is intentionally small:
search_laws— search current Japanese laws by keyword.get_article— retrieve a specific article from a law by law ID or law number.get_law— retrieve basic metadata and a text preview for a law.find_related_laws— find likely related enforcement orders and regulations.
Requirements
Node.js 20 or later
Network access to
https://laws.e-gov.go.jp
Install
From npm:
{
"mcpServers": {
"egov-law": {
"command": "npx",
"args": ["-y", "@codeagentjp/egov-law-mcp"]
}
}
}From source for development:
git clone https://github.com/SHAYOUWORLD/egov-law-mcp.git
cd egov-law-mcp
node bin/egov-law-mcp.mjs{
"mcpServers": {
"egov-law": {
"command": "node",
"args": ["/absolute/path/to/egov-law-mcp/bin/egov-law-mcp.mjs"]
}
}
}Tools
search_laws
Searches the e-Gov law list.
{
"keyword": "個人情報",
"limit": 10
}get_article
Retrieves article text. Provide either lawId or lawNum.
{
"lawId": "503AC0000000035",
"article": "2"
}get_law
Retrieves basic metadata and a plain text preview of a law.
{
"lawId": "503AC0000000035",
"previewChars": 3000
}find_related_laws
Searches for laws whose names look related to a base law name, including enforcement orders and regulations.
{
"lawName": "個人情報の保護に関する法律",
"limit": 10
}Data Source and Attribution
This package uses the e-Gov Law Search API:
e-Gov Law Search: https://laws.e-gov.go.jp/
Law API documentation: https://laws.e-gov.go.jp/docs/law-data-basic/8529371-law-api-v1/
e-Gov terms: https://developer.e-gov.go.jp/contents/terms
MCP stdio transport: https://modelcontextprotocol.io/specification/2025-06-18/basic/transports
Tool results include source attribution. When you publish or redistribute output based on this package, include an appropriate e-Gov source attribution.
Suggested attribution:
出典: e-Gov法令検索(https://laws.e-gov.go.jp/)
Safety Notes
This package is a law reference tool, not legal advice. Verify important legal conclusions against the official e-Gov page and, where necessary, consult a qualified professional.
It does not execute shell commands.
It writes JSON-RPC messages only to stdout and logs only to stderr.
It fetches only e-Gov Law Search endpoints.
Related
Design notes: 源内のLawsy実装をMCP化するなら、どこを残してどこを捨てるべきか (codeagent.jp)
Background on Gennai OSS release: 政府AI「源内」のソースコードが商用利用可能な形で公開 (codeagent.jp)
Reference implementation we learned from: digital-go-jp/genai-ai-api/google-cloud/lawsy-custom-bq
License
MIT © codeagent.jp
Available Tools
4 toolsget_articleB
Retrieve a specific article from e-Gov Law Search by law ID or law number.
| Name | Required | Description | Default |
|---|---|---|---|
| lawId | No | e-Gov law ID, for example 503AC0000000035. | |
| lawNum | No | Japanese law number. Either lawId or lawNum is required. | |
| article | Yes | Article number, for example 2. | |
| paragraph | No | Optional paragraph number. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, and the description only states 'retrieve' without disclosing behavioral traits such as idempotency, authentication needs, rate limits, or error handling for missing articles.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that front-loads the core purpose. However, it may be too brief for a tool with four parameters, missing important details about parameter dependencies.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with four parameters and no output schema or annotations, the description omits crucial context: it does not mention that the 'article' parameter is required, nor does it explain what the return value contains or how errors are handled.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description's mention of 'by law ID or law number' adds minimal value beyond the existing schema descriptions, which already specify parameter purposes and constraints.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states the action (retrieve), resource (a specific article from e-Gov Law Search), and method (by law ID or law number). It distinguishes from sibling tools like get_law and search_laws by targeting articles specifically.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage context (retrieving a specific article) but provides no explicit when-to-use or when-not-to-use guidance, nor does it reference alternatives among sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_lawA
Retrieve law metadata and a plain text preview from e-Gov Law Search.
| Name | Required | Description | Default |
|---|---|---|---|
| lawId | No | e-Gov law ID. Either lawId or lawNum is required. | |
| lawNum | No | Japanese law number. Either lawId or lawNum is required. | |
| previewChars | No | Maximum preview length. Defaults to 5000. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided; description implies a read operation but doesn't explicitly confirm idempotency, authentication needs, or rate limits. It only states what is retrieved, which is adequate but not exhaustive.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence, clear, no unnecessary words. Front-loads the key action and resource.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 3 parameters, no output schema, and no annotations, the description is brief but covers the essential purpose. However, it lacks details about return format or side effects, which could be useful for a tool with no output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema covers 100% of parameters with descriptions. The description adds no extra meaning beyond the schema (e.g., 'metdata and preview' is generic). Baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states it retrieves law metadata and plain text preview from e-Gov. It specifies the source and distinguishes from sibling tools like search_laws (search) and get_article (specific article).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus siblings, nor any prerequisites (e.g., need a law ID from search_laws). The description is silent on usage context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_lawsB
Search current Japanese laws from e-Gov Law Search by keyword.
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | Keyword to search in law name, law number, or law ID. | |
| category | No | Law category. Defaults to all. | |
| limit | No | Maximum number of results. Defaults to 10. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description must disclose behavioral traits. It only mentions 'current' laws, but lacks details on authorization, rate limits, data freshness, or any side effects. The bare statement is insufficient for a search tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single concise sentence with no superfluous words. It front-loads the action and resource, perfect for quick comprehension.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema and only three parameters, the description fails to explain return format, pagination, or result structure. Given the tool's complexity (search across categories), completeness is lacking.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, and the description adds no extra meaning beyond the schema. The search logic (e.g., partial matching, case sensitivity) is not explained, meeting the baseline for high coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'search', the resource 'current Japanese laws', and the source 'e-Gov Law Search by keyword', distinguishing it from siblings like find_related_laws and get_article which target specific relations or articles.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies general keyword search but does not explicitly state when to use this tool versus alternatives, nor does it mention when not to use it. No exclusions or prerequisites are provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.1.0- First observed
find_related_laws - First observed
get_article - First observed
get_law - First observed
search_laws
TDQS
Scored across 4 tools
Each tool has a distinct purpose: searching laws, retrieving law metadata, retrieving specific articles, and finding related laws. No overlap in functionality.
All tool names follow a consistent verb_noun pattern in snake_case, e.g., search_laws, get_law, get_article, find_related_laws.
With 4 tools, the server is well-scoped for a focused legal search assistant. The count is neither excessive nor insufficient.
The tool set covers the core operations for searching and retrieving Japanese laws and articles. A minor gap is the lack of a tool to list all laws, but for search purposes this is acceptable.
Maintenance
Related MCP Connectors
Japan Law MCP — Japanese national laws & ordinances via the e-Gov Law API.
Task-oriented MCP for Indonesian law: search, resolve citations, read laws, and MK decisions.
Japanese law, corporation & statistics data as MCP, normalized to English with source attribution.
MCP server for Japan geodata: cadastral lot numbers (chiban) and reverse geocoding, for AI agents.
Related MCP Servers
- FlicenseAqualityDmaintenanceLightweight MCP server that exposes tools for system information and weather lookup, designed for agent integration via stdio.1-
- AlicenseAqualityAmaintenanceA stdio MCP server that provides a single tool to query Gemini with Google Search grounding for current web information, returning synthesized answers with source links.152 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA lightweight, stdio-based MCP server enabling AI assistants to perform local file system operations like reading, writing, searching, and executing commands.2,994 npmMIT
- AlicenseNot gradedqualityBmaintenanceA local stdio MCP server that exposes xAI-compatible server-side search through a Responses API relay, providing web and X search tools with citation and cost reporting.17 npmMIT