Skip to content

Commit ed5c69e

Browse files
use boolean
1 parent e273888 commit ed5c69e

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

src/McpContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class McpContext implements Context {
128128
return context;
129129
}
130130

131-
getNetworkRequests(includePreviousNavigations?: number): HTTPRequest[] {
131+
getNetworkRequests(includePreviousNavigations?: boolean): HTTPRequest[] {
132132
const page = this.getSelectedPage();
133133
return this.#networkCollector.getData(page, includePreviousNavigations);
134134
}

src/McpResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class McpResponse implements Response {
4040
include: boolean;
4141
pagination?: PaginationOptions;
4242
resourceTypes?: ResourceType[];
43-
includePreviousNavigations?: number;
43+
includePreviousNavigations?: boolean;
4444
};
4545
#consoleDataOptions?: {
4646
include: boolean;
@@ -61,7 +61,7 @@ export class McpResponse implements Response {
6161
value: boolean,
6262
options?: PaginationOptions & {
6363
resourceTypes?: ResourceType[];
64-
includePreviousNavigations?: number;
64+
includePreviousNavigations?: boolean;
6565
},
6666
): void {
6767
if (!value) {

src/PageCollector.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,18 @@ export class PageCollector<T> {
133133
this.storage.delete(page);
134134
}
135135

136-
getData(page: Page, includePreviousNavigations?: number): T[] {
136+
getData(page: Page, includePreviousNavigations?: boolean): T[] {
137137
const navigations = this.storage.get(page);
138138
if (!navigations) {
139139
return [];
140140
}
141141

142+
if (!includePreviousNavigations) {
143+
return navigations[0];
144+
}
145+
142146
const data: T[] = [];
143-
for (let index = includePreviousNavigations ?? 0; index >= 0; index--) {
147+
for (let index = this.#maxNavigationSaved; index >= 0; index--) {
144148
data.push(...navigations[index]);
145149
}
146150
return data;

src/tools/ToolDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface Response {
5050
value: boolean,
5151
options?: PaginationOptions & {
5252
resourceTypes?: string[];
53-
includePreviousNavigations?: number;
53+
includePreviousNavigations?: boolean;
5454
},
5555
): void;
5656
setIncludeConsoleData(

src/tools/network.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ export const listNetworkRequests = defineTool({
6464
'Filter requests to only return requests of the specified resource types. When omitted or empty, returns all requests.',
6565
),
6666
includePreviousNavigations: zod
67-
.number()
68-
.int()
69-
.positive()
70-
.max(2)
67+
.boolean()
68+
.default(false)
7169
.optional()
7270
.describe(
7371
'Number of previous navigations to include. Current navigation is always included.',

tests/tools/network.test.js.snapshot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ reqid=3 GET data:text/html,<div>Hello 3</div> [success - 200]
88
exports[`network > network_list_requests > list requests from previous navigations 1`] = `
99
# list_request response
1010
## Network requests
11-
Showing 1-2 of 2 (Page 1 of 1).
11+
Showing 1-3 of 3 (Page 1 of 1).
12+
reqid=1 GET data:text/html,<div>Hello 1</div> [success - 200]
1213
reqid=2 GET data:text/html,<div>Hello 2</div> [success - 200]
1314
reqid=3 GET data:text/html,<div>Hello 3</div> [success - 200]
1415
`;

tests/tools/network.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('network', () => {
4949
await listNetworkRequests.handler(
5050
{
5151
params: {
52-
includePreviousNavigations: 1,
52+
includePreviousNavigations: true,
5353
},
5454
},
5555
response,

0 commit comments

Comments
 (0)