Skip to content

Commit 7fbba75

Browse files
authored
chore(mcp): encourage relative path usage (#37857)
1 parent 7e7455b commit 7fbba75

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/playwright/src/mcp/browser/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ async function resolveFile(config: FullConfig, clientInfo: ClientInfo, fileName:
328328
fileName = fileName.split('\\').join('/');
329329
const resolvedFile = path.resolve(dir, fileName);
330330
if (!resolvedFile.startsWith(path.resolve(dir) + path.sep))
331-
throw new Error(`Resolved file path for ${fileName} is outside of the output directory`);
331+
throw new Error(`Resolved file path ${resolvedFile} is outside of the output directory ${dir}. Use relative file names to stay within the output directory.`);
332332
return resolvedFile;
333333
}
334334

packages/playwright/src/mcp/browser/tools/pdf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as javascript from '../codegen';
2020
import { dateAsFileName } from './utils';
2121

2222
const pdfSchema = z.object({
23-
filename: z.string().optional().describe('File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.'),
23+
filename: z.string().optional().describe('File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.'),
2424
});
2525

2626
const pdf = defineTabTool({

packages/playwright/src/mcp/browser/tools/screenshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type * as playwright from 'playwright-core';
2323

2424
const screenshotSchema = z.object({
2525
type: z.enum(['png', 'jpeg']).default('png').describe('Image format for the screenshot. Default is png.'),
26-
filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.'),
26+
filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory.'),
2727
element: z.string().optional().describe('Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too.'),
2828
ref: z.string().optional().describe('Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too.'),
2929
fullPage: z.boolean().optional().describe('When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.'),

0 commit comments

Comments
 (0)