@@ -286,9 +286,25 @@ func (t *FileTool) Execute(ctx context.Context, inputs map[string]interface{}) (
286286 return nil , & errors.ValidationError {
287287 Field : "max_lines" ,
288288 Message : err .Error (),
289- Suggestion : "Provide a non-negative integer for max_lines" ,
289+ Suggestion : "Provide a null or positive integer for max_lines" ,
290290 }
291291 } else if found {
292+ // Validate max_lines is positive (0 is not allowed)
293+ if ml == 0 {
294+ return nil , & errors.ValidationError {
295+ Field : "max_lines" ,
296+ Message : "max_lines must be null or a positive integer" ,
297+ Suggestion : "Provide a positive integer or omit max_lines for unlimited read" ,
298+ }
299+ }
300+ // Validate max_lines doesn't exceed maximum
301+ if ml > 100000 {
302+ return nil , & errors.ValidationError {
303+ Field : "max_lines" ,
304+ Message : "max_lines exceeds maximum allowed value (100000)" ,
305+ Suggestion : "Provide a max_lines value of 100000 or less" ,
306+ }
307+ }
292308 maxLines = ml
293309 }
294310
@@ -301,12 +317,20 @@ func (t *FileTool) Execute(ctx context.Context, inputs map[string]interface{}) (
301317 Suggestion : "Provide a non-negative integer for offset" ,
302318 }
303319 } else if found {
320+ // Validate offset doesn't exceed maximum
321+ if off > 10000000 {
322+ return nil , & errors.ValidationError {
323+ Field : "offset" ,
324+ Message : "offset exceeds maximum allowed value (10000000)" ,
325+ Suggestion : "Provide an offset value of 10000000 or less" ,
326+ }
327+ }
304328 offset = off
305329 }
306330
307331 // Validate path for read access
308332 if err := t .validatePath (path , security .ActionRead ); err != nil {
309- return nil , fmt .Errorf ("read access validation failed for path %s : %w" , path , err )
333+ return nil , fmt .Errorf ("read access validation failed: %w" , err )
310334 }
311335 return t .read (ctx , path , maxLines , offset )
312336 case "write" :
@@ -320,7 +344,7 @@ func (t *FileTool) Execute(ctx context.Context, inputs map[string]interface{}) (
320344 }
321345 // Validate path for write access
322346 if err := t .validatePath (path , security .ActionWrite ); err != nil {
323- return nil , fmt .Errorf ("write access validation failed for path %s : %w" , path , err )
347+ return nil , fmt .Errorf ("write access validation failed: %w" , err )
324348 }
325349 return t .write (ctx , path , content )
326350 default :
0 commit comments