Skip to content

fix(mcp): use outputFile for custom filenames to respect --output-dir#1

Open
Limitless2023 wants to merge 1 commit intomainfrom
fix/mcp-output-dir
Open

fix(mcp): use outputFile for custom filenames to respect --output-dir#1
Limitless2023 wants to merge 1 commit intomainfrom
fix/mcp-output-dir

Conversation

@Limitless2023
Copy link
Owner

Summary

Fixes microsoft/playwright-mcp#1390

When --output-dir is configured, custom filenames passed to screenshot/pdf/etc. tools were being saved to workspace root instead of --output-dir.

Root Cause

In resolveClientFile(), when a suggestedFilename was provided, it used workspaceFile() which always saves to workspace root. Only auto-generated filenames used outputFile() which respects --output-dir.

Fix

Changed resolveClientFile() to always use outputFile() for both auto-generated and custom filenames. The outputFile() method already correctly handles suggestedFilename - it uses it as the basename and resolves against outputDir.

Code Change

- let fileName: string;
- if (template.suggestedFilename)
-   fileName = await this._context.workspaceFile(template.suggestedFilename, this._clientWorkspace);
- else
-   fileName = await this._context.outputFile(template, { origin: 'llm' });
+ const fileName = await this._context.outputFile(template, { origin: 'llm' });

When --output-dir is configured, custom filenames passed to screenshot/pdf/etc.
tools were being saved to workspace root instead of --output-dir.

This fix ensures both auto-generated and custom filenames use outputFile(),
which correctly resolves paths against --output-dir.

Closes microsoft/playwright-mcp#1390
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

browser_take_screenshot: custom filenames bypass --output-dir, save to workspace root instead

2 participants