fileReadLineLimit vs fileWriteLineLimit in DesktopCommanderMCP: What Is the Difference?
The fileReadLineLimit and fileWriteLineLimit configurations in DesktopCommanderMCP define line-based boundaries for filesystem tools, where fileReadLineLimit caps how many lines a read operation can return (default 1000) while fileWriteLineLimit restricts how many lines a write operation may accept (default 50).
Both settings are numeric safety limits stored in the ServerConfig interface within src/config-manager.ts. They govern opposite data flows: fileReadLineLimit protects the LLM context window from overflow, while fileWriteLineLimit prevents excessive disk writes that could degrade server performance.
How fileReadLineLimit Controls Read Output
The fileReadLineLimit setting acts as a hard ceiling on read operations. When you invoke the read_file tool without an explicit length parameter, the system defaults to this configured value defined at line 174 of src/config-manager.ts.
According to the source code, the default is 1000 lines. This limit is actively enforced across multiple files:
src/handlers/filesystem-handlers.ts(line 93): The read handler applies this limit before returning content to the clientsrc/tools/improved-process-tools.ts(line 253): Process-related tools use this value to bound their output streamssrc/tools/filesystem.ts(line 65): A helper function retrieves the current read limit for validation purposes
When reading large files, the tool returns only the first N lines up to the configured limit, preventing a single read from generating an excessively large payload.
How fileWriteLineLimit Controls Write Input
Conversely, fileWriteLineLimit restricts input size for write operations. This setting protects the server from processing or persisting huge writes that could fill disk space or cause performance bottlenecks. The default value is 50 lines, defined alongside the read limit in src/config-manager.ts (lines 174-176).
The write limit is documented and enforced in the write file handlers, with specific commentary located in src/server.ts (line 853) describing how the limit governs the write_file command. When a write request exceeds this limit, the system either truncates the input or rejects the operation entirely, depending on the specific handler implementation.
Configuration Implementation Details
Both limits are defined in the ServerConfig interface at line 15 of src/config-manager.ts. The configuration manager provides a centralized store for these values, allowing runtime adjustments without restarting the server.
// src/config-manager.ts
interface ServerConfig {
fileReadLineLimit: number; // Default: 1000
fileWriteLineLimit: number; // Default: 50
// ... other config options
}
Practical Configuration Examples
Adjust these limits at runtime using the configuration manager:
import { configManager } from './config-manager.js';
// Raise the read limit to handle larger log files
await configManager.setValue('fileReadLineLimit', 2000);
// Restrict writes to smaller chunks for safety
await configManager.setValue('fileWriteLineLimit', 30);
When reading files, the limit applies automatically:
import { readFile } from './tools/filesystem.js';
// Returns up to config.fileReadLineLimit lines (default 1000)
const content = await readFile('/var/log/syslog');
For write operations, exceeding the limit triggers protection:
import { writeFile } from './tools/filesystem.js';
// Attempting to write 100 lines will be limited to 50 by default
const manyLines = Array(100).fill('log entry').join('\n');
await writeFile('/path/to/output.txt', manyLines);
Summary
fileReadLineLimit(default 1000) caps the number of lines returned by theread_filetool, preventing LLM context overflowfileWriteLineLimit(default 50) restricts the number of lines accepted by thewrite_filetool, protecting server performance and disk space- Both are defined in
src/config-manager.ts(lines 15 and 174-176) and enforced across the respective filesystem handlers - Modify these values via
configManager.setValue()to match specific workload requirements
Frequently Asked Questions
What happens if I try to read a file larger than fileReadLineLimit?
The read_file handler in src/handlers/filesystem-handlers.ts (line 93) truncates the output to the configured fileReadLineLimit value. You receive the first N lines of the file (default 1000), and the system indicates that additional content exists beyond the limit.
Can I disable these limits by setting them to zero?
Setting either limit to zero is not recommended and would likely result in no lines being processed. The enforcement logic in src/tools/filesystem.ts and the handlers treats these as hard numeric bounds, so a value of zero would effectively block all read or write operations.
Where are the default values for these limits defined?
Both default values are defined in src/config-manager.ts at lines 174-176, where the configuration implementation sets fileReadLineLimit to 1000 and fileWriteLineLimit to 50.
Do these line limits affect binary file operations?
No, these limits specifically govern text-based line counting for tools that process newline-delimited content. Binary files are handled through separate logic that does not split content by newline characters, so fileReadLineLimit and fileWriteLineLimit do not apply to binary read or write operations.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →