Compare commits

...

27 Commits

Author SHA1 Message Date
6fa6bb53ad Merge pull request 'fix: use system Python to fix venv symlink issue' (#4) from fix/netbox-mcp-python-venv into main
All checks were successful
Build and Push Docker Images / build (push) Successful in 21s
Reviewed-on: #4
2026-01-11 10:30:01 +00:00
a0078d331e fix: use system Python to fix venv symlink issue
- Add UV_PYTHON_PREFERENCE=only-system to prevent uv from downloading its own Python
- Use python:3.13-alpine3.21 (stable) instead of 3.14 (RC)

Fixes: exec /app/.venv/bin/netbox-mcp-server: no such file or directory
2026-01-11 10:25:32 +00:00
c3bef1afe0 Merge pull request 'feat: add netbox-mcp-server Docker image' (#3) from feature/netbox-mcp-server into main
All checks were successful
Build and Push Docker Images / build (push) Successful in 23s
Reviewed-on: #3
2026-01-11 10:12:37 +00:00
9e6ac27484 fix: use multi-stage build based on official Dockerfile 2026-01-10 20:22:51 +00:00
b577369cdd docs: add netbox-mcp-server README 2026-01-10 20:19:25 +00:00
9b7264bf56 feat: add netbox-mcp-server version file 2026-01-10 20:19:11 +00:00
3c2a4886e6 feat: add netbox-mcp-server image 2026-01-10 20:19:05 +00:00
f76d4cab71 fix: add --no-cache to docker build to avoid stale layers 2026-01-07 17:56:19 +00:00
9cff273a6a chore: remove plugins.py (now mounted at runtime from netbox-deployment)
All checks were successful
Build and Push Docker Images / build (push) Successful in 39s
2026-01-07 15:43:05 +00:00
faf1ca0404 refactor: remove plugins.py from image (mount at runtime)
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:42:49 +00:00
5212600c8d chore: remove local_settings.py (now mounted at runtime from netbox-deployment)
All checks were successful
Build and Push Docker Images / build (push) Successful in 5s
2026-01-07 15:36:03 +00:00
6375641926 refactor: remove local_settings.py from image (mount at runtime)
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:23:44 +00:00
93575f8569 fix: delete DATABASE after wrapping to avoid conflict
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:19:25 +00:00
3ff6ace420 fix: build DATABASE from env vars instead of importing
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:15:53 +00:00
b05a59213a fix: use relative import for configuration
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:10:44 +00:00
876abcf8d0 fix: move local_settings.py to /etc/netbox/config/
All checks were successful
Build and Push Docker Images / build (push) Successful in 7s
2026-01-07 15:10:29 +00:00
71e980fd8c fix: import DATABASE from configuration instead of env vars
All checks were successful
Build and Push Docker Images / build (push) Successful in 7s
2026-01-07 15:02:55 +00:00
b60a3f0b1e fix: move netbox_branching to end of PLUGINS list (required)
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 14:56:35 +00:00
2eef404f14 feat: add local_settings.py for netbox-branching support
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 14:56:12 +00:00
425b618a3a feat: add local_settings.py for netbox-branching DynamicSchemaDict
All checks were successful
Build and Push Docker Images / build (push) Successful in 5s
2026-01-07 14:55:50 +00:00
277761107d docs(netbox): add branching configuration and version compatibility matrix
All checks were successful
Build and Push Docker Images / build (push) Successful in 5s
2026-01-07 13:43:43 +00:00
ef3dd25957 fix(netbox): pin plugin versions for NetBox 4.4.x compatibility
All checks were successful
Build and Push Docker Images / build (push) Successful in 8s
- netbox-branching: >=0.7.0,<0.8.0 (0.7.x for NetBox 4.4)
- netbox-bgp: >=0.17.0,<0.18.0 (0.17.x for NetBox 4.4, 0.18+ requires 4.5)
2026-01-07 13:43:03 +00:00
afcb1b2e60 fix(netbox): skip collectstatic at build time for complex plugins
All checks were successful
Build and Push Docker Images / build (push) Successful in 30s
netbox_branching requires DynamicSchemaDict for DATABASES which cannot
be configured at build time. Static assets will be collected at container
startup instead.
2026-01-07 13:41:26 +00:00
dce74cddfd Update images/netbox/Dockerfile
Some checks failed
Build and Push Docker Images / build (push) Failing after 5s
2026-01-07 13:39:13 +00:00
f0dc1fe699 Update images/netbox/plugins.py
Some checks failed
Build and Push Docker Images / build (push) Failing after 4s
2026-01-07 13:38:19 +00:00
daa9afdb5f Merge pull request 'Update images/netbox/plugin_requirements.txt' (#2) from feature/netbox-plugins into main
Some checks failed
Build and Push Docker Images / build (push) Failing after 5s
Reviewed-on: #2
2026-01-07 13:36:50 +00:00
8f194987c8 Update images/netbox/plugin_requirements.txt 2026-01-07 13:36:32 +00:00
8 changed files with 205 additions and 129 deletions

View File

@@ -114,12 +114,12 @@ jobs:
fi fi
done done
# Build the image # Build the image with --no-cache to ensure fresh build
if [ -n "$BUILD_ARGS" ]; then if [ -n "$BUILD_ARGS" ]; then
echo "🔧 Building with args: $BUILD_ARGS" echo "🔧 Building with args: $BUILD_ARGS"
docker build $BUILD_ARGS -t "${IMAGE_NAME}:latest" "$IMAGE_PATH" docker build --no-cache $BUILD_ARGS -t "${IMAGE_NAME}:latest" "$IMAGE_PATH"
else else
docker build -t "${IMAGE_NAME}:latest" "$IMAGE_PATH" docker build --no-cache -t "${IMAGE_NAME}:latest" "$IMAGE_PATH"
fi fi
# Push latest tag # Push latest tag

View File

@@ -0,0 +1,62 @@
# =============================================================================
# NetBox MCP Server
#
# Image Docker pour le serveur MCP NetBox (Model Context Protocol)
# Permet l'interaction read-only avec NetBox via LLMs
# Source: https://github.com/netboxlabs/netbox-mcp-server
# =============================================================================
ARG NETBOX_MCP_VERSION=1.0.0
# -----------------------------------------------------------------------------
# Stage 1: Builder
# -----------------------------------------------------------------------------
FROM python:3.13-alpine3.21 AS builder
ARG NETBOX_MCP_VERSION
RUN apk add --no-cache git \
&& pip install --root-user-action=ignore --no-cache-dir --upgrade pip \
&& pip install --root-user-action=ignore --no-cache-dir uv
ENV UV_LINK_MODE=copy
ENV UV_PYTHON_PREFERENCE=only-system
WORKDIR /app
# Clone le repo à la version spécifiée
RUN git clone --depth 1 --branch v${NETBOX_MCP_VERSION} \
https://github.com/netboxlabs/netbox-mcp-server.git .
# Sync des dépendances avec cache uv
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev
# -----------------------------------------------------------------------------
# Stage 2: Runtime
# -----------------------------------------------------------------------------
FROM python:3.13-alpine3.21
LABEL maintainer="Damien Arnodo"
LABEL org.opencontainers.image.title="NetBox MCP Server"
LABEL org.opencontainers.image.description="A read-only MCP server for NetBox"
LABEL org.opencontainers.image.url="https://github.com/netboxlabs/netbox-mcp-server"
LABEL org.opencontainers.image.source="https://github.com/netboxlabs/netbox-mcp-server"
LABEL org.opencontainers.image.licenses="Apache-2.0"
ENV PYTHONUNBUFFERED=1
RUN apk add --no-cache ca-certificates \
&& addgroup -g 1000 appuser \
&& adduser -D -u 1000 -G appuser appuser
COPY --from=builder --chown=appuser:appuser /app /app
WORKDIR /app
USER appuser
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
CMD ["netbox-mcp-server"]

View File

@@ -0,0 +1 @@
1.0.0

View File

@@ -0,0 +1,70 @@
# NetBox MCP Server
Image Docker pour le [NetBox MCP Server](https://github.com/netboxlabs/netbox-mcp-server) - serveur Model Context Protocol permettant l'interaction read-only avec NetBox via LLMs.
## Usage avec Claude Desktop (STDIO)
Configuration dans `claude_desktop_config.json` :
```json
{
"mcpServers": {
"netbox": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "NETBOX_URL",
"-e", "NETBOX_TOKEN",
"gitea.arnodo.fr/damien/netbox-mcp-server:latest"
],
"env": {
"NETBOX_URL": "https://netbox.example.com/",
"NETBOX_TOKEN": "your-api-token"
}
}
}
}
```
## Usage en mode HTTP
Pour les clients web MCP :
```bash
docker run --rm \
-e NETBOX_URL=https://netbox.example.com/ \
-e NETBOX_TOKEN=your-api-token \
-e TRANSPORT=http \
-p 8000:8000 \
gitea.arnodo.fr/damien/netbox-mcp-server:latest
```
Le serveur sera accessible sur `http://localhost:8000/mcp`.
## Variables d'environnement
| Variable | Défaut | Description |
|----------|--------|-------------|
| `NETBOX_URL` | - | URL de l'instance NetBox (requis) |
| `NETBOX_TOKEN` | - | Token API NetBox read-only (requis) |
| `TRANSPORT` | `stdio` | Transport MCP : `stdio` ou `http` |
| `VERIFY_SSL` | `true` | Vérification des certificats SSL |
| `LOG_LEVEL` | `INFO` | Niveau de log |
| `HOST` | `0.0.0.0` | Adresse d'écoute (mode HTTP) |
| `PORT` | `8000` | Port d'écoute (mode HTTP) |
## Outils MCP disponibles
| Outil | Description |
|-------|-------------|
| `get_objects` | Récupère les objets NetBox selon type et filtres |
| `get_object_by_id` | Détails d'un objet par son ID |
| `get_changelogs` | Historique des modifications |
## Exemples de requêtes
```
> Liste tous les devices du site 'DC1'
> Montre-moi l'utilisation IPAM
> Qui a modifié le routeur principal cette semaine ?
```

View File

@@ -17,10 +17,6 @@ COPY plugin_requirements.txt /opt/netbox/
# Installation des plugins via uv pip (méthode officielle NetBox Docker) # Installation des plugins via uv pip (méthode officielle NetBox Docker)
RUN /usr/local/bin/uv pip install --no-cache -r /opt/netbox/plugin_requirements.txt RUN /usr/local/bin/uv pip install --no-cache -r /opt/netbox/plugin_requirements.txt
# Copie de la configuration des plugins # NOTE: configuration.py et plugins.py doivent être montés au runtime
COPY plugins.py /etc/netbox/config/plugins.py # via docker-compose pour configurer DynamicSchemaDict et les plugins.
# Voir: https://gitea.arnodo.fr/Damien/netbox-deployment
# Collecte des assets statiques des plugins
# Nécessite une SECRET_KEY dummy pour le build
RUN SECRET_KEY="build-time-dummy-key-not-used-in-production" \
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input

View File

@@ -6,12 +6,12 @@ Image Docker NetBox personnalisée avec plugins pré-installés, construite auto
Par défaut, les plugins suivants sont installés : Par défaut, les plugins suivants sont installés :
| Plugin | Description | Activé | | Plugin | Description | Version (pour NetBox 4.4.x) |
|--------|-------------|--------| |--------|-------------|----------------------------|
| `netbox-branching` | Branching et change management (NetBox Labs) | | | `netbox-branching` | Branching et change management (NetBox Labs) | 0.7.x |
| `netbox-bgp` | Gestion des sessions BGP, peers, communities | | | `netbox-bgp` | Gestion des sessions BGP, peers, communities | 0.17.x |
| `netbox-secrets` | Gestion sécurisée des secrets et mots de passe | | | `netbox-secrets` | Gestion sécurisée des secrets et mots de passe | latest |
| `netbox-topology-views` | Visualisation de topologie réseau | | | `netbox-topology-views` | Visualisation de topologie réseau | latest |
## Utilisation ## Utilisation
@@ -22,7 +22,7 @@ Par défaut, les plugins suivants sont installés :
docker pull gitea.arnodo.fr/damien/netbox:latest docker pull gitea.arnodo.fr/damien/netbox:latest
# Version spécifique # Version spécifique
docker pull gitea.arnodo.fr/damien/netbox:v4.2 docker pull gitea.arnodo.fr/damien/netbox:v4.4
``` ```
### Avec Docker Compose ### Avec Docker Compose
@@ -32,32 +32,68 @@ Créer un `docker-compose.override.yml` pour utiliser l'image personnalisée :
```yaml ```yaml
services: services:
netbox: netbox:
image: gitea.arnodo.fr/damien/netbox:v4.2 image: gitea.arnodo.fr/damien/netbox:v4.4
pull_policy: always pull_policy: always
netbox-worker: netbox-worker:
image: gitea.arnodo.fr/damien/netbox:v4.2 image: gitea.arnodo.fr/damien/netbox:v4.4
pull_policy: always pull_policy: always
netbox-housekeeping: netbox-housekeeping:
image: gitea.arnodo.fr/damien/netbox:v4.2 image: gitea.arnodo.fr/damien/netbox:v4.4
pull_policy: always pull_policy: always
``` ```
## ⚠️ Configuration requise pour netbox-branching
Le plugin `netbox-branching` nécessite une configuration spéciale de la base de données. Tu dois modifier ta configuration NetBox pour wrapper `DATABASES` avec `DynamicSchemaDict`.
### Dans ton `configuration.py` ou via variables d'environnement :
```python
from netbox_branching.utilities import DynamicSchemaDict
DATABASES = DynamicSchemaDict({
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'password',
'HOST': 'postgres',
'PORT': '',
}
})
DATABASE_ROUTERS = [
'netbox_branching.database.BranchAwareRouter',
]
```
### Permissions PostgreSQL requises
L'utilisateur PostgreSQL doit avoir la permission de créer des schemas :
```sql
GRANT CREATE ON DATABASE netbox TO netbox;
```
Voir la [documentation officielle netbox-branching](https://netboxlabs.com/docs/extensions/branching/) pour plus de détails.
## Gestion des versions ## Gestion des versions
La version de NetBox est définie dans le fichier `NETBOX_VERSION`. Pour changer de version : La version de NetBox est définie dans le fichier `NETBOX_VERSION`. Pour changer de version :
1. Modifier le fichier `NETBOX_VERSION` avec la version souhaitée (ex: `v4.2`) 1. Modifier le fichier `NETBOX_VERSION` avec la version souhaitée (ex: `v4.4`)
2. Commit et push 2. **Mettre à jour les versions des plugins** dans `plugin_requirements.txt` si nécessaire
3. Le CI va automatiquement : 3. Commit et push
4. Le CI va automatiquement :
- Builder l'image avec cette version de NetBox - Builder l'image avec cette version de NetBox
- Tagger l'image avec `latest` ET avec la version (ex: `v4.2`) - Tagger l'image avec `latest` ET avec la version (ex: `v4.4`)
### Tags disponibles ### Compatibilité plugins / NetBox
| Tag | Description | | NetBox | netbox-branching | netbox-bgp |
|-----|-------------| |--------|------------------|------------|
| `latest` | Dernière version buildée | | 4.4.x | 0.7.x | 0.17.x |
| `v4.2` | Version spécifique de NetBox | | 4.5.x | 0.8.x+ | 0.18.x+ |
## Personnalisation des plugins ## Personnalisation des plugins
@@ -68,45 +104,13 @@ La version de NetBox est définie dans le fichier `NETBOX_VERSION`. Pour changer
3. Configurer le plugin dans `PLUGINS_CONFIG` si nécessaire 3. Configurer le plugin dans `PLUGINS_CONFIG` si nécessaire
4. Commit et push - l'image sera rebuild automatiquement 4. Commit et push - l'image sera rebuild automatiquement
### Exemple : Activer netbox-proxbox
```python
# plugin_requirements.txt
netbox-proxbox
# plugins.py
PLUGINS = [
"netbox_branching",
"netbox_bgp",
"netbox_secrets",
"netbox_topology_views",
"netbox_proxbox", # Ajouter ici
]
PLUGINS_CONFIG = {
# ...
"netbox_proxbox": {
"proxmox": [
{
"domain": "proxmox.home.arpa",
"http_port": 8006,
"user": "netbox@pve",
"password": "your-api-token",
"ssl": True,
"node": "pve",
}
],
},
}
```
## Structure des fichiers ## Structure des fichiers
``` ```
images/netbox/ images/netbox/
├── Dockerfile # Image principale ├── Dockerfile # Image principale
├── NETBOX_VERSION # Version de NetBox à utiliser ├── NETBOX_VERSION # Version de NetBox à utiliser
├── plugin_requirements.txt # Liste des plugins PyPI ├── plugin_requirements.txt # Liste des plugins PyPI (avec versions)
├── plugins.py # Configuration des plugins ├── plugins.py # Configuration des plugins
└── README.md # Cette documentation └── README.md # Cette documentation
``` ```
@@ -114,16 +118,14 @@ images/netbox/
## Plugins - Liens et documentation ## Plugins - Liens et documentation
- **netbox-branching** : https://github.com/netboxlabs/netbox-branching - **netbox-branching** : https://github.com/netboxlabs/netbox-branching
- **netbox-bgp** : https://github.com/netbox-community/netbox-bgp - **netbox-bgp** : https://github.com/netbox-community/netbox-bgp
- **netbox-secrets** : https://github.com/Onemind-Services-LLC/netbox-secrets - **netbox-secrets** : https://github.com/Onemind-Services-LLC/netbox-secrets
- **netbox-topology-views** : https://github.com/netbox-community/netbox-topology-views
- **netbox-branching** : https://github.com/netboxlabs/netbox-branching
## Notes ## Notes
- L'image utilise `uv pip` pour l'installation des plugins (méthode officielle NetBox Docker) - L'image utilise `uv pip` pour l'installation des plugins (méthode officielle NetBox Docker)
- Les assets statiques sont collectés au build pour les plugins qui en ont - Les assets statiques sont collectés au premier démarrage (pas au build)
- Compatible avec NetBox >= 4.0 (netbox-branching requiert NetBox 4.0+) - Compatible avec NetBox >= 4.0 (netbox-branching requiert NetBox 4.1+)
- Le fichier `NETBOX_VERSION` contrôle la version de base et le tag de l'image - Le fichier `NETBOX_VERSION` contrôle la version de base et le tag de l'image
- **Les versions des plugins sont fixées** pour garantir la compatibilité

View File

@@ -4,6 +4,9 @@
# Liste des plugins à installer dans l'image NetBox # Liste des plugins à installer dans l'image NetBox
# Format: nom-du-package==version (ou sans version pour la dernière) # Format: nom-du-package==version (ou sans version pour la dernière)
# #
# IMPORTANT: Les versions sont fixées pour garantir la compatibilité avec
# NetBox 4.4.x. Mettre à jour les versions lors du passage à NetBox 4.5+
#
# Documentation des plugins: # Documentation des plugins:
# - netbox-branching: Branching et change management (NetBox Labs) # - netbox-branching: Branching et change management (NetBox Labs)
# https://github.com/netboxlabs/netbox-branching # https://github.com/netboxlabs/netbox-branching
@@ -11,15 +14,11 @@
# https://github.com/netbox-community/netbox-bgp # https://github.com/netbox-community/netbox-bgp
# - netbox-secrets: Gestion des secrets (remplace netbox-secretstore pour NetBox >= 3.5) # - netbox-secrets: Gestion des secrets (remplace netbox-secretstore pour NetBox >= 3.5)
# - netbox-topology-views: Visualisation de topologie réseau # - netbox-topology-views: Visualisation de topologie réseau
# - netbox-documents: Gestion de documents
# - netbox-acls: Gestion des ACLs
# - netbox-qrcode: Génération de QR codes
# - netbox-proxbox: Intégration Proxmox
# ============================================================================= # =============================================================================
# Plugins actifs # Plugins actifs - versions fixées pour NetBox 4.4.x
netbox-branching netboxlabs-netbox-branching>=0.7.0,<0.8.0
netbox-bgp netbox-bgp>=0.17.0,<0.18.0
netbox-secrets netbox-secrets
netbox-topology-views netbox-topology-views

View File

@@ -1,54 +0,0 @@
# =============================================================================
# NetBox Plugins Configuration
# =============================================================================
# Ce fichier est copié dans /etc/netbox/config/plugins.py
# Il active et configure les plugins installés
# =============================================================================
# Liste des plugins activés
# Doit correspondre aux packages installés dans plugin_requirements.txt
PLUGINS = [
"netbox_branching",
"netbox_bgp",
"netbox_secrets",
"netbox_topology_views",
# "netbox_documents",
# "netbox_acls",
# "netbox_qrcode",
# "netbox_proxbox",
]
# Configuration des plugins
PLUGINS_CONFIG = {
"netbox_branching": {
# Configuration par défaut
# Voir: https://github.com/netboxlabs/netbox-branching#configuration
},
"netbox_bgp": {
# Configuration par défaut
# "top_level_menu": True, # Ajoute un menu BGP au niveau supérieur
# "asdot": False, # Utilise la notation ASPLAIN par défaut
},
"netbox_secrets": {
# Configuration par défaut
# "public_key_size": 4096,
},
"netbox_topology_views": {
# Configuration par défaut
# "static_image_directory": "netbox_topology_views/img",
# "allow_coordinates_saving": True,
# "always_save_coordinates": False,
},
# "netbox_proxbox": {
# "proxmox": [
# {
# "domain": "proxmox.example.com",
# "http_port": 8006,
# "user": "root@pam",
# "password": "your-password",
# "ssl": True,
# "node": "pve",
# }
# ],
# },
}