search_code
Search code patterns using regex to find functions, classes, methods, and declarations across your codebase with advanced filtering options.
Instructions
Search for code patterns using ripgrep (very fast). Supports regex patterns and advanced filtering.
PATTERN EXAMPLES:
Exact text: "functionName"
Multiple options: "\b(class|struct|record|interface|enum)\s+TypeName\b" (finds: class TypeName, record TypeName, interface TypeName, etc.)
Regex: "async.Promise<.>" (finds async functions returning Promise)
Any declaration: "\b(public|private|protected)\s+\w+\s+methodName"
COMMON USE CASES:
Find type declaration: "\b(class|struct|interface|record|enum)\s+TypeName\b"
Find method: "\b(public|private|protected|internal).\s+methodName\s\("
Find property: "\bpublic\s+\w+\s+propertyName\s*\{"
Find async methods: "async.*Task<"
Find implementations: ":\s*IInterfaceName\b"
TIPS:
Use \b for word boundaries
Use \s+ for whitespace
Combine alternatives with (opt1|opt2|opt3)
Escape special chars: \( \) \{ \}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | Regex pattern to search. For multiple alternatives use: (class|struct|interface) to match any | |
| path | No | Limit search to specific directory (e.g., 'src/components'). Omit to search entire workspace. | |
| filePattern | No | File glob pattern (ripgrep -g flag). Examples: '*.js', '*.{ts,tsx}', '!*test*' (exclude). Can specify multiple patterns separated by comma. | |
| caseInsensitive | No | Ignore case in search (ripgrep -i). Default: true for LLM-friendly searching | |
| contextLines | No | Lines of context before/after match (ripgrep -C) | |
| maxResults | No | Maximum number of results to return (per page). Default: 100. Configure via MCP_MAX_SEARCH_RESULTS env var. | |
| page | No | Page number for paginated results (1-based). Use to get more results beyond maxResults. | |
| literalString | No | Treat pattern as literal string, not regex (ripgrep -F) | |
| wordBoundary | No | Match whole words only (ripgrep -w) |