You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1163104
Browse filesBrowse the repository at this point in the historyBrowse files
Reads a text file and returns its content with line numbers in the format "line_number: line_content". Default 2000 lines per call, capped at 50KB of output. Path must be absolute.
1
+
Reads a text file. Path must be absolute. Output is capped at 50KB.
2
2
IMPORTANT: Do NOT use read to search for content inside files. Use grep first to locate exact line numbers, then use offset+limit to read only the relevant section. Reading entire files to find content wastes context and is strongly discouraged.
3
-
- offset + limit: read a specific line range (e.g. offset=50 limit=40 reads lines 50–89).
4
-
- tail: efficiently read the last N lines (mutually exclusive with offset/limit).
- "byte": offset = 0-indexed start byte; limit = max bytes (capped at 50KB). Use this for tool-overflow spill files — the truncation marker gives exact byte ranges, plug them in directly.
7
+
- "endLine": offset = number of lines back from EOF where the read starts; defaults to limit. Pass just limit=N to read the last N lines.
8
+
- "endByte": offset = number of bytes back from EOF; defaults to limit. Pass just limit=N to read the last N bytes.
9
+
5
10
- Returns "Did you mean?" suggestions when the file is not found.
6
11
- Automatically detects and rejects binary files; use read_media_file for binary files.
7
12
- Use ls to list directory contents instead of reading a directory path.
parts.push(`(Above: ${before} earlier line${before===1 ? '' : 's'} (1-${before}) not read. Use mode="line" offset=1 limit=${before} to read them.)`);
108
+
}
109
+
110
+
parts.push(raw.join('\n'));
111
+
112
+
// 后置:终点之后没有读到的行
113
+
if(completelyRead){
114
+
parts.push(`(End of file - total ${total} lines)`);
115
+
}elseif(totalKnown){
116
+
constafter=total-lastReadLine;
117
+
parts.push(`(Below: ${after} more line${after===1 ? '' : 's'} (${nextOffset}-${total}) not read. Use mode="line" offset=${nextOffset} to continue.)`);
118
+
}else{
119
+
parts.push(`(Below: output capped at ${MAX_BYTES/1024}KB after reading lines ${startLine}-${lastReadLine}; more lines follow, total unknown. Use mode="line" offset=${nextOffset} to continue.)`);
filePath: z.string().describe('Absolute path to the file'),
99
-
offset: z.number().int().min(1).optional().describe('Line number to start reading from (1-indexed), default 1'),
100
-
limit: z.number().int().positive().optional().describe(`Max lines to read, default ${DEFAULT_LIMIT}`),
101
-
tail: z.number().int().positive().optional().describe('Read the last N lines (mutually exclusive with offset/limit)'),
172
+
mode: z.enum(ReadMode).optional()
173
+
.describe('line/byte: from start. endLine/endByte: from EOF. Default "line".'),
174
+
offset: z.number().int().min(0).optional()
175
+
.describe('line: 1-indexed start line. byte: 0-indexed start byte. endLine/endByte: distance from EOF where read starts (defaults to limit so "last N" works with just limit).'),
176
+
limit: z.number().int().positive().optional()
177
+
.describe(`Max lines (line/endLine, default ${DEFAULT_LINE_LIMIT}) or max bytes (byte/endByte, capped at ${MAX_BYTES/1024}KB).`),
0 commit comments