ast-editor
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Capabilities
Features and capabilities supported by this server
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| replace_functionA | Replace an entire function definition with new content -- signature, body, and decorators. Use this when: You're rewriting a function top-to-bottom (e.g., renaming it,
changing parameters AND implementation together).
Don't use this when: You only need to change the body -> use Example: target="LRUCache.get" content=' def get(self, key, default=None):\n return self.items.get(key, default)' |
| replace_function_bodyA | Replace only the body of a function, preserving its signature and decorators. Use this when: You're changing the implementation while keeping the interface stable.
Don't use this when: You're also changing parameters or return type -> use
Example: target="LRUCache.get" content=' if key in self.items:\n return self.items[key]\n return None' |
| replace_in_bodyA | Replace a byte-identical snippet inside a named function/method body, without touching the surrounding code. The match is scoped to the target's body so accidental matches elsewhere in the file cannot happen. Raises if the snippet is not found, or if it appears more than once in the body (include more surrounding context to disambiguate). Use this when: You need to change a specific statement or block inside a
large function body without rewriting the whole body. The single biggest
token-saver for long functions with ~30 similar lines where you only want
to change one of them.
Don't use this when: You're replacing the entire body -> use
Example: target="init" old_snippet="viper.BindPFlag("port", cmd.Flags().Lookup("port"))" new_snippet="viper.BindPFlag("port", cmd.PersistentFlags().Lookup("port"))" |
| delete_in_bodyA | Delete a byte-identical snippet inside a named function/method body. Scoped to the target's body so global file matches don't apply. Raises if the snippet is not found, or if it appears more than once in the body (include more surrounding context to make the match unique). Use this when: You want to remove a specific statement, block, or line
inside a function body without rewriting the whole body. Also useful for
removing a single entry from an inline object-literal passed as a function
argument -- target the enclosing function and delete the entry text.
Don't use this when: You're deleting the entire function/class -> use
Example (remove a mount call inside a function): target="RegisterRoutes" snippet='\tr.Mount("/kb", kbHandler)\n' Example (remove a key from an inline object arg): target="main" snippet="\t\tclassification,\n" |
| insert_in_bodyA | Insert new_snippet inside a named function/method body. Pass EXACTLY ONE
of
The anchor match (for Use this when: You're inserting new lines into a function body. Use
Example (prepend): target="handle" new_snippet=' log("start")\n' at="top" Example (append): target="handle" new_snippet=' log("end")\n' at="bottom" Example (after anchor): target="handle" new_snippet=' metrics.incr("calls")\n' after=' validate(request)\n' Example (before anchor): target="handle" new_snippet=' auth_check(request)\n' before=' validate(request)\n' |
| add_methodA | Add a new method at the end of a class body. Use this when: You're adding a method to an existing class.
Don't use this when: You're adding a field/attribute -> use Example: class_target="LRUCache" content=' def clear(self):\n self.items.clear()' |
| delete_symbolA | Delete an entire function or class definition, including its decorators.
By default, also removes the contiguous leading comment block above the
symbol (Godoc, Javadoc Use this when: You want to remove a function, method, or class entirely from a
source file -- along with its doc comment by default.
Don't use this when: You want to remove a config key -> use Example: target="LRUCache.old_method" # deletes a method + its leading comment target="DeprecatedClass" # deletes class, all methods, and preceding Javadoc target="Foo", include_leading_comments=False # keep the comment, delete only the symbol |
| replace_valueA | Replace the value of an existing key in a JSON, YAML, or TOML file. Use this when: A key already exists and you want to update its value.
Don't use this when: The key doesn't exist yet -> use Example: target="project.version" content='"2.0.0"' |
| add_importA | Add an import statement to a source file. Skips exact duplicates. Places new imports after existing ones, or at the top of the file if none exist. Use this when: You need to import something the file does not already reference.
Don't use this when: You're adding a single name to an existing multi-name
import statement like Example: import_text="from typing import Optional" # Python import_text="import { readFile } from 'fs';" # JS/TS import_text="#include <stdlib.h>" # C/C++ |
| remove_importA | Remove a matching import statement from a source file. Matching is by stripped text equality -- pass the exact import line you want to remove. Use this when: You want to remove an unused import.
Don't use this when: You want to remove one name from a multi-name import -> use
Example: import_text="import os" |
| add_keyA | 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 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" |
| delete_keyA | Delete a key-value pair from a dict-like container.
For JSON and JS/TS, the adjacent comma is also removed to keep the file valid. Use this when: You want to remove an entire entry.
Don't use this when: You want to remove an item from a list/array -> use
Example (JSON):
target="dependencies.tree-sitter"
Example (Python):
target='CONFIG."timeout"'
Example (TS):
target="CONFIG.port" # regular pair
target="CONFIG.name" # shorthand |
| append_to_arrayA | Append a literal value to an array/list. Works for JSON arrays, YAML sequences, TOML arrays, AND Python module-level list literals. For JSON/YAML/TOML: target is the dotted path to the array. For Python (.py): target is the module-level variable name (e.g. 'ITEMS'). Use this when: You want to add an item to a list (dependencies, keywords,
include paths, fixtures, etc.).
Don't use this when: You're adding a key-value pair -> use Example (TOML): target="project.dependencies" value='"new-package"' Example (Python): target="ITEMS" value='"new-item"' |
| remove_from_arrayA | Remove the first element matching value_match (stripped text equality) from an array/list. Works for JSON/YAML/TOML config arrays AND Python module-level list literals. For JSON/YAML/TOML: target is the dotted path to the array. For Python (.py): target is the module-level variable name. Use this when: You want to remove a specific item from a list.
Don't use this when: You want to remove a whole key -> use Example (TOML): target="project.dependencies" value_match='"old-package"' Example (Python): target="ITEMS" value_match='"old-item"' |
| add_fieldA | Add a field/attribute/member at the top of a class body (fields-before-methods convention). Use this when: You're adding a class attribute (Python), class field (JS/TS),
or member variable (C++).
Don't use this when: You're adding a method -> use Example: class_target="LRUCache" content=' version = "1.0"' |
| replace_signatureA | Replace only the signature of a function, preserving its body and decorators. Use this when: You're changing parameters, return type, or function name
without modifying the implementation.
Don't use this when: You also want to change the body -> use Example: target="LRUCache.get" new_signature=" def get(self, key, default=None):" |
| list_symbolsA | Return a formatted outline of all top-level functions, classes, and methods in a source file (Python, JS, TS, C, C++), with line numbers. Read-only. Use this when: You're about to edit an unfamiliar file and want to see its structure and exact symbol names. ALWAYS a good first call before editing -- avoids guessing at target names. Don't use this when: You already know the exact target name. Example: file_path="/abs/path/to/module.py" |
| add_import_nameA | Add a name to an existing named-import statement. Idempotent: skips if the name is already present.
Use this when: The module is already imported via a named-import form and
you want to add another name to that existing statement.
Don't use this when: The import statement doesn't exist yet -> use
Example (Python): module="typing" name="Optional" Example (TS): module="./utils" name="baz" |
| remove_import_nameA | Remove a name from a named-import statement.
If the name removed is the only remaining one AND there are no other
bindings (default / namespace) in the same statement, the entire import
line is removed. Raises an error if removing the last name would leave
an invalid Use this when: You want to remove a single name from a multi-name import.
Don't use this when: You want to remove the entire import line -> use
Example (Python): module="typing" name="List" Example (TS): module="./utils" name="bar" |
| add_parameterA | Add a parameter to a function signature at position 'end' (default) or 'start'. Leaves the body untouched. Use this when: You need to add one or two parameters without retyping the whole
signature.
Don't use this when: You need to replace the entire signature -> use
Example: target="LRUCache.get" parameter="default=None" position="end" |
| remove_parameterA | Remove a parameter by name from a function signature. Leaves the body untouched. Use this when: You need to remove one parameter without retyping the whole
signature.
Don't use this when: You need to replace the whole signature -> use
Example: target="LRUCache.get" parameter_name="default" |
| replace_docstringA | Replace or insert a Python docstring on a function or class. Python-only. The new_docstring should be a valid Python string literal including its surrounding triple quotes. Use this when: You want to add or update a Python docstring without touching
the function body.
Don't use this when: You're editing a Example: target="LRUCache.get" new_docstring=(triple-quoted string, e.g. with three double-quotes before and after the summary text) |
| find_referencesA | Return all occurrences of an identifier named Use this when: You're about to rename or refactor a symbol and need a quick survey of where it appears in the file. Don't use this when: You need cross-file or scope-aware analysis -> use a full language server. Example: target="LRUCache" |
| add_top_levelA | Insert top-level content into the file: a function, class, constant, type
alias, or any other top-level statement.
Use this when: You're adding any kind of top-level code. Use position="top"
when inserting multiple declarations at the top of a file without the
Example: content="def parse_version(text):\n return tuple(int(x) for x in text.split('.'))" content="class Logger:\n pass", position="top" content="MAX_CONNECTIONS = 10", position="top" |
| read_symbolA | Return source text for a single named symbol (function, class, method, config key) without reading the entire file. Read-only.
Use this when: You need to read a specific symbol without reading the
whole file. Pick the narrowest depth that contains what you need.
Don't use this when: You need a structural overview of the whole file
-> use Example: target="LRUCache.get" # full method source target="LRUCache", depth="interface" # class skeleton target="LRUCache.get", depth="signature" # just the def line target="project.version" # config value |
| read_importsA | Return all import statements in a source file as a multi-line string. Read-only. Use this when: You need to see a file's dependencies without reading the entire
file (e.g. before adding a new import, or to understand what a module uses).
Don't use this when: You want to add/remove imports -> use Example: file_path="/abs/path/to/module.py" |
| edit_leading_commentA | Edit the contiguous leading-comment block above a named symbol. One tool covering three operations on the same comment block. Supported values for
The comment must include the language's comment marker ( Use this when: You want to document, update, or delete a leading
comment on a function/class/method.
Don't use this when: You want a Python docstring (which lives inside
the function body) -> use Example: target="LRUCache.get", op="add", comment=" # Retrieve an item by key, returning None if absent" |
| insert_siblingA | Insert content as a sibling of a named symbol (function, class, method,
or top-level assignment). Pass Use this when: You need precise placement relative to another top-level
symbol -- e.g. a helper function immediately before its caller, a
constant immediately above the class that uses it.
Don't use this when: You just want to append to the end of the file ->
use Example: target="LRUCache" content="CACHE_SIZE = 100" position="before" |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
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/ast-editor'
If you have feedback or need assistance with the MCP directory API, please join our Discord server