Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/formatters/NetworkFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,11 @@ export class NetworkFormatter {
const failure = request.failure();
let status: string;
if (httpResponse) {
const responseStatus = httpResponse.status();
status =
responseStatus >= 200 && responseStatus <= 299
? `[success - ${responseStatus}]`
: `[failed - ${responseStatus}]`;
status = httpResponse.status().toString();
} else if (failure) {
status = `[failed - ${failure.errorText}]`;
status = failure.errorText;
} else {
status = '[pending]';
status = 'pending';
}
return status;
}
Expand Down Expand Up @@ -231,7 +227,7 @@ function convertNetworkRequestConciseToString(
data: NetworkRequestConcise,
): string {
// TODO truncate the URL
return `reqid=${data.requestId} ${data.method} ${data.url} ${data.status}${data.selectedInDevToolsUI ? ` [selected in the DevTools Network panel]` : ''}`;
return `reqid=${data.requestId} ${data.method} ${data.url} [${data.status}]${data.selectedInDevToolsUI ? ` [selected in the DevTools Network panel]` : ''}`;
}

function formatHeadlers(headers: Record<string, string>): string[] {
Expand Down
4 changes: 2 additions & 2 deletions tests/McpContext.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`McpContext > should include detailed network request in structured cont
"requestId": 456,
"method": "GET",
"url": "http://example.com/detail",
"status": "[pending]",
"status": "pending",
"requestHeaders": {
"content-size": "10"
}
Expand Down Expand Up @@ -37,7 +37,7 @@ exports[`McpContext > should include network requests in structured content 1`]
"requestId": 123,
"method": "GET",
"url": "http://example.com/api",
"status": "[pending]",
"status": "pending",
"selectedInDevToolsUI": false
}
]
Expand Down
Loading