mcp-dolibarr

mcp-dolibarr

Enables AI assistants to natively interact with Dolibarr ERP/CRM through its REST API, providing over 30 tools for managing customers, contacts, products, quotes, orders, invoices, stock, projects, contracts, interventions, and PDF generation, while supporting complex workflow orchestration and read-only security modes.

Category
Visit Server

README

🚀 mcp-dolibarr

Serveur MCP (Model Context Protocol) hautement performant et sécurisé basé sur FastMCP, permettant à n'importe quel assistant IA (Claude Desktop, Cursor, AI Agents) d'interagir nativement avec l'ERP/CRM Dolibarr via son API REST officielle.


✹ FonctionnalitĂ©s Principales

Le serveur MCP couvre l'ensemble des besoins de gestion d'entreprise sur Dolibarr à travers plus de 30 outils dédiés répartis dans 12 modules :

  • 🏱 Tiers & SociĂ©tĂ©s (tools/thirdparties.py) : Listing, recherche plein-texte par nom, consultation dĂ©taillĂ©e par ID, crĂ©ation et mise Ă  jour partielle des fiches clients/prospects.
  • đŸ‘€ Contacts & Intervenants (tools/contacts.py) : Listing et crĂ©ation des contacts (personnes physiques) rattachĂ©s Ă  des sociĂ©tĂ©s.
  • 📩 Produits & Services (tools/products.py) : Catalogue complet d'articles et services, recherche par rĂ©fĂ©rence, crĂ©ation, mise Ă  jour et gestion des prix HT / taux de TVA.
  • 📄 Devis & Propositions Commerciales (tools/proposals.py) : CrĂ©ation de devis multi-lignes, validation, mise Ă  jour / suppression de lignes et conversion automatique.
  • 🛒 Commandes Clients (tools/orders.py) : GĂ©nĂ©ration de commandes Ă  partir d'un devis validĂ©, consultation et modification fine des lignes de commande.
  • 💳 Factures & RĂšglements (tools/invoices.py) : CrĂ©ation de factures depuis une commande ou en direct, validation finale et gestion des lignes de facture.
  • 📊 Stocks par EntrepĂŽt (tools/stocks.py) : Consultation instantanĂ©e des niveaux de stock rĂ©el d'un produit, entrepĂŽt par entrepĂŽt.
  • 📁 Projets (tools/projects.py) : CrĂ©ation, consultation et rattachement de projets aux fiches clients.
  • 📜 Contrats (tools/contracts.py) : Suivi des contrats de service et crĂ©ation pour un tiers.
  • đŸ› ïž Fiches d'Intervention (tools/interventions.py) : Gestion des fiches d'intervention technique sur le terrain.
  • 📑 Documents & PDF (tools/documents.py) : GĂ©nĂ©ration automatisĂ©e de PDF officiels (modĂšles Azur, Crabe, etc.) et tĂ©lĂ©chargement avec encodage Base64.
  • 🔌 API Rest Directe (Mode Secours) (tools/raw.py) : Outil call_dolibarr_api permettant d'interroger directement n'importe quelle route REST de Dolibarr non couverte par un outil dĂ©diĂ©.

🌟 Ce que mcp-dolibarr offre en plus par rapport aux autres serveurs MCP

