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
2 changes: 2 additions & 0 deletions packages/insomnia/src/main/network/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ const createErrorResponse = async ({
parentId: requestId,
environmentId: environmentId,
timelinePath,
status: 'danger',
statusMessage: 'Error',
error: message,
transportType,
Expand Down Expand Up @@ -826,6 +827,7 @@ const createStdioTransport = async (
parentId: requestId,
environmentId: responseEnvironmentId,
url,
status: 'success',
elapsedTime: performance.now() - start,
timelinePath,
eventLogPath,
Expand Down
4 changes: 4 additions & 0 deletions packages/insomnia/src/models/mcp-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const canSync = false;

export interface BaseMcpResponse {
environmentId: string | null;
// Only for STDIO transport
status: string;
// Only for HTTP transport
statusCode: number;
statusMessage: string;
url: string;
Expand All @@ -41,6 +44,7 @@ export function init(): BaseMcpResponse {
timelinePath: '',
eventLogPath: '',
error: '',
status: '',
statusCode: 0,
statusMessage: '',
requestVersionId: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useRequestMetaPatcher } from '../../hooks/use-request';
import { Dropdown, type DropdownHandle, DropdownItem, DropdownSection, ItemContent } from '../base/dropdown';
import { useDocBodyKeyboardShortcuts } from '../keydown-binder';
import { SizeTag } from '../tags/size-tag';
import { StatusTag } from '../tags/status-tag';
import { StatusTag, StringStatusTag } from '../tags/status-tag';
import { TimeTag } from '../tags/time-tag';
import { URLTag } from '../tags/url-tag';
import { TimeFromNow } from '../time-from-now';
Expand Down Expand Up @@ -140,7 +140,14 @@ export const ResponseHistoryDropdown = ({
onClick={() => handleSetActiveResponse(requestId, response)}
label={
<div className="leading-10">
{!isSocketIOResponse(response) && (
{isSocketIOResponse(response) ? null : isMcpResponse(response) && response.transportType === 'stdio' ? (
<StringStatusTag
small
status={response.status}
statusMessage={response.statusMessage || undefined}
tooltipDelay={1000}
/>
) : (
<StatusTag
small
statusCode={response.statusCode}
Expand Down
68 changes: 54 additions & 14 deletions packages/insomnia/src/ui/components/tags/status-tag.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames';
import React, { type FC, memo } from 'react';
import React, { type FC, memo, type ReactNode } from 'react';

import { RESPONSE_CODE_DESCRIPTIONS, RESPONSE_CODE_REASONS } from '../../../common/constants';
import { Tooltip } from '../tooltip';
Expand All @@ -11,19 +11,56 @@ interface Props {
tooltipDelay?: number;
}

export const StringStatusTag = memo(
({
status,
small,
title = '',
statusMessage,
description = 'Unknown Status',
tooltipDelay,
}: {
status: string;
small?: boolean;
title?: ReactNode;
statusMessage?: ReactNode;
description?: ReactNode;
tooltipDelay?: number;
}) => {
const colorClass =
{
info: 'bg-info',
success: 'bg-success',
surprise: 'bg-surprise',
warning: 'bg-warning',
danger: 'bg-danger',
}[status] || 'bg-surprise';

return (
<div className={classnames('tag', colorClass, { 'tag--small': small })} data-testid="response-status-tag">
<Tooltip message={description} position="bottom" delay={tooltipDelay}>
<strong>{title}</strong> {statusMessage}
</Tooltip>
</div>
);
},
);

StringStatusTag.displayName = 'StringStatusTag';

export const StatusTag: FC<Props> = memo(({ statusMessage, statusCode, small, tooltipDelay }) => {
let statusCodeToDisplay: string | number = statusCode;
const firstChar = (statusCode + '')[0] || '';

const colorClass =
const status =
{
'1': 'bg-info',
'2': 'bg-success',
'3': 'bg-surprise',
'4': 'bg-warning',
'5': 'bg-danger',
'0': 'bg-danger',
}[firstChar] || 'bg-surprise';
'1': 'info',
'2': 'success',
'3': 'surprise',
'4': 'warning',
'5': 'danger',
'0': 'danger',
}[firstChar] || 'surprise';

if (firstChar === '0') {
statusCodeToDisplay = '';
Expand All @@ -36,11 +73,14 @@ export const StatusTag: FC<Props> = memo(({ statusMessage, statusCode, small, to
statusMessageToShow = RESPONSE_CODE_REASONS[statusCode] || statusMessage;
}
return (
<div className={classnames('tag', colorClass, { 'tag--small': small })} data-testid="response-status-tag">
<Tooltip message={description} position="bottom" delay={tooltipDelay}>
<strong>{statusCodeToDisplay}</strong> {statusMessageToShow}
</Tooltip>
</div>
<StringStatusTag
status={status}
small={small}
statusMessage={statusMessageToShow}
tooltipDelay={tooltipDelay}
title={statusCodeToDisplay}
description={description}
/>
);
});

Expand Down
Loading