Skip to main content
Glama

encapsulate_field

Encapsulate a class attribute into getter/setter methods, rewriting reads to the getter and writes to the setter across the project, with a dry-run preview.

Instructions

Encapsulate a class attribute behind getter/setter methods, rewriting reads to the getter and writes to the setter across the project. Point at the attribute name (0-based LSP line/character, UTF-16 units), exactly as your LSP returns it. getter_name and setter_name override the default get_/set_ names. Defaults to a Dry Run preview; set apply=true to write. Accesses that cannot be proven to be this attribute are reported as uncertain_occurrences, never silently rewritten. Supply expected_symbol when edits may have intervened since your LSP answer. Locate the attribute with your LSP first; this tool only changes code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
lineYes
rootNo
applyNo
characterYes
getter_nameNo
setter_nameNo
expected_symbolNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

With no annotations, the description fully discloses key behaviors: defaults to Dry Run, apply=true writes, uncertain accesses are reported as 'uncertain_occurrences' and never silently rewritten, and expected_symbol handles stale LSP answers. It also states the tool only changes code, setting accurate expectations for project-wide effects.

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?

The description is concise yet dense, with each sentence serving a purpose. It front-loads the primary function and then explains parameters, safety defaults, and usage prerequisites without irrelevant filler.

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 the tool's complexity (8 params, project-wide rewrites, LSP dependency, dry-run default), the description covers what the tool does, how to invoke it, what to expect (uncertain occurrences), and when to supply extra params. The output schema handles return details, so no further elaboration is needed.

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 coverage is 0%, so the description must explain parameters. It explains file/line/character as LSP coordinates (0-based, UTF-16), getter_name/setter_name overrides, apply=true, and expected_symbol. This adds substantial meaning beyond the bare schema, covering all essential params except root, which is inferable.

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 specifies a clear action: 'Encapsulate a class attribute behind getter/setter methods, rewriting reads to the getter and writes to the setter across the project.' This distinguishes it from sibling refactoring tools like rename or move, and includes the target resource (class attribute) and the specific transformation.

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?

Provides clear usage context: point at the attribute name with LSP coordinates, defaults to dry run, apply=true to write, and 'Locate the attribute with your LSP first; this tool only changes code.' It does not explicitly mention alternatives or exclusions versus siblings, but the context is clear enough for appropriate use.

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/andrewesweet/ropey'

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