33 * Copyright 2025 Google LLC
44 * SPDX-License-Identifier: Apache-2.0
55 */
6- import type { ImageContentData , Response } from './tools/ToolDefinition.js' ;
7- import type { McpContext } from './McpContext.js' ;
8- import { ImageContent , TextContent } from '@modelcontextprotocol/sdk/types.js' ;
6+ import type { ImageContentData , Response } from './tools/ToolDefinition.js' ;
7+ import type { McpContext } from './McpContext.js' ;
8+ import { ImageContent , TextContent } from '@modelcontextprotocol/sdk/types.js' ;
99import {
1010 getFormattedHeaderValue ,
1111 getShortDescriptionForRequest ,
1212 getStatusFromRequest ,
1313} from './formatters/networkFormatter.js' ;
14- import { formatA11ySnapshot } from './formatters/snapshotFormatter.js' ;
15- import { formatConsoleEvent } from './formatters/consoleFormatter.js' ;
14+ import { formatA11ySnapshot } from './formatters/snapshotFormatter.js' ;
15+ import { formatConsoleEvent } from './formatters/consoleFormatter.js' ;
1616import {
1717 paginateNetworkRequests ,
1818 type NetworkPaginationOptions ,
@@ -39,29 +39,18 @@ export class McpResponse implements Response {
3939
4040 setIncludeNetworkRequests (
4141 value : boolean ,
42- options ?: { pageSize ?: number ; pageToken ?: string | null } ,
42+ options ?: { pageSize ?: number ; pageToken ?: string | null } ,
4343 ) : void {
4444 this . #includeNetworkRequests = value ;
45- if ( ! value ) {
45+ if ( ! value || ! options ) {
4646 this . #networkRequestsPaginationOptions = undefined ;
4747 return ;
4848 }
4949
50- if ( ! options ) {
51- this . #networkRequestsPaginationOptions = undefined ;
52- return ;
53- }
54-
55- const sanitizedOptions : NetworkPaginationOptions = { } ;
56- if ( options . pageSize !== undefined ) {
57- sanitizedOptions . pageSize = options . pageSize ;
58- }
59- if ( options . pageToken !== undefined ) {
60- sanitizedOptions . pageToken = options . pageToken ?? undefined ;
61- }
62-
63- this . #networkRequestsPaginationOptions =
64- Object . keys ( sanitizedOptions ) . length > 0 ? sanitizedOptions : undefined ;
50+ this . #networkRequestsPaginationOptions = {
51+ pageSize : options . pageSize ,
52+ pageToken : options . pageToken ?? undefined ,
53+ } ;
6554 }
6655
6756 setIncludeConsoleData ( value : boolean ) : void {
@@ -201,7 +190,7 @@ Call browser_handle_dialog to handle it before continuing.`);
201190 if ( paginationResult . invalidToken ) {
202191 response . push ( 'Invalid page token provided. Showing first page.' ) ;
203192 }
204- const { startIndex, endIndex} = paginationResult ;
193+ const { startIndex, endIndex } = paginationResult ;
205194 response . push (
206195 `Showing ${ startIndex + 1 } -${ endIndex } of ${ requests . length } .` ,
207196 ) ;
0 commit comments