Skip to content

fix(mcp): avoid echoing script file contents in run code response - #44297

Closed
Vishal Sharma (TbhVishal) wants to merge 1 commit into
microsoft:mainfrom
TbhVishal:fix/mcp-run-code-filename-echo
Closed

Vishal Sharma (TbhVishal) wants to merge 1 commit into
microsoft:mainfrom
TbhVishal:fix/mcp-run-code-filename-echo

Conversation

@TbhVishal

Copy link
Copy Markdown

Fixes #44294

When browser_run_code_unsafe loads code from a file via filename, it previously passed the entire file contents to response.addCode(). This echoed large scripts back into the tool response under "Ran Playwright code" and consumed unnecessary LLM context tokens.

This patch updates runCode.ts to reference the source filename instead of embedding the raw file body when filename is provided.

Local test command:

npx playwright test tests/mcp/run-code.spec.ts -g "browser_run_code_unsafe with filename"

@TbhVishal

Copy link
Copy Markdown
Author

Closing this for now to reconsider the implementation.

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.

[MCP]: browser_run_code_unsafe with filename echoes the whole file in "Ran Playwright code"

1 participant