File search and analysis tools
glob
Fast file pattern matching tool that finds files by name and pattern.The glob pattern to match files against
The directory to search in (defaults to current working directory)
*matches any sequence of non-separator characters**matches any sequence of characters, including separators?matches any single non-separator character[...]matches any character in the brackets[!...]matches any character not in the brackets
- Results limited to 100 files (newest first)
- Hidden files (starting with
.) are skipped - Does not search file contents
grep
Fast content search tool that finds files containing specific text or regex patterns.The regex pattern to search for in file contents
The directory to search in (defaults to current working directory)
File pattern to include in search (e.g.,
"*.js", "*.{ts,tsx}")If true, pattern is treated as literal text with special regex characters escaped
- Results limited to 100 files (newest first)
- Hidden files are skipped
- Very large binary files may be skipped
ls
List directory contents with detailed information.The directory path to list (defaults to current working directory)
Array of glob patterns to ignore (e.g.,
["node_modules", "*.log"])- File/directory names
- File sizes
- Last modified timestamps
- File types (directory, file, symlink)
File operation tools
view
Read and display file contents with line numbers.The path to the file to read
Line number to start reading from (0-based)
Number of lines to read
- Displays line numbers for easy reference
- Can read specific sections using offset
- Automatically truncates very long lines (>2000 characters)
- Suggests similar file names when file not found
- Shows LSP diagnostics if available
- Maximum file size: 250KB
- Cannot display binary files or images
- Lines longer than 2000 characters are truncated
write
Create or overwrite files with new content.The path to the file to write
The content to write to the file
- Creates parent directories automatically
- Checks if file was modified since last read
- Tracks file history for session
- Avoids unnecessary writes when content unchanged
- Shows diff of changes
- Displays LSP diagnostics after write
- Success message with file path
- Diff showing additions/removals
- LSP diagnostics (errors, warnings)
edit
Edit files by replacing specific text sections.The absolute path to the file to modify
The text to replace (must be unique within the file)
The text to replace it with
Ensure uniqueness
The
old_string MUST uniquely identify the section to change:- Include 3-5 lines of context BEFORE the change point
- Include 3-5 lines of context AFTER the change point
- Match all whitespace and indentation exactly
- Returns error if
old_stringnot found - Returns error if
old_stringappears multiple times - Returns error if file modified since last read
- Returns error if file is a directory
patch
Apply multiple coordinated changes across multiple files in one operation.The full patch text describing all changes
- Atomic operation (all changes or none)
- Updates file history for all modified files
- Shows aggregated statistics
- Runs LSP diagnostics on all changed files
- All files being updated must be read first using
view - New files must not already exist
- Context lines must uniquely identify sections
- All paths must be absolute
- Number of files changed
- Total additions and removals
- LSP diagnostics for all modified files
System interaction tools
bash
Execute shell commands in a persistent shell session.The command to execute
Timeout in milliseconds (max 600000 / 10 minutes)
- All commands share the same shell session
- Environment variables persist between commands
- Current directory persists
- Virtual environments remain active
- File listing:
ls,pwd,df,du - Process info:
ps,top,uptime - Git read operations:
git status,git log,git diff,git show - Go commands:
go version,go list,go env
- Output exceeding 30,000 characters is truncated
- Both stdout and stderr are captured
- Exit codes are reported
- Execution time is tracked
diagnostics
Get LSP diagnostics (errors, warnings, hints) for files or the entire project.Path to file for diagnostics (leave empty for project-wide diagnostics)
- Error: Code will not compile/run
- Warning: Potential issues or bad practices
- Hint: Suggestions for improvement
- Info: Informational messages
- Automatically opens file if not already open
- Waits for LSP server to process file
- Groups diagnostics by severity
- Limits output to 10 diagnostics per category
- Shows source (e.g.,
typescript,gopls,rust-analyzer)
fetch
Fetch data from URLs (when MCP web-search tools are not available).The URL to fetch
Response format:
html, json, text, or markdownTimeout in milliseconds
- Fetching API documentation
- Reading online resources
- Accessing project documentation
For searching public code repositories, use the
sourcegraph tool instead.sourcegraph
Search code across public repositories using Sourcegraph.The search query
Number of results to return
Number of lines of context to show around matches
Timeout in milliseconds
- Finding implementation examples
- Researching API usage patterns
- Discovering best practices
- Learning from open source projects
Tool interaction patterns
Reading and modifying files
Multi-file refactoring
Debugging workflow
Permission model
All tools follow a consistent permission system:Safe read-only operations
Safe read-only operations
Auto-approved operations:
- Reading files with
view - Listing directories with
ls - Searching with
globandgrep - Getting diagnostics
- Safe read-only bash commands
Requires permission
Requires permission
Operations requiring user approval:
- Writing files with
write - Editing files with
edit - Applying patches with
patch - Executing commands with
bash(non-read-only) - Creating/deleting files
Session permissions
Session permissions
Grant permission for entire session:
- Press
Ain permission dialog - Permission persists until session ends
- Useful for iterative workflows
Best practices
Always read first
Use
view before edit or write to avoid conflicts and understand contextUse unique context
Include sufficient surrounding code in
edit operations to ensure uniquenessBatch operations
Use
patch for coordinated multi-file changes instead of sequential edit callsCheck diagnostics
Run
diagnostics after file modifications to catch errors earlyParallel tool calls
Send multiple independent tool calls in a single message for better performance
Use absolute paths
Always use absolute paths for file operations to avoid ambiguity