Skip to main content
Glama

ctx_search

Read-only

Search project code by identifier or short query to get ranked, de-duplicated hits with paths, enclosing symbols and snippets under a token budget; use it instead of grep plus file reads.

Instructions

Ranked code search over the project (BM25 on identifier-split tokens; symbol names weigh most). Returns path:start-end, the enclosing symbol and a trimmed snippet for each hit, merged and de-duplicated, within budget_tokens. Use instead of grep + reading files. Expand a hit with ctx_symbol or ctx_read.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "ctx_search"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesWhat you are looking for: identifiers, or a short natural-language description.
path_globNoOnly files matching this glob, e.g. "src/**/*.ts" or "*.py".
max_resultsNoMost results to show (default 6).
budget_tokensNoHard cap on the tokens returned (estimate; default 1500).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only cover readOnly and closed-world, but the description discloses result shape (path:start-end, enclosing symbol, trimmed snippet), that hits are merged and de-duplicated, and that output is bounded by budget_tokens. For a tool with no output schema, this is the behavior an agent needs to plan token usage.

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?

Three sentences, front-loaded with what it does, then how to use it, then how to continue. Every clause carries distinct information; nothing is padded.

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?

No output schema exists, and the description still explains the return format and the budget cap, which is the main source of failure for search tools. Combined with usage routing to siblings, an agent can call this correctly without further context.

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 each parameter (query, path_glob, max_results, budget_tokens) is already documented, including the hard cap on budget_tokens. The description restates the token budget bound but adds no syntax or format details beyond the schema, so 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?

States a specific verb and resource (ranked code search over the project) plus the ranking mechanism (BM25 on identifier-split tokens with symbol names weighted highest), which separates it from a plain text grep and from sibling tools like ctx_read/ctx_symbol.

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?

"Use instead of grep + reading files" gives an explicit when-to-use, and "Expand a hit with ctx_symbol or ctx_read" names the follow-up path. Both the primary and downstream tools are named, so nothing is left to inference.

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