Skip to main content

MCP Server for e-Gov Law API - Japanese law search and retrieval

Project description

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

関連リンク

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

egov_law_mcp-0.1.0.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

egov_law_mcp-0.1.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file egov_law_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: egov_law_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for egov_law_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3c3f48a3887933437350bc882055ecdda9ec3109d29e8430d63d2053ab35298
MD5 f10ff073c38c875a4d7ced2330b1a238
BLAKE2b-256 18c916341921c6cd4423db9e4f97edf80cc25bf5cd192a9c60285fbbfd9c8b19

See more details on using hashes here.

Provenance

The following attestation bundles were made for egov_law_mcp-0.1.0.tar.gz:

Publisher: release.yml on takurot/egov-law-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file egov_law_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: egov_law_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for egov_law_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9577714df931fff160ef691dde58b3bf5d667885b5c7ce6f73fd22a0914aa9d
MD5 b065153cd8d48bb844dd65d78b99b183
BLAKE2b-256 d8edb4d1914cc9a540ef437b631f55c58a10d3ab881d778bdc3eee804684534e

See more details on using hashes here.

Provenance

The following attestation bundles were made for egov_law_mcp-0.1.0-py3-none-any.whl:

Publisher: release.yml on takurot/egov-law-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page