Skip to main content
Glama

add_key

Adds a new key-value pair to a dictionary in JSON, YAML, TOML, or Python files at a specified parent target. Only use when the key does not already exist.

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, the description carries full burden. It explains different behavior per file type, required value syntax, and parent_target usage. Does not cover error handling or permissions, but these are less critical for this code manipulation tool.

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

Conciseness4/5

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

Well-structured with purpose, format-specific notes, usage guidelines, and examples. Slightly verbose due to examples, but content earns its place.

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 output schema exists, return values need not be explained. Description covers purpose, parameters, usage boundaries, and multiple file formats. No significant gaps for intended use.

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 has 0% description coverage, so description compensates fully. It explains parent_target as dotted path vs. variable name, key as any string, value as literal expression. Examples clarify syntax for JSON and Python.

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 adds a new key-value pair to dict-like containers, specifying supported formats (JSON, YAML, TOML, Python). It distinguishes from siblings like replace_value and append_to_array.

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?

Explicitly provides when to use (key does not exist) and when not to use (key exists -> replace_value; adding to list -> append_to_array). Also gives format-specific guidance for parent_target and value.

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