Skip to content

Commit e714ad9

Browse files
use boolean
1 parent b2a08a0 commit e714ad9

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
@@ -141,7 +141,7 @@ export class McpContext implements Context {
141141
return context;
142142
}
143143

144-
getNetworkRequests(includePreviousNavigations?: number): HTTPRequest[] {
144+
getNetworkRequests(includePreviousNavigations?: boolean): HTTPRequest[] {
145145
const page = this.getSelectedPage();
146146
return this.#networkCollector.getData(page, includePreviousNavigations);
147147
}

src/McpResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class McpResponse implements Response {
4242
include: boolean;
4343
pagination?: PaginationOptions;
4444
resourceTypes?: ResourceType[];
45-
includePreviousNavigations?: number;
45+
includePreviousNavigations?: boolean;
4646
};
4747
#consoleDataOptions?: {
4848
include: boolean;
@@ -63,7 +63,7 @@ export class McpResponse implements Response {
6363
value: boolean,
6464
options?: PaginationOptions & {
6565
resourceTypes?: ResourceType[];
66-
includePreviousNavigations?: number;
66+
includePreviousNavigations?: boolean;
6767
},
6868
): void {
6969
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
@@ -53,7 +53,7 @@ export interface Response {
5353
value: boolean,
5454
options?: PaginationOptions & {
5555
resourceTypes?: string[];
56-
includePreviousNavigations?: number;
56+
includePreviousNavigations?: boolean;
5757
},
5858
): void;
5959
setIncludeConsoleData(

src/tools/network.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ export const listNetworkRequests = defineTool({
6363
'Filter requests to only return requests of the specified resource types. When omitted or empty, returns all requests.',
6464
),
6565
includePreviousNavigations: zod
66-
.number()
67-
.int()
68-
.positive()
69-
.max(2)
66+
.boolean()
67+
.default(false)
7068
.optional()
7169
.describe(
7270
'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)