{"record":{"id":"3cf73f11699aa637","repo":"modelcontextprotocol/servers","slug":"cannot-specify-both-head-and-tail-parameters-simul","errorCode":null,"errorMessage":"Cannot specify both head and tail parameters simultaneously","messagePattern":"Cannot specify both head and tail parameters simultaneously","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/filesystem/index.ts","lineNumber":195,"sourceCode":"    stream.on('data', (chunk) => {\n      chunks.push(chunk as Buffer);\n    });\n    stream.on('end', () => {\n      const finalBuffer = Buffer.concat(chunks);\n      resolve(finalBuffer.toString('base64'));\n    });\n    stream.on('error', (err) => reject(err));\n  });\n}\n\n// Tool registrations\n\n// read_file (deprecated) and read_text_file\nconst readTextFileHandler = async (args: z.infer<typeof ReadTextFileArgsSchema>) => {\n  const validPath = await validatePath(args.path);\n\n  if (args.head && args.tail) {\n    throw new Error(\"Cannot specify both head and tail parameters simultaneously\");\n  }\n\n  let content: string;\n  if (args.tail) {\n    content = await tailFile(validPath, args.tail);\n  } else if (args.head) {\n    content = await headFile(validPath, args.head);\n  } else {\n    content = await readFileContent(validPath);\n  }\n\n  return {\n    content: [{ type: \"text\" as const, text: content }],\n    structuredContent: { content }\n  };\n};\n\nserver.registerTool(","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/filesystem/index.ts#L177-L213","documentation":"Thrown by the filesystem server's `read_text_file`/`read_file` handler when a request supplies both `head` and `tail` in the same call. The two are mutually exclusive read modes: `head` reads the first N lines, `tail` reads the last N lines. Supplying both is ambiguous, so the server rejects it before any I/O.","triggerScenarios":"Calling `read_text_file` (or deprecated `read_file`) with both `head` and `tail` set to positive integers in one request, e.g. `{ path: '/x', head: 10, tail: 10 }`.","commonSituations":"LLMs or clients that default-fill both optional fields, a UI that lets users toggle both options, or a refactor that merges two code paths without clearing the other flag.","solutions":["Send only one of `head` or `tail` per call; omit the other.","If you need both the start and end of a file, issue two separate calls.","Validate the args before sending: `!(args.head && args.tail)`."],"exampleFix":"// before\n{ path: '/var/log/syslog', head: 10, tail: 10 }\n// after (two calls)\n{ path: '/var/log/syslog', head: 10 }\n{ path: '/var/log/syslog', tail: 10 }","handlingStrategy":"validation","validationCode":"if (args.head && args.tail) {\n  throw new Error('Specify only one of head or tail');\n}\n// or simply delete one before sending\nconst { head, ...rest } = args;\nif (args.tail) { delete rest.head; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Send only one of head/tail per call; omit the other.","Issue two separate calls if you need both ends of a file.","Guard the request builder: if both are set, clear one."],"tags":["mcp","typescript","filesystem-server","validation","tools"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}