Skip to content

Conversation

@OzTamir
Copy link
Contributor

@OzTamir OzTamir commented Sep 25, 2025

Summary

This PR enhances the list_network_requests tool with pagination support to handle large numbers of network requests efficiently. See this issue.

Motivation

In my experience, the list_network_requests tool frequently hits LLM token limits on pages with many requests, making it unusable for modern web applications. I wanted to add pagination to allow agents to be more flexible and manage token limits on their own.

Changes

Pagination Support

  • Added pageSize parameter to limit requests per call
  • Added pageToken parameter for navigation between pages
  • Added pagination metadata in responses (nextPageToken, previousPageToken, startIndex, endIndex, total)

Implementation Details

  • New utility: src/utils/pagination.ts - generic pagination function
  • Enhanced McpResponse: Added pagination options to setIncludeNetworkRequests()
  • Updated network tool: Added pagination parameters to schema
  • Offset-based pagination: Uses numeric tokens, handles invalid tokens gracefully

Testing

  • Comprehensive test coverage for pagination scenarios
  • Tests for first page, subsequent pages, invalid tokens, and edge cases
  • All existing tests continue to pass

Backward Compatibility

  • If no pagination parameters are provided, the MCP will return all requests (same as before)

@OzTamir
Copy link
Contributor Author

OzTamir commented Sep 25, 2025

@OrKoN this is the first PR out of the two in #107 (with your comments fixed 🙂) - let's get this through and I will build the request filtering on top of this and create an additional PR later.

Copy link
Collaborator

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Looks good, one question about pageToken (see inline).

@OrKoN
Copy link
Collaborator

OrKoN commented Sep 25, 2025

Thanks!

@OrKoN OrKoN merged commit 4c909bb into ChromeDevTools:main Sep 25, 2025
16 checks passed
OrKoN pushed a commit that referenced this pull request Sep 25, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.3.0](chrome-devtools-mcp-v0.2.7...chrome-devtools-mcp-v0.3.0)
(2025-09-25)


### Features

* Add pagination list_network_requests
([#145](#145))
([4c909bb](4c909bb))


### Bug Fixes

* avoid reporting page close errors as errors
([#127](#127))
([44cfc8f](44cfc8f))
* clarify the node version message
([#135](#135))
([0cc907a](0cc907a))
* do not set channel if executablePath is provided
([#150](#150))
([03b59f0](03b59f0))
* **performance:** ImageDelivery insight errors
([#144](#144))
([d64ba0d](d64ba0d))
* roll latest DevTools to handle Insight errors
([#149](#149))
([b2e1e39](b2e1e39))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
OrKoN pushed a commit that referenced this pull request Sep 26, 2025
### Summary
This PR build upon #145 to also adds filtering by resource type to
`list_network_requests` (Also see: #137 and #107).

### Motivation
Agents often need specific request types (e.g., scripts, stylesheets,
images). Filtering reduces noise and improves performance.

### Changes
- **New parameter**: `resourceType` (array) to filter by resource types
- **Supported types**: all resource types supported by Puppeteer
- **Backward compatible**: when omitted, returns all requests

Filtering runs before pagination, so pagination applies to the filtered
results.
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.

2 participants