Skip to content
Closed
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
8 changes: 7 additions & 1 deletion src/McpContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,17 @@ export class McpContext implements Context {
): Promise<{filename: string}> {
try {
const filePath = path.resolve(filename);
const cwd = process.cwd();
if (!filePath.startsWith(cwd + path.sep) && filePath !== cwd) {
throw new Error(
`File path must be within the current working directory: ${cwd}`,
);
}
await fs.writeFile(filePath, data);
return {filename};
} catch (err) {
this.logger(err);
throw new Error('Could not save a screenshot to a file', {cause: err});
throw new Error('Could not save a file', {cause: err});
}
}

Expand Down