Skip to main content
Glama

Edit function code

function_replace

Replace exact, unique snippets of an edge function. Copy old_str from function_get, using only the text after the TAB on each line. The whole function is typechecked once and saved only if it passes; changes that compile only together go in one call as edits. Supply either old_str and new_str or 1-50 edits, applied in order.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "name": "<name>",
      "explanation": "<explanation>",
      "account": "<account>"
    },
    "name": "function_replace"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYesFunction name
editsNo
accountYesAccount (app) UUID; call account_list to find it
new_strNoReplacement source text
old_strNoExact, unique source text to replace
explanationYesWhy you are making this call, in one sentence for the user.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior4/5

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

Beyond the annotations, the description discloses behavior that matters for planning: the whole function is typechecked once and saved only if it passes, so the operation is atomic and all-or-nothing. It also says edits apply in order, which matters because idempotentHint=false. It does not say what an agent sees when typechecking fails, or what the call returns.

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?

Three sentences, each carrying distinct information: the core action, where to source old_str, and the transactional and ordering rules. The purpose comes first and nothing is padded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a non-idempotent mutation tool with no output schema, the definition covers atomicity, edit ordering, mode exclusivity, and the 50-edit limit. The remaining gap is behavior on failure, since an agent cannot tell whether a failed typecheck returns diagnostics or rolls back silently.

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

Parameters3/5

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

The schema already documents 83% of the parameters, so the bar is set high. The description still adds real value by stating that old_str and new_str are alternatives to the 1-50 edits array, and that matching must be exact and unique. Its most useful addition is the format instruction to copy only the text after the TAB from function_get output, which the schema does not cover.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description pairs a specific verb with a specific resource: 'Replace exact, unique snippets of an edge function.' That is far more informative than the title alone. It stops short of a 5 because it never explicitly contrasts itself with the close siblings function_update or file_replace, so an agent must infer which one to reach for.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives concrete procedural guidance: pull old_str from function_get, and combine edits that compile only together into a single call. It also states the two mutually exclusive input modes. What it lacks is an explicit exclusion rule naming when to use function_update or a full rewrite instead of a snippet replace.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources