Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/filesystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,20 @@ server.registerTool(
async (args: z.infer<typeof MoveFileArgsSchema>) => {
const validSourcePath = await validatePath(args.source);
const validDestPath = await validatePath(args.destination);

// Check if destination exists (documented behavior: fail if destination exists)
try {
await fs.stat(validDestPath);
throw new Error(`Destination already exists: ${args.destination}`);
} catch (err: any) {
if (err instanceof Error && err.message.startsWith("Destination already exists")) {
throw err;
}
if ((err as NodeJS.ErrnoException).code !== "ENOENT") {
throw err;
}
}

await fs.rename(validSourcePath, validDestPath);
const text = `Successfully moved ${args.source} to ${args.destination}`;
const contentBlock = { type: "text" as const, text };
Expand Down