Skip to main content
Glama

Code search (exact terms + meaning)

search

Query an indexed codebase using natural language or keywords. Get ranked code chunks with paths and line ranges to locate implementations, understand behavior, and prepare for changes.

Instructions

Semantic + keyword code search over the indexed repository - a strong default for finding and understanding code. Use it to: understand how a subsystem or feature works, find code by meaning when you don't know the exact name, locate the code behind a behaviour or bug, gather context before making a change, review existing implementations and patterns, find everything a refactor would touch, understand the architecture for feature work, or spot similar/duplicate code. One pass fuses exact keyword matching (BM25: identifiers, error strings, function names, stemmed and scored) with semantic similarity (renamed symbols, paraphrases, 'where is X handled'), so it works whether or not you know the words. Each hit carries path, line range, and the chunk content with a relevance score - treat it as authoritative and answer directly from it, citing path plus line range; you don't need to re-confirm a hit with grep or by opening the file. When one search isn't enough, refine the query and search again - the index has already ranked the relevant regions. Read a file only for a hit marked truncated (its cited start-end range via offset/limit), or when results genuinely don't cover the question. (Until the index's vector stage finishes, results are keyword-ranked and say so.) The result includes a 'usage' field - a one-line receipt (tokens returned, chunks/files, session total). After you answer, end your reply by showing that 'usage' line to the user verbatim.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNoMaximum hits.
pathNoAbsolute path to the repository root to search. Defaults to the server's configured root; set it to target a specific repo when a session spans more than one.
queryYesWhat you're looking for - terms, a phrase, or a description.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden and delivers richly: it discloses the BM25+semantic fusion behavior, the keyword-ranked fallback before the vector stage completes, the authoritative-hit contract (no need to re-confirm with grep), the truncated-hit edge case, and the 'usage' receipt the agent must show verbatim. This is unusually complete behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but earns its length: purpose is front-loaded, then use cases, behavior, hit handling, and the usage receipt follow in a sensible order. Every sentence adds operational value the agent needs. It is dense rather than padded, though the extended list of use cases could be trimmed without losing meaning.

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?

For a search tool with no output schema and no annotations, this description is genuinely complete: it covers what the tool does, when to use it, what each hit contains, how to treat results as authoritative, the truncated-hit exception, the index-state caveat, and the required usage-line display. Nothing an agent needs to invoke it correctly is missing.

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?

The input schema covers all 3 parameters at 100%, including query ('terms, a phrase, or a description'), k ('Maximum hits'), and path ('Absolute path to the repository root'). The description adds marginal value beyond the schema—it reiterates that queries may be paraphrases and that k caps hits—but the schema already carries the semantic weight, so the baseline 3 applies.

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 opening sentence ('Semantic + keyword code search over the indexed repository - a strong default for finding and understanding code') names a specific verb, resource, and primary use. It distinguishes itself from siblings sql and reindex by framing itself as the default discovery tool, and the extensive use-case list sharpens the scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

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

Provides explicit when-to-use guidance across eight distinct scenarios (understand a subsystem, find by meaning, locate code behind a bug, gather pre-change context, review patterns, refactor impact, architecture, duplicate detection). It also states when NOT to read files (only for truncated hits or when results don't cover the question), giving clear decision rules.

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

Deploy Server

Other Tools