Skip to main content
Glama

neurocode_graft

Replace a specific function, class, or method by deterministic AST subtree grafting, avoiding fragile whitespace diff errors; optionally run tests and auto-rollback on failure.

Instructions

Perform deterministic AST subtree grafting on Python, TypeScript, JavaScript, Go, or Rust code. Directly mutates/replaces a specific function, class, or method AST node without fragile whitespace diff errors. Supports test_command with automated rollback on test failures.

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": {
      "file_path": "<file_path>",
      "symbol": "<symbol>",
      "replacement_code": "<replacement_code>"
    },
    "name": "neurocode_graft"
  }
}

Input Schema

NameRequiredDescriptionDefault
applyNoWhether to write modifications to disk (default false for preview)
symbolYesFunction, method (e.g. 'ClassName.methodName'), or class to replace
file_pathYesRelative path to file being modified
repo_pathNoPath to repository root (default '.').
test_commandNoOptional test command to run after grafting (e.g. 'pytest tests/test_calc.py')
auto_rollbackNoWhether to revert file if test_command fails (default true)
replacement_codeYesNew code block to graft into the AST

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations at all, the description carries the full disclosure burden. It usefully reveals that the tool mutates files in place, that grafting is deterministic and immune to whitespace diff errors, and that failures of test_command trigger rollback — genuine behavioral context. It omits what happens when the symbol is missing or ambiguous, what a preview returns, and any permission or repository-state requirements, which matter for a write operation.

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 tight sentences, front-loaded with the core action and language scope, then the safety/rollback feature. No filler, no repetition, and the most decision-relevant facts come first.

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

Completeness3/5

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

For a 7-parameter destructive file-mutation tool with no annotations and no output schema, the description covers the core operation and the rollback safety net but leaves the agent guessing about error behavior, preview output, and ambiguity handling. Adequate as a starting point, not complete for the risk profile.

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?

Schema description coverage is 100%, so every parameter is already documented, and the description largely restates the test_command/auto_rollback relationship that the schema properties already describe. It adds a little framing by presenting rollback as an integrated feature rather than two independent flags, but contributes no new detail about symbol syntax, repo_path resolution, or file_path semantics.

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?

States a specific verb and resource ('deterministic AST subtree grafting' on a 'specific function, class, or method AST node') and enumerates the five supported languages, which lets an agent distinguish it from generic patch tools. It stops short of naming or contrasting any sibling such as neurocode_validate_patch or neurocode_slice, so the boundary is inferred rather than stated.

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

Usage Guidelines3/5

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

Usage is implied: graft when you want to replace a whole symbol and avoid whitespace-diff fragility, and optionally attach a test command. There is no explicit 'use this instead of X' routing, no stated preconditions (e.g. symbol must exist and be unambiguous), and no guidance on when a preview versus an applied write is appropriate beyond the schema default.

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