Skip to main content
Glama

code_search

Read-onlyIdempotent

Retrieve relevant code snippets from the local index with file:start-end references, using hybrid keyword/embedding ranking and graceful fallback to keyword-only.

Instructions

Search the local project index built by code_index and get the most relevant windows back with file:start-end references — cheaper and more targeted than grepping or reading whole files. Ranking is hybrid: SQLite FTS5 keyword (BM25) plus embeddings when an embed host answers, fused by reciprocal rank. When no host answers it degrades to keyword-only with a degraded note instead of failing. Optional rerank=true reorders the top hits with a small chat model (ASK_FABLE_EMBED_RERANK_MODEL); skipped with a note when unset or unreachable. Returns not_indexed until code_index has run.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNoMaximum hits to return (default 8, max 50).
queryYesNatural-language or code search query.
rerankNoReorder the top hits with the chat model in `ASK_FABLE_EMBED_RERANK_MODEL` (opt-in; skipped with a note when unset or unreachable).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.16.0

TDQS

A4.5/5.0
Behavior5/5

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

Annotations already mark it readOnly/idempotent/non-destructive, and the description goes well beyond them: hybrid FTS5+embedding ranking, reciprocal-rank fusion, keyword-only degradation with a degraded note, opt-in rerank behavior, and pre-index behavior. No contradiction with annotations.

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?

Four dense sentences, front-loaded with the core behavior and then moving to ranking, degradation, rerank, and prerequisite. No filler; each sentence adds operational information.

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 tool with no output schema, it covers the return format (window references), the ranking/behavior nuances, the optional rerank, and the not-indexed precondition. There is no obvious missing detail an agent needs to decide or invoke correctly.

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 describes all three parameters with defaults, max, and behavior for rerank, so the description adds little param-level meaning beyond 'natural-language or code search query' already in schema. It enriches context on output and ranking, not on the parameters themselves.

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 ('Search') and resource ('local project index built by code_index'), and specifies the output form ('windows ... with file:start-end references'). It also distinguishes itself from cruder alternatives ('cheaper and more targeted than grepping or reading whole files'), which positions it clearly among the toolset.

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?

Gives clear when-to-use context: it is the targeted way to query the local code index, cheaper than grepping or reading whole files, and depends on code_index having run ('Returns not_indexed until code_index has run'). It does not explicitly enumerate exclusions against sibling ask/context tools, but the context is strong enough.

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