Filesystem Tools
CTX MCP server includes a comprehensive set of filesystem tools that allow Claude to directly interact with your project files. These tools enable powerful AI-assisted development workflows and make it easy to analyze, modify, and create files without leaving your conversation.
Available Tools
file-read
Reads content from a file with encoding support.
Parameters:
path
(required): Path to the file to readencoding
(optional): File encoding (default: utf-8)
Example:
{
"path": "src/ExampleClass.php"
}
Response: Returns the content of the file as text.
file-write
Writes content to a file with optional directory creation.
Parameters:
path
(required): Relative path to the file (e.g., "src/file.txt")content
(required): Content to write to the filecreateDirectory
(optional): Create directory if it doesn't exist (default: true)
Example:
{
"path": "src/utils/Helper.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nclass Helper\n{\n // Class implementation\n}"
}
Response: Returns a success message with the number of bytes written.
file-rename
Renames a file or directory.
Parameters:
path
(required): Current relative pathnewPath
(required): New relative path
Example:
{
"path": "src/OldName.php",
"newPath": "src/NewName.php"
}
Response: Returns a success message confirming the rename operation.
file-move
Moves a file to a different location with optional directory creation.
Parameters:
source
(required): Source relative pathdestination
(required): Destination relative pathcreateDirectory
(optional): Create destination directory if it doesn't exist (default: true)
Example:
{
"source": "src/utils/Helper.php",
"destination": "src/helpers/UtilityHelper.php"
}
Response: Returns a success message confirming the move operation.
file-info
Gets detailed information about a file or directory.
Parameters:
path
(required): Path to the file or directory
Example:
{
"path": "src/ExampleClass.php"
}
Response: Returns detailed information about the file or directory in JSON format:
{
"path": "src/ExampleClass.php",
"exists": true,
"type": "file",
"size": 1024,
"permissions": "644",
"lastModified": "2023-04-12 15:30:42"
}
For directories, it also includes the list of files and subdirectories.
Use Cases
Code Analysis and Modification
Claude can read existing files, analyze them, and suggest modifications or improvements. For example:
- Read a class file to understand its structure
- Analyze dependencies and relationships
- Suggest refactoring or optimization
- Write the modified version back to the file
Code Generation
Claude can generate new files based on your requirements and project context:
- Understand your project structure using context tools
- Generate new classes, interfaces, or utility functions
- Write the generated code to appropriate locations
- Create necessary directories if they don't exist
Project Exploration
Claude can explore your project structure to better understand its organization:
- Get information about directories to understand the project layout
- Examine specific files to understand their purpose and functionality
- Build a mental model of your codebase to provide more relevant assistance
Refactoring and Reorganization
Claude can assist with refactoring and reorganizing your project:
- Rename files to follow naming conventions
- Move files to more appropriate locations
- Create new directory structures for better organization
- Update file content to reflect the new structure