MCPcopy
hub / github.com/modelcontextprotocol/servers / readTextFileHandler

Function readTextFileHandler

src/filesystem/index.ts:191–211  ·  view source on GitHub ↗
(args: z.infer<typeof ReadTextFileArgsSchema>)

Source from the content-addressed store, hash-verified

189
190// read_file (deprecated) and read_text_file
191const 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
213server.registerTool(
214 "read_file",

Callers

nothing calls this directly

Calls 4

validatePathFunction · 0.85
tailFileFunction · 0.85
headFileFunction · 0.85
readFileContentFunction · 0.85

Tested by

no test coverage detected