Skip to main content
Glama

search_code

Semantically search a codebase to find relevant code snippets with file paths and line numbers, reducing token usage by returning top matches instead of full files.

Instructions

Semantically search an indexed codebase for code relevant to a query.

Embeds the query and performs cosine similarity search against indexed
code chunks, returning the most semantically relevant snippets with
file paths and line numbers.

If the codebase is not yet indexed, it will be indexed automatically first.

Args:
    query: Natural language description of what you're looking for.
           E.g. "how does authentication work", "database connection setup"
    path: Absolute path to the codebase root directory.
    top_k: Number of results to return (default 8, max 20).
    min_score: Minimum cosine similarity score to include a result (default 0.35).
               Results below this threshold are filtered out as noise. Set to 0.0
               to disable filtering.

Returns:
    Formatted list of matching code chunks with file:line references and
    similarity scores.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
queryYes
top_kNo
min_scoreNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Install Server

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description fully carries the behavioral disclosure burden. It reveals the internal mechanism (embedding + cosine similarity), the auto-indexing side effect, and the min_score filtering behavior. This goes well beyond a simple verb phrase and gives the agent confidence about what happens when called.

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?

The description is well-structured with a purpose statement, a short mechanism note, a clear args list, and a returns line. Every sentence contributes necessary information, and the most important scoping detail (semantic vs. other search) is front-loaded.

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 tool's complexity, the description covers what it does, how it behaves when the index is missing, all parameter details, and the return format. An output schema exists for the return shape, so listing field details is unnecessary. No essential information for calling it correctly is missing.

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 description coverage is 0%, so the description must compensate, and it does thoroughly. Each of the four parameters is explained with type, default, and relevant examples or constraints (e.g., min_score semantics, max for top_k), adding significant meaning beyond the bare schema titles.

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 opens with a specific verb and resource: 'Semantically search an indexed codebase for code relevant to a query.' It clearly differentiates from sibling tools like search_graph or hybrid_search by explaining the embedding/cosine similarity mechanism, so an agent can tell what this tool uniquely does without opening a schema.

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?

The description gives clear context: use it for natural-language semantic search over code, and it even notes that auto-indexing happens if needed. It does not explicitly name alternative tools or state when not to use it, but the context is strong enough that an agent can infer appropriate usage.

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

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/VecGrep/vecgrep'

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