Skip to main content
Glama

semantic_search

Describe the concept you need in natural language, and retrieve code symbols that match semantically, even without exact keywords.

Instructions

Read-only. Semantic search using pre-computed symbol embeddings.

Finds symbols conceptually related to a natural-language query, even when the query words don't appear literally in the code. Uses cosine similarity over 1024-dimensional embeddings generated during fw-context index.

When to prefer over search_code: When you're describing a concept rather than searching for a known keyword. Examples:

  • "parcel locker state" finds door-state and shipment methods even though "parcel" and "locker" don't appear in their names.

  • "cell modem" finds _socket_t and ModemMsg* classes.

  • "delivery box" finds set_shipment and get_zrtdata.

  • "power consumption" finds get_load_power and INA260 class.

When to prefer search_code instead: When you know the exact keyword or symbol name ("fram_write", "cbor encode"). FTS5 is faster and more precise for lexical matches.

Threshold guidance (mxbai-embed-large model):

  • 0.50 — exploratory: more results, lower precision

  • 0.55 — balanced (default, ~1000 results)

  • 0.60 — precise: ~175 avg, high precision

  • 0.65 — strict: few results, may miss relevant symbols

Source-aware ranking: Project code (src/) boosted 1.2×, library code (lib/) 1.1×, vendored SDK (mbed-os/) 0.85×.

Requires Ollama with an embedding model (mxbai-embed-large). Falls back to search_code with a warning if Ollama is unavailable.

Args: query: Natural language description of what you're looking for. Be specific — 5–15 words works best. project_root: Project root. Auto-detected if omitted. threshold: Minimum cosine similarity (0.0-1.0). Default 0.60. limit: Maximum number of results (default 20, max 100).

Returns: list of dicts, each with: name, qualified_name, kind, file, line, is_definition, signature, docstring, plus _similarity (cosine similarity score) and _method ("embedding" or "search_code_fallback").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum results (default 20, max 100).
queryYesNatural language description, 5-15 words. E.g. 'parcel locker state machine' or 'how does the modem connect?'.
thresholdNoMinimum cosine similarity (0.0-1.0). Default 0.60. Use 0.55 for exploratory, 0.50 for broad search.
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?

Even though annotations are absent, the description fully discloses behavioral traits: it's read-only, uses cosine similarity, applies source-aware boosting, requires Ollama with a fallback mechanism, and describes the return structure including additional fields like _similarity and _method.

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 clear sections (read-only, when to use, threshold guidance, source-aware ranking, fallback, parameters). It is front-loaded with the core purpose. However, it is somewhat lengthy; some threshold details could be abbreviated without losing clarity.

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?

Given the complexity of the tool (semantic search, embedding model, fallback, multiple parameters), the description covers all essential aspects: purpose, usage conditions, parameter details, return format, dependencies (Ollama), and source-aware ranking. No gaps remain for an AI agent to use it correctly.

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

Parameters5/5

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

Schema coverage is 100%, but the description adds significant value: it recommends query length (5-15 words), provides threshold usage guidance with specific values (0.50-0.65), explains the default and max limit, and clarifies that project_root is auto-detected.

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 immediately states 'Semantic search using pre-computed symbol embeddings' and explains it finds symbols conceptually related to a query, even without exact keyword match. It clearly distinguishes from the sibling tool search_code, providing multiple examples.

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?

It explicitly indicates when to use semantic_search (concept search) and when to prefer search_code (exact keyword), with concrete examples. Also provides threshold guidance for different precision levels and notes source-aware ranking.

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