Skip to main content
Glama
erwanpaccard

irpp-mcp

by erwanpaccard

🧮 irpp-mcp — Official DGFiP IRPP Simulator

Python MCP server that calculates French income tax using the official DGFiP source code, compiled via Mlang (OCamlPro/DGFiP). 100% local calculation, zero network calls.

Income covered: 2023 (2024 tax return). See Limitations.


Architecture

Sources DGFiP (langage M)  →  Mlang (OCamlPro/DGFiP)  →  C (~55 Mo)  →  irpp_calc
                                                                           ↓
                                                                    irpp_mcp.py (MCP)
                                                                           ↓
                                                                      Claude Code

Related MCP server: itr-mcp

Expected Directory Structure

Before starting, create a working directory. At the end of the installation, the structure will be:

~/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

Start by cloning this repo:

mkdir ~/impots && cd ~/impots
git clone https://github.com/erwanpaccard/irpp-mcp.git

Quick Installation (pre-compiled binary)

If you are on Linux x86-64 or WSL (Ubuntu 22.04+), you can skip steps 1 to 4 and download the pre-compiled binary directly:

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, ...}

Then proceed directly to Step 5.


Full Installation (compilation from source)

Prerequisites

  • WSL (Ubuntu 22.04 recommended) — required to compile and run the Linux binary

  • Python 3.11+ with pip

  • gcc, make, git, opam, unzip


Step 1 — DGFiP Sources (M language)

The official tax code is published by the DGFiP on Adullact under the CeCILL 2.1 license. No account required.

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

Useful folder: calculette-ir-master/sources2023m_8_0/


Step 2 — Compile Mlang (~15 min)

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

Produced binary: mlang-src/_build/default/src/main.exe


Step 3 — Generate C files from M sources

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 must be passed first — it declares the iliad application.

Result: ~55 MB of C files in ~/impots/output/.


Step 4 — Compile the binary

irpp_driver.c and Makefile are already in output/ (provided by this repo). Copy from the repo:

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

Test:

printf "V_0AC=1\nTSHALLOV=50000.00\n" | ./irpp_calc
# → {"IINET": 6786.00, "NBPT": 1.00, "RNI": 45000.00, ...}

Step 5 — Install the MCP server

pip install mcp pydantic

Verify that BINARY_PATH in irpp_mcp.py points to the compiled binary. By default:

BINARY_PATH = Path(__file__).parent.parent / "output" / "irpp_calc"
# → ~/impots/output/irpp_calc  ✓ si vous avez suivi l'arborescence ci-dessus

Step 6 — Configure Claude Code

Create .mcp.json at the root of the Claude Code project:

{
  "mcpServers": {
    "irpp-mcp": {
      "command": "python3",
      "args": ["/home/user/impots/irpp-mcp/irpp_mcp.py"]
    }
  }
}

On Windows (invocation via WSL):

{
  "mcpServers": {
    "irpp-mcp": {
      "command": "wsl",
      "args": ["-e", "python3", "/mnt/c/Users/vous/impots/irpp-mcp/irpp_mcp.py"]
    }
  }
}

Adapt the path to your directory structure. Find the Python path: which python3 in WSL.


Usage

The MCP tool irpp_calculer_ir accepts parameters from form 2042:

Parameter

Box 2042

Description

situation

celibataire / marie / pacse / divorce / veuf

salaires_declarant1

1AJ

Net taxable wages declarant 1

salaires_declarant2

1BJ

Net taxable wages declarant 2

pensions_declarant1

1AS

Pensions, retirement, annuities declarant 1

pensions_declarant2

1BS

Pensions, retirement, annuities declarant 2

bnc_declarant1

5QC

Professional BNC standard regime

micro_foncier

4BE

Micro-foncier gross receipts

dividendes

2DC

Dividends (40% allowance)

plus_values

3VG

Capital gains on securities

nb_enfants_charge

0CF

Dependent minor children

nb_enfants_alternee

0CH

Children in shared custody

per_declarant1

6NS

Deductible PER contributions declarant 1

per_declarant2

6NT

Deductible PER contributions declarant 2

pension_alimentaire

6GI

Alimony paid to adult child

revenus_fonciers_reels

4BA

Net property income real regime

annee_naissance_declarant1

Birth year declarant 1

response_format

markdown (default) or json

Returned variables: IINET (net tax), NBPT (shares), RNI (net taxable income), REVKIRE (reference tax income), IRNET, IAVIM, IRTOTAL.


Usage with the impots skill

The erwanpaccard/impots skill automatically detects this MCP server and uses it for IR simulations — calculations then rely on the official DGFiP engine rather than LLM estimates.


Limitations

  • 2023 income only: 2024 sources (sources2024m_3_13) are incompatible with the current version of Mlang (GLOBAL.REPRCM variable not resolved in the correctif context).

  • micro_bnc_declarant1 (box 5TE): calculates REVKIRE correctly but gives IINET=0. Workaround: pass receipts × 66% in bnc_declarant1 (5QC).

  • Linux binary only: on Windows, the invocation automatically goes through WSL.


Sources and licenses

Component

Source

License

DGFiP Sources (2023 income)

Adullact — calculette-ir

CeCILL 2.1

Mlang Compiler

Mlang (Adullact)

GPL-3.0

irpp_driver.c + irpp_mcp.py

This repo

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    A local MCP server that enables Claude to answer Norwegian tax questions with actual calculations, covering income, wealth, stocks, funds, real estate, crypto, and more.
    12
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Local-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.
    12
    6 npm
    8
    MIT
  • F
    license
    A
    quality
    C
    maintenance
    MCP server for the Swiss federal tax calculator, providing income, wealth, inheritance, and corporate tax figures for all Swiss municipalities and tax years 2010-2026.
    13
    2
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    A 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.
    MIT