Skip to main content
Glama

add_key

Add a new key-value pair to dictionary-like structures in JSON, YAML, TOML, or Python files using AST-based editing.

Instructions

Add a new key-value pair inside a dict-like container. Works for JSON objects, YAML mappings, TOML tables, AND Python module-level dict literals.

For JSON/YAML/TOML: parent_target is the dotted path to the parent (use "" for root). For Python (.py): parent_target is the module-level variable name (e.g. 'CONFIG'). value should be a literal source expression in the target file's syntax (e.g. JSON '"foo"' or '42'; Python '"foo"' or '42').

Use this when: The key does not exist yet and you want to add it. Don't use this when: The key already exists -> use replace_value. You're adding an item to a list/array -> use append_to_array.

Example (JSON): parent_target="dependencies" key="mcp" value='"^1.2.0"' Example (Python): parent_target="CONFIG" # module-level CONFIG = {...} key='"timeout"' # include quotes if key is a string literal value="30"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
parent_targetYes
keyYes
valueYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It does well by explaining the tool mutates files (implied by 'Add'), specifies syntax requirements for different file types, and provides concrete examples. However, it doesn't mention error handling, permissions needed, or whether changes are reversible, leaving some behavioral aspects uncovered.

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 efficiently structured with clear sections: general purpose, format-specific instructions, usage guidelines, and examples. Every sentence adds value - no repetition or fluff. The information is front-loaded with the core purpose, followed by necessary details and clear demarcation of when/not to use the tool.

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?

Given the tool's complexity (handles multiple file formats with different syntax rules), zero schema description coverage, and no annotations, the description provides comprehensive coverage. It explains the tool's behavior, all parameter semantics, usage context relative to siblings, and includes practical examples. The presence of an output schema means return values don't need explanation here.

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?

With 0% schema description coverage, the description fully compensates by explaining all 4 parameters in detail. It clarifies that `parent_target` has different meanings for different file types (dotted path vs variable name), specifies that `value` should be a 'literal source expression in the target file's syntax', and provides examples showing how each parameter should be formatted for different scenarios.

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 description clearly states the tool's purpose with specific verb ('Add') and resource ('key-value pair inside a dict-like container'), and distinguishes it from siblings by specifying it's for dict-like containers only (not lists/arrays). It explicitly mentions the supported formats (JSON objects, YAML mappings, TOML tables, Python module-level dict literals), making the scope unambiguous.

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?

The description provides explicit usage guidelines with 'Use this when:' and 'Don't use this when:' sections, naming specific alternative tools (`replace_value` for existing keys, `append_to_array` for lists/arrays). This gives clear context for when to choose this tool versus its siblings, addressing the exact decision points an agent would face.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kambleakash0/agent-skills'

If you have feedback or need assistance with the MCP directory API, please join our Discord server