Commit Graph

10 Commits

Author SHA1 Message Date
kaffa
79254835e9 feat: Zero-downtime certificate management via Runtime API
Changes:
- Replace USR2 signal reload with HAProxy Runtime API for cert updates
  - new ssl cert → set ssl cert → commit ssl cert
  - No connection drops during certificate changes
- Add certificates.json for persistence (domain list only)
- Add haproxy_load_cert tool for manual certificate loading
- Auto-restore certificates on MCP startup
- Update startup sequence to load both servers and certificates

certificates.json format:
{
  "domains": ["inouter.com", "anvil.it.com"]
}

Paths derived from convention:
- Host: /opt/haproxy/certs/{domain}.pem
- Container: /etc/haproxy/certs/{domain}.pem

Total MCP tools: 28 → 29

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 04:23:28 +00:00
kaffa
dbacb86d60 feat: Add certificate management tools (6 new MCP tools)
New tools for SSL/TLS certificate management via acme.sh:
- haproxy_list_certs: List all certificates with expiry info
- haproxy_cert_info: Get detailed certificate info (expiry, issuer, SANs)
- haproxy_issue_cert: Issue new certificate via Cloudflare DNS validation
- haproxy_renew_cert: Renew specific certificate (with force option)
- haproxy_renew_all_certs: Renew all certificates due for renewal
- haproxy_delete_cert: Delete certificate from acme.sh and HAProxy

Features:
- Automatic PEM deployment to HAProxy certs directory
- HAProxy hot-reload after certificate changes (USR2 signal)
- Cloudflare DNS validation with CF_Token support
- Wildcard certificate support

Total MCP tools: 22 → 28

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:55:26 +00:00
kaffa
7bee373684 refactor: Modularize MCP server with command batching
- Split monolithic mcp/server.py (1874 lines) into haproxy_mcp/ package:
  - config.py: Configuration constants and environment variables
  - exceptions.py: Custom exception classes
  - validation.py: Input validation functions
  - haproxy_client.py: HAProxy Runtime API client with batch support
  - file_ops.py: Atomic file operations with locking
  - utils.py: CSV parsing utilities
  - tools/: MCP tools organized by function
    - domains.py: Domain management (3 tools)
    - servers.py: Server management (7 tools)
    - health.py: Health checks (3 tools)
    - monitoring.py: Monitoring (4 tools)
    - configuration.py: Config management (4 tools)

- Add haproxy_cmd_batch() for sending multiple commands in single TCP connection
- Optimize server operations: 1 connection instead of 2 per server
- Optimize startup restore: All servers in 1 connection (was 2×N)
- Update type hints to Python 3.9+ style (built-in generics)
- Remove unused imports and functions
- Update CLAUDE.md with new structure and performance notes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:50:42 +00:00
kaffa
a3d5d61454 docs: Update CLAUDE.md with safety features
- Update server.py line count
- Add Safety Features section documenting:
  - Atomic file writes
  - File locking
  - Disk-first pattern with rollback
  - Command validation
  - Input validation
  - Bulk operation limits

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:15:57 +00:00
kaffa
bdc1f8a279 docs: Update CLAUDE.md with new features
- Update tool count: 21 → 22
- Add haproxy_wait_drain to server management tools
- Update haproxy_add_server: slot=0 for auto-select
- Update server.py description (~1750 lines, 22 tools)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 14:09:04 +00:00
kaffa
ab5b4aa648 docs: Update CLAUDE.md with new features
- Update tool count: 20 → 21
- Add haproxy_set_domain_state to server management tools
- Add container status to health check example
- Update server.py description (~1600 lines, 21 tools)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:59:03 +00:00
kaffa
7985501d48 docs: Update CLAUDE.md with new features and improvements
- Update tool count: 19 → 20
- Add HAPROXY_CONTAINER environment variable
- Add haproxy_add_servers (bulk operations) to tool list
- Document IPv6 support in haproxy_add_domain
- Add include_wildcards parameter note for haproxy_list_domains
- Update haproxy_reload: now auto-restores servers
- Add Bulk Server Operations section with example
- Update server.py description (~1500 lines, 20 tools)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:45:02 +00:00
kaffa
d51e982f7c docs: Update CLAUDE.md with health checks and environment variables
- Add Environment Variables table with all configurable options
- Add Health Check section with haproxy_health and haproxy_domain_health examples
- Update MCP Tools count from 17 to 19
- Add new Health Check tools section
- Update server.py description (line count and tool count)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 13:10:42 +00:00
kaffa
196374e70c Simplify backend configuration to HTTP only
Remove SSL/QUIC backend templates - all backends now use HTTP only
with SSL termination at HAProxy frontend. This improves performance
(~33% faster than HTTPS backends based on benchmarks).

Changes:
- server.py: Remove https_port parameter from all functions
- haproxy.cfg: Remove ssl/h3 server templates from pool backends
- CLAUDE.md: Update docs for HTTP-only backends and acme.sh

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 12:34:47 +00:00
root
432154c850 Initial commit: HAProxy MCP Server
- Zero-reload domain management with map-based routing
- 100 pool backends with 10 server slots each
- Runtime API integration for dynamic configuration
- Auto-restore servers from persistent config on startup
- 17 MCP tools for domain/server management

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 11:37:06 +00:00