π OpenHands: AI-Driven Development
[codex] Show MCP server names on installed cards (#1429)
Graham Neubigbd15cea15113
diff --git a/.pr/app2499-installed-mcp-card-configured-name.png b/.pr/app2499-installed-mcp-card-configured-name.pngnew file mode 100644index 0000000000..7345378db5Binary files /dev/null and b/.pr/app2499-installed-mcp-card-configured-name.png differdiff --git a/.pr/app2499-installed-mcp-card-fresh-configured-name.png b/.pr/app2499-installed-mcp-card-fresh-configured-name.pngnew file mode 100644index 0000000000..e3e93cf295Binary files /dev/null and b/.pr/app2499-installed-mcp-card-fresh-configured-name.png differdiff --git a/.pr/app2499-installed-mcp-card-marketplace-or-url-fallback.png b/.pr/app2499-installed-mcp-card-marketplace-or-url-fallback.pngnew file mode 100644index 0000000000..cc19411c25Binary files /dev/null and b/.pr/app2499-installed-mcp-card-marketplace-or-url-fallback.png differdiff --git a/.pr/app2499-installed-mcp-section-overview.png b/.pr/app2499-installed-mcp-section-overview.pngnew file mode 100644index 0000000000..25cdd0a906Binary files /dev/null and b/.pr/app2499-installed-mcp-section-overview.png differdiff --git a/src/components/features/mcp-page/installed-server-card.tsx b/src/components/features/mcp-page/installed-server-card.tsxindex 1bf478bf06..3f64588f2a 100644--- a/src/components/features/mcp-page/installed-server-card.tsx+++ b/src/components/features/mcp-page/installed-server-card.tsx@@ -15,6 +15,7 @@ import {extensionModuleCardInteractiveClassName,extensionModuleCardSurfaceClassName,} from "#/utils/extension-module-card-classes";+import { getInstalledServerTitle } from "#/utils/mcp-installed-server-display";interface InstalledServerCardProps {server: MCPServerConfig;@@ -35,11 +36,6 @@ function getServerTransportLabel(type: MCPServerConfig["type"]) {}}-function getServerTitle(server: MCPServerConfig): string {- if (server.type === "stdio") return server.name ?? server.command ?? "";- return server.url ?? "";-}-function getServerDetailLine(server: MCPServerConfig): string {if (server.type === "stdio") {const args =@@ -60,7 +56,7 @@ export function InstalledServerCard({getMcpMarketplaceCatalog(MCP_MARKETPLACE),);- const title = catalog?.name ?? getServerTitle(server);+ const title = getInstalledServerTitle(server, catalog);const detailLine = getServerDetailLine(server);const transport = getServerTransportLabel(server.type);diff --git a/src/utils/mcp-installed-server-display.test.ts b/src/utils/mcp-installed-server-display.test.tsnew file mode 100644index 0000000000..b7292ff9fd--- /dev/null+++ b/src/utils/mcp-installed-server-display.test.ts@@ -0,0 +1,76 @@+import { describe, expect, it } from "vitest";+import type { IntegrationCatalogEntry as MarketplaceEntry } from "@openhands/extensions/integrations";+import type { MCPServerConfig } from "#/types/mcp-server";+import { getInstalledServerTitle } from "./mcp-installed-server-display";++const githubCatalog = {+ id: "github",+ name: "GitHub",+} as MarketplaceEntry;++describe("getInstalledServerTitle", () => {+ it("uses a configured remote server name as the installed card title", () => {+ const server: MCPServerConfig = {+ id: "shttp-0",+ type: "shttp",+ name: "work_github",+ url: "https://api.githubcopilot.com/mcp/",+ };++ expect(getInstalledServerTitle(server, githubCatalog)).toBe("work_github");+ });++ it("uses the catalog title when the stored name is only the marketplace slug", () => {+ const server: MCPServerConfig = {+ id: "shttp-0",+ type: "shttp",+ name: "github",+ url: "https://api.githubcopilot.com/mcp/",+ };++ expect(getInstalledServerTitle(server, githubCatalog)).toBe("GitHub");+ });++ it("falls back to the URL for unnamed remote servers", () => {+ const server: MCPServerConfig = {+ id: "shttp-0",+ type: "shttp",+ url: "https://example.com/mcp",+ };++ expect(getInstalledServerTitle(server)).toBe("https://example.com/mcp");+ });++ it("falls back to the command for unnamed stdio servers", () => {+ const server: MCPServerConfig = {+ id: "stdio-0",+ type: "stdio",+ command: "npx",+ args: ["-y", "some-mcp"],+ };++ expect(getInstalledServerTitle(server)).toBe("npx");+ });++ it("trims surrounding whitespace so a stored name equal to the catalog slug falls back to the catalog title", () => {+ const server: MCPServerConfig = {+ id: "shttp-0",+ type: "shttp",+ name: " github ",+ url: "https://api.githubcopilot.com/mcp/",+ };++ expect(getInstalledServerTitle(server, githubCatalog)).toBe("GitHub");+ });++ it("treats a whitespace-only name as no name and falls back to the URL", () => {+ const server: MCPServerConfig = {+ id: "shttp-0",+ type: "shttp",+ name: " ",+ url: "https://example.com/mcp",+ };++ expect(getInstalledServerTitle(server)).toBe("https://example.com/mcp");+ });+});diff --git a/src/utils/mcp-installed-server-display.ts b/src/utils/mcp-installed-server-display.tsnew file mode 100644index 0000000000..d9951c1a5a--- /dev/null+++ b/src/utils/mcp-installed-server-display.ts@@ -0,0 +1,32 @@+import type { IntegrationCatalogEntry as MarketplaceEntry } from "@openhands/extensions/integrations";+import type { MCPServerConfig } from "#/types/mcp-server";++function configuredServerName(server: MCPServerConfig): string | undefined {+ const name = server.name?.trim();+ return name ? name : undefined;+}++/**+ * Marketplace installs persist the catalog slug as the MCP server name so the+ * backend has a stable reference key. Treat that implicit slug as metadata,+ * while still honoring names the user entered explicitly.+ */+export function getInstalledServerTitle(+ server: MCPServerConfig,+ catalog?: MarketplaceEntry,+): string {+ const name = configuredServerName(server);+ if (name && name !== catalog?.id) {+ return name;+ }++ if (catalog?.name) {+ return catalog.name;+ }++ if (server.type === "stdio") {+ return name ?? server.command ?? "";+ }++ return server.url ?? "";+}