Skip to main content
Glama
Search Code MCP

Search Code MCP

by joutvhu

Search Code

search
Read-onlyIdempotent

Find code matches across files using regex, literal text, or AST patterns; returns paginated results and supports hybrid filtering for large codebases.

Instructions

Search code across files using ripgrep ('regex' default, 'text'), ast-grep ('ast' pattern, 'ast_rule' YAML rule), or 'hybrid' (ripgrep pre-filter + ast-grep for large repos). Returns paginated results with a 'searchId' when total matches exceed 'limit'. Prefer 'find_symbols' when you want structured symbol tables or a single-file outline, and 'count' when you only need match counts.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "search"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathNoFile or directory to search in (relative to workspace root or absolute; default: '.')..
typeNoSearch mode: 'regex' (default, ripgrep regex), 'text' (exact literal match), 'ast' (structural AST pattern), 'ast_rule' (YAML rule with relational checks like inside/has/not), or 'hybrid' (ripgrep pre-filter + ast-grep for large repos).regex
limitNoMaximum matches to return per page (1-500, default: 50).
queryNoRequired for a new search (omit when using 'searchId'). Interpretation depends on 'type': PCRE2/Rust regex ('regex'), literal substring ('text'), ast-grep code pattern with $VAR / $$$ARGS ('ast'/'hybrid'), or YAML rule with id/language/rule ('ast_rule').
offsetNo1-based starting match index for pagination (default: 1).
contextNo[regex/text only] Number of context lines before and after each match (0-20).
languageNo[ast/hybrid only] Target language (e.g. 'typescript', 'tsx', 'javascript', 'python', 'rust', 'go', 'java'). Auto-detected from extension when 'path' is a single file; pass explicitly when searching a directory to avoid multi-language ambiguity.
noIgnoreNoIf true, also search files ignored by .gitignore. Default: false (respects .gitignore).
searchIdNoPagination ID (e.g. 's_a1b2c3d4') returned by a previous search when results exceeded 'limit'. When provided, omit 'query' and pass 'offset'/'limit' to read cached results instantly.
multilineNo[regex/text only] Allow pattern to match across multiple lines.
wordMatchNo[regex/text] Match whole words only.
filePatternNoGlob pattern(s) to include, comma-separated, e.g. '*.{ts,tsx}' or 'src/**/*.py'.
outputFormatNoOutput format: 'content' (default, file:line + full match text), 'compact' (file:line: first-line snippet), 'files_only' (unique file paths), 'json' (structured JSON).content
caseSensitiveNo[regex/text/hybrid] Force case-sensitive (true) or case-insensitive (false). Omitting uses smart-case (insensitive unless query has uppercase).
includeHiddenNoInclude hidden dotfiles and dot-directories (excludes .git unless noIgnore is true).
excludePatternNoComma-separated glob patterns to exclude, e.g. '**/dist/**,**/*.test.ts'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed28 schema fields changedv1.1.0
    • changedInput schema / properties / caseSensitive / description
      Previous value: -"Match case sensitively. If omitted, smart-case is used"New value: +"[regex/text/hybrid] Force case-sensitive (true) or case-insensitive (false). Omitting uses smart-case (insensitive unless query has uppercase)."
    • changedInput schema / properties / context / description
      Previous value: -"Number of context lines before and after match (-C)"New value: +"[regex/text only] Number of context lines before and after each match (0-20)."
    • addedInput schema / properties / context / maximum
      Added value: +20
    • addedInput schema / properties / context / minimum
      Added value: +0
    • changedInput schema / properties / context / type
      Previous value: -"number"New value: +"integer"
    • changedInput schema / properties / excludePattern / description
      Previous value: -"Pattern to exclude, e.g. '**/dist/**', '**/*.spec.ts'"New value: +"Comma-separated glob patterns to exclude, e.g. '**/dist/**,**/*.test.ts'."
    • changedInput schema / properties / filePattern / description
      Previous value: -"Glob pattern to filter files, e.g. '*.{ts,tsx}' or '!**/*.test.ts'"New value: +"Glob pattern(s) to include, comma-separated, e.g. '*.{ts,tsx}' or 'src/**/*.py'."
    • removedInput schema / properties / fileType
      Removed value: -{
      -  "description": "Ripgrep file type filter, e.g. 'ts', 'py', 'rust', 'json'",
      -  "type": "string"
      -}
    • changedInput schema / properties / includeHidden / description
      Previous value: -"Search hidden files and folders (-.)"New value: +"Include hidden dotfiles and dot-directories (excludes .git unless noIgnore is true)."
    • changedInput schema / properties / language / description
      Previous value: -"Target language (e.g. 'typescript', 'python'). If omitted, auto-detected from file extension"New value: +"[ast/hybrid only] Target language (e.g. 'typescript', 'tsx', 'javascript', 'python', 'rust', 'go', 'java'). Auto-detected from extension when 'path' is a single file; pass explicitly when searching a directory to avoid multi-language ambiguity."
    • changedInput schema / properties / limit / description
      Previous value: -"Maximum matches to return for this chunk (default: 50)"New value: +"Maximum matches to return per page (1-500, default: 50)."
    • addedInput schema / properties / limit / maximum
      Added value: +500
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • changedInput schema / properties / limit / type
      Previous value: -"number"New value: +"integer"
    • removedInput schema / properties / maxLineLength
      Removed value: -{
      -  "default": 500,
      -  "description": "Max characters per line before truncating long lines (default: 500)",
      -  "type": "number"
      -}
    • changedInput schema / properties / multiline / description
      Previous value: -"Match regex across multiple lines (-U)"New value: +"[regex/text only] Allow pattern to match across multiple lines."
    • changedInput schema / properties / noIgnore / description
      Previous value: -"If true, do NOT respect .gitignore (search ignored files). Default is false (respects .gitignore)"New value: +"If true, also search files ignored by .gitignore. Default: false (respects .gitignore)."
    • changedInput schema / properties / offset / description
      Previous value: -"Starting index for pagination (1-based, default: 1)"New value: +"1-based starting match index for pagination (default: 1)."
    • addedInput schema / properties / offset / maximum
      Added value: +9007199254740991
    • addedInput schema / properties / offset / minimum
      Added value: +1
    • changedInput schema / properties / offset / type
      Previous value: -"number"New value: +"integer"
    • changedInput schema / properties / outputFormat / description
      Previous value: -"Output format: 'content' (default), 'compact' (file:line only), 'files_only', 'json'"New value: +"Output format: 'content' (default, file:line + full match text), 'compact' (file:line: first-line snippet), 'files_only' (unique file paths), 'json' (structured JSON)."
    • changedInput schema / properties / path / description
      Previous value: -"Directory or file to search in. Accepts relative or absolute paths (default: '.')"New value: +"File or directory to search in (relative to workspace root or absolute; default: '.')."
    • changedInput schema / properties / query / description
      Previous value: -"Search query: plain text, regex, AST pattern, or YAML rule"New value: +"Required for a new search (omit when using 'searchId'). Interpretation depends on 'type': PCRE2/Rust regex ('regex'), literal substring ('text'), ast-grep code pattern with $VAR / $$$ARGS ('ast'/'hybrid'), or YAML rule with id/language/rule ('ast_rule')."
    • changedInput schema / properties / searchId / description
      Previous value: -"Previous search result ID to view remaining results instantly without re-scanning"New value: +"Pagination ID (e.g. 's_a1b2c3d4') returned by a previous search when results exceeded 'limit'. When provided, omit 'query' and pass 'offset'/'limit' to read cached results instantly."
    • changedInput schema / properties / type / description
      Previous value: -"Search engine/type: 'regex' (default), 'text', 'ast', 'ast_rule', 'hybrid', 'symbol'"New value: +"Search mode: 'regex' (default, ripgrep regex), 'text' (exact literal match), 'ast' (structural AST pattern), 'ast_rule' (YAML rule with relational checks like inside/has/not), or 'hybrid' (ripgrep pre-filter + ast-grep for large repos)."
    • changedInput schema / properties / type / enum
      Previous value: -[
      -  "regex",
      -  "text",
      -  "ast",
      -  "ast_rule",
      -  "hybrid",
      -  "symbol"
      -]New value: +[
      +  "regex",
      +  "text",
      +  "ast",
      +  "ast_rule",
      +  "hybrid"
      +]
    • changedInput schema / properties / wordMatch / description
      Previous value: -"Match whole words only (-w)"New value: +"[regex/text] Match whole words only."
  2. Changed1 schema field changedv1.0.2
    • changedInput schema / properties / path / description
      Previous value: -"Directory or file to search in (default: current directory '.')"New value: +"Directory or file to search in. Accepts relative or absolute paths (default: '.')"
  3. First observedv1.0.0

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already declare readOnly/idempotent/non-destructive, so the safety profile is covered. The description adds real behavioral context beyond that: results are paginated, a 'searchId' is emitted only when total matches exceed 'limit', and hybrid mode uses ripgrep as a pre-filter for large repos. It does not discuss performance limits or truncation behavior beyond pagination, so not a full 5.

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 purpose, then return behavior, then sibling routing. Every clause carries information; no filler or restatement of the title.

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 16-parameter tool with no output schema, the description supplies the parts the schema cannot: the engine-selection model, the pagination/searchId lifecycle, and the sibling alternatives. Remaining parameter detail is fully documented in the schema, so nothing essential is missing.

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?

Schema coverage is 100%, so the baseline is 3; the description still earns credit by explaining the mode architecture that ties 'type', 'query', 'language', and 'searchId' together — notably that 'searchId' replaces 'query' for cached pagination. This cross-parameter interaction is genuinely hard to infer from per-property descriptions alone.

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?

Opens with a specific verb+resource ('Search code across files') and immediately names the three execution engines (ripgrep, ast-grep, hybrid), so an agent knows exactly what the tool does and how it differs in mechanism. It also states the return contract (paginated results with 'searchId'), making the tool identifiable without opening the schema.

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?

Explicitly routes the agent: 'Prefer find_symbols when you want structured symbol tables or a single-file outline, and count when you only need match counts.' That is a named-alternative plus the condition selecting each, exactly the when-not guidance needed.

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

Deploy Server

Other Tools