MCPcopy
hub / github.com/coder/mux / validateFileSize

Function validateFileSize

src/node/services/tools/fileCommon.ts:99–108  ·  view source on GitHub ↗
(stats: FileStat)

Source from the content-addressed store, hash-verified

97 * @returns Error object if file is too large, null if valid
98 */
99export function validateFileSize(stats: FileStat): { error: string } | null {
100 if (stats.size > MAX_FILE_SIZE) {
101 const sizeMB = (stats.size / (1024 * 1024)).toFixed(2);
102 const maxMB = (MAX_FILE_SIZE / (1024 * 1024)).toFixed(2);
103 return {
104 error: `File is too large (${sizeMB}MB). The maximum file size for file operations is ${maxMB}MB. Please use system tools like grep, sed, awk, or split the file into smaller chunks.`,
105 };
106 }
107 return null;
108}
109
110/**
111 * Validates that a file path doesn't contain redundant workspace prefix.

Callers 10

fileCommon.test.tsFile · 0.90
createFileReadToolFunction · 0.90
executeFileEditOperationFunction · 0.90
readAgentDefinitionFunction · 0.90
readAgentSkillFromDirFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected