(args: z.infer<typeof ReadTextFileArgsSchema>)
| 189 | |
| 190 | // read_file (deprecated) and read_text_file |
| 191 | const readTextFileHandler = async (args: z.infer<typeof ReadTextFileArgsSchema>) => { |
| 192 | const validPath = await validatePath(args.path); |
| 193 | |
| 194 | if (args.head && args.tail) { |
| 195 | throw new Error("Cannot specify both head and tail parameters simultaneously"); |
| 196 | } |
| 197 | |
| 198 | let content: string; |
| 199 | if (args.tail) { |
| 200 | content = await tailFile(validPath, args.tail); |
| 201 | } else if (args.head) { |
| 202 | content = await headFile(validPath, args.head); |
| 203 | } else { |
| 204 | content = await readFileContent(validPath); |
| 205 | } |
| 206 | |
| 207 | return { |
| 208 | content: [{ type: "text" as const, text: content }], |
| 209 | structuredContent: { content } |
| 210 | }; |
| 211 | }; |
| 212 | |
| 213 | server.registerTool( |
| 214 | "read_file", |
nothing calls this directly
no test coverage detected