Skip to main content

codebolt.fs

File system operations for reading, writing, and managing files and directories.

Available Tools

  • read_file - Read contents of a file
  • write_file - Write content to a file
  • edit - Edit a file by replacing text
  • ls - List files and directories in a path
  • read_many_files - Read multiple files at once

Tool Parameters

read_file

Reads and returns the content of a specified file. If the file is large, the content will be truncated.

ParameterTypeRequiredDescription
absolute_pathstringYesThe absolute path to the file to read (e.g., '/home/user/project/file.txt'). Relative paths are not supported.
offsetnumberNoFor text files, the 0-based line number to start reading from. Use for paginating through large files.
limitnumberNoFor text files, maximum number of lines to read. Use with 'offset' to paginate through large files.

write_file

Creates a new file or overwrites an existing file with the provided content.

ParameterTypeRequiredDescription
absolute_pathstringYesThe absolute path to the file to write (e.g., '/home/user/project/file.txt'). Relative paths are not supported.
contentstringYesThe content to write to the file.

edit

Edits a file by replacing specified text with new text. The tool finds all occurrences of 'old_string' in the file and replaces them with 'new_string'.

ParameterTypeRequiredDescription
absolute_pathstringYesThe absolute path to the file to edit (e.g., '/home/user/project/file.txt').
old_stringstringYesThe exact text to find in the file. Must be unique enough to identify the correct location.
new_stringstringYesThe text to replace old_string with. Can be empty to delete the old text.
expected_occurrencesnumberNoThe expected number of times old_string appears. If specified and the actual count differs, the edit will fail.

ls

Lists files and directories in a specified path. Returns information about directory contents including file names, types, and optionally sizes.

ParameterTypeRequiredDescription
pathstringYesThe absolute path to the directory to list (e.g., '/home/user/project'). Relative paths are not supported.
ignorestring[]NoArray of glob patterns for files/directories to ignore (e.g., ['node_modules', '*.log']).
show_hiddenbooleanNoWhether to show hidden files and directories (those starting with a dot). Defaults to false.
detailedbooleanNoWhether to include detailed information like file sizes. Defaults to false.
limitnumberNoMaximum number of entries to return. Useful for large directories.

read_many_files

Reads multiple files at once based on file paths, directory paths, or glob patterns. Efficiently retrieves content from multiple files in a single operation.

ParameterTypeRequiredDescription
pathsstring[]YesAn array of file paths, directory paths, or glob patterns to read (e.g., ['/path/to/file.ts', '/path/to/dir', '**/*.json']).
includestring[]NoGlob patterns for files to include (e.g., ['.ts', '.tsx']).
excludestring[]NoGlob patterns for files/directories to exclude (e.g., ['*.test.ts', 'node_modules']).
recursivebooleanNoWhether to search recursively through subdirectories. Defaults to true.
use_default_excludesbooleanNoWhether to use default exclusion patterns (node_modules, .git, etc.). Defaults to true.
max_filesnumberNoMaximum number of files to read. Useful for limiting output size.
max_total_sizenumberNoMaximum total size of content to read in bytes.
include_metadatabooleanNoWhether to include file metadata (size, etc.) in output.

Sample Usage

// Read a file
const readResult = await codebolt.tools.executeTool(
"codebolt.fs",
"read_file",
{ absolute_path: "/home/user/project/README.md" }
);

// Read a file with pagination
const readPaginatedResult = await codebolt.tools.executeTool(
"codebolt.fs",
"read_file",
{
absolute_path: "/home/user/project/large-file.txt",
offset: 100,
limit: 50
}
);

// List files in a directory
const listResult = await codebolt.tools.executeTool(
"codebolt.fs",
"ls",
{
path: "/home/user/project",
show_hidden: false,
detailed: true
}
);

// Write to a file
const writeResult = await codebolt.tools.executeTool(
"codebolt.fs",
"write_file",
{
absolute_path: "/home/user/project/test-fs-mcp.txt",
content: "test content"
}
);

// Edit a file
const editResult = await codebolt.tools.executeTool(
"codebolt.fs",
"edit",
{
absolute_path: "/home/user/project/config.json",
old_string: '"version": "1.0.0"',
new_string: '"version": "1.1.0"',
expected_occurrences: 1
}
);

// Read multiple files
const readManyResult = await codebolt.tools.executeTool(
"codebolt.fs",
"read_many_files",
{
paths: ["/home/user/project/src"],
include: ["*.ts", "*.tsx"],
exclude: ["*.test.ts"],
recursive: true,
max_files: 10
}
);
info

This functionality provides file system operations through the MCP interface.