Skip to main content
Glama

code-index-mcp

search_code_advanced

Search and analyze code patterns in projects using advanced CLI tools (e.g., ugrep, ripgrep). Supports regex, fuzzy matching, file filtering, and case-sensitive options for efficient code discovery.

Instructions

Search for a code pattern in the project using an advanced, fast tool.

This tool automatically selects the best available command-line search tool
(like ugrep, ripgrep, ag, or grep) for maximum performance.

Args:
    pattern: The search pattern. Can be literal text or regex (see regex parameter).
    case_sensitive: Whether the search should be case-sensitive.
    context_lines: Number of lines to show before and after the match.
    file_pattern: A glob pattern to filter files to search in
                 (e.g., "*.py", "*.js", "test_*.py").
                 All search tools now handle glob patterns consistently:
                 - ugrep: Uses glob patterns (*.py, *.{js,ts})
                 - ripgrep: Uses glob patterns (*.py, *.{js,ts})
                 - ag (Silver Searcher): Automatically converts globs to regex patterns
                 - grep: Basic glob pattern matching
                 All common glob patterns like "*.py", "test_*.js", "src/*.ts" are supported.
    fuzzy: If True, enables fuzzy/partial matching behavior varies by search tool:
           - ugrep: Native fuzzy search with --fuzzy flag (true edit-distance fuzzy search)
           - ripgrep, ag, grep, basic: Word boundary pattern matching (not true fuzzy search)
           IMPORTANT: Only ugrep provides true fuzzy search. Other tools use word boundary
           matching which allows partial matches at word boundaries.
           For exact literal matches, set fuzzy=False (default and recommended).
    regex: Controls regex pattern matching behavior:
           - If True, enables regex pattern matching
           - If False, forces literal string search
           - If None (default), automatically detects regex patterns and enables regex for patterns like "ERROR|WARN"
           The pattern will always be validated for safety to prevent ReDoS attacks.

Returns:
    A dictionary containing the search results or an error message.

Input Schema

NameRequiredDescriptionDefault
case_sensitiveNo
context_linesNo
file_patternNo
fuzzyNo
patternYes
regexNo

Input Schema (JSON Schema)

{ "properties": { "case_sensitive": { "default": true, "title": "Case Sensitive", "type": "boolean" }, "context_lines": { "default": 0, "title": "Context Lines", "type": "integer" }, "file_pattern": { "default": null, "title": "File Pattern", "type": "string" }, "fuzzy": { "default": false, "title": "Fuzzy", "type": "boolean" }, "pattern": { "title": "Pattern", "type": "string" }, "regex": { "default": null, "title": "Regex", "type": "boolean" } }, "required": [ "pattern" ], "title": "search_code_advancedArguments", "type": "object" }

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/johnhuang316/code-index-mcp'

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