Caddy MCP Server
MCP server for managing Caddy web servers via the admin API
Caddy MCP Server scores 74 (Good), licensed MIT and written in TypeScript. It installs as a local process. It declares 18 tools. Filed under Monitoring. GitHub shows 15 stars. Package registries report about 565 downloads a week. Install configs are generated for 12 clients. Being listed in the registry is not the same as being vendor-official.
Good trust
74 of 100 from six public signals. Nobody can buy a point.
- Listed in the official MCP registry.
- OSI-style license: mit.
License, quality and maintenance
Where the 74 comes from
22 + 20 + 8 + 10 + 4 + 10 = 74. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 22 of 30 points.How recently the repository saw a commit or release.
Maintenance: 20 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 8 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "yawlabs-caddy-mcp": { "command": "npx", "args": [ "-y", "@yawlabs/caddy-mcp@2.6.5" ] } }}
Environment variables
This server does not declare environment variables.
Tools18Tool docs quality grade B
All capabilitiescaddy_adapttoolConvert a config in any registered adapter format to Caddy JSON without applying it. caddyfile (built-in, default) plus any adapter module compiled into your Caddy binary — e.g., nginx ([caddy-nginx-adapter](https://g
caddy_add_routetoolAdd a route with full match/handle control (any Caddy handler).
Get/set/delete config by @id tag — much easier than navigating deep paths. The delete action requires confirm=true. Every set and delete first asks Caddy where the id resolves, and refuses one that does not re
Delete config at a path. Requires confirm=true (deleting a parent path also removes every descendant). A path that addresses the config root ('', '/', 'config', '/config/', a slash-only variant, or any of those
caddy_config_gettoolRead config at any JSON path (or the full config).
caddy_config_settoolWrite config at a path. Modes: overwrite (PATCH, default, idempotent; the key must exist, and the whole subtree at the path is replaced), append (POST: appends to an array, but replaces an existing non-array key and c
Human-readable route summary. Defensive: never crashes on weird config.
List all HTTP servers with names, addresses, route counts, and TLS status. Same labels as caddystatus, but this tool reads only apps/http/servers and so assumes the default httpport 80 / httpsport 443 — on an i
caddy_loadtoolReplace the entire config atomically. Runs on CADDYLOADTIMEOUT (55 seconds by default), like every config change. Auto-snapshots the prior config, and keeps that snapshot when the load times out with its outcome unkno
caddy_metricstoolPrometheus metrics (request counts, durations, connections, TLS handshakes). Optional filter (substring match on metric name, keeps # HELP / # TYPE lines for retained metrics) and maxlines (default 500) keep resp
caddy_pkitoolCA info and certificate chains (default CA: local).
Remove a route by @id (preferred) or by index. Requires confirm=true.
About
@yawlabs/caddy-mcp
One click adds this to your local Yaw MCP config so it's available in every Yaw Terminal session. Tested with Yaw MCP 1.1.18 or newer. Or install manually below.
Manage Caddy web servers from Claude Code, Cursor, and any MCP client. 18 tools + 4 resources covering every endpoint in Caddy's admin API reference — config, routes, reverse proxies, TLS, PKI, metrics, snapshots.
Built and maintained by Yaw Labs.
Why this one?
Other Caddy MCP servers wrap half the admin API and silently swallow errors. This one doesn't.
- Complete admin API coverage — every endpoint in Caddy's admin API reference:
/load,/config/*,/id/*,/stop,/adapt,/pki/ca/*,/reverse_proxy/upstreams,/metrics. No placeholder tools that 404. Caddy's Go runtime debug endpoints (/debug/pprof/*,/debug/vars) are deliberately not wrapped — for leak trends usecaddy_metricswithfilter: "go_goroutines"or"go_memstats", which come from the same admin registry; for stack dumps, CPU profiles and traces, curl the admin endpoint directly (Caddy profiling docs). - Safe concurrent writes — uses ETags (
If-Match) so your changes never silently overwrite someone else's. SurfacesHTTP 412 Precondition Failedas a clear message, not a cryptic error. - Safe-by-default mutations —
caddy_config_setdefaults to idempotentoverwrite(PATCH), notappend(POST). Calling twice doesn't duplicate your route. A write to the config root — which replaces the entire config, admin endpoint included — is refused withoutconfirm=trueand snapshotted first, likecaddy_load. - Defensive parsing —
caddy_list_routesnever crashes on malformed config, even if routes are null, handlers are strings, or matchers are non-arrays. Regression-tested. - No leaked credentials in errors — if
CADDY_ADMIN_URLcontains a token in the path/query, the connect-failed message shows only the origin. (ACADDY_ADMIN_URLrefused as malformed -- a bad unix-socket spelling, or one with no http(s) scheme -- is echoed in full, so the operator can see what was wrong.) - Fallback error surfacing — when a TLS write PATCH fails and the PUT fallback also fails, both error bodies are returned so you know what actually went wrong.
- Tool annotations — every tool declares
readOnlyHint,destructiveHint, andidempotentHint, so MCP clients can skip confirmations for safe ops. - Instant startup — ships as a single bundle with two runtime deps (the MCP SDK + Zod). No 5-minute
node_modulesinstall. - Input hardening — adapter names,
@idvalues, server names, and CA ids are all regex-validated with length caps. Blocks CRLF header injection and ReDoS.
Quick start
1. Enable the Caddy admin API
Caddy ships with the admin API enabled on localhost:2019 by default. If you're running Caddy in Docker or on a remote host, expose it via CADDY_ADMIN_URL.
2. Create .mcp.json in your project root
macOS / Linux / WSL:
{
"mcpServers": {
"caddy": {
"command": "npx",
"args": ["-y", "@yawlabs/caddy-mcp@latest"]
}
}
}
Windows:
{
"mcpServers": {
"caddy": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@yawlabs/caddy-mcp@latest"]
}
}
}
Why the extra step on Windows? Since Node 20,
child_process.spawncannot directly execute.cmdfiles (that's whatnpxis on Windows). Wrapping withcmd /cis the standard workaround. This file is safe to commit — it contains no secrets.
3. Restart and approve
Restart Claude Code (or your MCP client) and approve the Caddy MCP server when prompted.
That's it. Now ask your AI assistant:
"Proxy api.local to localhost:3000"
"What routes are configured on srv0?"
"Show me the Prometheus metrics"
Configuration
| Environment variable | Default | Description |
|---|---|---|
CADDY_ADMIN_URL | http://localhost:2019 | Caddy admin API URL. Set to http://caddy:2019 inside Docker, or an https URL for an admin endpoint behind a TLS-terminating reverse proxy — see Troubleshooting for the Host / Origin rules Caddy applies to anything that is not its own loopback address. Caddy's native remote admin listener (admin.remote, default :2021) is not supported: it requires a TLS client certificate, which caddy-mcp does not present. Also accepts a unix socket, in either unix:///var/run/caddy-admin.sock or Caddy's own unix//var/run/caddy-admin.sock spelling — see below. Include the scheme: a bare localhost:2019 (Caddy's own CADDY_ADMIN spelling), 127.0.0.1:2019 or :2019 is refused up front with a hint to use http://localhost:2019. |
CADDY_API_TOKEN | (none) | Optional Bearer token, sent as Authorization: Bearer <token> on every request. Caddy's admin API has no token auth of its own and ignores this header — it matters only to an authenticating proxy in front of the admin endpoint, so leave it unset when caddy-mcp reaches Caddy directly. If the header does arrive at the admin listener, Caddy 2.0 through 2.11.2 writes it in clear into the admin.api "received request" log line, at INFO — on every path except /metrics, which has logged at DEBUG since 2.2.1. Run Caddy 2.11.3 or later, which logs it as REDACTED, or have the proxy strip the header once it has authenticated (Caddy: header_up -Authorization; nginx: proxy_set_header Authorization "";). |
CADDY_MCP_SNAPSHOT_DIR | (none) | Directory for persisting caddy_revert snapshots. Unset, snapshots live in memory only and are lost when this server restarts. Snapshots are full Caddy configs and can contain secrets, so the location is opt-in rather than defaulted, and on POSIX a directory the server creates is 0700 and each snapshot file 0600. |
CADDY_MAX_RETRIES | 2 | Number of retries on transient failures: network errors, and 502/503/504 (which only a proxy in front of Caddy sends). Caddy's own 500s are deterministic rejections and never retry, nor do 4xx and 412. Requests a replay could change the outcome of also skip retry: POSTs to /config/* and /id/* (they append, or replace an existing key -- retrying could duplicate routes), and a PUT or DELETE at an array index such as .../routes/0 (a replay would insert a second route, or remove the one that slid into that index), including a PUT to a bare /id/<id>, which Caddy resolves to the identified element's array index. Those match however the path is spelled — with trailing slashes, or with the trailing /... segment Caddy strips before it picks a method, so .../routes/0/... and PUT /id/<id>/... are covered too. A config change whose timeout fired is never retried (see CADDY_LOAD_TIMEOUT). A refused connection retries for every method, since nothing was sent. POSTs to /load, /adapt, /stop still retry. Hard-capped at 5; values above the cap log a one-time stderr notice so the clamp is visible. Set to 0 to disable. Anything but a plain non-negative integer (after trimming) means the default, 2. |
CADDY_TIMEOUT | 10000 | Timeout in ms for admin API requests that do not change the config: GETs, /adapt, /stop, PKI, upstreams and metrics. Config changes use CADDY_LOAD_TIMEOUT. Anything but a plain positive decimal integer (after trimming) falls back to the default -- 0x10, 1e3 and 1.5 included; values above 2147483647 (the largest delay a timer honours) are clamped to it. |
CADDY_LOAD_TIMEOUT | 55000 | Timeout in ms for every request that changes the config: POST /load, and every POST/PUT/PATCH/DELETE under /config/* and /id/*. Each is a full synchronous reload inside Caddy, which can legitimately run long -- Caddy sleeps through apps.http.shutdown_delay inside the reload whenever a change closes a listener, and a change can wait behind another reload. A timeout here is never retried: Caddy keeps applying a change after the client gives up, so the error says the outcome is unknown and to re-read the config before retrying (caddy_load and caddy_revert keep their snapshot in that case). Keep it below your MCP client's request timeout (60 s by default in the MCP SDK), or that error arrives after the client has given up and is never shown; the default sits 5 s under it. Anything but a plain positive decimal integer (after trimming) falls back to the default -- 0x10, 1e3 and 1.5 included; values above 2147483647 (the largest delay a timer honours) are clamped to it. |
Unix socket admin endpoints:
Caddy's recommended hardening is to move the admin API off a loopback port and onto a unix socket, where access is governed by filesystem permissions:
{
admin unix//var/run/caddy-admin.sock
}
Point CADDY_ADMIN_URL at the same path (unix:///var/run/caddy-admin.sock)
and requests are sent over the socket instead of TCP. The process running
caddy-mcp needs read/write permission on the socket file. Leave
CADDY_API_TOKEN unset here unless an authenticating proxy actually listens on
that socket: over a unix path caddy-mcp is usually talking to Caddy's own
socket, where the token does nothing — and, before Caddy 2.11.3, is logged in
clear.
Runtime (oam or Node):
The caddy-mcp command prefers oam when it finds a usable
one and otherwise runs on Node. It never serves on an oam older than 0.22.0.
| Environment variable | Default | Description |
|---|---|---|
CADDY_MCP_RUNTIME | auto | auto: the newest oam at 0.22.0 or newer, else Node. oam: oam or exit with an error. node: always Node -- the escape hatch when a problem only shows up under oam. Trimmed and case-insensitive. |
CADDY_MCP_SANDBOX | (unset) | 1 or true (any case) runs the server under oam's --permission sandbox: network limited to the CADDY_ADMIN_URL host and port (a CADDY_ADMIN_URL with no readable host, such as a schemeless localhost:2019, leaves the network grant open to every host, and the launcher says so on stderr; write it as http://host:port), filesystem limited to CADDY_MCP_SNAPSHOT_DIR, no child processes. Needs oam; under auto a machine without one runs unsandboxed, so pair it with CADDY_MCP_RUNTIME=oam when the sandbox has to hold. A unix-socket CADDY_ADMIN_URL is not reachable under the sandbox yet. Any other non-empty value leaves the sandbox off and warns on stderr. |
OAM_BIN | (unset) | Path to the oam binary to use. Otherwise the launcher checks OAM_INSTALL_DIR, the installed locations (~/.oam/bin, and %LOCALAPPDATA%\oam\bin on Windows) and PATH, and takes the newest. |
An outdated oam is fixed with oam self-update. Under Yaw MCP, which runs servers
on oam by default, yaw-mcp set <namespace> runtime=node switches this server to
Node.
Alternate MCP clients:
| Client | Config file |
|---|---|
| Claude Code | .mcp.json (project root) or ~/.claude.json (global) |
| Claude Desktop | ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) |
| Cursor | ~/.cursor/mcp.json |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
| VS Code | .vscode/mcp.json |
Use the same JSON block shown above in any of these.
Tools
Config management (6)
- caddy_config_get — Read config at any JSON path (or the full config).
- caddy_config_set — Write config at a path. Modes:
overwrite(PATCH, default, idempotent; the key must exist, and the whole subtree at the path is replaced),append(POST: appends to an array, but replaces an existing non-array key and cannot create missing parents),insert(PUT: inserts at an array position, or strictly creates a key along with any missing parents and fails with 409 if it exists — the way to create a server or app, even on an instance with no config).appendat a path ending in/...(e.g.apps/http/servers/srv0/routes/...) with an array value appends every element in one request — all or nothing, one reload; without the/..., an array value is added as a single element and Caddy rejects the load for typed arrays likeroutesorlisten. A path that addresses the config root ('','/','config','/config/', a slash-only variant, or any of those followed by a lone...segment) addresses the entire config and requiresconfirm=true:overwriteandappendthere replace the whole configuration withvalue, exactly ascaddy_loadwould, including theadminblock unlessvaluecarries one — after which Caddy re-binds its admin endpoint to the new config'sadmin.listen, to its default address when it sets none, or to no address at all when it setsadmin.disabled, and aCADDY_ADMIN_URLpointing anywhere else stops working. A root write auto-snapshots the prior config first (when it can be read) socaddy_revertcan restore it; no other path is snapshotted.insertat the root only succeeds after a rootcaddy_config_delete(409 otherwise), andoverwriteis the reverse: after a root delete it answers 404 untilappend,insertorcaddy_loadre-creates the config. - caddy_config_delete — Delete config at a path. Requires
confirm=true(deleting a parent path also removes every descendant). A path that addresses the config root ('','/','config','/config/', a slash-only variant, or any of those followed by a lone...segment) addresses the entire config: it unloads every app and server plus theadminblock, after which Caddy re-binds its admin endpoint to its default address (localhost:2019, or$CADDY_ADMINin Caddy's environment) — ifCADDY_ADMIN_URLpoints anywhere else, neither caddy-mcp norcaddy_revertcan reach Caddy afterwards. A root delete auto-snapshots the prior config first (when it can be read), socaddy_revertcan restore it while Caddy is still reachable; no other path is snapshotted. To replace the config rather than unload it, usecaddy_load. - caddy_config_by_id — Get/set/delete config by
@idtag — much easier than navigating deep paths. Thedeleteaction requiresconfirm=true. Everysetanddeletefirst asks Caddy where theidresolves, and refuses one that does not resolve inside the config tree. If it resolves to the config root — normally because it is the config's own top-level@id, string or number — it names the entire config:setanddeletewith no subpath (or a lone...) then replace or unload the whole configuration, exactly as a rootcaddy_config_set/caddy_config_deletedoes — both requireconfirm=true, snapshot the prior config first, and report where the admin endpoint went. A subpath inside it is an ordinary write. - caddy_load — Replace the entire config atomically. Runs on
CADDY_LOAD_TIMEOUT(55 seconds by default), like every config change. Auto-snapshots the prior config, and keeps that snapshot when the load times out with its outcome unknown. Lists the Caddyfile adapter's warnings, and reports a load that failed as an error even when Caddy answered HTTP 200 — which Caddy 2.11.4 does for a Caddyfile that adapted with warnings (caddyserver/caddy#7246); Caddy 2.11.6 and later answer that failure with a 400 that carries the error and the warnings together (caddyserver/caddy#7267), which caddy-mcp also reports as an error with both parts.formatisjson(default) orcaddyfile; stock Caddy registers only thecaddyfileadapter, so for any other adapter compiled into a custom build, adapt first withcaddy_adaptand load the JSON (the Atomic deploy example below). A successful JSON load says where the admin endpoint went, in the same words as a rootcaddy_config_set; a Caddyfile load does not, because the adaptedadmin.listenis never visible to caddy-mcp. - caddy_revert — Manage config snapshots for rollback. Actions:
list,save,apply(confirm-gated). In-memory, last 10. Auto-captured beforecaddy_load, and before acaddy_config_delete,caddy_config_setorcaddy_config_by_idthat addresses the config root. Anapplythat times out with its outcome unknown keeps the pre-revert config as snapshot [0], which shifts every older snapshot down one index; the error says where the target now sits. A successfulapplyreports where the admin endpoint went, likecaddy_load.
Route operations (4)
- caddy_reverse_proxy — Add a reverse proxy in one call:
from='api.local' to=['localhost:3000']. Pass an optionalidfor idempotent writes — repeat calls replace the route in place instead of duplicating. The upstream scheme matches case-insensitively (HTTPS://gets the TLS transport too). Anhttp(s)://upstream carrying a path, query or fragment is refused: a dial is host and port only, so rewrite the path with a separate handler (arewriteroute viacaddy_add_route, or Caddyfilehandle_path). - caddy_add_route — Add a route with full match/handle control (any Caddy handler).
- caddy_remove_route — Remove a route by
@id(preferred) or by index. Requiresconfirm=true. - caddy_list_routes — Human-readable route summary. Defensive: never crashes on weird config.
TLS & config conversion (2)
- caddy_tls — Check or set TLS settings. Actions:
status,set_email(ACME email),set_acme_ca(ACME CA URL),set_acme_profile(ACME profile, Caddy 2.10+ — experimental upstream: the ACME profiles spec is still a draft and Caddy marks the field subject to change. Caddy accepts any profile name on load, so a name the CA does not advertise fails only at issuance, in Caddy's own logs), and the read-onlyech_status(the Encrypted ClientHello config atapps/tls/encrypted_client_hello, Caddy 2.10+). The set actions PATCH first; whenapps/tlsis not set they PUT a minimal config, which also creates any missing parents, so they work on an instance with no config at all. On an existing config they deep-merge into the issuer path and PATCH the result back, preserving siblings (custom certs,on_demand, additional policies). Whenpolicies[0].issuers[0]already carries the field, the PATCH overwrites it in place whatever the issuer's module; only the merge path checks for anacmemodule. Otherwise it refuses with a shape-specific error if the existing structure is unexpected. AnnotateddestructiveHint: true, since the set actions overwrite existing values. - caddy_adapt — Convert a config in any registered adapter format to Caddy JSON without applying it.
caddyfile(built-in, default) plus any adapter module compiled into your Caddy binary — e.g.,nginx(caddy-nginx-adapter),yaml(caddy-yaml). Great for previewing or porting from existing configs. One caveat on Caddy 2.11.4 and earlier: a Caddyfileorderglobal option is not preview-only. It mutates that Caddy process's directive order, so it carries into later Caddyfile adapts and loads in the same process, and anorderline that fails still removes the directive it names (caddyserver/caddy#7995, fixed in Caddy 2.11.6).
Server operations (6)
- caddy_status — Connectivity check + config summary (server count, routes, TLS mode). The TLS label replays Caddy's own automatic-HTTPS rule over the stored config instead of guessing from the listen port, so it reads
enabled,enabled (no listener gets TLS: all are on the HTTP port),auto (HTTPS),auto (HTTPS: host matchers on a non-HTTP port),mixed (TLS on non-HTTP listeners only),off (HTTP only),off (no host matchers),off (automatic HTTPS disabled)oroff (empty tls_connection_policies). The two qualifiedenabledreadings come from Caddy deciding TLS per socket rather than per server (app.go:535): connection policies are ignored on the HTTP-port listener, so a server that binds only that port is configured for TLS and serves none of it. - caddy_list_servers — List all HTTP servers with names, addresses, route counts, and TLS status. Same labels as
caddy_status, but this tool reads onlyapps/http/serversand so assumes the defaulthttp_port80 /https_port443 — on an instance with custom ports,caddy_statusis the one that gets the label right. - caddy_upstreams — Reverse proxy backend health, as Caddy's
/reverse_proxy/upstreamsarray returned verbatim. On Caddy 2.11.2+ this is not the configured upstream list: dynamic upstreams stay listed about 1 h after the dynamic source last returned them (so an address can outlive the config that referenced it), and a backend with requests in flight can appear twice when its resolved address differs from the entry's dial text. The extra copy always showsfails 0and repeatsnum_requests— do not sumnum_requestsacross entries. - caddy_metrics — Prometheus metrics (request counts, durations, connections, TLS handshakes). Optional
filter(substring match on metric name, keeps# HELP/# TYPElines for retained metrics) andmax_lines(default 500) keep responses compact on busy servers. A filter that keeps nothing answersNo metrics matched filter "<filter>", an empty body answersCaddy returned an empty metrics body, and a non-text body (e.g. JSON from a proxy) is rendered as JSON in the tool and incaddy://metrics. - caddy_pki — CA info and certificate chains (default CA:
local). - caddy_stop — Graceful shutdown. Requires
confirm=trueto prevent accidents.
Resources
Browsable read-only data — MCP clients can fetch these directly without a tool call:
caddy://config— Current full Caddy JSON configuration.caddy://servers— The rawapps/http/serversconfig for all configured HTTP servers.caddy://upstreams— Reverse proxy upstream health status, verbatim. Same 2.11.2+ caveat ascaddy_upstreams: lingering dynamic upstreams and duplicate in-flight entries; do not sumnum_requests.caddy://metrics— Prometheus metrics (text exposition format). Capped at the first 500 lines to keep client context bounded; use thecaddy_metricstool withfilter/max_linesfor filtered or larger output.
Examples
Add a reverse proxy
> "Proxy api.example.com to my app on port 3000"
→ caddy_reverse_proxy({ from: "api.example.com", to: ["localhost:3000"] })
Idempotent reverse proxy (safe to re-run from automation)
> "Make sure api.example.com points at localhost:3000, with a stable id"
→ caddy_reverse_proxy({ from: "api.example.com", to: ["localhost:3000"], id: "api-prod" })
# First call creates the route under @id="api-prod".
# Subsequent calls with the same id REPLACE in place — no duplicate routes.
# Refuses with a clear error if "api-prod" is already in use by a non-route
# config object (TLS issuer, server, etc.) — @ids are config-global in Caddy.
Filter Prometheus metrics
> "Just the HTTP request metrics, please"
→ caddy_metrics({ filter: "http_requests" })
# Keeps sample lines whose metric name contains "http_requests",
# plus their `# HELP` / `# TYPE` lines. Drops the rest.
Preview a Caddyfile before applying it
> "Convert this Caddyfile to JSON so I can review it:
example.com {
reverse_proxy localhost:8080
}"
→ caddy_adapt({ config: "..." })
Diagnose slow routes
> "Fetch Prometheus metrics and tell me which route is slowest"
→ caddy_metrics()
Safely update a route by @id
> "Update the route with @id 'api-v2' to point to the new backend"
→ caddy_config_by_id({ id: "api-v2", action: "set", value: {...} })
# Uses ETags — you'll get HTTP 412 if someone else changed it first
Atomic deploy
> "Replace the whole config with this Caddyfile"
→ caddy_adapt({ config: "..." }) # validate first
→ caddy_load({ config: adaptedJson }) # apply atomically
Troubleshooting
"Cannot connect to Caddy admin API"
- Make sure Caddy is running.
caddy runorsystemctl status caddy. - Check the admin endpoint. Default is
http://localhost:2019. If Caddy is in Docker, use the container hostname. - Set
CADDY_ADMIN_URLin your MCP configenvto match. - Over an SSH tunnel, map the same port on both ends (
ssh -L 2019:localhost:2019 <host>) and leaveCADDY_ADMIN_URLat its default. Caddy checks theHostheader against its own listen address, so a tunnel on a different local port answers403 host not allowed: localhost:<port>. - Behind a reverse proxy, add the proxy's
host:portto the remote Caddy'sadmin.origins. Caddy checks bothHostandOrigin, and settingadmin.originsreplaces the defaultlocalhost/127.0.0.1/::1entries, so listlocalhost:2019too if local tools still need access. A non-loopback or wildcardadmin.listen— the Dockerhttp://caddy:2019above, for instance — does not allow an arbitraryHosteither, so it needsadmin.originsset as well. - Pointing
CADDY_ADMIN_URLat Caddy's native remote admin listener (admin.remote, default:2021) fails before any HTTP is exchanged, because that listener requires a TLS client certificate and caddy-mcp does not present one. It surfaces as this message even though Caddy is running and accepted the connection.
"HTTP 412 Precondition Failed"
- Someone (or something) changed the config between your read and your write.
- The cached ETag has been invalidated. Re-read the config and retry.
"HTTP 401" or "HTTP 403" on any request
- Caddy's own checks run on every admin request, reads included, and always answer with a JSON
{"error":...}body. If you got one, it is Caddy: theadmin.listen/admin.originsallowlists (host not allowed: ...,client is not allowed to access from origin ...,required Origin header is missing or invalid— see the tunnel and proxy bullets above), or, onadmin.remote, its mTLS identity and permission checks. - A bodiless 401/403 came from something in front of Caddy — a proxy, a gateway, an SSO layer.
CADDY_API_TOKENapplies there and only there, so a missing or wrong token is one cause and the proxy's other access rules are another. - Caddy's admin API has no bearer-token auth of its own, so setting
CADDY_API_TOKENwill not clear a 401/403 that carries a Caddy error body.
"directive 'X' is not an ordered HTTP handler" from caddy_adapt, or from caddy_load with format: "caddyfile"
- Two causes, and Caddy's error cannot tell them apart:
- The directive has no registered order — usually a plugin directive. Add an
orderglobal option, or wrap it in arouteblock. - On Caddy 2.11.4 and earlier, an earlier failed or concurrent Caddyfile adaptation that used
orderin this same Caddy process removed that directive from the process-wide directive order. Restarting Caddy restores the default order (caddyserver/caddy#7995, unreleased).
- The directive has no registered order — usually a plugin directive. Add an
- The second cause is why a Caddyfile that adapted a minute ago can start failing with no edit to it. Caddy's own advice ("try … using the order global option") fixes the first cause and papers over the second.
SIGUSR1 / systemctl reload caddy stops reloading the Caddyfile
- Expected, and not caused by a bug here. Since Caddy 2.11.1,
SIGUSR1reloads from the file on disk only if the config has never been changed through the admin API. The first write from caddy-mcp (or any other API client) makes Caddy consider the running config API-owned, andSIGUSR1becomes a no-op. - Pick one owner per instance. If the Caddyfile is the source of truth, use
caddy-mcp read-only tools (
caddy_status,caddy_list_routes,caddy_adapt) and reload from the file. If caddy-mcp owns the config, apply changes withcaddy_loadinstead ofSIGUSR1. - One qualification on Caddy 2.11.4 and earlier:
caddy_adaptis read-only with respect to the config, but not with respect to the adapter. A Caddyfileorderglobal option changes that process's directive order, and a failedorderline can break later in-process adaptations — which is what aSIGUSR1reload andcaddy run --watchdo.caddy reload, which is what the packagedsystemctl reload caddyruns, adapts in the CLI process and is unaffected.
Windows: MCP server doesn't start
- Use the
cmd /c npx ...pattern from the Quick start section. Node 20+ can't spawn.cmdfiles directly.
Requirements
-
Node.js 20+
-
Caddy 2.11.3 or later, with the admin API enabled (default:
localhost:2019). The latest 2.11.x is recommended; verified against Caddy 2.11.4. Two admin-side reasons for that floor:- Caddy 2.11.2 and earlier log every admin request's headers at INFO, so if the
Authorizationheader fromCADDY_API_TOKENreaches the admin listener, the token is written to Caddy's log in plain text (caddyserver/caddy#7578). - Caddy 2.11.1 and earlier accept a duplicate
@idsilently. A racingcaddy_reverse_proxycreate, or acaddy_config_by_idset withmode: "insert"on a route id, leaves two elements sharing one@id, and/id/resolves to only one of them.
Older 2.x mostly works, with two exceptions that both come from how Caddy sends its
ETag. Caddy 2.8.0 and later send it as a response header. Caddy 2.5.2 through 2.7.x send it as an HTTP trailer, which this client cannot read, and earlier versions send none. So before 2.8.0:- the
If-Match(ETag) concurrency guard is inactive, because no ETag is ever cached to echo back; - every
caddy_config_by_idsetanddeleteis refused, because the tool reads the ETag to learn where Caddy resolves the@idbefore it writes through it, and fails closed when it cannot.
The
@idwrite path relies onPATCHsemantics that the live integration suite pins per release. - Caddy 2.11.2 and earlier log every admin request's headers at INFO, so if the
Contributing
git clone https://github.com/YawLabs/caddy-mcp.git
cd caddy-mcp
npm install
npm run lint # Biome check
npm run lint:fix # Auto-fix
npm run build # tsup bundle
npm test # Vitest (941 unit tests, +47 POSIX-only unix-socket and launcher tests; +39 live-Caddy integration tests gated by CADDY_MCP_INTEGRATION=1)
npm run typecheck # oam check . if oam is found, else tsc --noEmit
The integration suite replaces the target Caddy's config while it runs and loads
the original back afterwards, so point it at a scratch instance. Set its admin
address with CADDY_ADMIN, not an admin block: each test loads {}, and Caddy
then re-binds to its default admin address.
CADDY_ADMIN=127.0.0.1:20190 caddy run
CADDY_MCP_INTEGRATION=1 CADDY_ADMIN_URL=http://127.0.0.1:20190 npx vitest run src/tests/integration.test.ts
See CONTRIBUTING.md for the full workflow, including release process.
License
MIT
Frequently asked questions
What is Caddy MCP Server?
MCP server for managing Caddy web servers via the admin API
How do I install Caddy MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. Caddy MCP Server runs locally from the npm package @yawlabs/caddy-mcp with the command npx -y @yawlabs/caddy-mcp@2.6.5.
Is Caddy MCP Server free and open source?
Yes. Caddy MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does Caddy MCP Server support remote (HTTP) connections?
No remote endpoint is listed for Caddy MCP Server. It runs locally on your machine over stdio, started by your MCP client.
What tools does Caddy MCP Server provide?
Caddy MCP Server provides 18 tools, including caddy_adapt, caddy_add_route, caddy_config_by_id, and caddy_config_delete. See the full tool list for descriptions and parameters.
How is Caddy MCP Server's trust score calculated?
Caddy MCP Server scores 74 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yet—Be the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.