Search Code MCP
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Unified code search, symbol lookup, and structural AST refactoring server powered by ripgrep and ast-grep. If the 'search-code' skill is available in your agent environment, load it first for ast-grep syntax rules, YAML constraints, and non-obvious engine behaviors. Key usage rules:
Use 'search' with type='text' for exact strings, 'regex' (default) for patterns, 'ast'/'ast_rule' for syntax-aware queries, and 'hybrid' for AST queries on large repositories.
Use 'find_symbols' to locate definitions or get a file outline (pass a file path with name='').
In ast-grep patterns, use $NAME for a single AST node and $$$ARGS for zero or more nodes (there is no $$ syntax). Always pass 'language' when running AST queries on a directory.
Call 'dump_tree' (format='ast' or 'pattern') before writing complex 'ast_rule' YAML queries when unsure of Tree-sitter node kinds.
IMPORTANT: 'replace' defaults to type='ast' (unlike 'search' and 'count' which default to 'regex'). Keep dryRun=true first to inspect the unified diff before setting dryRun=false.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| searchA | 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. |
| replaceA | Refactor or replace code using structural AST rewrites ('ast', DEFAULT) or regex/literal matching ('regex', 'text'). Runs in dryRun=true by default to return a unified diff preview without modifying files; inspect the diff first, then re-run with dryRun=false to write changes. Capped at maxReplacements (default 50) matches per call. Note: 'regex' mode uses ripgrep for discovery and JavaScript RegExp for replacement. |
| countA | Count matching lines or occurrences of a regex, literal text, or AST pattern without returning match content. Use before 'search' or 'replace' to gauge blast radius and save context tokens. |
| dump_treeA | Inspect the Tree-sitter syntax tree of a short code snippet or pattern via ast-grep. Call this BEFORE writing 'ast_rule' YAML queries (use format='ast' to discover exact node 'kind' names) or when debugging why an 'ast' pattern didn't match (use format='pattern'). |
| find_symbolsA | Locate symbol definitions (functions, classes, interfaces, methods, types, variables, structs, enums, traits, modules) with filtering by 'kinds' and 'exactMatch'. Pass a single file as 'path' with empty 'name' to get a full symbol outline without reading the whole file. |
| list_filesA | Fast file enumeration matching glob patterns or file types without scanning file contents. Respects .gitignore and excludes hidden files by default. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 6 tools
Each tool has a clearly distinct role: search retrieves matches, count only tallies them, find_symbols returns structured symbol data, list_files enumerates files, dump_tree inspects ASTs, and replace modifies code. The descriptions explicitly guide when to prefer find_symbols or count over search, removing the main potential overlap.
All names are snake_case and action-oriented, but the pattern mixes bare verbs (search, replace, count) with verb_noun forms (dump_tree, find_symbols, list_files). This is a minor stylistic deviation rather than a confusing inconsistency.
Six tools is well-scoped for a code search and refactoring server, with each tool covering a distinct operation. There are no redundant or filler tools.
The surface covers discovery (list_files, search, count, find_symbols), AST inspection (dump_tree), and modification (replace) with dry-run previews. No obvious lifecycle gaps remain for a code search/refactor domain.