xpipe-io/xpipe · error · BeaconClientException
Directory ${path} does already exist
Error message
Directory ${path} does already exist What it means
Thrown by the createDirectory MCP tool when the given path already exists (the code checks fs.fileExists(path) then aborts). mkdirs() is only executed on a non-existing path. Note the pre-check does not treat an existing directory as acceptable — any existing entry blocks creation.
Source
Thrown at app/src/main/java/io/xpipe/app/beacon/mcp/McpTools.java:403
.addTextContent("File written successfully")
.build();
}))
.build();
}
public static McpServerFeatures.SyncToolSpecification createDirectory() throws IOException {
var tool = McpSchemaFiles.loadTool("create_directory.json");
return McpServerFeatures.SyncToolSpecification.builder()
.tool(tool)
.callHandler(McpToolHandler.of((req) -> {
var system = req.getStringArgument("system");
var shellStore = req.getShellStoreRef(system, true);
var shellSession = AppBeaconServer.get().getCache().getOrStart(shellStore);
var path = req.getFilePath(shellSession.getControl(), "path");
var fs = new ShellFileSystem(shellSession.getControl());
if (fs.fileExists(path)) {
throw new BeaconClientException("Directory " + path + " does already exist");
}
fs.mkdirs(path);
return McpSchema.CallToolResult.builder()
.addTextContent("Directory created successfully")
.build();
}))
.build();
}
public static McpServerFeatures.SyncToolSpecification runCommand() throws IOException {
var tool = McpSchemaFiles.loadTool("run_command.json");
return McpServerFeatures.SyncToolSpecification.builder()
.tool(tool)
.callHandler(McpToolHandler.of((req) -> {
var command = req.getStringArgument("command");
var system = req.getStringArgument("system");View on GitHub (pinned to d85ca821ba)
Solutions
- Skip the call when the directory already exists (check first)
- Use a different directory name
- Remove the existing entry first if replacement is intended
- Do not use createDirectory as mkdir -p; guard the call in automation
Example fix
// before
createDirectory(system: "host", path: "/opt/app") // exists
// after
if (!directoryExists(system: "host", path: "/opt/app")) {
createDirectory(system: "host", path: "/opt/app")
} Defensive patterns
Strategy: validation
Validate before calling
async function ensureDirectory(mcp, system, path) {
const exists = await mcp.call('directoryExists', {system, path}); // or shell test -d
if (exists) return;
return mcp.call('createDirectory', {system, path});
} Try / catch
try {
await mcp.call('createDirectory', {system, path});
} catch (e) {
if (String(e.message).includes('does already exist')) return; // idempotent success
throw e;
} Prevention
- Remember createDirectory is not mkdir -p
- Guard setup scripts with existence checks
- Use unique paths per run in automation
When it happens
Trigger: Calling createDirectory with a 'path' that already exists as a file or directory on the target system.
Common situations: Idempotency mistakes in automation re-running setup scripts, or assuming the tool behaves like mkdir -p (it does not — it fails if the target exists).
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- File ${path} does already exist
- Path ${path} does not exist
- File path " + msg.getPath() + " is not absolute
- File " + msg.getPath() + " does not exist
- File path " + msg.getPath() + " is not absolute
AI-assisted analysis of xpipe-io/xpipe@d85ca821ba (2026-09-06).
Data as JSON: /api/errors/96278e146418542c.
Report an issue: GitHub.