Skip to main content
Glama

rails_search_code

Read-onlyIdempotent

Search a Rails codebase by method, class, or call site to trace definitions, callers, and internal calls in one query. Narrow results by path or file type.

Instructions

Search the Rails codebase with smart modes. Use match_type:"trace" to see where a method is defined, who calls it, and what it calls - in one call. Use match_type:"definition" for definitions only, "call" for call sites only, "class" for class/module definitions. Requires pattern:"method_name". Narrow with path:"app/models" and file_type:"rb".

Input Schema

NameRequiredDescriptionDefault
pathNoSubdirectory or file to search (e.g. 'app/models', 'config/routes.rb'). Default: entire app.
limitNoMax lines to return. Default: auto-sized so the page holds a useful number of matches. A limit too small for one match and its context still returns that match.
offsetNoSkip this many emitted lines for pagination. Default: 0.
patternYesSearch pattern (regex supported). For definition and class, a plain method or constant name matches literally (`valid?`), anything else as a regex (`generate_.*`).
file_typeNoFilter by file extension (e.g. 'rb', 'js', 'erb'). Default: all files.
match_typeNoany: all matches (default). definition: `def` lines whose method name contains the pattern. class: `class/module` lines whose name contains it. call: call sites only (excludes definitions). trace: FULL PICTURE - shows definition + source code + all callers + what it calls internally.
exact_matchNoMatch the pattern literally, whole-word where its edges are word characters. `def reblog?` will not match `def reblog`. Default: false.
context_linesNoLines of context before and after each match (like grep -C). Default: 2, max: 5.
exclude_testsNoExclude test/spec files from results. Default: false.
group_by_fileNoGroup results by file with match counts. Default: false.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv5.39.1

TDQS

A4/5.0
Behavior4/5

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

The annotations already establish read-only, idempotent, non-destructive behavior. The description adds useful behavioral context, especially that trace mode returns definitions, source, callers, and internal calls in one call, though it does not discuss pagination or result-shape details beyond that.

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 compact and front-loaded: purpose first, then mode selection, then required input and narrowing options. Every sentence contributes useful selection or invocation guidance.

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 rich annotations and full schema coverage, the description is largely complete for a read-only search tool. It could say more about general return behavior outside trace mode, but the critical invocation guidance is present.

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 all parameters are already documented in detail. The description reinforces required pattern usage and mode semantics, but adds little beyond the schema's own parameter descriptions.

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 states a specific verb and resource: search the Rails codebase. It clearly distinguishes search modes (trace, definition, call, class), but does not explicitly differentiate this tool from sibling tools such as rails_search_docs or rails_get_model_details.

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 explicit guidance on which match_type to use for definitions, call sites, class/module definitions, and full trace results. It also notes required pattern usage and path/file_type narrowing, though it does not compare usage against sibling search or retrieval tools.

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