Skip to main content

MCP server exposing the AFNOR XP Z12-013 APIs for French electronic invoicing (Compatible Solution)

Project description

mcp-facture-electronique-fr 🇫🇷

English | Francais

License PyPI version Python mcp-facture-electronique-fr MCP server

A Python MCP server exposing the standardized AFNOR XP Z12-013 APIs for the French e-invoicing reform (effective September 1, 2026). This project enables AI agents (Claude, IDEs) to interact natively with the Approved Platform (PA/PDP) ecosystem as a Compatible Solution (SC).

Built on

This package is built on top of mcp-einvoicing-core, a shared base library for European e-invoicing MCP servers. It provides the OAuth2 HTTP client, token cache, shared models, logging utilities, and exception hierarchy used by this package.

mcp-einvoicing-core is installed automatically as a transitive dependency, no extra step is needed.

For contributors: pip install -e ".[dev]" installs the base package from PyPI automatically.


Scope (Compatible Solution)

This server operates in Compatible Solution (CS) mode as defined by the French e-invoicing reform. The CS acts as an intermediary between the company's information system and an Approved Platform (AP/PDP). This means:

  • No profile validation of caller-supplied payloads. The server transmits the invoice file (Factur-X PDF/A-3, UBL 2.1, or CII XML) as provided. Structural and business-rule validation (NF XP Z12-012 profiles, Schematron rules) is performed by the receiving Approved Platform, not by this server.
  • No e-reporting payload validation beyond schema-level XSD. Transaction reports (Flux 10.1/10.3) and payment reports (Flux 10.2/10.4) are validated against the DGFiP v3.2 XSD schema when validate_ereporting_xml is called, but deeper business-rule checks (e.g. coherence between declared amounts and invoice totals) are the responsibility of the AP.
  • No PDF/A-3 envelope generation. The caller must produce the conformant Factur-X PDF/A-3 file with embedded CII XML. This server transmits the finished binary.

The Approved Platform performs final validation and may reject non-conformant submissions with an error code and message.


🏗️ Architecture

The server acts as an intelligent communication interface between your AI agent and the technical infrastructure of the reform:

[ ERP / Business IS ] <--> [ MCP Server ] <--> [ Approved Platform (PA/PDP) ]
          ^                        |
          |                        v
   [ AI Agent (Claude) ] <--- (XP Z12-013 Standard)

🛠️ Exposed services

Service Domain Standard MCP Tools
Flow Service Invoice flows and e-reporting Annex A, v1.2.0 5 tools
Directory Service Central directory (SIREN/SIRET) Annex B, v1.2.0 12 tools
Webhook Service Event notification subscriptions Annex A, v1.2.0 5 tools

🚀 Installation

Via PyPI (recommended)

pip install mcp-facture-electronique-fr

Or without prior installation using uvx:

uvx mcp-facture-electronique-fr

From source

# Clone the repository
git clone https://github.com/cmendezs/mcp-facture-electronique-fr.git
cd mcp-facture-electronique-fr

# Create the virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in editable mode
pip install -e ".[dev]"
# Initial configuration
cp .env.example .env
# Edit .env with the credentials provided by your PA/PDP

⚙️ Configuration (.env)

The server requires the following variables to authenticate with an Approved Platform (PA):

Variable Description
PA_BASE_URL_FLOW Base URL of the PA Flow Service
PA_BASE_URL_DIRECTORY Base URL of the PA Directory Service
PA_CLIENT_ID OAuth2 Client ID
PA_CLIENT_SECRET OAuth2 Client Secret
PA_TOKEN_URL Authentication server URL
PA_ORGANIZATION_ID Organization identifier for multi-tenant AP (optional)
HTTP_TIMEOUT Request timeout (default: 30s)

🤖 Claude Desktop integration

To use this server with Claude, add this configuration to your claude_desktop_config.json file:

{
  "mcpServers": {
    "facture-electronique-fr": {
      "command": "uvx",
      "args": ["mcp-facture-electronique-fr"],
      "env": {
        "PA_BASE_URL_FLOW": "https://api.votre-pdp.fr/flow",
        "PA_BASE_URL_DIRECTORY": "https://api.votre-pdp.fr/directory",
        "PA_CLIENT_ID": "votre-id",
        "PA_CLIENT_SECRET": "votre-secret",
        "PA_TOKEN_URL": "https://auth.votre-pdp.fr/oauth/token"
      }
    }
  }
}

⌨️ Cursor integration

Cursor supports MCP servers via stdio. Add the configuration in:

  • Global (all projects): ~/.cursor/mcp.json
  • Project (this repository only): .cursor/mcp.json
{
  "mcpServers": {
    "facture-electronique-fr": {
      "command": "uvx",
      "args": ["mcp-facture-electronique-fr"],
      "env": {
        "PA_BASE_URL_FLOW": "https://api.votre-pdp.fr/flow",
        "PA_BASE_URL_DIRECTORY": "https://api.votre-pdp.fr/directory",
        "PA_CLIENT_ID": "votre-id",
        "PA_CLIENT_SECRET": "votre-secret",
        "PA_TOKEN_URL": "https://auth.votre-pdp.fr/oauth/token"
      }
    }
  }
}

Reload the Cursor window (Ctrl+Shift+P then Reload Window) to apply the changes.

🪐 Kiro integration

Kiro supports MCP servers via its dedicated configuration file. Two levels are available:

  • Global (all projects): ~/.kiro/settings/mcp.json
  • Workspace (this repository only): .kiro/settings/mcp.json
{
  "mcpServers": {
    "facture-electronique-fr": {
      "command": "uvx",
      "args": ["mcp-facture-electronique-fr"],
      "env": {
        "PA_BASE_URL_FLOW": "https://api.votre-pdp.fr/flow",
        "PA_BASE_URL_DIRECTORY": "https://api.votre-pdp.fr/directory",
        "PA_CLIENT_ID": "votre-id",
        "PA_CLIENT_SECRET": "votre-secret",
        "PA_TOKEN_URL": "https://auth.votre-pdp.fr/oauth/token"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

The file is automatically reloaded on save. You can also open the config via the command palette (Cmd+Shift+P / Ctrl+Shift+P) then MCP.

Kiro security tip: rather than writing secrets in plain text, use the syntax "PA_CLIENT_SECRET": "${PA_CLIENT_SECRET}", Kiro resolves shell environment variables at startup.

🧰 Available MCP tools

Flow Service (Flow management)

  • submit_flow: Submit invoices (Factur-X, UBL, CII) or e-reporting data.
  • search_flows: Multi-criteria search of sent or received flows using the standard filters.
  • submit_lifecycle_status: Update the lifecycle status (e.g., Made available, Collected, Dispute).
  • get_flow: Retrieve the full details and attachments of a specific flow.
  • healthcheck_flow: Test the connectivity and availability of the PA Flow API.

Directory Service (Directory)

  • get_company_by_siren / get_establishment_by_siret: Look up company and establishment records in the central directory.
  • search_routing_code: Identify the platform code (routing address) of a recipient for invoice submission.
  • manage_directory_line: Create, modify, and delete directory lines for managing the taxable entity services.

Webhook Service (Webhook management)

  • list_webhooks: List all webhook subscription IDs for the current token holder.
  • get_webhook: Retrieve the full details of a webhook subscription.
  • create_webhook: Subscribe to flow event notifications (filter by flow type, direction, processing rule).
  • update_webhook: Update a webhook's technical parameters (authentication, signature).
  • delete_webhook: Unsubscribe from a webhook.

📚 Regulatory references

  • AFNOR XP Z12-013: Service interface specifications (February 2026 edition).
  • AFNOR XP Z12-014: Technical implementation guide for business use cases.
  • France B2B reform: Mandatory rollout schedule (2024-2026).

🧪 Tests

# Run the unit and integration test suite
pytest tests/ -v

Other e-invoicing MCP servers

Country Server
🌍 Global mcp-einvoicing-core
🇧🇪 Belgium mcp-einvoicing-be
🇧🇷 Brazil mcp-nfe-br
🇫🇷 France mcp-facture-electronique-fr
🇩🇪 Germany mcp-einvoicing-de
🇮🇹 Italy mcp-fattura-elettronica-it
🇵🇱 Poland mcp-ksef-pl
🇪🇸 Spain mcp-facturacion-electronica-es

📄 License

This project is distributed under the Apache 2.0 license. See the LICENSE file for details.


Project maintained by cmendezs. For any questions about the XP Z12-013 standard implementation, feel free to open an Issue.

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

mcp_facture_electronique_fr-0.5.0.tar.gz (134.9 kB view details)

Uploaded Source

Built Distribution

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

mcp_facture_electronique_fr-0.5.0-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_facture_electronique_fr-0.5.0.tar.gz.

File metadata

File hashes

Hashes for mcp_facture_electronique_fr-0.5.0.tar.gz
Algorithm Hash digest
SHA256 87060c512e6ac3f2692b90361c00cae64ba78ac698454d51fa6ac816c65d877a
MD5 69db05b0c9c4488c7d54c4c2cdb42f88
BLAKE2b-256 7adb90fc8e266516c03ebc9a194e744aee167b1798047d6e06176445d2b1b3e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_facture_electronique_fr-0.5.0.tar.gz:

Publisher: publish.yml on cmendezs/mcp-facture-electronique-fr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_facture_electronique_fr-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_facture_electronique_fr-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 663c85feb9b9bfad9875051e530fc491442a9ec80b5d5435554941caf98bffeb
MD5 10663dbb0143521c3bb4c2b8f776fb48
BLAKE2b-256 2c845bf9b8c13cee5e0dd15ddade3bf63f89f0b028f51fe13d0c7fb904c77d65

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_facture_electronique_fr-0.5.0-py3-none-any.whl:

Publisher: publish.yml on cmendezs/mcp-facture-electronique-fr

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