Skip to main content
Glama

edit_cell_source

Destructive

Replace an exact string in a Jupyter notebook cell with another, supporting single or multiple occurrences. Returns a diff of changes made.

Instructions

Perform a surgical find-and-replace within a cell's source (like an editor's Edit tool). Finds old_string in the cell and replaces it with new_string. Matching is literal (not regex) and may span multiple lines. By default, old_string must appear exactly once; set replace_all=True for multiple occurrences. Returns a diff of the changes made.

Prefer this over overwrite_cell_source for small, targeted edits — it is safer because
unchanged parts of the cell are left untouched. Use read_cell first to see the current
source and construct an accurate old_string.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cell_indexYesIndex of the cell to edit (0-based)
new_stringYesReplacement string
old_stringYesExact string to find in cell source
replace_allNoReplace all occurrences (default: first only)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYesSuccess message with diff showing changes made
Behavior5/5

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

Discloses key behaviors: literal matching (not regex), multi-line support, default uniqueness of old_string, and replace_all option. Mentions return of a diff. Annotations include destructiveHint: true, which is consistent with description's 'safer' claim. No contradictions.

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?

Description is concise (4 sentences) and well-structured: first sentence states core purpose, second explains mechanics, third provides usage guidance and alternative, fourth suggests prerequisite action. No unnecessary words.

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?

Covers all essential aspects: purpose, mechanics, constraints, usage guidance, comparison with alternative, prerequisite, and return value (diff). Given 4 parameters, 3 required, and presence of output schema, the description is complete for agent to select and invoke correctly.

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 covers 100% of parameters with descriptions. Description adds nuance: literal matching, multi-line, default uniqueness behavior for old_string, and semantics of replace_all (default first only). This adds meaningful context beyond schema.

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?

Clearly states the tool performs a surgical find-and-replace on a cell's source, using specific verb (edit) and resource (cell source). Explicitly distinguishes from sibling overwrite_cell_source by contrasting targeted edits vs full overwrite.

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 advises when to use: prefer for small targeted edits over overwrite_cell_source. Recommends reading the cell first with read_cell to construct an accurate old_string. Provides clear usage conditions.

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/datalayer/jupyter-mcp-server'

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