Skip to main content
Glama

caddy_config_set

Destructive

Write JSON config at a specified Caddy admin API path. Choose overwrite, append, or insert mode to replace values, add to arrays, or create keys with missing parents.

Instructions

Write config at a JSON path. Mode 'overwrite' (default) replaces the value at the path (PATCH) — idempotent, but it replaces the WHOLE subtree there: writing [] to '.../routes' drops every route. Mode 'append' (POST) adds to an array — NOT idempotent: calling twice with the same route duplicates it — but on a non-array key it REPLACES whatever is there, and it cannot create missing parent objects. Mode 'insert' (PUT) inserts at an array index (useful for route ordering), or strictly creates an object key together with any missing parents and fails with 409 if the key already exists — the safe way to create a server or app, including on an instance with no config at all. Any 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 requires confirm=true: 'overwrite' and 'append' there REPLACE the whole configuration with value — Caddy runs it exactly as caddy_load would — so every app, server and route not in value is discarded, and so is the 'admin' block unless value carries one. Caddy then re-binds its admin endpoint to the new config's admin.listen, or to its default address (localhost:2019, or $CADDY_ADMIN in Caddy's environment) when it sets none, or to no address at all when it sets admin.disabled; if CADDY_ADMIN_URL points anywhere else, neither this server nor caddy_revert can reach Caddy afterwards. A root write is snapshotted first, so caddy_revert can restore it while Caddy is still reachable; no other path is snapshotted. 'insert' at the root only succeeds after a root caddy_config_delete (Caddy answers 409 on any other instance, including one started with no config), and 'overwrite' is the reverse: after a root caddy_config_delete it answers 404 until 'append', 'insert' or caddy_load re-creates the config. To replace the whole config deliberately, caddy_load does the same thing behind the same gate and also accepts a Caddyfile.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNo'overwrite' = PATCH (replace existing, default, idempotent; 404 if the key does not exist), 'append' = POST (appends to arrays, NOT idempotent; REPLACES an existing non-array key; cannot create missing parents), 'insert' = PUT (inserts at an array index, or strictly creates an object key and any missing parents; 409 if the key exists)overwrite
pathYesConfig path to write to (e.g., 'apps/http/servers/srv0/routes')
valueYesThe JSON value to set at the path
confirmNoMust be true when `path` addresses the config root ('', '/', 'config', '/config/', slash-only variants, or a lone '...' segment): that write replaces the ENTIRE config (safety). Ignored for every other path.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.5.6
    • addedInput schema / properties / confirm
      Added value: +{
      +  "default": false,
      +  "description": "Must be true when `path` addresses the config root ('', '/', 'config', '/config/', slash-only variants, or a lone '...' segment): that write replaces the ENTIRE config (safety). Ignored for every other path.",
      +  "type": "boolean"
      +}
  2. Changed1 schema field changedv2.5.3
    • changedInput schema / properties / mode / description
      Previous value: -"'overwrite' = PATCH (replace existing, default, idempotent), 'append' = POST (add to arrays / create keys, NOT idempotent), 'insert' = PUT (insert at array index)"New value: +"'overwrite' = PATCH (replace existing, default, idempotent; 404 if the key does not exist), 'append' = POST (appends to arrays, NOT idempotent; REPLACES an existing non-array key; cannot create missing parents), 'insert' = PUT (inserts at an array index, or strictly creates an object key and any missing parents; 409 if the key exists)"
  3. First observedv2.2.0

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the destructiveHint annotation, the description discloses major non-obvious consequences: root writes discard all apps, servers and routes not in `value`, may re-bind the admin endpoint and can make Caddy unreachable from both this server and caddy_revert; append is non-idempotent; insert at root only works after a root caddy_config_delete; and root writes are snapshotted while other paths are not. This is exactly the kind of behavioral context an agent needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long, but every sentence carries unique operational or safety information, covering mode behavior, root-path edge cases, error codes, admin endpoint reachability, and interaction with caddy_load/caddy_revert. The core purpose is front-loaded in the first sentence, and the rest is logically grouped, making it a dense but efficient reference.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no output schema and only a destructive annotation, the description covers error conditions (404, 409), preconditions (root delete before insert), side effects on admin endpoint connectivity, rollback capability, and interactions with sibling tools. An agent can correctly invoke this tool and anticipate all major consequences across every required mode.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds critical meaning beyond the schema's one-line mode definitions: it explains that writing [] to routes drops every route, that append replaces non-array keys and cannot create parents, that insert fails with 409 if the key exists, and the precise root path variants and confirm=true requirement. It enriches the semantics of path, mode, and confirm substantially.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence states a specific action and resource ('Write config at a JSON path'), and the description immediately distinguishes the three modes (overwrite/append/insert) with their HTTP semantics. It also differentiates from caddy_load by noting that tool replaces the whole config while this one targets a path (except at root), and contrasts with caddy_revert and caddy_config_delete in the behavioral descriptions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit guidance for when to use each mode: 'insert' is called the safe way to create a server or app, 'append' is for arrays, and 'overwrite' for replacement. It explicitly directs whole-config replacements to caddy_load as the deliberate alternative and mentions caddy_revert for rollback after root writes, giving agents clear decision criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.