@yawlabs/caddy-mcp 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -27
- package/dist/api.d.ts +20 -0
- package/dist/format.d.ts +10 -1
- package/dist/index.js +408 -89
- package/dist/server.js +408 -89
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://github.com/YawLabs/caddy-mcp/stargazers)
|
|
6
6
|
|
|
7
|
-
**Manage Caddy web servers from Claude Code, Cursor, and any MCP client.** 18 tools + 4 resources covering every endpoint
|
|
7
|
+
**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.
|
|
8
8
|
|
|
9
9
|
Built and maintained by [Yaw Labs](https://yaw.sh).
|
|
10
10
|
|
|
@@ -16,12 +16,12 @@ One click adds this to your local Yaw MCP config so it's available in every Yaw
|
|
|
16
16
|
|
|
17
17
|
Other Caddy MCP servers wrap half the admin API and silently swallow errors. This one doesn't.
|
|
18
18
|
|
|
19
|
-
- **Complete admin API coverage** — every
|
|
19
|
+
- **Complete admin API coverage** — every endpoint in [Caddy's admin API reference](https://caddyserver.com/docs/api): `/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 use `caddy_metrics` with `filter: "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](https://caddyserver.com/docs/profiling)).
|
|
20
20
|
- **Safe concurrent writes** — uses ETags (`If-Match`) so your changes never silently overwrite someone else's. Surfaces `HTTP 412 Precondition Failed` as a clear message, not a cryptic error.
|
|
21
21
|
- **Safe-by-default mutations** — `caddy_config_set` defaults to idempotent `overwrite` (PATCH), not `append` (POST). Calling twice doesn't duplicate your route.
|
|
22
22
|
- **Defensive parsing** — `caddy_list_routes` never crashes on malformed config, even if routes are null, handlers are strings, or matchers are non-arrays. Regression-tested.
|
|
23
23
|
- **No leaked credentials in errors** — if `CADDY_ADMIN_URL` contains a token in the path/query, the connect-failed message shows only the origin.
|
|
24
|
-
- **Fallback error surfacing** — when a TLS write PATCH fails and the
|
|
24
|
+
- **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.
|
|
25
25
|
- **Tool annotations** — every tool declares `readOnlyHint`, `destructiveHint`, and `idempotentHint`, so MCP clients can skip confirmations for safe ops.
|
|
26
26
|
- **Instant startup** — ships as a single bundle with two runtime deps (the MCP SDK + Zod). No 5-minute `node_modules` install.
|
|
27
27
|
- **Input hardening** — adapter names, `@id` values, server names, and CA ids are all regex-validated with length caps. Blocks CRLF header injection and ReDoS.
|
|
@@ -78,12 +78,12 @@ That's it. Now ask your AI assistant:
|
|
|
78
78
|
|
|
79
79
|
| Environment variable | Default | Description |
|
|
80
80
|
|---|---|---|
|
|
81
|
-
| `CADDY_ADMIN_URL` | `http://localhost:2019` | Caddy admin API URL. Set to `http://caddy:2019` inside Docker, or an https URL for remote admin. 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. |
|
|
82
|
-
| `CADDY_API_TOKEN` | (none) | Optional Bearer token
|
|
81
|
+
| `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. |
|
|
82
|
+
| `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 "";`). |
|
|
83
83
|
| `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. |
|
|
84
|
-
| `CADDY_MAX_RETRIES` | `2` | Number of retries on transient failures
|
|
85
|
-
| `CADDY_TIMEOUT` | `10000` | Timeout in ms for
|
|
86
|
-
| `CADDY_LOAD_TIMEOUT` | `
|
|
84
|
+
| `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. |
|
|
85
|
+
| `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`. Non-numeric, `<= 0`, or fractional values below 1ms fall back to the default. |
|
|
86
|
+
| `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. Non-numeric, `<= 0`, or fractional values below 1ms fall back to the default. |
|
|
87
87
|
|
|
88
88
|
**Unix socket admin endpoints:**
|
|
89
89
|
|
|
@@ -98,8 +98,11 @@ onto a unix socket, where access is governed by filesystem permissions:
|
|
|
98
98
|
|
|
99
99
|
Point `CADDY_ADMIN_URL` at the same path (`unix:///var/run/caddy-admin.sock`)
|
|
100
100
|
and requests are sent over the socket instead of TCP. The process running
|
|
101
|
-
caddy-mcp needs read/write permission on the socket file.
|
|
102
|
-
|
|
101
|
+
caddy-mcp needs read/write permission on the socket file. Leave
|
|
102
|
+
`CADDY_API_TOKEN` unset here unless an authenticating proxy actually listens on
|
|
103
|
+
that socket: over a unix path caddy-mcp is usually talking to Caddy's own
|
|
104
|
+
socket, where the token does nothing — and, before Caddy 2.11.3, is logged in
|
|
105
|
+
clear.
|
|
103
106
|
|
|
104
107
|
**Alternate MCP clients:**
|
|
105
108
|
|
|
@@ -118,11 +121,11 @@ Use the same JSON block shown above in any of these.
|
|
|
118
121
|
### Config management (6)
|
|
119
122
|
|
|
120
123
|
- **caddy_config_get** — Read config at any JSON path (or the full config).
|
|
121
|
-
- **caddy_config_set** — Write config at a path. Modes: `overwrite` (PATCH, default, idempotent), `append` (POST), `insert` (PUT
|
|
122
|
-
- **caddy_config_delete** — Delete config at a path. Requires `confirm=true` (deleting a parent path also removes every descendant).
|
|
124
|
+
- **caddy_config_set** — Write config at a path. Modes: `overwrite` (PATCH, default, idempotent; the key must exist), `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). `append` at 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 like `routes` or `listen`.
|
|
125
|
+
- **caddy_config_delete** — Delete config at a path. Requires `confirm=true` (deleting a parent path also removes every descendant). An empty path (`''`, `'/'`, `'config'`, `'/config/'`) addresses the **entire** config: it unloads every app and server plus the `admin` block, after which Caddy re-binds its admin endpoint to its default address (`localhost:2019`, or `$CADDY_ADMIN` in Caddy's environment) — if `CADDY_ADMIN_URL` points anywhere else, neither caddy-mcp nor `caddy_revert` can reach Caddy afterwards. A root delete auto-snapshots the prior config first (when it can be read), so `caddy_revert` can restore it while Caddy is still reachable; no other path is snapshotted. To replace the config rather than unload it, use `caddy_load`.
|
|
123
126
|
- **caddy_config_by_id** — Get/set/delete config by `@id` tag — much easier than navigating deep paths. The `delete` action requires `confirm=true`.
|
|
124
|
-
- **caddy_load** — Replace the entire config atomically.
|
|
125
|
-
- **caddy_revert** — Manage config snapshots for rollback. Actions: `list`, `save`, `apply` (confirm-gated). In-memory, last 10.
|
|
127
|
+
- **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](https://github.com/caddyserver/caddy/issues/7246)). `format` is `json` (default) or `caddyfile`; stock Caddy registers only the `caddyfile` adapter, so for any other adapter compiled into a custom build, adapt first with `caddy_adapt` and load the JSON (the Atomic deploy example below).
|
|
128
|
+
- **caddy_revert** — Manage config snapshots for rollback. Actions: `list`, `save`, `apply` (confirm-gated). In-memory, last 10. Auto-captured before `caddy_load`, and before a `caddy_config_delete` at the config root. An `apply` that 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.
|
|
126
129
|
|
|
127
130
|
### Route operations (4)
|
|
128
131
|
|
|
@@ -133,14 +136,14 @@ Use the same JSON block shown above in any of these.
|
|
|
133
136
|
|
|
134
137
|
### TLS & config conversion (2)
|
|
135
138
|
|
|
136
|
-
- **caddy_tls** — Check or set TLS settings: ACME email, ACME CA URL.
|
|
137
|
-
- **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](https://github.com/caddyserver/nginx-adapter)), `yaml` ([caddy-yaml](https://github.com/abiosoft/caddy-yaml)). Great for previewing or porting from existing configs.
|
|
139
|
+
- **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-only `ech_status` (the Encrypted ClientHello config at `apps/tls/encrypted_client_hello`, Caddy 2.10+). The set actions PATCH first; when `apps/tls` is 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). Refuses with a shape-specific error if the existing structure is unexpected — never clobbers.
|
|
140
|
+
- **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](https://github.com/caddyserver/nginx-adapter)), `yaml` ([caddy-yaml](https://github.com/abiosoft/caddy-yaml)). Great for previewing or porting from existing configs. One caveat on Caddy 2.11.4 and earlier: a Caddyfile `order` global 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 an `order` line that *fails* still removes the directive it names ([caddyserver/caddy#7995](https://github.com/caddyserver/caddy/pull/7995), fixed upstream but unreleased as of 2.11.4).
|
|
138
141
|
|
|
139
142
|
### Server operations (6)
|
|
140
143
|
|
|
141
|
-
- **caddy_status** — Connectivity check + config summary (server count, routes, TLS mode).
|
|
142
|
-
- **caddy_list_servers** — List all HTTP servers with names, addresses, route counts, and TLS status.
|
|
143
|
-
- **caddy_upstreams** — Reverse proxy backend health.
|
|
144
|
+
- **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)` or `off (empty tls_connection_policies)`. The two qualified `enabled` readings 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.
|
|
145
|
+
- **caddy_list_servers** — List all HTTP servers with names, addresses, route counts, and TLS status. Same labels as `caddy_status`, but this tool reads only `apps/http/servers` and so assumes the default `http_port` 80 / `https_port` 443 — on an instance with custom ports, `caddy_status` is the one that gets the label right.
|
|
146
|
+
- **caddy_upstreams** — Reverse proxy backend health, as Caddy's `/reverse_proxy/upstreams` array 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 shows `fails 0` and repeats `num_requests` — do not sum `num_requests` across entries.
|
|
144
147
|
- **caddy_metrics** — Prometheus metrics (request counts, durations, connections, TLS handshakes). Optional `filter` (substring match on metric name, keeps `# HELP` / `# TYPE` lines for retained metrics) and `max_lines` (default 500) keep responses compact on busy servers.
|
|
145
148
|
- **caddy_pki** — CA info and certificate chains (default CA: `local`).
|
|
146
149
|
- **caddy_stop** — Graceful shutdown. Requires `confirm=true` to prevent accidents.
|
|
@@ -151,7 +154,7 @@ Browsable read-only data — MCP clients can fetch these directly without a tool
|
|
|
151
154
|
|
|
152
155
|
- `caddy://config` — Current full Caddy JSON configuration.
|
|
153
156
|
- `caddy://servers` — Summary of all configured HTTP servers.
|
|
154
|
-
- `caddy://upstreams` — Reverse proxy upstream health status.
|
|
157
|
+
- `caddy://upstreams` — Reverse proxy upstream health status, verbatim. Same 2.11.2+ caveat as `caddy_upstreams`: lingering dynamic upstreams and duplicate in-flight entries; do not sum `num_requests`.
|
|
155
158
|
- `caddy://metrics` — Prometheus metrics (text exposition format). Capped at the first 500 lines to keep client context bounded; use the `caddy_metrics` tool with `filter` / `max_lines` for filtered or larger output.
|
|
156
159
|
|
|
157
160
|
## Examples
|
|
@@ -223,16 +226,27 @@ Browsable read-only data — MCP clients can fetch these directly without a tool
|
|
|
223
226
|
- Make sure Caddy is running. `caddy run` or `systemctl status caddy`.
|
|
224
227
|
- Check the admin endpoint. Default is `http://localhost:2019`. If Caddy is in Docker, use the container hostname.
|
|
225
228
|
- Set `CADDY_ADMIN_URL` in your MCP config `env` to match.
|
|
229
|
+
- Over an SSH tunnel, map the **same** port on both ends (`ssh -L 2019:localhost:2019 <host>`) and leave `CADDY_ADMIN_URL` at its default. Caddy checks the `Host` header against its own listen address, so a tunnel on a different local port answers `403 host not allowed: localhost:<port>`.
|
|
230
|
+
- Behind a reverse proxy, add the proxy's `host:port` to the remote Caddy's `admin.origins`. Caddy checks both `Host` and `Origin`, and setting `admin.origins` **replaces** the default `localhost` / `127.0.0.1` / `::1` entries, so list `localhost:2019` too if local tools still need access. A non-loopback or wildcard `admin.listen` — the Docker `http://caddy:2019` above, for instance — does not allow an arbitrary `Host` either, so it needs `admin.origins` set as well.
|
|
231
|
+
- Pointing `CADDY_ADMIN_URL` at 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.
|
|
226
232
|
|
|
227
233
|
**"HTTP 412 Precondition Failed"**
|
|
228
234
|
|
|
229
235
|
- Someone (or something) changed the config between your read and your write.
|
|
230
236
|
- The cached ETag has been invalidated. Re-read the config and retry.
|
|
231
237
|
|
|
232
|
-
**"HTTP 403" on
|
|
238
|
+
**"HTTP 401" or "HTTP 403" on any request**
|
|
233
239
|
|
|
234
|
-
-
|
|
235
|
-
-
|
|
240
|
+
- 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: the `admin.listen` / `admin.origins` allowlists (`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, on `admin.remote`, its mTLS identity and permission checks.
|
|
241
|
+
- A **bodiless** 401/403 came from something in front of Caddy — a proxy, a gateway, an SSO layer. `CADDY_API_TOKEN` applies there and only there, so a missing or wrong token is one cause and the proxy's other access rules are another.
|
|
242
|
+
- Caddy's admin API has no bearer-token auth of its own, so setting `CADDY_API_TOKEN` will not clear a 401/403 that carries a Caddy error body.
|
|
243
|
+
|
|
244
|
+
**"directive 'X' is not an ordered HTTP handler"** from `caddy_adapt`, or from `caddy_load` with `format: "caddyfile"`
|
|
245
|
+
|
|
246
|
+
- Two causes, and Caddy's error cannot tell them apart:
|
|
247
|
+
- The directive has no registered order — usually a plugin directive. Add an `order` global option, or wrap it in a `route` block.
|
|
248
|
+
- On Caddy 2.11.4 and earlier, an earlier failed or concurrent Caddyfile adaptation that used `order` in this same Caddy process removed that directive from the process-wide directive order. Restarting Caddy restores the default order ([caddyserver/caddy#7995](https://github.com/caddyserver/caddy/pull/7995), unreleased).
|
|
249
|
+
- 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.
|
|
236
250
|
|
|
237
251
|
**`SIGUSR1` / `systemctl reload caddy` stops reloading the Caddyfile**
|
|
238
252
|
|
|
@@ -244,6 +258,12 @@ Browsable read-only data — MCP clients can fetch these directly without a tool
|
|
|
244
258
|
caddy-mcp read-only tools (`caddy_status`, `caddy_list_routes`, `caddy_adapt`)
|
|
245
259
|
and reload from the file. If caddy-mcp owns the config, apply changes with
|
|
246
260
|
`caddy_load` instead of `SIGUSR1`.
|
|
261
|
+
- One qualification on Caddy 2.11.4 and earlier: `caddy_adapt` is read-only with
|
|
262
|
+
respect to the config, but not with respect to the adapter. A Caddyfile `order`
|
|
263
|
+
global option changes that process's directive order, and a failed `order` line
|
|
264
|
+
can break later in-process adaptations — which is what a `SIGUSR1` reload and
|
|
265
|
+
`caddy run --watch` do. `caddy reload`, which is what the packaged
|
|
266
|
+
`systemctl reload caddy` runs, adapts in the CLI process and is unaffected.
|
|
247
267
|
|
|
248
268
|
**Windows: MCP server doesn't start**
|
|
249
269
|
|
|
@@ -252,9 +272,21 @@ Browsable read-only data — MCP clients can fetch these directly without a tool
|
|
|
252
272
|
## Requirements
|
|
253
273
|
|
|
254
274
|
- Node.js 20+
|
|
255
|
-
- Caddy 2.
|
|
256
|
-
|
|
257
|
-
|
|
275
|
+
- Caddy 2.11.3 or later, with the admin API enabled (default: `localhost:2019`).
|
|
276
|
+
The latest 2.11.x is recommended; verified against Caddy 2.11.4. Two admin-side
|
|
277
|
+
reasons for that floor:
|
|
278
|
+
- Caddy 2.11.2 and earlier log every admin request's headers at INFO, so if the
|
|
279
|
+
`Authorization` header from `CADDY_API_TOKEN` reaches the admin listener, the
|
|
280
|
+
token is written to Caddy's log in plain text
|
|
281
|
+
([caddyserver/caddy#7578](https://github.com/caddyserver/caddy/pull/7578)).
|
|
282
|
+
- Caddy 2.11.1 and earlier accept a duplicate `@id` silently. A racing
|
|
283
|
+
`caddy_reverse_proxy` create, or a `caddy_config_by_id` set with
|
|
284
|
+
`mode: "insert"` on a route id, leaves two elements sharing one `@id`, and
|
|
285
|
+
`/id/` resolves to only one of them.
|
|
286
|
+
|
|
287
|
+
Older 2.x mostly works, but the `If-Match` (ETag) concurrency guard needs Caddy
|
|
288
|
+
2.5.2 or later — before that Caddy ignores the header silently. The `@id` write
|
|
289
|
+
path relies on `PATCH` semantics that the live integration suite pins per release.
|
|
258
290
|
|
|
259
291
|
## Contributing
|
|
260
292
|
|
|
@@ -265,7 +297,7 @@ npm install
|
|
|
265
297
|
npm run lint # Biome check
|
|
266
298
|
npm run lint:fix # Auto-fix
|
|
267
299
|
npm run build # tsup bundle
|
|
268
|
-
npm test # Vitest (
|
|
300
|
+
npm test # Vitest (692 unit tests, +39 POSIX-only unix-socket and launcher tests; +33 live-Caddy integration tests gated by CADDY_MCP_INTEGRATION=1)
|
|
269
301
|
npm run typecheck # tsc --noEmit
|
|
270
302
|
```
|
|
271
303
|
|
package/dist/api.d.ts
CHANGED
|
@@ -4,6 +4,26 @@ export interface ApiResponse<T = any> {
|
|
|
4
4
|
data?: T;
|
|
5
5
|
error?: string;
|
|
6
6
|
etag?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Config-adapter warnings Caddy attached to a `POST /load` answer, set on a
|
|
9
|
+
* load that applied and on one that failed alike (see readLoadBody). Kept
|
|
10
|
+
* apart from `data` and `error` so neither has to be a rendered string;
|
|
11
|
+
* formatResult prints them for every consumer, so none can drop them.
|
|
12
|
+
* Elements are whatever Caddy sent -- `{file, line, directive, message}` on
|
|
13
|
+
* 2.11.4 -- and are not validated here.
|
|
14
|
+
*/
|
|
15
|
+
warnings?: unknown[];
|
|
16
|
+
/**
|
|
17
|
+
* Set (to true) only on a failure where this client's deadline fired on a
|
|
18
|
+
* config change (isConfigChange): no answer came, and Caddy may have applied
|
|
19
|
+
* the change, may still apply it, or may never have received it. `ok` is
|
|
20
|
+
* false, because nothing confirmed success -- but unlike every other failure
|
|
21
|
+
* it does NOT mean "nothing changed", and a caller that skips its bookkeeping
|
|
22
|
+
* on `!ok` needs to know the difference. caddy_load and caddy_revert apply key
|
|
23
|
+
* on it to keep the snapshot they would otherwise drop. A flag rather than a
|
|
24
|
+
* match on the error text, so rewording the message cannot change behaviour.
|
|
25
|
+
*/
|
|
26
|
+
outcomeUnknown?: boolean;
|
|
7
27
|
}
|
|
8
28
|
/**
|
|
9
29
|
* Caddy's "a segment of this config path does not exist" failure.
|
package/dist/format.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { ApiResponse } from "./api.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Convert an API response to MCP tool result format.
|
|
4
|
+
*
|
|
5
|
+
* `warnings` are appended to the SAME text item as the result, on a success and
|
|
6
|
+
* on an error alike, rather than sent as a second content item. They are set
|
|
7
|
+
* only by `POST /load` today, where they matter most on the failure path -- a
|
|
8
|
+
* load Caddy refused, reported next to the adapter warnings that came with it --
|
|
9
|
+
* and a client that reads only `content[0]` must still see both. Rendering them
|
|
10
|
+
* here, not in caddy_load, means no consumer of an ApiResponse can drop them.
|
|
11
|
+
*/
|
|
3
12
|
export declare function formatResult(res: ApiResponse): {
|
|
4
13
|
isError: boolean;
|
|
5
14
|
content: {
|