Skip to main content

e-Gov法令API MCPサーバー

CI PyPI version Python License: MIT

日本の法令データを検索・取得できる「e-Gov 法令API Version 2」をラップしたMCPサーバーです。LLMが最新の法令条文に基づいて回答できるようになります。

特徴

  • 🔍 法令検索: キーワードで日本の法令を検索
  • 📜 条文取得: 特定の条文をMarkdown形式で取得(最重要機能)
  • 📖 全文/目次取得: 法令全文または目次のみを取得
  • 📅 改正履歴: 法令の改正履歴を取得
  • 🔎 キーワード検索: 法令本文内の横断検索

なぜこのMCPサーバーが必要か?

課題 解決策
ハルシネーション LLMの学習データに頼らず、現行の正確な条文を取得
トークン消費 法令全文ではなく、必要な条文のみを抽出してコンテキストに含める
可読性 複雑な法制執務XMLを、LLMが解釈しやすいMarkdownに変換

インストール

pip install egov-law-mcp

使用方法

Claude Desktopでの設定

~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "egov-law": {
      "command": "python",
      "args": ["-m", "egov_law_mcp.server"]
    }
  }
}

Gemini (Antigravity) での設定

~/.gemini/antigravity/mcp_config.json:

{
  "mcpServers": {
    "egov-law": {
      "command": "/path/to/.venv/bin/python",
      "args": ["-m", "egov_law_mcp.server"]
    }
  }
}

利用可能なツール

1. search_laws - 法令検索

keyword="民法" → LawID: 129AC0000000089

2. get_law_article - 条文取得(最重要機能)

# 民法 第七百九条(不法行為による損害賠償)

故意又は過失によって他人の権利又は法律上保護される利益を侵害した者は、
これによって生じた損害を賠償する責任を負う。

3. get_law_full_text - 全文/目次取得

  • output_format="markdown": 全文をMarkdown形式で取得
  • output_format="toc": 目次のみ(トークン節約)

4. get_law_revisions - 改正履歴取得

法令の改正履歴と施行日を取得

5. keyword_search - キーワード横断検索

複数の法令を横断してキーワード検索

6. list_law_types - 法令種別一覧

検索時に使用可能な法令種別コードを取得

プロンプト例

ユーザー: 「隣の家の木の枝が自分の敷地に入ってきているんだけど、勝手に切ってもいいの?民法の条文を根拠に教えて。」

LLMの動作:

  1. search_laws(keyword="民法") → 民法のLawIDを特定
  2. get_law_full_text(law_id="...", output_format="toc") → 目次を確認
  3. get_law_article(law_id="...", article_number="233") → 民法233条を取得

結果: 民法233条(竹木の枝の切除及び根の切取り)の正確な条文に基づいて回答

開発

セットアップ

git clone https://github.com/takurot/egov-law-mcp.git
cd egov-law-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

テスト実行

# ユニットテストのみ
pytest tests/ -v -m "not e2e"

# E2Eテスト含む(実APIを使用)
pytest tests/ -v

ライセンス

MIT License

関連リンク

Metadata

Release files for egov-law-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for egov-law-mcp 0.1.0
File Size Uploaded
egov_law_mcp-0.1.0.tar.gz 26.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for egov-law-mcp 0.1.0
File Interpreter ABI Platform
egov_law_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.0 kB

Release files / egov_law_mcp-0.1.0.tar.gz

Download URL egov_law_mcp-0.1.0.tar.gz
Size 26.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c3c3f48a3887933437350bc882055ecdda9ec3109d29e8430d63d2053ab35298
BLAKE2b-256 checksum
How to use checksums
18c916341921c6cd4423db9e4f97edf80cc25bf5cd192a9c60285fbbfd9c8b19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 4, 2026.

Transparency log

Release files / egov_law_mcp-0.1.0-py3-none-any.whl

Download URL egov_law_mcp-0.1.0-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9577714df931fff160ef691dde58b3bf5d667885b5c7ce6f73fd22a0914aa9d
BLAKE2b-256 checksum
How to use checksums
d8edb4d1914cc9a540ef437b631f55c58a10d3ab881d778bdc3eee804684534e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page