|
| 1 | +# Filesystem Tools |
| 2 | + |
| 3 | +The Context Generator MCP server includes a comprehensive set of filesystem tools that allow Claude to directly interact |
| 4 | +with your project files. These tools enable powerful AI-assisted development workflows and make it easy to analyze, |
| 5 | +modify, and create files without leaving your conversation. |
| 6 | + |
| 7 | +## Available Tools |
| 8 | + |
| 9 | +### file-read |
| 10 | + |
| 11 | +Reads content from a file with encoding support. |
| 12 | + |
| 13 | +**Parameters:** |
| 14 | + |
| 15 | +- `path` (required): Path to the file to read |
| 16 | +- `encoding` (optional): File encoding (default: utf-8) |
| 17 | + |
| 18 | +**Example:** |
| 19 | + |
| 20 | +```json |
| 21 | +{ |
| 22 | + "path": "src/ExampleClass.php" |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +**Response:** |
| 27 | +Returns the content of the file as text. |
| 28 | + |
| 29 | +### file-write |
| 30 | + |
| 31 | +Writes content to a file with optional directory creation. |
| 32 | + |
| 33 | +**Parameters:** |
| 34 | + |
| 35 | +- `path` (required): Relative path to the file (e.g., "src/file.txt") |
| 36 | +- `content` (required): Content to write to the file |
| 37 | +- `createDirectory` (optional): Create directory if it doesn't exist (default: true) |
| 38 | + |
| 39 | +**Example:** |
| 40 | + |
| 41 | +```json |
| 42 | +{ |
| 43 | + "path": "src/utils/Helper.php", |
| 44 | + "content": "<?php\n\ndeclare(strict_types=1);\n\nclass Helper\n{\n // Class implementation\n}" |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +**Response:** |
| 49 | +Returns a success message with the number of bytes written. |
| 50 | + |
| 51 | +### file-rename |
| 52 | + |
| 53 | +Renames a file or directory. |
| 54 | + |
| 55 | +**Parameters:** |
| 56 | + |
| 57 | +- `path` (required): Current relative path |
| 58 | +- `newPath` (required): New relative path |
| 59 | + |
| 60 | +**Example:** |
| 61 | + |
| 62 | +```json |
| 63 | +{ |
| 64 | + "path": "src/OldName.php", |
| 65 | + "newPath": "src/NewName.php" |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +**Response:** |
| 70 | +Returns a success message confirming the rename operation. |
| 71 | + |
| 72 | +### file-move |
| 73 | + |
| 74 | +Moves a file to a different location with optional directory creation. |
| 75 | + |
| 76 | +**Parameters:** |
| 77 | + |
| 78 | +- `source` (required): Source relative path |
| 79 | +- `destination` (required): Destination relative path |
| 80 | +- `createDirectory` (optional): Create destination directory if it doesn't exist (default: true) |
| 81 | + |
| 82 | +**Example:** |
| 83 | + |
| 84 | +```json |
| 85 | +{ |
| 86 | + "source": "src/utils/Helper.php", |
| 87 | + "destination": "src/helpers/UtilityHelper.php" |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +**Response:** |
| 92 | +Returns a success message confirming the move operation. |
| 93 | + |
| 94 | +### file-info |
| 95 | + |
| 96 | +Gets detailed information about a file or directory. |
| 97 | + |
| 98 | +**Parameters:** |
| 99 | + |
| 100 | +- `path` (required): Path to the file or directory |
| 101 | + |
| 102 | +**Example:** |
| 103 | + |
| 104 | +```json |
| 105 | +{ |
| 106 | + "path": "src/ExampleClass.php" |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +**Response:** |
| 111 | +Returns detailed information about the file or directory in JSON format: |
| 112 | + |
| 113 | +```json |
| 114 | +{ |
| 115 | + "path": "src/ExampleClass.php", |
| 116 | + "exists": true, |
| 117 | + "type": "file", |
| 118 | + "size": 1024, |
| 119 | + "permissions": "644", |
| 120 | + "lastModified": "2023-04-12 15:30:42" |
| 121 | +} |
| 122 | +``` |
| 123 | + |
| 124 | +For directories, it also includes the list of files and subdirectories. |
| 125 | + |
| 126 | +## Use Cases |
| 127 | + |
| 128 | +### Code Analysis and Modification |
| 129 | + |
| 130 | +Claude can read existing files, analyze them, and suggest modifications or improvements. For example: |
| 131 | + |
| 132 | +1. Read a class file to understand its structure |
| 133 | +2. Analyze dependencies and relationships |
| 134 | +3. Suggest refactoring or optimization |
| 135 | +4. Write the modified version back to the file |
| 136 | + |
| 137 | +### Code Generation |
| 138 | + |
| 139 | +Claude can generate new files based on your requirements and project context: |
| 140 | + |
| 141 | +1. Understand your project structure using context tools |
| 142 | +2. Generate new classes, interfaces, or utility functions |
| 143 | +3. Write the generated code to appropriate locations |
| 144 | +4. Create necessary directories if they don't exist |
| 145 | + |
| 146 | +### Project Exploration |
| 147 | + |
| 148 | +Claude can explore your project structure to better understand its organization: |
| 149 | + |
| 150 | +1. Get information about directories to understand the project layout |
| 151 | +2. Examine specific files to understand their purpose and functionality |
| 152 | +3. Build a mental model of your codebase to provide more relevant assistance |
| 153 | + |
| 154 | +### Refactoring and Reorganization |
| 155 | + |
| 156 | +Claude can assist with refactoring and reorganizing your project: |
| 157 | + |
| 158 | +1. Rename files to follow naming conventions |
| 159 | +2. Move files to more appropriate locations |
| 160 | +3. Create new directory structures for better organization |
| 161 | +4. Update file content to reflect the new structure |
0 commit comments