Skip to main content

MCP Server and SDK for OpenFisca-Japan

Project description

OpenFisca-Japan-MCP

OpenFisca-Japan-MCP は、日本の税制・社会保障制度をシミュレーションするOSSのOpenFisca-Japan を、 MCP (Model Context Protocol) 経由でアクセス可能なサーバーおよび Python SDK です。本サーバーはMCPクライアント(Claude Codeなど)が利用しやすい型とインターフェースを提供します。

利点

LLMは単独でも日本の税制・社会保障制度を知っており、入力された世帯情報をもとにそれらの金額を計算することができます。
しかし、OpenFisca-Japan-MCPを用いることで、再現性・透明性のある制度計算が可能になります。特に所得税や社会保険料、生活保護など多段階のステップで算出される制度において、検証が容易になります。 また、複数の世帯を一括して計算可能なため、大規模シミュレーションのオーバーヘッドを削減できます。(一括であっても、MCPクライアントが大規模データを読み込み、サーバーとやりとりするトークンは必要になります。)

制限事項

主に官庁・自治体が公開している制度情報を基に計算ロジックを実装していますが、例外的な条件などは反映されていない場合があり、完全に正しい結果を保証するものではありません。あくまで目安としてご利用ください。
OpenFisca-JapanのGitHubリポジトリ上で、実装されている計算ロジックおよび必要条件を確認できます。

機能 (Tools)

  • tax_benefit_info(tax_benefit_name): 入力された制度を計算するために必要な属性情報を取得します。
  • calculate_tax_benefit(household_list, output_tax_benefit_list, date): 世帯の配列データを元に、指定した制度の金額を計算し、元の配列を拡張して返します。

データ構造の例

calculate_tax_benefit ツールに渡す household_list は以下のような構造になります。

[
  {
    "name": "世帯1",
    "household_attribute": {
      "居住都道府県": "東京都",
      "居住市区町村": "千代田区"
    },
    "member_attribute": [
      {
        "name": "親1",
        "年齢": 40,
        "年収": 6000000,
        "個人事業主の必要経費": 0
      },
      {
        "name": "子1",
        "年齢": 10,
        "年収": 0
      }
    ]
  }
]

対応制度

  • 所得税
  • 住民税
  • 社会保険料
  • 児童手当
  • 生活保護

MCP Client からの利用

openfisca-japan-mcp は PyPI に登録されており、uvx を使用して、様々な MCP クライアントから簡単に呼び出すことができます。

PythonパッケージマネージャーのuvをローカルPCにインストールしてください。

[!IMPORTANT] 本パッケージは Python 3.11 で動作させる必要があります(OpenFisca の依存関係の制約による)。 uvx で実行する際は、必ず --python 3.11 オプションを指定してください。

設定の基本構成 (JSON)

多くのクライアント(Claude, Copilot, Gemini など)では、以下の内容を設定ファイルに追加します。

{
  "mcpServers": {
    "openfisca-japan-mcp": {
      "command": "uvx",
      "args": ["--python", "3.11", "openfisca-japan-mcp"]
    }
  }
}

各クライアントの設定場所

[!NOTE] Claude Desktop と Claude Code (CLI) は設定ファイルを共有しません。両方で利用する場合は、それぞれに対して設定が必要です。

  • Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Claude Code (CLI): 以下のように CLI コマンドで追加するのが推奨されています。
    claude mcp add openfisca-japan-mcp -- uvx --python 3.11 openfisca-japan-mcp
    
    (手動設定の場合は ~/.claude.json に追記します)
  • GitHub Copilot CLI: ~/.config/github-copilot/mcp-servers.json
  • Gemini CLI / Google AI Studio: ~/.gemini/settings.json
  • Cursor / Codex:
    • 設定画面の MCP セクションから以下のコマンドを登録します。
    • Type: command
    • Command: uvx --python 3.11 openfisca-japan-mcp

ローカルでの開発・検証

GitHub からクローンしたリポジトリを直接参照する場合は、--from オプションでディレクトリを指定します。

{
  "mcpServers": {
    "openfisca-japan-mcp": {
      "command": "uvx",
      "args": [
        "--python", "3.11",
        "--from", "/path/to/OpenFisca-Japan-MCP",
        "openfisca-japan-mcp"
      ]
    }
  }
}

Python SDK としての利用

MCP を介さず、Python ライブラリとして直接計算ロジックを利用することも可能です。

from openfisca_japan_mcp.sdk import calc

household_list = [
    {
        "name": "household1",
        "household_attribute": { "居住都道府県": "東京都" },
        "member_attribute": [
            { "name": "member1", "年齢": 35, "年収": 5000000 }
        ]
    }
]

# 計算の実行
result = calc(
    household_list, 
    [{"name": "児童手当", "household_or_member": "household"}]
)

print(result[0]["household_attribute"]["児童手当"])

開発者向けのセットアップ

リポジトリをクローンしてローカルで開発・テストを行う手順です。

  1. リポジトリのクローン

    git clone https://github.com/project-inclusive/OpenFisca-Japan-MCP.git
    cd OpenFisca-Japan-MCP
    
  2. 依存関係のインストール uv を使用して環境を構築します。Python 3.11 がインストールされている必要があります。

    uv python install 3.11
    uv sync --python 3.11
    
  3. テストの実行

    uv run test.py
    

ライセンス

Apache License 2.0

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

openfisca_japan_mcp-0.2.3.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

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

openfisca_japan_mcp-0.2.3-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file openfisca_japan_mcp-0.2.3.tar.gz.

File metadata

  • Download URL: openfisca_japan_mcp-0.2.3.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openfisca_japan_mcp-0.2.3.tar.gz
Algorithm Hash digest
SHA256 d9dab42c8af73e03e8f1d741ac870bcb1500cf5e115e12e72aab37191c1b33bd
MD5 116d298ba0b62ba3dab8bf69209c0563
BLAKE2b-256 da4f14bf91b7673a045fa58c0ee25bd69dae869745334f6465e2bd30ba127013

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfisca_japan_mcp-0.2.3.tar.gz:

Publisher: publish.yml on project-inclusive/OpenFisca-Japan-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 openfisca_japan_mcp-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for openfisca_japan_mcp-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f85af96209dae81f5cafbe86eac5310805711cf6088daafc624ec061abee074e
MD5 a8443d65b52ef8efe9ee12e9b5920927
BLAKE2b-256 e8c17be8ec3fc0d8a786af89caa351ea1caeeebd4a56e3b0eca85b82ef24e61a

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfisca_japan_mcp-0.2.3-py3-none-any.whl:

Publisher: publish.yml on project-inclusive/OpenFisca-Japan-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