Skip to main content

codebolt.search

Tools for searching files, code patterns, and discovering available MCP tools across the codebase.

Available Tools

  • glob - Finds files matching a glob pattern (e.g., **/*.ts, src/**/*.js)
  • grep - Searches for text patterns in files using grep-like functionality with regex support
  • search_files - Searches for content in files using regex patterns and returns matching lines
  • codebase_search - Performs semantic search across the codebase using natural language queries
  • search_mcp_tool - Searches for available MCP tools that can help with a specific task
  • list_code_definition_names - Lists code definitions (functions, classes, interfaces) in a file or directory

Tool Parameters

glob

ParameterTypeRequiredDescription
patternstringYesThe glob pattern to match files (e.g., **/*.ts, src/**/*.{js,jsx})
pathstringNoThe directory to search in. If not specified, searches from project root

grep

ParameterTypeRequiredDescription
pathstringYesThe absolute path to search within. Can be a file or directory
patternstringYesThe text pattern or regex to search for
includestringNoGlob pattern for files to include (e.g., *.ts, *.{js,jsx,ts,tsx})
excludestringNoGlob pattern for files/directories to exclude (e.g., 'node_modules/**')
case_sensitivebooleanNoWhether the search is case sensitive. Defaults to true

search_files

ParameterTypeRequiredDescription
pathstringYesThe absolute path to the directory to search within
regexstringYesThe regex pattern to search for in file contents
file_patternstringNoGlob pattern to filter which files to search. Defaults to all files

ParameterTypeRequiredDescription
querystringYesNatural language description of what you're looking for
target_directoriesarrayNoArray of directory paths to limit the search scope

search_mcp_tool

ParameterTypeRequiredDescription
querystringYesDescription of what you need a tool for
tagsarrayNoTags to filter results (e.g., ['database', 'api'])

list_code_definition_names

ParameterTypeRequiredDescription
pathstringYesThe absolute path to the file or directory to analyze for code definitions

Sample Usage

// Find files matching a glob pattern
const globResult = await codebolt.tools.executeTool(
"codebolt.search",
"glob",
{ pattern: "**/*.ts", path: "/project/src" }
);

// Find all test files
const testFilesResult = await codebolt.tools.executeTool(
"codebolt.search",
"glob",
{ pattern: "**/*.{spec,test}.{ts,js}" }
);

// Search for text patterns with grep
const grepResult = await codebolt.tools.executeTool(
"codebolt.search",
"grep",
{
path: "/project/src",
pattern: "function\\s+handleAuth",
include: "*.ts",
exclude: "node_modules/**",
case_sensitive: false
}
);

// Search for import statements
const importResult = await codebolt.tools.executeTool(
"codebolt.search",
"grep",
{
path: "/project/src",
pattern: "import.*from.*react",
include: "*.{ts,tsx}"
}
);

// Search files using regex
const searchResult = await codebolt.tools.executeTool(
"codebolt.search",
"search_files",
{
path: "/project/src",
regex: "TODO|FIXME|HACK",
file_pattern: "*.ts"
}
);

// Semantic search across the codebase
const semanticResult = await codebolt.tools.executeTool(
"codebolt.search",
"codebase_search",
{
query: "function that handles user authentication and token refresh",
target_directories: ["/project/src/auth", "/project/src/api"]
}
);

// Search for error handling patterns
const errorHandlingResult = await codebolt.tools.executeTool(
"codebolt.search",
"codebase_search",
{ query: "error handling for API requests with retry logic" }
);

// Search for available MCP tools
const mcpToolsResult = await codebolt.tools.executeTool(
"codebolt.search",
"search_mcp_tool",
{ query: "database query", tags: ["database", "sql"] }
);

// Find tools for file operations
const fileToolsResult = await codebolt.tools.executeTool(
"codebolt.search",
"search_mcp_tool",
{ query: "file conversion and manipulation" }
);

// List code definitions in a file
const definitionsResult = await codebolt.tools.executeTool(
"codebolt.search",
"list_code_definition_names",
{ path: "/project/src/utils/helpers.ts" }
);

// List definitions in a directory
const dirDefinitionsResult = await codebolt.tools.executeTool(
"codebolt.search",
"list_code_definition_names",
{ path: "/project/src/components" }
);
info

The search tools provide multiple strategies for finding code and files: use glob for file name patterns, grep for literal or regex text search, search_files for regex content search with file filtering, codebase_search for semantic/natural language queries, search_mcp_tool to discover available tools, and list_code_definition_names to understand code structure without reading full file contents.