irpp-mcp
🧮 irpp-mcp — DGFiP 官方 IRPP 模拟器
这是一个 Python MCP 服务器,通过 Mlang (OCamlPro/DGFiP) 编译的 DGFiP 官方源代码来计算法国所得税。100% 本地计算,零网络调用。
涵盖收入:2023 年(2024 年申报)。请参阅 限制。
架构
Sources DGFiP (langage M) → Mlang (OCamlPro/DGFiP) → C (~55 Mo) → irpp_calc
↓
irpp_mcp.py (MCP)
↓
Claude CodeRelated MCP server: itr-mcp
预期目录结构
开始之前,请创建一个工作目录。安装完成后,结构如下:
~/impots/
├── calculette-ir-master/ ← sources DGFiP téléchargées (étape 1)
│ └── sources2023m_8_0/
├── mlang-src/ ← compilateur Mlang cloné (étape 2)
│ ├── _build/default/src/main.exe
│ ├── m_ext/2023/
│ └── examples/dgfip_c/ml_primitif/c_driver/
│ └── irdata.c
├── output/ ← C générés (étape 3) + binaire (étape 4)
│ ├── irpp_driver.c ← fourni dans ce repo
│ ├── Makefile ← fourni dans ce repo
│ └── irpp_calc ← binaire compilé
└── irpp-mcp/ ← ce repo (cloné en premier)
└── irpp_mcp.py首先克隆此仓库:
mkdir ~/impots && cd ~/impots
git clone https://github.com/erwanpaccard/irpp-mcp.git快速安装(预编译二进制文件)
如果您使用的是 Linux x86-64 或 WSL (Ubuntu 22.04+),您可以跳过第 1 到 4 步,直接下载预编译的二进制文件:
mkdir -p ~/impots/output
wget https://github.com/erwanpaccard/irpp-mcp/releases/download/v1.0.0/irpp_calc \
-O ~/impots/output/irpp_calc
chmod +x ~/impots/output/irpp_calc
# Tester
printf "V_0AC=1\nTSHALLOV=50000.00\n" | ~/impots/output/irpp_calc
# → {"IINET": 6786.00, "NBPT": 1.00, "RNI": 45000.00, ...}然后直接进入第 5 步。
完整安装(从源代码编译)
前置要求
WSL (推荐 Ubuntu 22.04) — 编译和运行 Linux 二进制文件所必需
Python 3.11+ 及
pipgcc,make,git,opam,unzip
第 1 步 — DGFiP 源代码 (M 语言)
官方税务代码由 DGFiP 在 Adullact 上发布,采用 CeCILL 2.1 许可证。无需账户。
cd ~/impots
curl -L "https://gitlab.adullact.net/dgfip/impots-nationaux-revenu-patrimoine-particuliers/calculette-ir/-/archive/master/calculette-ir-master.zip" \
-o calculette-ir-master.zip
unzip calculette-ir-master.zip有用文件夹:calculette-ir-master/sources2023m_8_0/
第 2 步 — 编译 Mlang (~15 分钟)
cd ~/impots
sudo apt install libgmp-dev libmpfr-dev git opam bubblewrap unzip bzip2 patch
git clone https://gitlab.adullact.net/dgfip/impots-nationaux-revenu-patrimoine-particuliers/Mlang.git mlang-src
cd mlang-src
# Correctif obligatoire (version non substituée dans les fichiers opam)
sed -i 's/%%VERSION%%/0.0.1/g' mlang.opam irj_checker.opam
OPAMYES=1 make init
make build生成的二进制文件:mlang-src/_build/default/src/main.exe
第 3 步 — 从 M 源代码生成 C 文件
cd ~/impots/mlang-src
eval $(opam env --switch=$(pwd) --set-switch)
./_build/default/src/main.exe \
-A iliad \
--display_time \
--precision double \
--mpp_function=enchainement_primitif \
--income-year=2023 \
--dgfip_options=-g,-O,-k4,-m2023,-X \
--backend dgfip_c \
--output ../output/irpp_2023.c \
$(find ../calculette-ir-master/sources2023m_8_0 -name 'tgvI.m') \
$(find ../calculette-ir-master/sources2023m_8_0 -name 'errI.m') \
$(find ../calculette-ir-master/sources2023m_8_0 -name '*.m' \
! -name 'err*.m' ! -name 'tgv*.m' ! -name 'cibles.m' | sort) \
m_ext/2023/cibles.m m_ext/2023/codes_1731.m m_ext/2023/commence_par_5.m \
m_ext/2023/commence_par_7.m m_ext/2023/commence_par_H.m \
m_ext/2023/correctif.m m_ext/2023/main.m
tgvI.m必须首先传递 — 它声明了iliad应用程序。
结果:~/impots/output/ 中约 55 MB 的 C 文件。
第 4 步 — 编译二进制文件
irpp_driver.c 和 Makefile 已经在 output/ 中(由本仓库提供)。从仓库复制:
cp ~/impots/irpp-mcp/output/irpp_driver.c ~/impots/output/
cp ~/impots/irpp-mcp/output/Makefile ~/impots/output/
cd ~/impots/output
make CDRIVER=../mlang-src/examples/dgfip_c/ml_primitif/c_driver测试:
printf "V_0AC=1\nTSHALLOV=50000.00\n" | ./irpp_calc
# → {"IINET": 6786.00, "NBPT": 1.00, "RNI": 45000.00, ...}第 5 步 — 安装 MCP 服务器
pip install mcp pydantic验证 irpp_mcp.py 中的 BINARY_PATH 是否指向已编译的二进制文件。默认情况下:
BINARY_PATH = Path(__file__).parent.parent / "output" / "irpp_calc"
# → ~/impots/output/irpp_calc ✓ si vous avez suivi l'arborescence ci-dessus第 6 步 — 配置 Claude Code
在 Claude Code 项目根目录下创建 .mcp.json:
{
"mcpServers": {
"irpp-mcp": {
"command": "python3",
"args": ["/home/user/impots/irpp-mcp/irpp_mcp.py"]
}
}
}在 Windows 上(通过 WSL 调用):
{
"mcpServers": {
"irpp-mcp": {
"command": "wsl",
"args": ["-e", "python3", "/mnt/c/Users/vous/impots/irpp-mcp/irpp_mcp.py"]
}
}
}请根据您的目录结构调整路径。在 WSL 中查找 Python 路径:
which python3。
使用方法
MCP 工具 irpp_calculer_ir 接受 2042 表格的参数:
参数 | 2042 栏目 | 描述 |
| — |
|
| 1AJ | 申报人 1 应纳税净工资 |
| 1BJ | 申报人 2 应纳税净工资 |
| 1AS | 申报人 1 养老金、退休金、年金 |
| 1BS | 申报人 2 养老金、退休金、年金 |
| 5QC | BNC 专业人士正常税制 |
| 4BE | 微型房产收入总额 |
| 2DC | 股息(40% 减免) |
| 3VG | 动产资本利得 |
| 0CF | 受抚养未成年子女 |
| 0CH | 轮流居住子女 |
| 6NS | 申报人 1 可抵扣 PER 缴款 |
| 6NT | 申报人 2 可抵扣 PER 缴款 |
| 6GI | 支付给成年子女的赡养费 |
| 4BA | 实际税制下的净房产收入 |
| — | 申报人 1 出生年份 |
| — |
|
返回变量:IINET (净税额), NBPT (份额), RNI (应纳税净收入), REVKIRE (参考税收收入), IRNET, IAVIM, IRTOTAL。
与 impôts 技能配合使用
erwanpaccard/impots 技能会自动检测此 MCP 服务器并将其用于 IR 模拟 — 计算将基于官方 DGFiP 引擎,而不是 LLM 估算。
限制
仅限 2023 年收入:2024 年源代码 (
sources2024m_3_13) 与当前版本的 Mlang 不兼容(GLOBAL.REPRCM变量在correctif上下文中未解析)。micro_bnc_declarant1(5TE 栏目):能正确计算REVKIRE但IINET=0。解决方法:将收入 × 66% 填入bnc_declarant1(5QC)。仅限 Linux 二进制文件:在 Windows 上,调用会自动通过 WSL 进行。
来源与许可证
组件 | 来源 | 许可证 |
DGFiP 源代码 (2023 年收入) | CeCILL 2.1 | |
Mlang 编译器 | GPL-3.0 | |
| 本仓库 | MIT |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Exact French tax & payroll calculations for AI agents: income tax (impôt sur le revenu: parts, quotient familial, décote, TMI), micro-entrepreneur URSSAF contributions (ACRE, versement libératoire) with an optional VAT franchise check (franchise en base de TVA: must I charge VAT?), and gross-to-net salary with employer cost — CDI or CDD (prime de précarité, congés payés), full-time or part-time. Missing information? Your agent gets, for free, the exact questions to ask the user (in French, with types and allowed values) in a single round trip. Deterministic, no LLM: matches all 7,095 values of the official DGFiP tax tables, 60 cases from the official simulators and the official worked examples of the tax doctrine (BOFiP). Unsupported cases are refused for free; you pay $0.005 in USDC via x402 only when the calculation succeeds. Free catalogue tool: list_france_calculators.
The first fiscal MCP server for Spain: IAE/CNAE 2025, AEAT modelos, IRPF/IVA, RETA quota.
Brazil tax reform simulator for AI (CBS/IBS/IS) on Receita Federal's official open-source code.
TaxSort — Tollbooth-monetized MCP server for personal tax transaction classification
Related MCP Servers
- AlicenseAqualityFmaintenanceA local MCP server that enables Claude to answer Norwegian tax questions with actual calculations, covering income, wealth, stocks, funds, real estate, crypto, and more.6121MIT
- AlicenseAqualityBmaintenanceLocal-first MCP server for Indian income tax computation, enabling users to compute taxes, compare regimes, plan advance tax, and parse Form 26AS without sending data to the cloud.16461 npm10MIT
- FlicenseAqualityDmaintenanceMCP server for the Swiss federal tax calculator, providing income, wealth, inheritance, and corporate tax figures for all Swiss municipalities and tax years 2010-2026.132-
- AlicenseNot gradedqualityDmaintenanceA standalone MCP server for Indian personal income-tax work (ITR-1/2/3/4 + post-filing notices) with 8 deterministic tools, running fully offline with no API keys.66 PyPIMIT