Caddy MCP Server
Tools for Caddy web server management and plugin development: scaffolding new plugins with Go module structure, building custom Caddy binaries via xcaddy, running a development server for testing, validating Caddyfile/JSON configuration, and safely deploying plugins to production with timestamped binary backups and rollback support.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Caddy MCP Server create a Caddy plugin called 'hello' that adds a custom header to all requests"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Caddy MCP Server
A Model Context Protocol (MCP) server for Caddy web server management and plugin development.
Getting Started
Quick Start with Claude Code
Clone and setup the server:
git clone https://github.com/Cabooman/caddy-mcp.git cd caddy-mcp npm install npm run buildInstall xcaddy (required for plugin building):
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latestAdd to your Claude Code MCP configuration:
{ "mcpServers": { "caddy": { "command": "node", "args": ["/path/to/caddy-mcp/dist/index.js"] } } }Try it out in Claude Code:
Ask Claude to "create a simple hello world Caddy plugin"
Watch as it uses the MCP tools to generate, build, and configure your plugin
Test the example visitor-counter plugin in
examples/
First Plugin in 30 Seconds
Once connected to Claude Code, try this:
"Create a Caddy plugin called 'hello' that adds a custom header to all requests"
Claude will:
Generate the complete plugin structure
Show you how to build it with xcaddy
Provide a working Caddyfile configuration
Explain how to test it locally
Related MCP server: CaddyUI MCP
Features
Plugin Development Tools
caddy_create_plugin: Create new Caddy plugins with proper Go module structure
caddy_build_plugin: Build Caddy with custom plugins using xcaddy
caddy_dev_server: Start development server with plugin for testing
Production Deployment Tools
caddy_deploy_plugin: Safely deploy plugins to production with automatic backup
caddy_backup_list: Manage Caddy binary backups (backup, restore, list)
caddy_validate_config: Validate Caddy configuration files
Installation
Install dependencies:
npm installBuild the server:
npm run buildInstall xcaddy (required for plugin building):
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latestUsage
As MCP Server
Add to your MCP client configuration:
{
"mcpServers": {
"caddy": {
"command": "node",
"args": ["/path/to/caddy-mcp-server/dist/index.js"]
}
}
}Plugin Development Workflow
Create a new plugin:
caddy_create_plugin: - name: "myplugin" - directory: "./plugins" - module_path: "github.com/user/myplugin" - description: "My custom Caddy plugin"Build Caddy with your plugin:
caddy_build_plugin: - plugin_path: "./plugins/myplugin" - output_path: "./caddy-custom"Start development server:
caddy_dev_server: - caddy_binary: "./caddy-custom" - config_file: "./Caddyfile" - port: 8080
Tool Reference
caddy_create_plugin
Creates a new Caddy plugin with proper Go module structure.
Parameters:
name(required): Plugin namedirectory(required): Directory where plugin should be createdmodule_path(required): Go module path (e.g., github.com/user/plugin)description: Plugin descriptionauthor: Plugin author (default: "Claude Code")
Generated files:
main.go: Main entry pointplugin.go: Plugin implementation with middleware handlergo.mod: Go module fileREADME.md: DocumentationCaddyfile.example: Example configuration
caddy_build_plugin
Builds Caddy with a custom plugin using xcaddy.
Parameters:
plugin_path(required): Path to the plugin directoryoutput_path: Output path for the built Caddy binary (default: "./caddy")caddy_version: Caddy version to build with (default: "latest")
Requirements:
xcaddy must be installed
Plugin directory must contain valid go.mod file
caddy_dev_server
Starts a Caddy development server with the custom plugin.
Parameters:
caddy_binary: Path to the Caddy binary with plugin (default: "./caddy")config_file: Path to Caddyfile or JSON configport: Port to run the server on (default: 8080)admin_port: Admin API port (default: 2019)
caddy_deploy_plugin
Safely deploy a plugin to production by building and replacing the Caddy binary with automatic backup.
Parameters:
plugin_path(required): Path to the plugin directory to deploycaddy_binary: Path to current Caddy binary to replace (default: "/usr/bin/caddy")backup_dir: Directory to store backup of current binary (default: "/opt/caddy/backups")validate_config: Path to Caddyfile to validate with new binary
Safety features:
Automatically backs up current binary with timestamp
Validates configuration before deployment (if config provided)
Builds new binary with plugin using xcaddy
Provides clear restart instructions
caddy_backup_list
Manage Caddy binary backups for safe rollbacks.
Parameters:
action(required): "backup", "restore", or "list"caddy_binary: Path to Caddy binary (default: "/usr/bin/caddy")backup_dir: Directory containing backups (default: "/opt/caddy/backups")restore_name: Name of backup to restore (required for restore action)
Actions:
backup: Create timestamped backup of current binary
list: Show all available backups with dates and sizes
restore: Restore from specific backup
caddy_validate_config
Validate Caddy configuration file syntax.
Parameters:
config_file(required): Path to Caddyfile or JSON config to validatecaddy_binary: Path to Caddy binary to use for validation (default: "caddy")
Features:
Tests configuration syntax without starting server
Works with custom Caddy binaries (with plugins)
Shows detailed error messages for invalid configs
Production Deployment Workflow
Deploying a Plugin to Homelab
Develop and test your plugin:
caddy_create_plugin: Create plugin structure caddy_build_plugin: Build and test locally caddy_dev_server: Test with development serverValidate before deployment:
caddy_validate_config: - config_file: "/etc/caddy/Caddyfile" - caddy_binary: "./caddy-with-plugin"Deploy safely:
caddy_deploy_plugin: - plugin_path: "./my-plugin" - caddy_binary: "/usr/bin/caddy" - backup_dir: "/opt/caddy/backups" - validate_config: "/etc/caddy/Caddyfile"Restart Caddy service:
sudo systemctl restart caddy # OR docker-compose restart caddyIf something goes wrong:
caddy_backup_list: - action: "list" # Find the backup to restore caddy_backup_list: - action: "restore" - restore_name: "caddy-backup-2024-08-22T10-30-00-000Z"
Plugin Template
The generated plugin template includes:
HTTP middleware handler: Processes HTTP requests
Caddyfile directive: Configurable via Caddyfile
JSON configuration: Supports JSON config format
Proper interfaces: Implements Caddy's provisioner, validator, and unmarshaler interfaces
Example usage in Caddyfile:
example.com {
myplugin {
message "Hello from my plugin!"
}
respond "Server is running"
}Development
# Install dependencies
npm install
# Build
npm run build
# Development with watch
npm run dev
# Start server
npm start
# Run tests
npm testExamples
See the examples/ directory for sample Caddy plugins:
visitor-counter: A plugin that counts and displays website visitors
Requirements
Node.js 18+
Go 1.21+
xcaddy (for building plugins)
License
MIT
Available Tools
6 toolscaddy_backup_listC
Manage Caddy binary backups (backup, restore, list)
Inputs: action (required), backup_dir, caddy_binary, restore_name.
caddy_build_pluginC
Build Caddy with custom plugin using xcaddy
Inputs: plugin_path (required), output_path, caddy_version.
caddy_create_pluginC
Create a new Caddy plugin with Go module structure
Inputs: name (required), directory (required), module_path (required), author, +1 more.
caddy_deploy_pluginB
Deploy plugin to production by safely replacing Caddy binary with backup
Inputs: plugin_path (required), backup_dir, caddy_binary, validate_config.
caddy_dev_serverC
Start Caddy development server with plugin
Inputs: port, admin_port, config_file, caddy_binary.
caddy_validate_configC
Validate Caddy configuration file with specified binary
Inputs: config_file (required), caddy_binary.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools target distinct stages of a clear plugin lifecycle: create (scaffold), build (compile), dev_server (run locally), deploy (replace production binary), validate_config. Boundaries are generally clear, though build vs deploy vs dev_server can blur for an agent unfamiliar with the xcaddy workflow, and caddy_backup_list bundles three operations (backup/restore/list) under a name suggesting only listing.
All tools use a consistent caddy_ prefix with snake_case verb_noun style (caddy_build_plugin, caddy_create_plugin, caddy_deploy_plugin). The one deviation is caddy_backup_list, whose noun-first naming implies a single list operation while its description covers backup, restore, and list — a minor inconsistency.
Six tools is well-scoped for a Caddy plugin build/deploy workflow, with each tool earning its place at a distinct lifecycle stage. Nothing feels padded or missing at the count level.
The core plugin lifecycle (create, build, dev-run, deploy, backup, config validation) is covered, but there are notable gaps: no stop/teardown of the dev server, no plugin listing or removal, and backup/restore is compressed into a single overloaded tool. Agents can work around these but the surface is not fully closed.
Maintenance
Related MCP Connectors
Deploy services, add databases, run agents, read logs, check vulnerabilities and publish pages.
Deploy apps on your cloud. Create environments, configure infrastructure, and monitor jobs.
Create, deploy, and operate MCP servers directly from your GitHub repositories.
Build, validate and deploy workflows as Cloudflare Workers in your own account, with approval.
Related MCP Servers
- AlicenseAqualityBmaintenanceManage Caddy web servers from Claude Code, Cursor, and any MCP client with 18 tools + 4 resources covering every endpoint of Caddy's admin API — config, routes, reverse proxies, TLS, PKI, metrics, snapshots.18397 npm15MIT
- AlicenseNot gradedqualityBmaintenanceEnables inspection and management of Caddy reverse proxy configuration via CaddyUI's REST API, including proxy hosts, redirection hosts, raw routes, and TLS certificates.3MIT
- AlicenseAqualityDmaintenanceEnables management of Caddy web server via admin API, allowing inspection of routes, upstream health, certificates, and configuration reloading.16MIT
- AlicenseAqualityBmaintenanceEnables AI agents to set up and operate safe, approval-gated deployments to Plesk servers, including project inspection, deployment-kit generation and validation, status and log checks, and confirmed rollbacks over SSH.960 npmMIT