Skip to main content
Glama

rails_get_edit_context

Read-onlyIdempotent

Returns matching lines with surrounding code and line numbers so you can edit a specific method or section without reading the whole file. Use a file plus near text or line number to locate it.

Instructions

Get targeted code context for surgical edits: returns matching lines with surrounding code and line numbers. Use when: you need to edit a specific method or section without reading the entire file. Requires file:"app/models/user.rb" and near:"def activate" (or line:42) to locate the code region.

Input Schema

NameRequiredDescriptionDefault
fileYesFile path relative to Rails root (e.g. 'app/models/post.rb', 'app/controllers/posts_controller.rb').
lineNoShow context_lines either side of this line number instead of searching for `near` (e.g. a line from a stack trace).
nearNoWhat to find in the file - a method name, keyword, or string to locate (e.g. 'scope', 'def index', 'validates', 'STATUSES').
context_linesNoLines of context above and below the match. Default: 5.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv5.39.1

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint=false, so the safety profile is covered. The description adds value beyond that by disclosing the return format (matching lines plus line numbers) and the two locating strategies (near vs line). It does not say what happens when no match is found, which keeps it from a 5.

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?

Two sentences, front-loaded with the purpose and return shape, followed by the usage condition and required locator pattern. No filler or restatement of the tool name.

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?

With no output schema, the description carries the burden of describing returns and does so adequately (matching lines, surrounding code, line numbers). Minor gaps remain around no-match behavior and how context_lines interacts with near, but the schema covers the defaults.

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 coverage is 100%, so the baseline is 3, but the description goes further by showing concrete usage ('file:"app/models/user.rb" and near:"def activate" (or line:42)') and making the near/line alternative explicit. It adds real meaning about how the locator parameters combine.

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?

States a specific verb and resource ('Get targeted code context') and immediately specifies the return shape: matching lines with surrounding code and line numbers. It also implicitly distinguishes itself from the broader rails_get_context / rails_search_code siblings by framing the tool as a way to avoid 'reading the entire file'.

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?

The 'Use when: you need to edit a specific method or section without reading the entire file' clause gives a clear triggering condition. It stops short of naming alternatives such as rails_get_context or rails_search_code, so the agent must infer when to prefer those instead.

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