Skip to main content
Glama

smart_search

Describe code functionality in natural language to search a pre-indexed symbol database. Translates queries, generates search terms, refines results, and re-ranks by semantic relevance, turning vague questions into precise code findings.

Instructions

Natural-language search: an LLM generates FTS5 keywords, then searches the libclang index. Finds concepts by meaning rather than exact text match. Prefer this when you don't know the exact keywords and want to describe what you're looking for ("how does the modem connect?", "handle BLE pairing failure").

Read-only. No side effects. Slow (10-30 s) — delegates to the full SMART_SEARCH pipeline (translate → rough_search → llm_query → fts5_search → refine → embedding → adaptive_fusion → deduplicate → expand_context → format).

Multi-phase approach:

  1. Translate non-English queries

  2. Rough search to gather sample symbols for naming conventions

  3. LLM sees those samples + query and generates FTS5 terms

  4. FTS5 search with generated terms

  5. Refine: LLM checks results and course-corrects query terms

  6. Semantic embedding search (cosine similarity re-rank)

  7. Deduplicate, score, and format results

When to prefer over search_code: When you don't know the exact keywords and want to describe what you're looking for ("how does the modem connect?", "handle BLE pairing failure").

Fallback: When LLM is unavailable, falls back to direct FTS5 search with word-split terms from the query.

Args: query: Natural language description of what you're looking for. Be specific — 5–15 words works best. project_root: Project root directory. Auto-detected from CWD if omitted. limit: Maximum number of results (default 20, max 100).

Returns: list of dicts with metadata entries (_generated_queries, _rough_queries, _translated_from) followed by symbol results with name, qualified_name, kind, file, line, is_definition, signature, docstring.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum results (default 20, max 100).
queryYesNatural language description, 5-15 words. E.g. 'how does the modem connect?' or 'handle BLE pairing failure'.
project_rootNoProject root. Auto-detected if omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
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 meets it thoroughly. It discloses read-only status ('Read-only. No side effects.'), performance characteristics ('Slow (10-30 s)'), the full multi-phase pipeline (translate → rough_search → ... → format), and fallback behavior ('When LLM is unavailable, falls back to direct FTS5 search'). This gives the agent complete expectations about side effects, latency, and internal behavior.

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 well-structured with a clear intro, a multi-phase breakdown, and a fallback note. It is longer than most, but each phase is informative and explains the internal behavior. There is some redundancy: the 'Prefer this when...' guidance appears twice (once in the intro, once in the 'When to prefer' section), which could be trimmed. Overall, it is organized and front-loaded with the most critical usage guidance.

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?

The description is fully self-contained for a complex tool. It covers purpose, usage criteria, performance, internal pipeline, fallback semantics, parameter guidance, and return format (metadata keys and symbol result fields). The output schema exists, but the description further explains what the returned list contains, making it complete even without inspecting the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already covers all three parameters with 100% coverage, so the baseline is 3. The description adds value beyond the schema by advising 'Be specific — 5–15 words works best' for the query, clarifying that project_root is 'Auto-detected from CWD if omitted,' and noting the limit default and maximum. These are practical usage nuances that help the agent craft better parameters.

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 description starts with 'Natural-language search: an LLM generates FTS5 keywords, then searches the libclang index' — a specific verb+resource statement. It clearly distinguishes itself from exact-text tools like search_code by noting it 'finds concepts by meaning rather than exact text match.' This makes the tool's purpose unmistakable.

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?

The description explicitly states 'Prefer this when you don't know the exact keywords and want to describe what you're looking for,' with concrete examples. It also has a dedicated 'When to prefer over search_code' section, naming the alternative and the exact condition for choosing this tool. This is exemplary when-to-use guidance.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/turbyho/fw-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server