Skip to content

Claude Instructions

MCP Filesystem Ultra — Instructions for AI Agents

Section titled “MCP Filesystem Ultra — Instructions for AI Agents”

This document is designed to be included in AI agent system prompts or context. Copy this entire content to your AI’s custom instructions or memory.

You can also call get_help() at runtime to retrieve this information dynamically.


Before running search_files, ask the user if they know the file location:

Inefficient: "Let me search where X is..." [automatic search]
Efficient: "Do you know what file/line X is in? If not, I can search for it."

Only search when:

  • The user says they don’t know the location
  • The user explicitly requests “find X” or “search for X”
  • The user clearly does not have the information

Skipping unnecessary searches saves approximately 90% of tokens in cases where the user already knows the location.

For more detail, see guides/PREVENT_UNNECESSARY_SEARCHES.md.


Instead of reading through all documentation, call get_help at runtime:

get_help("overview") → Quick start guide
get_help("workflow") → The 4-step efficient workflow
get_help("tools") → Complete list of tools
get_help("edit") → Editing files
get_help("errors") → Common errors and fixes
get_help("examples") → Practical code examples
get_help("tips") → Efficiency tips

When mcp-filesystem-ultra tools are available, always prefer them over native file operations:

Use MCP tools:

read_file, write_file, edit_file, list_directory, search_files

Avoid native file operations:

  • Native file reading tools
  • Direct WSL commands for file operations
  • Any tool that does not handle /mnt/c/C:\ conversion

MCP tools automatically convert paths between WSL and Windows formats.


Inefficient — avoid this:

read_file(entire_large_file) → write_file(entire_large_file)
5000-line file = 250,000+ tokens

Efficient — prefer this:

search_files(file, pattern) → read_file(file, start_line, end_line) → edit_file(old, new)
5000-line file = approximately 2,000 tokens

ToolDescription
read_fileRead file (auto-optimizes for size, supports start_line/end_line)
write_fileAtomic write with auto path conversion
edit_fileSmart edit with backup, recovery, and path conversion (supports mode:"search_replace")
list_directoryCached directory listing
search_filesFile/content search (supports count_only:true)
ToolWhen to Use
edit_filePreferred — surgical text replacement
multi_editMultiple edits in one atomic operation
regex_transform_fileAdvanced regex transformations with capture groups
ToolWhen to Use
copy_fileDuplicate file/directory
move_fileMove or rename files
delete_fileDelete (soft-delete by default, permanent:true for hard delete)
get_file_infoFile metadata (size, date, etc.)
create_directoryCreate directory (with parents)
ToolWhen to Use
analyze_operationFile analysis, dry-run write/edit/delete, optimization suggestions
server_infoServer performance (action: “stats”)
ToolWhen to Use
batch_operationsMultiple operations atomically (also supports pipeline_json)
backupList, restore, compare, cleanup backups
ToolWhen to Use
wslCopy files between WSL/Windows, check status, configure auto-sync
ToolWhen to Use
server_infoHelp, performance stats, artifact capture

For any file edit, follow this sequence:

search_files(file, "function_name")
→ Returns: "Found at lines 45-67"
read_file(file, start_line=45, end_line=67)
→ Returns: Only those 22 lines
edit_file(file, "old_text", "new_text")
→ Returns: "OK: 1 changes"
server_info({ action: "stats" })
→ Goal: more than 80% targeted edits

Is file fewer than 1000 lines?
├── YES → read_file() is acceptable
└── NO → use search_files + read_file(start_line, end_line) + edit_file
Is file more than 5000 lines?
├── NO → standard workflow is fine
└── YES → never read the entire file

Cause: File changed since it was last read. Fix: Re-run search_files() + read_file() with start_line/end_line to get current content.

Cause: Text does not exist exactly as specified. Fix:

  1. Use search_files() to verify the location.
  2. Check for whitespace or indentation differences.
  3. Use search_files() with count_only:true to confirm the text exists.

Cause: Same text appears more than once. Fix: Use edit_file with mode:"search_replace" and occurrence parameter

  • 1 = first, 2 = second, -1 = last, -2 = second-to-last

Cause: create_file was previously an alias. Fix: Use write_file() — it creates files if they do not exist.

Cause: Path format mismatch. Fix: Use MCP tools — they convert paths automatically. Use read_file, write_file, etc.


TaskTool
Read a fileread_file
Read specific linesread_file with start_line/end_line (recommended)
Create a new filewrite_file
Edit text in a fileedit_file (recommended)
Make multiple editsmulti_edit (recommended)
Find where code issearch_files
Count occurrencessearch_files with count_only:true
List directorylist_directory
Copy or move filescopy_file, move_file
Delete safelydelete_file (soft-delete by default)
Multiple operationsbatch_operations
Check efficiencyserver_info with action “stats”

Example 1: Edit a function in a 5000-line file

Section titled “Example 1: Edit a function in a 5000-line file”

Inefficient approach (~250,000 tokens):

read_file("large.py") # 125,000 tokens
# ... process ...
write_file("large.py", all) # 125,000 tokens

Efficient approach (~2,500 tokens):

search_files("large.py", "def my_function") # 500 tokens
read_file("large.py", start_line=234, end_line=256) # 1,000 tokens
edit_file("large.py", "old", "new") # 500 tokens

Inefficient — 5 separate edit_file calls:

edit_file(path, old1, new1) # Read → Edit → Write
edit_file(path, old2, new2) # Read → Edit → Write (again)
edit_file(path, old3, new3) # Read → Edit → Write (again)
...

Efficient — 1 multi_edit call:

multi_edit(path, [
{"old_text": "old1", "new_text": "new1"},
{"old_text": "old2", "new_text": "new2"},
{"old_text": "old3", "new_text": "new3"}
])
# File read once, all edits applied, written once

All MCP tools handle path conversion automatically:

You provideTool converts to
/mnt/c/Users/John/file.txtC:\Users\John\file.txt (on Windows)
C:\Users\John\file.txt/mnt/c/Users/John/file.txt (on WSL)

  1. Prefer MCP filesystem tools over native file operations.
  2. Do not read entire large files — use read_file with start_line/end_line.
  3. Use edit_file instead of write_file for modifications.
  4. Use multi_edit for multiple changes in one file.
  5. Run search_files first to find exact locations.
  6. Check server_info with action “stats” to monitor efficiency.

Version: 3.13.2 | Last Updated: February 2026