Skip to main content
Glama

Search Code

search_code

Locate where a function, variable, string, or regex pattern appears across .js, .ts, .tsx, and .jsx files under a project directory.

Instructions

Searches for a text pattern (plain substring or regex) across all .js, .ts, .tsx, and .jsx files under a directory. Use this to find where a function, variable, string, or pattern is used in the codebase.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesText or regex pattern to search for.
directoryNoDirectory to search, relative to project root. Defaults to ".".

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the full disclosure burden. It usefully reveals the searched file extensions and that both plain substring and regex patterns are accepted, but says nothing about case sensitivity, ignore rules (node_modules, .git), result limits, or match/snippet format.

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 tight sentences, front-loaded with what is searched and scoped by file type, then the use case. No filler or redundancy.

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 two-parameter search tool with no output schema and no annotations, the description covers scope and pattern semantics but leaves out return-shape expectations and search behavior such as traversal/ignore rules. Adequate but with visible gaps an agent would want to know.

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 coverage is 100% and both parameters are described in the schema itself. The description's mention that the pattern may be "plain substring or regex" slightly enriches the schema's "Text or regex pattern" but adds no syntax or format detail, so the baseline 3 holds.

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 (searches) and resource (a text pattern across .js/.ts/.tsx/.jsx files), which implicitly separates it from read_project_file and list_project_structure. It does not name any sibling explicitly, so the differentiation is inferred from the file-type scope 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 Guidelines4/5

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

"Use this to find where a function, variable, string, or pattern is used in the codebase" gives a clear context for selecting this tool. There is no statement of when NOT to use it or which sibling to prefer for other read/inspection needs, so it stops short of full routing guidance.

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