This directory contains everything needed to deploy the phpIPAM MCP Server using Docker.
# Copy environment template
cp .env.example .env
# Edit with your credentials
nano .env
# Start the server
docker-compose up -d
# Check logs
docker-compose logs -f phpipam-mcp-server
# Verify health
curl http://localhost:8081/healthz- Dockerfile: Multi-stage Docker build configuration
- docker-compose.yml: Docker Compose deployment configuration
- .dockerignore: Files excluded from Docker build
- .env.example: Environment variables template
- README.md: This file
Required variables in .env:
# phpIPAM Configuration
PHPIPAM_URL=https://your-phpipam-instance.com
PHPIPAM_APP_ID=your_app_id
PHPIPAM_APP_CODE=your_app_code_token
# Optional Settings
PHPIPAM_VERIFY_SSL=true
PHPIPAM_TIMEOUT=30
LOG_LEVEL=INFO- Login to phpIPAM as administrator
- Navigate to Administration → phpIPAM settings → API
- Click Create API application
- Configure:
- App ID: Choose an identifier (e.g.,
mcp-server) - App permissions: Read/Write as needed
- App security:
SSL with App code token
- App ID: Choose an identifier (e.g.,
- Save and copy the App Code token
cd deploy
docker-compose up -dBenefits:
- Easy configuration via
.envfile - Automatic restart on failure
- Health checks included
- Log management configured
# Build image
docker build -t phpipam-mcp-server -f deploy/Dockerfile .
# Run container
docker run -d \
--name phpipam-mcp \
-p 8080:8080 \
-e PHPIPAM_URL="https://your-phpipam.com" \
-e PHPIPAM_APP_ID="your_app_id" \
-e PHPIPAM_APP_CODE="your_token" \
--restart unless-stopped \
phpipam-mcp-serverFor production environments, consider:
# docker-compose.prod.yml
version: '3.8'
services:
phpipam-mcp-server:
image: phpipam-mcp-server:1.0.0
restart: always
ports:
- "127.0.0.1:8080:8080" # Only localhost
env_file:
- .env
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081/healthz"]
interval: 30s
timeout: 10s
retries: 3
start_period: 5s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "10"
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256Mcurl http://localhost:8081/healthzExpected response:
{
"status": "ok",
"version": "1.0.0"
}docker ps
docker inspect phpipam-mcp-server | grep -A 5 Health# All logs
docker-compose logs
# Follow logs
docker-compose logs -f
# Last 100 lines
docker-compose logs --tail=100
# Specific service
docker-compose logs phpipam-mcp-serverSet via LOG_LEVEL environment variable:
DEBUG: Detailed debugging informationINFO: General informational messages (default)WARNING: Warning messagesERROR: Error messages only
Problem: Cannot connect to phpIPAM API
Solutions:
- Verify
PHPIPAM_URLis correct and accessible - Check SSL certificate (try
PHPIPAM_VERIFY_SSL=falsefor testing) - Verify firewall rules allow outbound HTTPS
- Test connectivity:
docker exec phpipam-mcp-server curl -v $PHPIPAM_URL
Problem: 401 or 403 errors
Solutions:
- Verify
PHPIPAM_APP_CODEis correct - Check API app is enabled in phpIPAM
- Ensure security type is "SSL with App Code token"
- Verify API app has appropriate permissions
Problem: Container exits immediately
Solutions:
- Check logs:
docker-compose logs - Verify all required environment variables are set
- Test configuration:
docker-compose config - Check Docker daemon status
Problem: Container uses too much memory
Solutions:
- Set resource limits in docker-compose.yml
- Reduce log level to WARNING or ERROR
- Check for memory leaks in logs
- Monitor with:
docker stats phpipam-mcp-server
# Pull latest image
docker-compose pull
# Recreate container
docker-compose up -d
# Or rebuild from source
docker-compose build
docker-compose up -d# Backup .env file
cp .env .env.backup
# Backup Docker configuration
tar -czf phpipam-mcp-backup.tar.gz .env docker-compose.yml# Stop container
docker-compose stop
# Stop and remove
docker-compose down
# Remove with volumes
docker-compose down -v- Use environment files: Never commit
.envto version control - Limit network exposure: Bind to localhost in production
- Enable SSL: Always use HTTPS for phpIPAM connections
- Rotate credentials: Periodically update API tokens
- Monitor logs: Watch for unauthorized access attempts
- Update regularly: Keep Docker image up to date
- Resource limits: Set CPU and memory limits
- Read-only filesystem: Consider mounting volumes as read-only
- SSL certificate valid and trusted
- API credentials secured
- Firewall rules configured
- Monitoring and alerting setup
- Backup strategy defined
- Log rotation configured
- Health checks working
- Resource limits set
- Documentation updated
The server can expose Prometheus metrics:
# Add to docker-compose.yml
environment:
- ENABLE_METRICS=true
ports:
- "9090:9090"- Prometheus: Scrape
/metricsendpoint - Grafana: Create dashboards for API calls, errors, latency
- ELK Stack: Forward logs to Elasticsearch
- Docker monitoring: Use cAdvisor or similar
- Issues: GitHub Issues
- Documentation: Main README
- Examples: Usage Examples