Skip to content

Commit 605af23

Browse files
author
Dimitar Grigorov
committed
Updated comments
1 parent 8718d93 commit 605af23

File tree

4 files changed

+33
-221
lines changed

4 files changed

+33
-221
lines changed

TOOLS.md

Lines changed: 9 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -203,111 +203,40 @@ Get a recursive tree view as JSON. **Use `tree` instead for 85% fewer tokens.**
203203

204204
### get_file_info
205205

206-
Get detailed metadata about a file or directory.
206+
Get metadata about a file or directory (size, timestamps, permissions).
207207

208208
**Parameters:**
209209
- `path` (required): Path to file or directory
210210

211-
**Response:**
212-
```json
213-
{
214-
"size": 1234,
215-
"created": "2024-01-15T10:30:00Z",
216-
"modified": "2024-01-15T10:30:00Z",
217-
"accessed": "2024-01-15T10:30:00Z",
218-
"isDirectory": false,
219-
"isFile": true,
220-
"permissions": "rw-r--r--"
221-
}
222-
```
223-
224211
### create_directory
225212

226-
Create a directory recursively (like `mkdir -p`). Succeeds silently if directory already exists.
213+
Create a directory recursively (like `mkdir -p`). Succeeds if already exists.
227214

228215
**Parameters:**
229216
- `path` (required): Path to directory to create
230217

231-
**Example:**
232-
```json
233-
{
234-
"path": "/path/to/project/new/nested/dir"
235-
}
236-
```
237-
238-
**Response:**
239-
```json
240-
{
241-
"message": "Directory created: /path/to/project/new/nested/dir"
242-
}
243-
```
244-
245218
### move_file
246219

247-
Move or rename files and directories. Can move between directories and rename in a single operation. Fails if destination already exists.
220+
Move or rename files and directories. Fails if destination exists.
248221

249222
**Parameters:**
250-
- `source` (required): Path to file or directory to move
223+
- `source` (required): Path to move
251224
- `destination` (required): Destination path
252225

253-
**Example:**
254-
```json
255-
{
256-
"source": "/path/to/old_name.txt",
257-
"destination": "/path/to/new_location/new_name.txt"
258-
}
259-
```
260-
261-
**Response:**
262-
```json
263-
{
264-
"message": "Moved /path/to/old_name.txt to /path/to/new_location/new_name.txt"
265-
}
266-
```
267-
268226
### copy_file
269227

270-
Copy a file to a new location. Fails if destination already exists. Only copies files, not directories.
228+
Copy a file. Fails if destination exists. Does not copy directories.
271229

272230
**Parameters:**
273-
- `source` (required): Path to the file to copy
231+
- `source` (required): Source file path
274232
- `destination` (required): Destination path
275233

276-
**Example:**
277-
```json
278-
{
279-
"source": "/path/to/original.txt",
280-
"destination": "/path/to/backup/original_copy.txt"
281-
}
282-
```
283-
284-
**Response:**
285-
```json
286-
{
287-
"message": "Successfully copied /path/to/original.txt to /path/to/backup/original_copy.txt"
288-
}
289-
```
290-
291234
### delete_file
292235

293236
Delete a file. Does not delete directories.
294237

295238
**Parameters:**
296-
- `path` (required): Path to the file to delete
297-
298-
**Example:**
299-
```json
300-
{
301-
"path": "/path/to/file_to_delete.txt"
302-
}
303-
```
304-
305-
**Response:**
306-
```json
307-
{
308-
"message": "Successfully deleted /path/to/file_to_delete.txt"
309-
}
310-
```
239+
- `path` (required): Path to delete
311240

312241
### search_files
313242

@@ -476,36 +405,11 @@ Detect line ending style (CRLF/LF/mixed) and find lines with inconsistent ending
476405

477406
### list_encodings
478407

479-
Returns all supported encodings with metadata.
480-
481-
**Parameters:** None
482-
483-
**Response:**
484-
```json
485-
{
486-
"encodings": [
487-
{
488-
"name": "windows-1251",
489-
"displayName": "Windows-1251",
490-
"aliases": ["cp1251"],
491-
"description": "Windows Cyrillic"
492-
}
493-
]
494-
}
495-
```
408+
Returns all 20 supported encodings with name, aliases, and description.
496409

497410
### list_allowed_directories
498411

499-
Returns directories the server is allowed to access.
500-
501-
**Parameters:** None
502-
503-
**Response:**
504-
```json
505-
{
506-
"directories": ["/home/user/projects", "/var/data"]
507-
}
508-
```
412+
Returns directories the server is allowed to access. If empty, add paths as args in config.
509413

510414
## Supported Encodings
511415

filetoolsserver/handler/read.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,34 @@ type encodingResult struct {
2121
autoDetected bool
2222
}
2323

24-
// HandleReadTextFile reads a file and returns UTF-8 content.
25-
// Auto-detects encoding if not specified. Supports offset/limit for line ranges.
2624
func (h *Handler) HandleReadTextFile(ctx context.Context, req *mcp.CallToolRequest, input ReadTextFileInput) (*mcp.CallToolResult, ReadTextFileOutput, error) {
2725
v := h.ValidatePath(input.Path)
2826
if !v.Ok() {
2927
return v.Result, ReadTextFileOutput{}, nil
3028
}
3129

32-
// Check file size - warn if large file will be loaded to memory
3330
if loadToMemory, size := h.shouldLoadEntireFile(v.Path); !loadToMemory {
3431
slog.Warn("loading large file into memory", "path", input.Path, "size", size, "threshold", h.config.MaxFileSize)
3532
}
3633

37-
// Resolve encoding (detection mode based on file size vs MaxFileSize threshold)
3834
encResult, err := h.resolveEncoding(input.Encoding, v.Path)
3935
if err != nil {
4036
return errorResult(err.Error()), ReadTextFileOutput{}, nil
4137
}
4238

43-
// Read file content
4439
data, err := os.ReadFile(v.Path)
4540
if err != nil {
4641
return errorResult(fmt.Sprintf("failed to read file: %v", err)), ReadTextFileOutput{}, nil
4742
}
4843

49-
// Decode content to UTF-8
5044
content, err := decodeContent(data, encResult)
5145
if err != nil {
5246
return errorResult(fmt.Sprintf("failed to decode file content: %v", err)), ReadTextFileOutput{}, nil
5347
}
5448

55-
// Count total lines
5649
lines := strings.Split(content, "\n")
5750
totalLines := len(lines)
5851

59-
// Apply line selection (offset/limit)
6052
var startLine, endLine int
6153
if input.Offset != nil || input.Limit != nil {
6254
content, startLine, endLine = applyOffsetLimit(lines, input.Offset, input.Limit)
@@ -66,7 +58,6 @@ func (h *Handler) HandleReadTextFile(ctx context.Context, req *mcp.CallToolReque
6658
endLine = totalLines
6759
}
6860

69-
// Build output
7061
output := ReadTextFileOutput{
7162
Content: content,
7263
TotalLines: totalLines,

0 commit comments

Comments
 (0)