irpp-mcp

irpp-mcp

A Python MCP server that calculates French income tax using the official DGFiP source code compiled locally. It enables accurate tax simulations for 2023 income based on real French tax forms without network calls.

Category
Visit Server

README

🧼 irpp-mcp — Simulateur IRPP officiel DGFiP

Serveur MCP Python qui calcule l'impÎt sur le revenu français à partir du code source officiel DGFiP, compilé via Mlang (OCamlPro/DGFiP). Calcul 100% local, zéro appel réseau.

Revenus couverts : 2023 (déclaration 2024). Voir Limitations.


Architecture

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

Arborescence attendue

Avant de commencer, crĂ©er un rĂ©pertoire de travail. À la fin de l'installation, la structure sera :

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

Commencer par cloner ce repo :

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

Installation rapide (binaire pré-compilé)

Si vous ĂȘtes sous Linux x86-64 ou WSL (Ubuntu 22.04+), vous pouvez sauter les Ă©tapes 1 Ă  4 et tĂ©lĂ©charger directement le binaire prĂ©-compilĂ© :

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

Puis passer directement à l'étape 5.


Installation complĂšte (compilation depuis les sources)

Prérequis

  • WSL (Ubuntu 22.04 recommandĂ©) — nĂ©cessaire pour compiler et exĂ©cuter le binaire Linux
  • Python 3.11+ avec pip
  • gcc, make, git, opam, unzip

Étape 1 — Sources DGFiP (langage M)

Le code fiscal officiel est publié par la DGFiP sur Adullact sous licence CeCILL 2.1. Aucun compte requis.

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

Dossier utile : calculette-ir-master/sources2023m_8_0/


Étape 2 — Compiler 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

Binaire produit : mlang-src/_build/default/src/main.exe


Étape 3 — GĂ©nĂ©rer les fichiers C depuis les sources M

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 doit ĂȘtre passĂ© en premier — il dĂ©clare l'application iliad.

Résultat : ~55 Mo de fichiers C dans ~/impots/output/.


Étape 4 — Compiler le binaire

irpp_driver.c et Makefile sont déjà dans output/ (fournis par ce repo). Copier depuis le 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

Tester :

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

Étape 5 — Installer le serveur MCP

pip install mcp pydantic

Vérifier que BINARY_PATH dans irpp_mcp.py pointe vers le binaire compilé. Par défaut :

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

Étape 6 — Configurer Claude Code

Créer .mcp.json à la racine du projet Claude Code :

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

Sur Windows (invocation via WSL) :

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

Adapter le chemin Ă  votre arborescence. Trouver le chemin Python : which python3 dans WSL.


Utilisation

L'outil MCP irpp_calculer_ir accepte les paramĂštres du formulaire 2042 :

ParamĂštre Case 2042 Description
situation — celibataire / marie / pacse / divorce / veuf
salaires_declarant1 1AJ Salaires nets imposables déclarant 1
salaires_declarant2 1BJ Salaires nets imposables déclarant 2
pensions_declarant1 1AS Pensions, retraites, rentes déclarant 1
pensions_declarant2 1BS Pensions, retraites, rentes déclarant 2
bnc_declarant1 5QC BNC professionnels régime normal
micro_foncier 4BE Micro-foncier recettes brutes
dividendes 2DC Dividendes (abattement 40 %)
plus_values 3VG Plus-values mobiliĂšres
nb_enfants_charge 0CF Enfants mineurs Ă  charge
nb_enfants_alternee 0CH Enfants en résidence alternée
per_declarant1 6NS Cotisations PER déductibles déclarant 1
per_declarant2 6NT Cotisations PER déductibles déclarant 2
pension_alimentaire 6GI Pension alimentaire versée à enfant majeur
revenus_fonciers_reels 4BA Revenus fonciers nets régime réel
annee_naissance_declarant1 — AnnĂ©e de naissance dĂ©clarant 1
response_format — markdown (dĂ©faut) ou json

Variables retournées : IINET (impÎt net), NBPT (parts), RNI (revenu net imposable), REVKIRE (revenu fiscal de référence), IRNET, IAVIM, IRTOTAL.


Utilisation avec le skill impĂŽts

Le skill erwanpaccard/impots dĂ©tecte automatiquement ce serveur MCP et l'utilise pour les simulations IR — les calculs s'appuient alors sur le moteur DGFiP officiel plutĂŽt que sur des estimations LLM.


Limitations

  • Revenus 2023 uniquement : les sources 2024 (sources2024m_3_13) sont incompatibles avec la version actuelle de Mlang (variable GLOBAL.REPRCM non rĂ©solue dans le contexte correctif).
  • micro_bnc_declarant1 (case 5TE) : calcule REVKIRE correctement mais donne IINET=0. Workaround : passer les recettes × 66 % dans bnc_declarant1 (5QC).
  • Binaire Linux uniquement : sur Windows, l'invocation passe automatiquement par WSL.

Sources et licences

Composant Source Licence
Sources DGFiP (revenus 2023) Adullact — calculette-ir CeCILL 2.1
Compilateur Mlang Mlang (Adullact) GPL-3.0
irpp_driver.c + irpp_mcp.py Ce dépÎt MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured