Skip to main content

MCP Server and SDK for OpenFisca-Japan

Project description

OpenFisca-Japan-MCP

OpenFisca-Japan-MCP は、OpenFisca-Japan を MCP (Model Context Protocol) 経由で呼び出すためのサーバーおよび Python SDK です。LLM エージェント(Claude Desktop など)から利用しやすい型とインターフェースを提供します。

OpenFisca-Japanは、日本の税制・社会保障制度をシミュレーションするためのオープンソースソフトウェアです。主に官庁・自治体が公開している制度情報を基に計算ロジックを実装していますが、例外的な条件などは反映されていない場合があり、完全に正しい結果を保証するものではありません。あくまで目安としてご利用ください。
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 クライアントから簡単に呼び出すことができます。

設定の基本構成 (JSON)

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

{
  "mcpServers": {
    "openfisca-japan-mcp": {
      "command": "uvx",
      "args": ["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 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 openfisca-japan-mcp

ローカルでの開発・検証

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

{
  "mcpServers": {
    "openfisca-japan-mcp": {
      "command": "uvx",
      "args": [
        "--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 を使用して環境を構築します。

    uv sync
    
  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.1.tar.gz (52.7 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.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openfisca_japan_mcp-0.2.1.tar.gz
  • Upload date:
  • Size: 52.7 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.1.tar.gz
Algorithm Hash digest
SHA256 628133457fb657efe827a7df565795a2346778fb0b7a9cfeca4740aafb1f0581
MD5 a3d560eff9390e50af490746cece0051
BLAKE2b-256 a1b9e307c4a9a3d8e9558004b22b957bd4417d756d0a2656bfb5999ddb3339bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfisca_japan_mcp-0.2.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openfisca_japan_mcp-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c866f36c7131b7cda6443a6a19c9c3c0572d9db931718879a2f371e94ed6dea
MD5 dd9e3812522ccd607e3e17a03a64a806
BLAKE2b-256 b5f0339abec273825b1506fab477bae8c8935b0ddb9e1c3d75ee06044815170c

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfisca_japan_mcp-0.2.1-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