add_key
Add a missing key-value pair to a JSON, YAML, TOML, Python dict, or JS/TS object while preserving its layout; existing keys are refused so you can use replacement instead.
Instructions
Add a key-value pair to a JSON object, YAML mapping, TOML table, Python dict literal or JS/TS object literal. The entry follows the container's layout: one key per line stays so, an inline object stays inline, and a trailing comma is kept. A YAML key with no value gets a nested mapping. A key the container already has is refused, naming the target to give replace_value.
Use this when: the key does not exist yet. Don't use this when: the key exists (replace_value), or you add a list item (append_to_array).
Example (TS, const CONFIG = { server: {...} }): parent_target="CONFIG.server" key="port" value="8080"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Key to add. JSON, YAML and JS/TS: one name, quoted for you when needed. TOML: a dotted key, so quote a name with a dot yourself ('"example.com"'). Python: a key expression, so quote string keys ('"timeout"'). | |
| value | Yes | Value as source text in the file's syntax, strings quoted (e.g. '"2.0.0"' or '42'). | |
| file_path | Yes | Absolute path to the source or config file. | |
| parent_target | Yes | Parent container: its key path from the top level in a config file ('' for the root; quote a key with dots, 'a."b.c"'), or a Python or JS/TS module-level variable's name, dotted into nested literals ('CONFIG.server'). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |