{"record":{"id":"353918aa49f0728d","repo":"xpipe-io/xpipe","slug":"file-path-does-not-exist","errorCode":null,"errorMessage":"File ${path} does not exist","messagePattern":"File (.+?) does not exist","errorType":"exception","errorClass":"BeaconClientException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/xpipe/app/beacon/mcp/McpTools.java","lineNumber":218,"sourceCode":"                                    JacksonMapper.getDefault().writeValueAsString(object))\n                            .build();\n                }))\n                .build();\n    }\n\n    public static McpServerFeatures.SyncToolSpecification readFile() throws IOException {\n        var tool = McpSchemaFiles.loadTool(\"read_file.json\");\n        return McpServerFeatures.SyncToolSpecification.builder()\n                .tool(tool)\n                .callHandler(McpToolHandler.of((req) -> {\n                    var system = req.getStringArgument(\"system\");\n                    var shellStore = req.getShellStoreRef(system, false);\n                    var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);\n                    var path = req.getFilePath(shellSession.getControl(), \"path\");\n                    var fs = new ShellFileSystem(shellSession.getControl());\n\n                    if (!fs.fileExists(path)) {\n                        throw new BeaconClientException(\"File \" + path + \" does not exist\");\n                    }\n\n                    try (var in = fs.openInput(path)) {\n                        var b = in.readAllBytes();\n                        var s = new String(b, StandardCharsets.UTF_8);\n                        return McpSchema.CallToolResult.builder()\n                                .addTextContent(s)\n                                .build();\n                    }\n                }))\n                .build();\n    }\n\n    public static McpServerFeatures.SyncToolSpecification listFiles() throws IOException {\n        var tool = McpSchemaFiles.loadTool(\"list_files.json\");\n        return McpServerFeatures.SyncToolSpecification.builder()\n                .tool(tool)\n                .callHandler(McpToolHandler.of((req) -> {","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/xpipe-io/xpipe/blob/d85ca821baa46092a320ebb13546d7240adb74f8/app/src/main/java/io/xpipe/app/beacon/mcp/McpTools.java#L200-L236","documentation":"The MCP readFile tool opens a ShellFileSystem on the target shell and checks fs.fileExists(path) before reading; if the file is absent it throws this BeaconClientException including the resolved path (tilde already expanded against the user home). This is a pre-flight existence check, not an I/O failure.","triggerScenarios":"Calling the MCP readFile tool with a 'path' that does not exist on the remote/local shell filesystem: typo, wrong relative base, file deleted, or case-mismatch on case-sensitive filesystems.","commonSituations":"Assuming the working directory differs from the shell's actual home; case-sensitive Linux paths vs case-insensitive local dev; referencing a file on the wrong connection (file exists on another host).","solutions":["Verify the file exists via the listFiles tool or an ls call on the same connection before reading","Use an absolute path to remove working-directory ambiguity","Check path casing exactly; Linux shells are case-sensitive","Catch BeaconClientException and fall back to listing the parent directory to find the correct name"],"exampleFix":"// before\n{\"system\": \"my-ssh\", \"path\": \"~/Config/app.conf\"} // file absent\n// after: confirm with listFiles on the parent directory, then\n{\"system\": \"my-ssh\", \"path\": \"~/config/app.conf\"}","handlingStrategy":"validation","validationCode":"// existence check via listFiles before reading\nconst parent = path.substring(0, path.lastIndexOf('/')) || '/';\nconst entries = await listFiles(system, parent);\nif (!entries.some(e => e.path === path)) {\n  throw new Error(`file '${path}' not found on '${system}'`);\n}","typeGuard":null,"tryCatchPattern":"try { return readFile(system, path); } catch (BeaconClientException e) { if (e.message.includes('does not exist')) { /* list parent directory and retry with corrected path */ } throw e; }","preventionTips":["List the parent directory before reading unfamiliar paths","Use absolute paths and exact casing on remote shells","Confirm you are targeting the intended connection/host"],"tags":["mcp","file-not-found","remote-shell"],"backgroundTag":"file-not-found","analyzedSha":"d85ca821baa46092a320ebb13546d7240adb74f8","analyzedAt":"2026-09-06T14:30:08.251Z","contentChangedAt":"2026-09-06T14:30:08.251Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}