Skip to main content
Glama

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

NameRequiredDescriptionDefault
keyYesKey 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"').
valueYesValue as source text in the file's syntax, strings quoted (e.g. '"2.0.0"' or '42').
file_pathYesAbsolute path to the source or config file.
parent_targetYesParent 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

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv3.2.0
    • addedInput schema / properties / file_path / description
      Added value: +"Absolute path to the source or config file."
    • addedInput schema / properties / key / description
      Added value: +"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\"')."
    • addedInput schema / properties / parent_target / description
      Added value: +"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')."
    • addedInput schema / properties / value / description
      Added value: +"Value as source text in the file's syntax, strings quoted (e.g. '\"2.0.0\"' or '42')."
  2. First observedv2.0.1

TDQS

A4.9/5.0
Behavior5/5

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

Goes well beyond the annotations (readOnlyHint=false, destructiveHint=false, openWorldHint=false) by disclosing preservation behavior (one key per line stays so, inline objects stay inline, trailing comma kept), a format-specific rule (YAML key with no value becomes a nested mapping), and error behavior (existing key is refused and the error names replace_value). These are exactly the traits an agent cannot infer from structured fields.

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?

Front-loaded with the action, then behavior, then a Use/Don't-use block, then a compact example. Every sentence carries information; no filler or restatement of the tool name.

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?

Output schema exists, so return values need not be described, and annotations cover the safety profile. The description fills the remaining gaps: container layout preservation, format-specific YAML behavior, duplicate-key failure, and concrete parameter composition.

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

Parameters4/5

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

Schema coverage is 100%, so the schema already carries the per-parameter meaning (dotted keys for TOML, key expressions for Python, source-text values), making 3 the baseline. The worked example showing parent_target="CONFIG.server" together with key/value adds real compositional meaning beyond the schema, earning a bump.

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?

States a specific verb (add) and resource (a key-value pair) and enumerates the concrete container formats it applies to: JSON object, YAML mapping, TOML table, Python dict, JS/TS object literal. It also names the sibling tools it is not (replace_value, append_to_array), so an agent can route without opening any schema.

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?

Explicit 'Use this when: the key does not exist yet' and 'Don't use this when: the key exists (replace_value), or you add a list item (append_to_array)' gives both the positive condition and two named alternatives. Nothing is left to inference.

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