Contrairement aux passerelles MCP basiques ou génériques, ce serveur apporte une valeur ajoutée déterminante :

  1. 🔄 Orchestration Complexe en 1 seul appel (convert_proposal_to_invoice) : Au lieu de forcer l'IA Ă  effectuer 4 requĂȘtes manuelles successives, l'outil orchestrateur enchaĂźne automatiquement : Devis validĂ© $\rightarrow$ Commande client $\rightarrow$ Facture $\rightarrow$ Validation de la facture.
  2. ✏ Manipulation Granulaire des Lignes (Add / Update / Delete) : Prise en charge complĂšte de la gestion ligne par ligne sur les devis, commandes et factures (ajout d'articles, modification de quantitĂ©s/prix/libellĂ©s, suppression de ligne).
  3. đŸ›Ąïž Mode SĂ©curitĂ© / Lecture Seule Natif (READ_ONLY=true) : PossibilitĂ© de brider le serveur en consultation seule pour des environnements de production sensibles. Toutes les requĂȘtes d'Ă©criture (POST, PUT, DELETE) sont interceptĂ©es et rejetĂ©es Ă  la source.
  4. 🔁 RĂ©silience et Backoff Exponentiel (HTTP 429) : Gestion intelligente des limites de dĂ©bit de l'API Dolibarr : rĂ©essaye automatiquement avec temporisation (1s, 2s, 4s) en cas de surcharge sans faire Ă©chouer l'agent IA.
  5. 🎯 Nettoyage et Formatage OptimisĂ©s pour LLM :
    • Les rĂ©ponses JSON brutes de Dolibarr (souvent truffĂ©es de +50 champs internes inutiles) sont nettoyĂ©es et rĂ©sumĂ©es en texte clair et lisible.
    • Validation stricte en amont (emails, montants positifs, champs obligatoires) pour Ă©viter d'envoyer des requĂȘtes malformĂ©es Ă  Dolibarr.
  6. 📄 GĂ©nĂ©ration et Extraction RĂ©elle de Fichiers PDF : Permet d'ordonner la gĂ©nĂ©ration des PDF rĂ©glementaires et de rĂ©cupĂ©rer leur contenu encodĂ© en Base64 pour l'agent IA.
  7. 🌐 Multi-Transport Natif (stdio, http, sse, streamable-http) : Fonctionne aussi bien localement sur ordinateur (Claude Desktop, Cursor) qu'en microservice conteneurisĂ© sur un serveur Cloud.

🏃 Comment Lancer et ExĂ©cuter le Serveur MCP (Run)

1. Préparation de l'environnement local

# 1. Créer l'environnement virtuel Python
python -m venv .venv

# 2. Activer l'environnement
# Linux / macOS / Git Bash :
source .venv/bin/activate
# Windows PowerShell :
# .venv\Scripts\Activate.ps1

# 3. Installer les dépendances
pip install -r requirements.txt

# 4. Configurer le fichier de variables d'environnement
cp .env.example .env

Dans le fichier .env, configurez l'accĂšs Ă  votre instance Dolibarr :

DOLIBARR_URL=http://localhost:8080/api/index.php
DOLIBARR_API_KEY=votre_cle_api_dolibarr
MCP_TRANSPORT=stdio
LOG_LEVEL=INFO
READ_ONLY=false

2. Démarrage du Serveur MCP

A. Mode Local stdio (Claude Desktop / Cursor / VS Code)

Lancement simple dans le terminal :

python server.py

Pour connecter Claude Desktop, ajoutez la configuration suivante dans votre fichier claude_desktop_config.json :

{
  "mcpServers": {
    "dolibarr": {
      "command": "python",
      "args": ["/chemin/absolu/vers/mcp-dolibarr/server.py"],
      "env": {
        "DOLIBARR_URL": "http://localhost:8080/api/index.php",
        "DOLIBARR_API_KEY": "votre_cle_api_dolibarr"
      }
    }
  }
}

B. Mode Serveur Distant http / Streamable HTTP

Pour exposer le serveur MCP via HTTP (par exemple sur un serveur distant ou un conteneur cloud) :

MCP_TRANSPORT=http MCP_PORT=8000 python server.py

Le serveur sera accessible sur http://0.0.0.0:8000.


3. Exécution avec Docker

Via Docker Compose (Recommandé)

docker-compose up -d --build

Via Docker CLI

docker build -t mcp-dolibarr .
docker run -d -p 8000:8000 --env-file .env mcp-dolibarr

đŸ§Ș ExĂ©cution des Tests Unitaires

La suite de tests unitaires valide le comportement du client et des outils à l'aide de pytest et du mock HTTP respx (aucun appel réseau réel ni modification sur votre Dolibarr) :

pytest

📁 Architecture et Structure du Projet

mcp-dolibarr/
├── app.py                # Initialisation de l'instance FastMCP & gestion du lifespan
├── server.py             # Point d'entrĂ©e principal (Transports stdio/http & Logging)
├── config/
│   └── settings.py       # Centralisation et validation des paramùtres d'environnement (.env)
├── dolibarr/
│   ├── client.py         # Client HTTP asynchrone httpx connectĂ© Ă  l'API REST Dolibarr
│   ├── auth.py           # Authentification HTTP via le header DOLAPIKEY
│   └── exceptions.py     # HiĂ©rarchie des erreurs et exceptions mĂ©tier
├── tools/                # 12 modules d'outils MCP exposĂ©s aux assistants IA
│   ├── thirdparties.py   # Gestion des tiers et sociĂ©tĂ©s clients/prospects
│   ├── contacts.py       # Gestion des contacts personnes physiques
│   ├── products.py       # Catalogue produits et services
│   ├── proposals.py      # Devis & Orchestrateur de conversion devis->facture
│   ├── orders.py         # Commandes clients et gestion de leurs lignes
│   ├── invoices.py       # Facturation, validation et paiements
│   ├── stocks.py         # Suivi des niveaux de stock par entrepît
│   ├── projects.py       # Fiches projets
│   ├── contracts.py      # Suivi des contrats clients
│   ├── interventions.py  # Fiches d'intervention technique
│   ├── documents.py      # GĂ©nĂ©ration & tĂ©lĂ©chargement de PDF
│   └── raw.py            # Outil de secours API REST brute
├── utils/
│   ├── formatters.py     # Nettoyage et mise en forme des rĂ©ponses JSON pour les LLM
│   └── validators.py     # Validation stricte des entrĂ©es utilisateur
├── tests/                # Tests unitaires automatisĂ©s (pytest + respx)
├── Dockerfile            # Image Docker du serveur MCP
├── docker-compose.yml    # Fichier Docker Compose
├── requirements.txt      # Liste des dĂ©pendances Python
└── README.md             # Documentation du projet

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
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

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
Qdrant Server

Qdrant Server

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

Official
Featured