feat(mcp): filtering and optional headers/body in browser_network_requests#39672
feat(mcp): filtering and optional headers/body in browser_network_requests#39672yury-s merged 6 commits intomicrosoft:mainfrom
Conversation
Adds `includeBody` option to `browser_network_requests` MCP tool and `--body` flag to the `network` CLI command to include POST/PUT/PATCH request bodies in the network log output.
There was a problem hiding this comment.
Pull request overview
Adds an opt-in path to include request bodies in the Playwright MCP network request log output, and exposes it via the CLI network command.
Changes:
- Add
includeBodyoption tobrowser_network_requestsand render requestpostData()when enabled. - Add
--bodyflag to thenetworkCLI command and map it to the MCP tool option. - Add MCP + CLI tests covering default omission and opt-in inclusion of request bodies.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/mcp/network.spec.ts | Adds coverage for includeBody option in MCP tool output. |
| tests/mcp/cli-devtools.spec.ts | Adds coverage for network --body CLI flag behavior. |
| packages/playwright-core/src/tools/cli-daemon/commands.ts | Introduces --body CLI option and forwards to MCP tool params. |
| packages/playwright-core/src/tools/backend/network.ts | Implements includeBody schema + request body rendering in network output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Test results for "MCP"5405 passed, 172 skipped Merge workflow run. |
Test results for "tests 1"4 flaky38691 passed, 846 skipped Merge workflow run. |
|
Great work on adding filtering and request headers/body support! This will be very useful for debugging network issues. I'd like to suggest adding a complementary tool: Use CaseCurrently, Proposed APIbrowser_get_network_response: {
request_id: string; // From browser_network_requests output
}Example Workflow# 1. List requests
browser_network_requests
# Output: [req_123] [GET] https://api.example.com/data
# 2. Get response body
browser_get_network_response: { request_id: "req_123" }
# Output: {"status": "success", "data": [...]}Implementation Notes
QuestionWould this fit within the scope of this PR, or should it be a separate contribution? I have a working implementation if you're interested. Thanks for driving these improvements to the network tools! |
Enhance the
browser_network_requeststool and CLInetworkcommand with additional debugging capabilities. Adds URL filtering via regexp (--filter) and optional inclusion of request headers (--request-headers) and request body (--request-body). Also renames includeStatic to static for consistency.Fixes microsoft/playwright-mcp#1128