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
24 changes: 22 additions & 2 deletions frontend/src/api/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,8 @@ export interface components {
configPath?: string | null;
/** Env */
env?: components["schemas"]["McpEnvEntryResponse"][];
/** Id */
id: string;
/** Label */
label: string;
/** Logokey */
Expand All @@ -1103,6 +1105,11 @@ export interface components {
payloadPreview: {
[key: string]: unknown;
};
/**
* Recommended
* @default false
*/
recommended: boolean;
/**
* Sourcekind
* @enum {string}
Expand Down Expand Up @@ -1146,6 +1153,11 @@ export interface components {
payloadPreview: {
[key: string]: unknown;
};
/**
* Recommended
* @default false
*/
recommended: boolean;
spec: components["schemas"]["McpServerSpecResponse"];
};
/** McpInstallConfigFieldResponse */
Expand Down Expand Up @@ -1215,10 +1227,14 @@ export interface components {
};
/** McpInventoryEntryResponse */
McpInventoryEntryResponse: {
/** Availabilityreason */
/**
* Availabilityreason
* @description Deprecated compatibility field; use mcpStatus.reason instead.
*/
availabilityReason?: string | null;
/**
* Availabilitystatus
* @description Deprecated compatibility field; use mcpStatus instead.
* @enum {string}
*/
availabilityStatus: "available" | "unavailable";
Expand Down Expand Up @@ -1458,10 +1474,14 @@ export interface components {
};
/** McpServerDetailResponse */
McpServerDetailResponse: {
/** Availabilityreason */
/**
* Availabilityreason
* @description Deprecated compatibility field; use mcpStatus.reason instead.
*/
availabilityReason?: string | null;
/**
* Availabilitystatus
* @description Deprecated compatibility field; use mcpStatus instead.
* @enum {string}
*/
availabilityStatus: "available" | "unavailable";
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,10 @@
"title": "Env",
"type": "array"
},
"id": {
"title": "Id",
"type": "string"
},
"label": {
"title": "Label",
"type": "string"
Expand Down Expand Up @@ -931,6 +935,11 @@
"title": "Payloadpreview",
"type": "object"
},
"recommended": {
"default": false,
"title": "Recommended",
"type": "boolean"
},
"sourceKind": {
"enum": [
"managed",
Expand All @@ -944,6 +953,7 @@
}
},
"required": [
"id",
"sourceKind",
"label",
"payloadPreview",
Expand Down Expand Up @@ -1071,6 +1081,11 @@
"title": "Payloadpreview",
"type": "object"
},
"recommended": {
"default": false,
"title": "Recommended",
"type": "boolean"
},
"spec": {
"$ref": "#/components/schemas/McpServerSpecResponse"
}
Expand Down Expand Up @@ -1281,9 +1296,11 @@
"type": "null"
}
],
"description": "Deprecated compatibility field; use mcpStatus.reason instead.",
"title": "Availabilityreason"
},
"availabilityStatus": {
"description": "Deprecated compatibility field; use mcpStatus instead.",
"enum": [
"available",
"unavailable"
Expand Down Expand Up @@ -2114,9 +2131,11 @@
"type": "null"
}
],
"description": "Deprecated compatibility field; use mcpStatus.reason instead.",
"title": "Availabilityreason"
},
"availabilityStatus": {
"description": "Deprecated compatibility field; use mcpStatus instead.",
"enum": [
"available",
"unavailable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function makeGroup(overrides: Partial<McpIdentityGroupDto> = {}): McpIdentityGro
sightings: [
{
harness: "cursor",
recommended: true,
label: "Cursor",
logoKey: "cursor",
configPath: "/c/.cursor/mcp.json",
Expand All @@ -40,6 +41,7 @@ function makeGroup(overrides: Partial<McpIdentityGroupDto> = {}): McpIdentityGro
},
{
harness: "claude",
recommended: false,
label: "Claude",
logoKey: "claude",
configPath: "/c/.claude.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,10 @@ describe("McpServerDetailView", () => {
],
configChoices: [
{
id: "managed",
sourceKind: "managed",
observedHarness: null,
recommended: true,
label: "Skill Manager config",
logoKey: null,
configPath: null,
Expand Down Expand Up @@ -519,8 +521,10 @@ describe("McpServerDetailView", () => {
],
configChoices: [
{
id: "managed",
sourceKind: "managed",
observedHarness: null,
recommended: false,
label: "Skill Manager config",
logoKey: null,
configPath: null,
Expand All @@ -537,8 +541,10 @@ describe("McpServerDetailView", () => {
env: [],
},
{
id: "harness:cursor",
sourceKind: "harness",
observedHarness: "cursor",
recommended: true,
label: "Cursor config",
logoKey: "cursor",
configPath: "/tmp/.cursor/mcp.json",
Expand Down
30 changes: 13 additions & 17 deletions frontend/src/features/mcp/components/detail/McpServerDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { formatDisplayHeaders } from "../../model/display-secrets";
import type { McpInstallConfigValues } from "../../model/install-config";
import { mcpStatusReason } from "../../model/mcp-status";
import { mcpServerSourceLinks, resolveMcpRegistryName } from "../../model/mcp-source-links";
import { useMcpEnableConfigGate } from "../../model/use-mcp-enable-config-gate";
import { useMcpEnableWorkflow } from "../../model/use-mcp-enable-workflow";
import { McpInstallConfigDialog } from "../config/McpInstallConfigDialog";
import {
McpConfigChoiceDialog,
Expand Down Expand Up @@ -74,7 +74,7 @@ export function McpServerDetailView({
cancelConfig: cancelEnableConfig,
submitConfig: submitEnableConfig,
configError: enableConfigError,
} = useMcpEnableConfigGate({
} = useMcpEnableWorkflow({
loadErrorMessage: copy.detail.unableToLoadInstallConfig,
});

Expand Down Expand Up @@ -221,20 +221,15 @@ export function McpServerDetailView({
canEnable={detail.canEnable}
serverPending={isServerPending}
pendingPerHarness={pendingPerHarness}
onEnable={(harness) =>
requestEnable({
spec,
displayName,
targetLabel: harness,
installConfigStatus: detail.installConfigStatus,
onProceed: (config) => {
if (config === undefined) {
onEnableHarness(harness);
return;
}
onEnableHarness(harness, config);
},
})}
onEnable={(harness) => {
requestEnable(detail, harness, (config) => {
if (config === undefined) {
onEnableHarness(harness);
return;
}
onEnableHarness(harness, config);
});
}}
onDisable={onDisableHarness}
onResolveConfigClick={() => setResolveDialogOpen(true)}
canResolveConfig={canResolveConfig}
Expand Down Expand Up @@ -296,7 +291,7 @@ export function McpServerDetailView({

function configChoiceToOption(choice: McpConfigChoiceDto, copy: McpCopy): McpConfigChoiceOption {
return {
id: choice.sourceKind === "managed" ? "managed" : (choice.observedHarness ?? choice.label),
id: choice.id,
sourceKind: choice.sourceKind,
observedHarness: choice.observedHarness,
label: choice.sourceKind === "managed" ? copy.detail.skillManagerConfig : choice.label,
Expand All @@ -305,6 +300,7 @@ function configChoiceToOption(choice: McpConfigChoiceDto, copy: McpCopy): McpCon
payloadPreview: choice.payloadPreview,
spec: choice.spec,
env: choice.env ?? [],
recommended: choice.recommended,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function options(): McpConfigChoiceOption[] {
id: "cursor",
sourceKind: "harness",
observedHarness: "cursor",
recommended: true,
label: "Cursor",
logoKey: "cursor",
configPath: "/c/.cursor/mcp.json",
Expand All @@ -34,6 +35,7 @@ function options(): McpConfigChoiceOption[] {
id: "claude",
sourceKind: "harness",
observedHarness: "claude",
recommended: false,
label: "Claude",
logoKey: "claude",
configPath: "/c/.claude.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { AlertTriangle, Check, ChevronDown, ChevronRight, Loader2, X } from "luc

import { UiTooltip } from "../../../../components/ui/UiTooltip";
import type {
McpConfigChoiceDto,
McpEnvEntryDto,
McpServerSpecDto,
} from "../../api/management-types";
Expand All @@ -13,7 +12,6 @@ import { maskMcpPayloadPreview } from "../../model/display-secrets";
import {
envChipLabel,
formatEnvKeyPreview,
pickRecommendedConfigChoice,
summarizeMcpConfig,
} from "../../model/selectors";

Expand All @@ -27,6 +25,7 @@ export interface McpConfigChoiceOption {
payloadPreview: Record<string, unknown>;
spec: McpServerSpecDto;
env: McpEnvEntryDto[];
recommended?: boolean;
}

interface McpConfigChoiceDialogProps {
Expand All @@ -50,7 +49,7 @@ export function McpConfigChoiceDialog({
}: McpConfigChoiceDialogProps) {
const copy = useMcpCopy();
const recommendedId = useMemo(
() => pickRecommendedConfigChoice(options.map(toConfigChoiceDto)),
() => options.find((option) => option.recommended)?.id ?? null,
[options],
);
const [chosenId, setChosenId] = useState<string>(
Expand Down Expand Up @@ -224,16 +223,3 @@ export function McpConfigChoiceDialog({
</Dialog.Root>
);
}

function toConfigChoiceDto(option: McpConfigChoiceOption): McpConfigChoiceDto {
return {
sourceKind: option.sourceKind,
observedHarness: option.observedHarness ?? null,
label: option.label,
logoKey: option.logoKey ?? null,
configPath: option.configPath ?? null,
payloadPreview: option.payloadPreview,
spec: option.spec,
env: option.env,
};
}
52 changes: 1 addition & 51 deletions frontend/src/features/mcp/model/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
filterMcpServersInUse,
formatEnvKeyPreview,
isMcpHarnessAddressable,
pickRecommendedSighting,
pillCounts,
summarizeSighting,
urlHasEmbeddedCredential,
Expand Down Expand Up @@ -169,6 +168,7 @@ function makeSighting(
): McpIdentitySightingDto {
return {
harness,
recommended: false,
label: harness.charAt(0).toUpperCase() + harness.slice(1),
logoKey: harness,
configPath: `/mock/${harness}.json`,
Expand Down Expand Up @@ -265,56 +265,6 @@ describe("summarizeSighting", () => {
});
});

describe("pickRecommendedSighting", () => {
it("returns null for empty input", () => {
expect(pickRecommendedSighting([])).toBeNull();
});

it("prefers stdio with env-var refs over stdio with literal", () => {
const envRef = makeSighting(
"cursor",
{ transport: "stdio", command: "npx" },
[{ key: "K", value: "${env:K}", isEnvRef: true }],
);
const envLiteral = makeSighting(
"codex",
{ transport: "stdio", command: "npx" },
[{ key: "K", value: "literal", isEnvRef: false }],
);
expect(pickRecommendedSighting([envLiteral, envRef])).toBe("cursor");
});

it("prefers any stdio over http", () => {
const stdio = makeSighting("codex", { transport: "stdio", command: "npx" });
const http = makeSighting("claude", {
transport: "http",
url: "https://mcp.example.com",
});
expect(pickRecommendedSighting([http, stdio])).toBe("codex");
});

it("prefers http without URL credential over http with URL credential", () => {
const dirty = makeSighting("claude", {
transport: "http",
url: "https://a.example?api_key=xyz",
});
const clean = makeSighting("cursor", { transport: "http", url: "https://b.example" });
expect(pickRecommendedSighting([dirty, clean])).toBe("cursor");
});

it("returns null when all options embed credentials in URL", () => {
const a = makeSighting("claude", {
transport: "http",
url: "https://a.example?api_key=xyz",
});
const b = makeSighting("cursor", {
transport: "http",
url: "https://b.example?token=xyz",
});
expect(pickRecommendedSighting([a, b])).toBeNull();
});
});

describe("isMcpHarnessAddressable", () => {
it("returns true when the CLI is installed", () => {
expect(
Expand Down
Loading