π OpenHands: AI-Driven Development
Promote MCP to top-level nav with marketplace catalog (#253)
Robert Brennan544ffcc5cc19
diff --git a/AGENTS.md b/AGENTS.mdindex 8442e45cc6..36f8da5dcd 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -181,6 +181,8 @@- Custom secrets are NOT auto-attached by the agent-server. `POST /api/conversations` only persists what the client sends in `request.secrets`; the persisted secrets store (`/api/settings/secrets`) is never read at conversation-start. `buildStartConversationRequestWithEncryptedSettings` enumerates `SecretsService.getSecrets()` and turns each entry into a `LookupSecret` whose `url` points back at `/api/settings/secrets/{name}` and whose `headers` carry `X-Session-API-Key` for auth. Pre-1.21.x agent-server SDKs would silently drop that header during validation when `secrets_encrypted=true` (the cipher in the validation context tried to `cipher.decrypt(plaintext_session_key)`, failed, and the validator removed the header β the conversation runtime then got 401s for every saved secret). The SDK fix preserves plaintext header values when decryption fails; if you still see saved secrets unavailable inside a conversation, verify the running agent-server bundles a `LookupSecret._validate_secrets` that falls back to plaintext on decrypt failure.+- MCP page layout: MCP is a **top-level** nav entry at `/mcp` (rendered by `src/routes/mcp.tsx`), shown right below "Skills" in `src/components/features/sidebar/sidebar.tsx`. The legacy `/settings/mcp` route still works as a redirect via `src/routes/mcp-settings-redirect.tsx`, and `src/routes/mcp-settings.tsx` re-exports the new page so the published `MCPSettings` library symbol (in `src/components/settings/index.ts`) keeps the same shape. Marketplace catalog lives in `src/constants/mcp-marketplace.ts` (Slack and Tavily must stay first) β `src/utils/mcp-marketplace-utils.ts` matches installed servers back to catalog entries (Tavily uses the `"tavily-builtin"` sentinel because it is gated by `search_api_key_set` rather than `mcp_config`). Components are colocated under `src/components/features/mcp-page/` and reuse the existing `MCPServerForm` for the "Add custom server" / edit flow.+- Library packaging notes:- Public npm entrypoints now come from `src/index.ts` β `src/lib/index.ts`, with domain barrels under `src/components/{conversation,terminal,browser,files,settings,sidebar}/index.ts`.- `npm run build` remains the standalone app build (`react-router build`), while `npm run build:lib` runs `vite build` in library mode plus `tsc -p tsconfig.lib.json` to emit `.d.ts` files into `dist/`.diff --git a/__tests__/components/features/mcp-page/custom-server-editor.test.tsx b/__tests__/components/features/mcp-page/custom-server-editor.test.tsxnew file mode 100644index 0000000000..334e23f2ba--- /dev/null+++ b/__tests__/components/features/mcp-page/custom-server-editor.test.tsx@@ -0,0 +1,89 @@+import React from "react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { render, screen, fireEvent, waitFor } from "@testing-library/react";+import { AxiosError } from "axios";+import { beforeEach, describe, expect, it, vi } from "vitest";+import SettingsService from "#/api/settings-service/settings-service.api";+import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";+import { ActiveBackendProvider } from "#/contexts/active-backend-context";+import { CustomServerEditor } from "#/components/features/mcp-page/custom-server-editor";+import { useSettings } from "#/hooks/query/use-settings";++/**+ * Wrapper that only mounts the editor once `useSettings` has resolved.+ * `useAddMcpServer`'s `mutationFn` silently no-ops when settings is+ * undefined (and that no-op resolves, triggering the per-call+ * `onSuccess` β which would close our modal). Waiting for the query+ * makes the test deterministic.+ */+function EditorOnceSettingsLoaded({ onClose }: { onClose: () => void }) {+ const { data } = useSettings();+ if (!data) return null;+ return (+ <CustomServerEditor+ server={{ id: "", type: "sse" }}+ existingServers={[]}+ onClose={onClose}+ />+ );+}++function renderWith(ui: React.ReactNode) {+ return render(ui, {+ wrapper: ({ children }) => (+ <QueryClientProvider+ client={+ new QueryClient({ defaultOptions: { queries: { retry: false } } })+ }+ >+ <ActiveBackendProvider>{children}</ActiveBackendProvider>+ </QueryClientProvider>+ ),+ });+}++describe("CustomServerEditor", () => {+ beforeEach(() => {+ vi.restoreAllMocks();+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(+ MOCK_DEFAULT_USER_SETTINGS,+ );+ });++ it("keeps the modal open and does not call onClose when the add mutation fails", async () => {+ // Simulate a backend rejection β the editor should surface the+ // failure as an `onError` toast and leave the modal open so the+ // user can retry. Previously these calls had no `onError` at+ // all, and the modal closed even on a 4xx/5xx because+ // tanstack-query's per-call `onSuccess` doesn't run on+ // rejection but didn't gate the close either way.+ const err = new AxiosError("Boom");+ err.response = {+ status: 400,+ data: { detail: "Server name already in use" },+ } as unknown as AxiosError["response"];+ const saveSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockRejectedValue(err);++ const onClose = vi.fn();+ renderWith(<EditorOnceSettingsLoaded onClose={onClose} />);++ // Wrapper waits for useSettings before mounting the editor, so+ // by the time we see the editor the mutation hook will fire its+ // mutationFn (rather than silently no-op).+ await screen.findByTestId("mcp-custom-editor");+ fireEvent.change(screen.getByTestId("url-input"), {+ target: { value: "https://example.com/mcp" },+ });+ fireEvent.click(screen.getByTestId("submit-button"));++ await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1));++ // Modal is still mounted β onClose was *not* called on failure.+ await waitFor(() => {+ expect(screen.queryByTestId("mcp-custom-editor")).toBeInTheDocument();+ expect(onClose).not.toHaveBeenCalled();+ });+ });+});diff --git a/__tests__/components/features/mcp-page/install-server-modal.test.tsx b/__tests__/components/features/mcp-page/install-server-modal.test.tsxnew file mode 100644index 0000000000..8bf10d9d56--- /dev/null+++ b/__tests__/components/features/mcp-page/install-server-modal.test.tsx@@ -0,0 +1,181 @@+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { render, screen, fireEvent, waitFor } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";+import SettingsService from "#/api/settings-service/settings-service.api";+import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";+import { ActiveBackendProvider } from "#/contexts/active-backend-context";+import { InstallServerModal } from "#/components/features/mcp-page/install-server-modal";+import { MCP_MARKETPLACE, MarketplaceEntry } from "#/constants/mcp-marketplace";++function renderWith(ui: React.ReactNode) {+ return render(ui, {+ wrapper: ({ children }) => (+ <QueryClientProvider+ client={+ new QueryClient({ defaultOptions: { queries: { retry: false } } })+ }+ >+ <ActiveBackendProvider>{children}</ActiveBackendProvider>+ </QueryClientProvider>+ ),+ });+}++describe("InstallServerModal", () => {+ beforeEach(() => {+ vi.restoreAllMocks();+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(+ MOCK_DEFAULT_USER_SETTINGS,+ );+ });++ it("requires Slack token + team id and posts a stdio mcp_config diff", async () => {+ const slack = MCP_MARKETPLACE.find((e) => e.id === "slack")!;+ const saveSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);++ const onClose = vi.fn();+ renderWith(<InstallServerModal entry={slack} onClose={onClose} />);++ await screen.findByTestId("mcp-install-modal");++ // Fail fast when required fields are empty.+ fireEvent.click(screen.getByTestId("mcp-install-submit"));+ await waitFor(() => {+ expect(saveSpy).not.toHaveBeenCalled();+ });++ fireEvent.change(screen.getByTestId("mcp-install-field-SLACK_BOT_TOKEN"), {+ target: { value: "xoxb-abc" },+ });+ fireEvent.change(screen.getByTestId("mcp-install-field-SLACK_TEAM_ID"), {+ target: { value: "T01" },+ });+ fireEvent.click(screen.getByTestId("mcp-install-submit"));++ await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1));+ const [payload] = saveSpy.mock.calls[0];+ const sentMcpConfig = (payload as Record<string, unknown>)+ .agent_settings_diff as {+ mcp_config: { mcpServers: Record<string, unknown> };+ };+ expect(sentMcpConfig.mcp_config.mcpServers).toMatchObject({+ slack: {+ command: "npx",+ env: { SLACK_BOT_TOKEN: "xoxb-abc", SLACK_TEAM_ID: "T01" },+ },+ });+ expect(onClose).toHaveBeenCalled();+ });++ it("installs Tavily by writing search_api_key", async () => {+ const tavily = MCP_MARKETPLACE.find((e) => e.id === "tavily")!;+ const saveSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);++ const onClose = vi.fn();+ renderWith(<InstallServerModal entry={tavily} onClose={onClose} />);++ await screen.findByTestId("mcp-install-modal");++ fireEvent.change(screen.getByTestId("mcp-install-field-search_api_key"), {+ target: { value: "tvly-secret" },+ });+ fireEvent.click(screen.getByTestId("mcp-install-submit"));++ await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1));+ expect(saveSpy.mock.calls[0][0]).toEqual({+ search_api_key: "tvly-secret",+ });+ expect(onClose).toHaveBeenCalled();+ });++ it("blocks submission of an shttp template when api_key is required and empty", async () => {+ // Build a synthetic catalog entry with apiKeyOptional: false so we+ // exercise the new required-key validation in handleHttpServerSubmit+ // without relying on the catalog choosing to mark one this way.+ const entry: MarketplaceEntry = {+ id: "synthetic-required",+ name: "Synthetic",+ description: "Synthetic catalog entry used in tests.",+ logo: null,+ iconBg: "#000000",+ template: {+ kind: "shttp",+ url: "https://example.com/mcp",+ apiKeyOptional: false,+ },+ };+ const saveSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);++ renderWith(<InstallServerModal entry={entry} onClose={vi.fn()} />);++ await screen.findByTestId("mcp-install-modal");++ fireEvent.click(screen.getByTestId("mcp-install-submit"));+ // No save call until the user fills in the key.+ await waitFor(() => {+ expect(saveSpy).not.toHaveBeenCalled();+ });++ fireEvent.change(screen.getByTestId("mcp-install-field-api_key"), {+ target: { value: "secret-123" },+ });+ fireEvent.click(screen.getByTestId("mcp-install-submit"));++ await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1));+ });++ it("renders an inline error when Tavily submit is clicked with no key", async () => {+ const tavily = MCP_MARKETPLACE.find((e) => e.id === "tavily")!;+ const saveSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);++ renderWith(<InstallServerModal entry={tavily} onClose={vi.fn()} />);+ await screen.findByTestId("mcp-install-modal");++ fireEvent.click(screen.getByTestId("mcp-install-submit"));++ // Error state set in handleTavilySubmit must actually render+ // (previously it was set but never displayed).+ await screen.findByText("MCP$ERROR_FIELD_REQUIRED");+ expect(saveSpy).not.toHaveBeenCalled();+ });++ it("allows submitting an shttp template with no key when apiKeyOptional is true", async () => {+ const entry: MarketplaceEntry = {+ id: "synthetic-optional",+ name: "Synthetic Optional",+ description: "Synthetic entry that allows empty api_key.",+ logo: null,+ iconBg: "#000000",+ template: {+ kind: "shttp",+ url: "https://example.com/mcp",+ apiKeyOptional: true,+ },+ };+ const getSpy = vi+ .spyOn(SettingsService, "getSettings")+ .mockResolvedValue(MOCK_DEFAULT_USER_SETTINGS);+ const saveSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);++ renderWith(<InstallServerModal entry={entry} onClose={vi.fn()} />);++ await screen.findByTestId("mcp-install-modal");+ // The add-mcp-server mutation bails when useSettings() hasn't+ // resolved yet, so wait for the initial settings fetch before+ // submitting β otherwise the test races React Query.+ await waitFor(() => expect(getSpy).toHaveBeenCalled());+ fireEvent.click(screen.getByTestId("mcp-install-submit"));++ await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1));+ });+});diff --git a/__tests__/hooks/use-settings-nav-items.test.tsx b/__tests__/hooks/use-settings-nav-items.test.tsxindex b48979da48..4448f3e583 100644--- a/__tests__/hooks/use-settings-nav-items.test.tsx+++ b/__tests__/hooks/use-settings-nav-items.test.tsx@@ -53,7 +53,7 @@ describe("useSettingsNavItems", () => {.map((item) => (item.type === "item" ? item.item.to : null));expect(paths).not.toContain("/settings");- expect(paths).toContain("/settings/mcp");+ expect(paths).toContain("/settings/app");expect(paths).toContain("/settings/secrets");});@@ -68,5 +68,8 @@ describe("useSettingsNavItems", () => {expect(paths).not.toContain("/settings/agent-server");expect(paths).not.toContain("/settings/integrations");expect(paths).not.toContain("/settings/skills");+ // MCP was elevated to a top-level /mcp nav entry; it must no+ // longer appear as a Settings sub-page.+ expect(paths).not.toContain("/settings/mcp");});});diff --git a/__tests__/routes/mcp-page.test.tsx b/__tests__/routes/mcp-page.test.tsxnew file mode 100644index 0000000000..2a71f6bea5--- /dev/null+++ b/__tests__/routes/mcp-page.test.tsx@@ -0,0 +1,182 @@+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { render, screen, fireEvent, waitFor } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";+import MCPPage from "#/routes/mcp";+import SettingsService from "#/api/settings-service/settings-service.api";+import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";+import { Settings } from "#/types/settings";+import { ActiveBackendProvider } from "#/contexts/active-backend-context";++function buildSettings(overrides: Partial<Settings> = {}): Settings {+ return {+ ...MOCK_DEFAULT_USER_SETTINGS,+ ...overrides,+ agent_settings: {+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,+ ...overrides.agent_settings,+ },+ mcp_config: overrides.mcp_config ?? MOCK_DEFAULT_USER_SETTINGS.mcp_config,+ };+}++function renderPage() {+ return render(<MCPPage />, {+ wrapper: ({ children }) => (+ <QueryClientProvider+ client={+ new QueryClient({ defaultOptions: { queries: { retry: false } } })+ }+ >+ <ActiveBackendProvider>{children}</ActiveBackendProvider>+ </QueryClientProvider>+ ),+ });+}++describe("MCPPage", () => {+ beforeEach(() => {+ vi.restoreAllMocks();+ });++ it("renders the empty installed state and the marketplace", async () => {+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(buildSettings());++ renderPage();++ await screen.findByTestId("mcp-marketplace-section");+ expect(screen.getByTestId("mcp-installed-empty")).toBeInTheDocument();+ expect(screen.getByTestId("mcp-marketplace-grid")).toBeInTheDocument();+ });++ it("lists GitHub, Slack, and Tavily as the first three marketplace tiles", async () => {+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(buildSettings());++ renderPage();++ await screen.findByTestId("mcp-marketplace-grid");++ const cards = screen.getAllByTestId(/^mcp-marketplace-card-/);+ expect(cards.length).toBeGreaterThan(3);+ expect(cards[0]).toHaveAttribute(+ "data-testid",+ "mcp-marketplace-card-github",+ );+ expect(cards[1]).toHaveAttribute(+ "data-testid",+ "mcp-marketplace-card-slack",+ );+ expect(cards[2]).toHaveAttribute(+ "data-testid",+ "mcp-marketplace-card-tavily",+ );+ });++ it("opens the install modal when clicking a marketplace tile", async () => {+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(buildSettings());++ renderPage();++ await screen.findByTestId("mcp-marketplace-card-slack");+ fireEvent.click(screen.getByTestId("mcp-marketplace-card-slack"));++ await waitFor(() => {+ expect(screen.getByTestId("mcp-install-modal")).toBeInTheDocument();+ });+ expect(+ screen.getByTestId("mcp-install-field-SLACK_BOT_TOKEN"),+ ).toBeInTheDocument();+ expect(+ screen.getByTestId("mcp-install-field-SLACK_TEAM_ID"),+ ).toBeInTheDocument();+ });++ it("filters marketplace tiles by the search input", async () => {+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(buildSettings());++ renderPage();++ const search = await screen.findByTestId("mcp-search-input");+ fireEvent.change(search, { target: { value: "Slack" } });++ await waitFor(() => {+ expect(+ screen.getByTestId("mcp-marketplace-card-slack"),+ ).toBeInTheDocument();+ });+ expect(+ screen.queryByTestId("mcp-marketplace-card-github"),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByTestId("mcp-marketplace-card-postgres"),+ ).not.toBeInTheDocument();+ });++ it("shows a search-empty state when the query matches nothing", async () => {+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(buildSettings());++ renderPage();++ const search = await screen.findByTestId("mcp-search-input");+ fireEvent.change(search, {+ target: { value: "totally-not-a-real-server" },+ });++ await waitFor(() => {+ expect(screen.getByTestId("mcp-marketplace-empty")).toBeInTheDocument();+ });+ });++ it("deletes an installed stdio server through the confirmation modal", async () => {+ // Pre-install a Slack stdio server via the SDK-shaped mcp_config+ // the route reads from agent_settings.mcp_config.+ const settingsWithSlack = buildSettings({+ agent_settings: {+ ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,+ mcp_config: {+ mcpServers: {+ slack: {+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-slack"],+ env: { SLACK_BOT_TOKEN: "xoxb-abc", SLACK_TEAM_ID: "T01" },+ },+ },+ },+ },+ });+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(+ settingsWithSlack,+ );+ const saveSpy = vi+ .spyOn(SettingsService, "saveSettings")+ .mockResolvedValue(true);++ renderPage();++ const deleteBtn = await screen.findByTestId("delete-mcp-server-button");+ fireEvent.click(deleteBtn);++ const confirmBtn = await screen.findByTestId("confirm-button");+ fireEvent.click(confirmBtn);++ await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1));+ const sent = (saveSpy.mock.calls[0][0] as Record<string, unknown>)+ .agent_settings_diff as { mcp_config: unknown };+ // Server gets pulled out of mcp_config entirely (parseMcpConfig+ // emits `null` once the last entry is removed).+ expect(sent.mcp_config).toBeNull();+ });++ it("badges Tavily as installed when search_api_key_set is true", async () => {+ vi.spyOn(SettingsService, "getSettings").mockResolvedValue(+ buildSettings({ search_api_key_set: true }),+ );++ renderPage();++ await screen.findByTestId("mcp-marketplace-card-tavily");+ expect(+ screen.getByTestId("mcp-marketplace-installed-tavily"),+ ).toBeInTheDocument();+ expect(screen.getByTestId("mcp-installed-list")).toBeInTheDocument();+ });+});diff --git a/__tests__/routes/mcp-settings.test.tsx b/__tests__/routes/mcp-settings.test.tsxdeleted file mode 100644index ca8dd861bf..0000000000--- a/__tests__/routes/mcp-settings.test.tsx+++ /dev/null@@ -1,51 +0,0 @@-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { render, screen } from "@testing-library/react";-import { beforeEach, describe, expect, it, vi } from "vitest";-import MCPSettingsScreen from "#/routes/mcp-settings";-import SettingsService from "#/api/settings-service/settings-service.api";-import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers";-import { Settings } from "#/types/settings";-import { ActiveBackendProvider } from "#/contexts/active-backend-context";--function buildSettings(overrides: Partial<Settings> = {}): Settings {- return {- ...MOCK_DEFAULT_USER_SETTINGS,- ...overrides,- agent_settings: {- ...MOCK_DEFAULT_USER_SETTINGS.agent_settings,- ...overrides.agent_settings,- },- mcp_config: overrides.mcp_config ?? MOCK_DEFAULT_USER_SETTINGS.mcp_config,- };-}--function renderMcpSettingsScreen() {- return render(<MCPSettingsScreen />, {- wrapper: ({ children }) => (- <QueryClientProvider- client={new QueryClient({- defaultOptions: { queries: { retry: false } },- })}- >- <ActiveBackendProvider>{children}</ActiveBackendProvider>- </QueryClientProvider>- ),- });-}--describe("MCPSettingsScreen", () => {- beforeEach(() => {- vi.restoreAllMocks();- });-- it("renders the OSS MCP settings list and search API key section", async () => {- vi.spyOn(SettingsService, "getSettings").mockResolvedValue(buildSettings());-- renderMcpSettingsScreen();-- await screen.findByTestId("mcp-search-settings-section");-- expect(screen.getByTestId("search-api-key-input")).toBeInTheDocument();- expect(screen.getByTestId("save-search-api-key-button")).toBeDisabled();- });-});\ No newline at end of filediff --git a/__tests__/routes/settings.test.tsx b/__tests__/routes/settings.test.tsxindex fc0baa272b..ae86778ad5 100644--- a/__tests__/routes/settings.test.tsx+++ b/__tests__/routes/settings.test.tsx@@ -15,10 +15,12 @@ import { OSS_NAV_ITEMS } from "#/constants/settings-nav";import { ActiveBackendProvider } from "#/contexts/active-backend-context";vi.mock("#/hooks/use-settings-nav-items", () => ({- useSettingsNavItems: () => [- { type: "item", item: OSS_NAV_ITEMS[0] },- { type: "item", item: OSS_NAV_ITEMS[4] },- ],+ // Mirror the real navigation: LLM + Application (which the title test+ // navigates to via `/settings/app`).+ useSettingsNavItems: () =>+ OSS_NAV_ITEMS.filter((item) =>+ ["/settings", "/settings/app"].includes(item.to),+ ).map((item) => ({ type: "item", item })),}));const cloudBackend: Backend = {@@ -47,7 +49,7 @@ describe("settings route", () => {hide_llm_settings: true,hide_users_page: true,}),- ).toBe("/settings/mcp");+ ).toBe("/settings/app");});it("redirects hidden OSS settings pages to the first available route", async () => {@@ -72,7 +74,7 @@ describe("settings route", () => {} as never)) as Response;expect(response.status).toBe(302);- expect(response.headers.get("Location")).toBe("/settings/mcp");+ expect(response.headers.get("Location")).toBe("/settings/app");});it("redirects /integrations to /conversations when the active backend is cloud", async () => {diff --git a/__tests__/utils/mcp-marketplace-utils.test.ts b/__tests__/utils/mcp-marketplace-utils.test.tsnew file mode 100644index 0000000000..7dca314e00--- /dev/null+++ b/__tests__/utils/mcp-marketplace-utils.test.ts@@ -0,0 +1,205 @@+import { describe, expect, it } from "vitest";+import {+ findCatalogEntryForServer,+ findInstalledMatch,+ installedServerMatchesQuery,+ isMarketplaceEntryAvailable,+ marketplaceEntryMatchesQuery,+} from "#/utils/mcp-marketplace-utils";+import { MCP_MARKETPLACE } from "#/constants/mcp-marketplace";++const slackEntry = MCP_MARKETPLACE.find((e) => e.id === "slack")!;+const tavilyEntry = MCP_MARKETPLACE.find((e) => e.id === "tavily")!;+const linearEntry = MCP_MARKETPLACE.find((e) => e.id === "linear")!;+const filesystemEntry = MCP_MARKETPLACE.find((e) => e.id === "filesystem")!;++describe("findInstalledMatch", () => {+ it("matches stdio servers by name", () => {+ const result = findInstalledMatch(slackEntry.template, [+ {+ id: "stdio-0",+ type: "stdio",+ name: "slack",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-slack"],+ },+ ]);+ expect(result).toEqual({+ kind: "mcp",+ server: expect.objectContaining({ id: "stdio-0" }),+ });+ });++ it("does not match a different stdio name", () => {+ const result = findInstalledMatch(slackEntry.template, [+ {+ id: "stdio-0",+ type: "stdio",+ name: "github",+ command: "npx",+ args: [],+ },+ ]);+ expect(result).toBeNull();+ });++ it("returns the tavily-builtin variant when search_api_key_set", () => {+ expect(+ findInstalledMatch(tavilyEntry.template, [], {+ search_api_key_set: true,+ }),+ ).toEqual({ kind: "tavily-builtin" });+ expect(+ findInstalledMatch(tavilyEntry.template, [], {+ search_api_key_set: false,+ }),+ ).toBeNull();+ });++ it("matches SSE servers loosely on URL", () => {+ const result = findInstalledMatch(linearEntry.template, [+ {+ id: "sse-0",+ type: "sse",+ url: "https://mcp.linear.app/sse/",+ },+ ]);+ expect(result).toEqual({+ kind: "mcp",+ server: expect.objectContaining({ id: "sse-0" }),+ });+ });++ it("returns null when servers carry malformed urls (defensive)", () => {+ const result = findInstalledMatch(linearEntry.template, [+ // Cast to any to simulate runtime data slipping past the type.+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ { id: "sse-0", type: "sse", url: undefined as any },+ ]);+ expect(result).toBeNull();+ });+});++describe("isMarketplaceEntryAvailable", () => {+ it("treats unset availability as 'all'", () => {+ expect(isMarketplaceEntryAvailable(slackEntry, "local")).toBe(true);+ expect(isMarketplaceEntryAvailable(slackEntry, "cloud")).toBe(true);+ });++ it("hides local-only entries on cloud", () => {+ expect(isMarketplaceEntryAvailable(filesystemEntry, "local")).toBe(true);+ expect(isMarketplaceEntryAvailable(filesystemEntry, "cloud")).toBe(false);+ });+});++describe("marketplaceEntryMatchesQuery", () => {+ it("matches by name (case-insensitive)", () => {+ expect(marketplaceEntryMatchesQuery(slackEntry, "slack")).toBe(true);+ expect(marketplaceEntryMatchesQuery(slackEntry, "SLACK")).toBe(true);+ });++ it("matches by keyword", () => {+ expect(marketplaceEntryMatchesQuery(slackEntry, "messaging")).toBe(true);+ });++ it("matches by substring of description", () => {+ expect(marketplaceEntryMatchesQuery(tavilyEntry, "web search")).toBe(true);+ });++ it("returns true for empty/whitespace queries", () => {+ expect(marketplaceEntryMatchesQuery(slackEntry, "")).toBe(true);+ expect(marketplaceEntryMatchesQuery(slackEntry, " ")).toBe(true);+ });++ it("returns false for non-matches", () => {+ expect(marketplaceEntryMatchesQuery(slackEntry, "zzzz-no-match")).toBe(+ false,+ );+ });+});++describe("installedServerMatchesQuery", () => {+ const slackServer = {+ id: "stdio-0",+ type: "stdio" as const,+ name: "slack",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-slack"],+ };++ it("matches by stdio server name", () => {+ expect(installedServerMatchesQuery(slackServer, undefined, "slack")).toBe(+ true,+ );+ });++ it("matches via the catalog entry's name even if server.name differs", () => {+ const renamed = { ...slackServer, name: "my-slack-instance" };+ expect(installedServerMatchesQuery(renamed, slackEntry, "slack")).toBe(+ true,+ );+ });++ it("matches by url for shttp/sse servers", () => {+ const sseServer = {+ id: "sse-0",+ type: "sse" as const,+ url: "https://mcp.linear.app/sse",+ };+ expect(installedServerMatchesQuery(sseServer, undefined, "linear")).toBe(+ true,+ );+ });++ it("empty query always matches", () => {+ expect(installedServerMatchesQuery(slackServer, undefined, "")).toBe(true);+ });+});++describe("findCatalogEntryForServer", () => {+ it("finds the Slack catalog entry for an installed Slack stdio server", () => {+ const match = findCatalogEntryForServer(+ {+ id: "stdio-0",+ type: "stdio",+ name: "slack",+ command: "npx",+ args: [],+ },+ MCP_MARKETPLACE,+ );+ expect(match?.id).toBe("slack");+ });++ it("returns undefined for unknown servers", () => {+ expect(+ findCatalogEntryForServer(+ {+ id: "stdio-0",+ type: "stdio",+ name: "unknown",+ command: "npx",+ args: [],+ },+ MCP_MARKETPLACE,+ ),+ ).toBeUndefined();+ });++ it("matches an SSE server whose URL differs only by trailing slash", () => {+ // Regression coverage for the strict-=== URL match that previously+ // diverged from findInstalledMatch and caused installed cards to+ // render the generic icon while the marketplace tile said+ // "Installed".+ const linear = MCP_MARKETPLACE.find((e) => e.id === "linear")!;+ if (linear.template.kind !== "sse") {+ throw new Error("Linear template should be SSE");+ }+ const normalizedUrl = linear.template.url.replace(/\/$/, "");+ const match = findCatalogEntryForServer(+ { id: "sse-0", type: "sse", url: `${normalizedUrl}/` },+ MCP_MARKETPLACE,+ );+ expect(match?.id).toBe("linear");+ });+});diff --git a/src/components/features/mcp-page/custom-server-editor.tsx b/src/components/features/mcp-page/custom-server-editor.tsxnew file mode 100644index 0000000000..ab167ea068--- /dev/null+++ b/src/components/features/mcp-page/custom-server-editor.tsx@@ -0,0 +1,89 @@+import React from "react";+import { AxiosError } from "axios";+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";+import { MCPServerForm } from "#/components/features/settings/mcp-settings/mcp-server-form";+import { useAddMcpServer } from "#/hooks/mutation/use-add-mcp-server";+import { useUpdateMcpServer } from "#/hooks/mutation/use-update-mcp-server";+import { MCPServerConfig } from "#/types/mcp-server";+import { displayErrorToast } from "#/utils/custom-toast-handlers";+import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";++interface CustomServerEditorProps {+ server: MCPServerConfig;+ existingServers: MCPServerConfig[];+ onClose: () => void;+}++/**+ * Modal wrapper around the legacy `MCPServerForm` so power users can+ * still hand-author arbitrary stdio / SSE / SHTTP entries without+ * reaching for raw JSON. An empty `server.id` means "Add new".+ */+export function CustomServerEditor({+ server,+ existingServers,+ onClose,+}: CustomServerEditorProps) {+ const { t } = useTranslation("openhands");+ const { mutate: addMcpServer, isPending: isAdding } = useAddMcpServer();+ const { mutate: updateMcpServer, isPending: isUpdating } =+ useUpdateMcpServer();++ const isEditing = !!server.id;+ const isPending = isAdding || isUpdating;++ // Shared error handler so both add and update surface backend errors+ // as a toast instead of failing silently β previously these calls+ // had no `onError` and the modal closed even on a 4xx/5xx, leaving+ // the user to discover the failure on the next page load.+ const handleError = (err: unknown) => {+ const message = retrieveAxiosErrorMessage(err as AxiosError);+ displayErrorToast(message || t(I18nKey.ERROR$GENERIC));+ };++ const handleSubmit = (payload: MCPServerConfig) => {+ if (isEditing) {+ updateMcpServer(+ { serverId: server.id, server: payload },+ { onSuccess: onClose, onError: handleError },+ );+ } else {+ addMcpServer(payload, { onSuccess: onClose, onError: handleError });+ }+ };++ return (+ <ModalBackdrop+ // Block backdrop-click / Escape from dismissing the modal while+ // a mutation is in flight β closing mid-request would orphan+ // the request and leave the user with no error feedback.+ onClose={isPending ? undefined : onClose}+ closeOnEscape={!isPending}+ aria-label={+ isEditing+ ? t(I18nKey.MCP$EDIT_CUSTOM_TITLE)+ : t(I18nKey.MCP$ADD_CUSTOM_TITLE)+ }+ >+ <div+ data-testid="mcp-custom-editor"+ className="bg-base-secondary p-6 rounded-xl border border-tertiary w-[680px] max-w-[90vw] max-h-[90vh] overflow-y-auto custom-scrollbar"+ >+ <h2 className="text-lg font-semibold mb-4">+ {isEditing+ ? t(I18nKey.MCP$EDIT_CUSTOM_TITLE)+ : t(I18nKey.MCP$ADD_CUSTOM_TITLE)}+ </h2>+ <MCPServerForm+ mode={isEditing ? "edit" : "add"}+ server={isEditing ? server : undefined}+ existingServers={existingServers}+ onSubmit={handleSubmit}+ onCancel={onClose}+ />+ </div>+ </ModalBackdrop>+ );+}diff --git a/src/components/features/mcp-page/index.ts b/src/components/features/mcp-page/index.tsnew file mode 100644index 0000000000..3ed10d2a6a--- /dev/null+++ b/src/components/features/mcp-page/index.ts@@ -0,0 +1,7 @@+export { InstalledServersSection } from "./installed-servers-section";+export { InstalledServerCard } from "./installed-server-card";+export { MarketplaceSection } from "./marketplace-section";+export { MarketplaceCard } from "./marketplace-card";+export { InstallServerModal } from "./install-server-modal";+export { CustomServerEditor } from "./custom-server-editor";+export { MarketplaceSearch } from "./marketplace-search";diff --git a/src/components/features/mcp-page/install-server-modal.tsx b/src/components/features/mcp-page/install-server-modal.tsxnew file mode 100644index 0000000000..d70a0b5249--- /dev/null+++ b/src/components/features/mcp-page/install-server-modal.tsx@@ -0,0 +1,414 @@+import React from "react";+import { useTranslation } from "react-i18next";+import { AxiosError } from "axios";+import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";+import { BrandButton } from "#/components/features/settings/brand-button";+import { SettingsInput } from "#/components/features/settings/settings-input";+import { I18nKey } from "#/i18n/declaration";+import { MarketplaceEntry } from "#/constants/mcp-marketplace";+import {+ ExistingInstall,+ MCPServerConfig,+ isMcpInstall,+} from "#/types/mcp-server";+import { useAddMcpServer } from "#/hooks/mutation/use-add-mcp-server";+import { useUpdateMcpServer } from "#/hooks/mutation/use-update-mcp-server";+import { useSaveSettings } from "#/hooks/mutation/use-save-settings";+import { displaySuccessToast } from "#/utils/custom-toast-handlers";+import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";++interface InstallServerModalProps {+ entry: MarketplaceEntry;+ /** Existing install (if any) β drives Edit vs Add. */+ existing?: ExistingInstall | null;+ onClose: () => void;+}++interface FieldState {+ values: Record<string, string>;+ errors: Record<string, string | null>;+}++function makeInitialState(entry: MarketplaceEntry): FieldState {+ const values: Record<string, string> = {};+ if (entry.template.kind === "stdio") {+ for (const field of entry.template.envFields ?? []) {+ values[field.key] = "";+ }+ for (const field of entry.template.argFields ?? []) {+ values[field.key] = "";+ }+ } else if (entry.template.kind === "shttp" || entry.template.kind === "sse") {+ values.api_key = "";+ } else if (entry.template.kind === "tavily-builtin") {+ values.search_api_key = "";+ }+ return { values, errors: {} };+}++export function InstallServerModal({+ entry,+ existing,+ onClose,+}: InstallServerModalProps) {+ const { t } = useTranslation("openhands");+ const { mutate: addMcpServer, isPending: isAdding } = useAddMcpServer();+ const { mutate: updateMcpServer, isPending: isUpdating } =+ useUpdateMcpServer();+ const { mutate: saveSettings, isPending: isSavingSettings } =+ useSaveSettings();++ const [state, setState] = React.useState<FieldState>(() =>+ makeInitialState(entry),+ );+ const [globalError, setGlobalError] = React.useState<string | null>(null);++ const isEditing = !!existing;+ const isPending = isAdding || isUpdating || isSavingSettings;++ const setValue = (key: string, value: string) => {+ setState((prev) => ({+ values: { ...prev.values, [key]: value },+ errors: { ...prev.errors, [key]: null },+ }));+ setGlobalError(null);+ };++ // ------------------------------------------------------------------+ // Shared add-or-update plumbing. Every per-template handler funnels+ // through this to keep success/error handling consistent (single+ // toast + single error path), and to centralize the "create new vs.+ // update existing" branching.+ // ------------------------------------------------------------------+ const submitServer = (payload: MCPServerConfig) => {+ const onSuccess = () => {+ displaySuccessToast(t(I18nKey.MCP$INSTALL_SUCCESS));+ onClose();+ };+ const onError = (err: unknown) => {+ const message = retrieveAxiosErrorMessage(err as AxiosError);+ setGlobalError(message || t(I18nKey.ERROR$GENERIC));+ };+ if (isMcpInstall(existing)) {+ updateMcpServer(+ { serverId: existing.server.id, server: payload },+ { onSuccess, onError },+ );+ } else {+ addMcpServer(payload, { onSuccess, onError });+ }+ };++ // ------------------------------------------------------------------+ // Per-template submit handlers. Each is small and self-contained:+ // validate user input, build the payload, then hand off to+ // submitServer / saveSettings.+ // ------------------------------------------------------------------+ const handleTavilySubmit = () => {+ const key = state.values.search_api_key?.trim() ?? "";+ if (!key && !isEditing) {+ setState((prev) => ({+ ...prev,+ errors: { search_api_key: t(I18nKey.MCP$ERROR_FIELD_REQUIRED) },+ }));+ return;+ }+ saveSettings(+ { search_api_key: key },+ {+ onSuccess: () => {+ displaySuccessToast(t(I18nKey.MCP$INSTALL_SUCCESS));+ onClose();+ },+ onError: (err) => {+ const message = retrieveAxiosErrorMessage(err as AxiosError);+ setGlobalError(message || t(I18nKey.ERROR$GENERIC));+ },+ },+ );+ };++ const handleHttpServerSubmit = () => {+ // TS narrows this branch to shttp|sse; the equality guard is a+ // runtime/defensive belt to make the helper safe in isolation.+ if (entry.template.kind !== "shttp" && entry.template.kind !== "sse") {+ return;+ }+ const apiKey = state.values.api_key?.trim() ?? "";+ if (!entry.template.apiKeyOptional && !apiKey) {+ setState((prev) => ({+ ...prev,+ errors: { api_key: t(I18nKey.MCP$ERROR_FIELD_REQUIRED) },+ }));+ return;+ }+ const existingMcp = isMcpInstall(existing) ? existing.server : null;+ const payload: MCPServerConfig = {+ id: existingMcp?.id ?? `${entry.template.kind}-${Date.now()}`,+ type: entry.template.kind,+ url: entry.template.url,+ ...(apiKey && { api_key: apiKey }),+ };+ submitServer(payload);+ };++ const handleStdioSubmit = () => {+ if (entry.template.kind !== "stdio") return;+ const stdio = entry.template;+ const errors: Record<string, string | null> = {};++ for (const field of stdio.envFields ?? []) {+ if (field.required && !(state.values[field.key] ?? "").trim()) {+ errors[field.key] = t(I18nKey.MCP$ERROR_FIELD_REQUIRED);+ }+ }+ for (const field of stdio.argFields ?? []) {+ if (field.required && !(state.values[field.key] ?? "").trim()) {+ errors[field.key] = t(I18nKey.MCP$ERROR_FIELD_REQUIRED);+ }+ }+ if (Object.values(errors).some(Boolean)) {+ setState((prev) => ({ ...prev, errors }));+ return;+ }++ const env: Record<string, string> = {};+ for (const field of stdio.envFields ?? []) {+ const v = state.values[field.key]?.trim();+ if (v) env[field.key] = v;+ }+ const extraArgs: string[] = [];+ for (const field of stdio.argFields ?? []) {+ const v = state.values[field.key]?.trim();+ if (v) {+ // Filesystem-style multi-token input: split on whitespace.+ for (const token of v.split(/\s+/)) {+ if (token) extraArgs.push(token);+ }+ }+ }++ const existingMcp = isMcpInstall(existing) ? existing.server : null;+ const payload: MCPServerConfig = {+ id: existingMcp?.id ?? `stdio-${Date.now()}`,+ type: "stdio",+ name: stdio.serverName,+ command: stdio.command,+ args: [...stdio.args, ...extraArgs],+ ...(Object.keys(env).length > 0 && { env }),+ };+ submitServer(payload);+ };++ const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {+ event.preventDefault();+ setGlobalError(null);+ if (entry.template.kind === "tavily-builtin") return handleTavilySubmit();+ if (entry.template.kind === "shttp" || entry.template.kind === "sse") {+ return handleHttpServerSubmit();+ }+ return handleStdioSubmit();+ };++ const renderFields = () => {+ if (entry.template.kind === "tavily-builtin") {+ return (+ <div className="flex flex-col gap-1">+ <SettingsInput+ testId="mcp-install-field-search_api_key"+ name="search_api_key"+ type="password"+ label={t(I18nKey.SETTINGS$SEARCH_API_KEY)}+ value={state.values.search_api_key ?? ""}+ onChange={(v) => setValue("search_api_key", v)}+ placeholder="tvly-..."+ className="w-full"+ />+ {/* `handleTavilySubmit` sets this error on submit when the+ key is empty; render it inline so the user actually sees+ the validation failure (previously the state was set but+ never displayed). */}+ {state.errors.search_api_key && (+ <p className="text-xs text-red-500">+ {state.errors.search_api_key}+ </p>+ )}+ </div>+ );+ }++ if (entry.template.kind === "shttp" || entry.template.kind === "sse") {+ const apiKeyOptional = entry.template.apiKeyOptional ?? false;+ return (+ <>+ <SettingsInput+ testId="mcp-install-field-url"+ name="url"+ type="url"+ label={t(I18nKey.SETTINGS$MCP_URL)}+ value={entry.template.url}+ onChange={() => {}}+ isDisabled+ className="w-full"+ />+ <div className="flex flex-col gap-1">+ <SettingsInput+ testId="mcp-install-field-api_key"+ name="api_key"+ type="password"+ label={t(I18nKey.SETTINGS$MCP_API_KEY)}+ value={state.values.api_key ?? ""}+ onChange={(v) => setValue("api_key", v)}+ placeholder={t(I18nKey.SETTINGS$MCP_API_KEY_PLACEHOLDER)}+ showOptionalTag={apiKeyOptional}+ required={!apiKeyOptional}+ className="w-full"+ />+ {state.errors.api_key && (+ <p className="text-xs text-red-500">{state.errors.api_key}</p>+ )}+ </div>+ </>+ );+ }++ const stdio = entry.template;+ return (+ <>+ <SettingsInput+ testId="mcp-install-field-command-readonly"+ name="command-readonly"+ type="text"+ label={t(I18nKey.MCP$COMMAND_LABEL)}+ value={`${stdio.command} ${stdio.args.join(" ")}`.trim()}+ onChange={() => {}}+ isDisabled+ className="w-full"+ />+ {(stdio.envFields ?? []).map((field) => (+ <div key={field.key} className="flex flex-col gap-1">+ <SettingsInput+ testId={`mcp-install-field-${field.key}`}+ name={field.key}+ type={field.type === "password" ? "password" : "text"}+ label={field.label}+ value={state.values[field.key] ?? ""}+ onChange={(v) => setValue(field.key, v)}+ placeholder={field.placeholder}+ required={field.required}+ showOptionalTag={!field.required}+ className="w-full"+ />+ {field.helperText && (+ <p className="text-xs text-tertiary-alt">{field.helperText}</p>+ )}+ {state.errors[field.key] && (+ <p className="text-xs text-red-500">{state.errors[field.key]}</p>+ )}+ </div>+ ))}+ {(stdio.argFields ?? []).map((field) => (+ <div key={field.key} className="flex flex-col gap-1">+ <SettingsInput+ testId={`mcp-install-field-${field.key}`}+ name={field.key}+ type={field.type === "password" ? "password" : "text"}+ label={field.label}+ value={state.values[field.key] ?? ""}+ onChange={(v) => setValue(field.key, v)}+ placeholder={field.placeholder}+ required={field.required}+ showOptionalTag={!field.required}+ className="w-full"+ />+ {field.helperText && (+ <p className="text-xs text-tertiary-alt">{field.helperText}</p>+ )}+ {state.errors[field.key] && (+ <p className="text-xs text-red-500">{state.errors[field.key]}</p>+ )}+ </div>+ ))}+ </>+ );+ };++ return (+ <ModalBackdrop onClose={onClose} aria-label={entry.name}>+ <form+ data-testid="mcp-install-modal"+ data-marketplace-id={entry.id}+ onSubmit={handleSubmit}+ className="bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-tertiary w-[520px] max-w-[90vw] max-h-[85vh] overflow-y-auto custom-scrollbar"+ >+ <div className="flex items-start gap-3">+ <span+ aria-hidden="true"+ className="shrink-0 inline-flex items-center justify-center h-10 w-10 rounded-lg"+ style={{+ backgroundColor: entry.iconBg,+ color: entry.iconColor ?? "#FFFFFF",+ }}+ >+ {entry.logo}+ </span>+ <div className="flex flex-col flex-1">+ <h2 className="text-lg font-semibold">{entry.name}</h2>+ <p className="text-xs text-tertiary-alt">{entry.description}</p>+ </div>+ </div>++ {entry.installHint && (+ <p className="text-xs text-content-2">{entry.installHint}</p>+ )}++ {entry.docsUrl && (+ <a+ href={entry.docsUrl}+ target="_blank"+ rel="noreferrer"+ className="text-xs text-primary hover:underline self-start"+ >+ {t(I18nKey.MCP$VIEW_DOCS)}+ </a>+ )}++ <div className="flex flex-col gap-3">{renderFields()}</div>++ {globalError && (+ <p+ data-testid="mcp-install-modal-error"+ className="text-sm text-red-500"+ >+ {globalError}+ </p>+ )}++ <div className="grid grid-cols-2 gap-2 mt-2">+ <BrandButton+ type="submit"+ variant="primary"+ isDisabled={isPending}+ testId="mcp-install-submit"+ className="w-full text-center"+ >+ {(() => {+ if (isPending) return t(I18nKey.SETTINGS$SAVING);+ if (isEditing) return t(I18nKey.SETTINGS$MCP_SAVE_SERVER);+ return t(I18nKey.MCP$INSTALL_BUTTON);+ })()}+ </BrandButton>+ <BrandButton+ type="button"+ variant="secondary"+ onClick={onClose}+ testId="mcp-install-cancel"+ className="w-full text-center"+ >+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton>+ </div>+ </form>+ </ModalBackdrop>+ );+}diff --git a/src/components/features/mcp-page/installed-server-card.tsx b/src/components/features/mcp-page/installed-server-card.tsxnew file mode 100644index 0000000000..fc3524ebbb--- /dev/null+++ b/src/components/features/mcp-page/installed-server-card.tsx@@ -0,0 +1,129 @@+import { FaPencil, FaTrash } from "react-icons/fa6";+import { Puzzle } from "lucide-react";+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { MCPServerConfig } from "#/types/mcp-server";+import { MCP_MARKETPLACE } from "#/constants/mcp-marketplace";+import { findCatalogEntryForServer } from "#/utils/mcp-marketplace-utils";+import { cn } from "#/utils/utils";++interface InstalledServerCardProps {+ server: MCPServerConfig;+ /** Force a specific marketplace catalog id β used for Tavily where the+ * persisted shape (search_api_key) doesn't look like a normal MCP+ * server. */+ catalogIdOverride?: string;+ onEdit: () => void;+ onDelete: () => void;+}++function getServerTransportLabel(type: MCPServerConfig["type"]) {+ switch (type) {+ case "sse":+ return "SSE";+ case "shttp":+ return "HTTP";+ case "stdio":+ return "stdio";+ default:+ return type;+ }+}++function getServerTitle(server: MCPServerConfig): string {+ if (server.type === "stdio") return server.name ?? server.command ?? "";+ return server.url ?? "";+}++function getServerSubtitle(server: MCPServerConfig): string {+ if (server.type === "stdio") {+ const args =+ server.args && server.args.length > 0 ? ` ${server.args.join(" ")}` : "";+ return `${server.command ?? ""}${args}`.trim();+ }+ return server.url ?? "";+}++export function InstalledServerCard({+ server,+ catalogIdOverride,+ onEdit,+ onDelete,+}: InstalledServerCardProps) {+ const { t } = useTranslation("openhands");+ // Match-by-content is delegated to the shared utility so this card+ // and `findInstalledMatch` agree on URL canonicalization (trailing+ // slashes, query strings, default ports) and stay in sync when one+ // is updated.+ const catalog = catalogIdOverride+ ? MCP_MARKETPLACE.find((entry) => entry.id === catalogIdOverride)+ : findCatalogEntryForServer(server, MCP_MARKETPLACE);++ const title = catalog?.name ?? getServerTitle(server);+ const subtitle = catalogIdOverride ? "" : getServerSubtitle(server);+ const transport = catalogIdOverride+ ? t(I18nKey.MCP$TRANSPORT_BUILTIN)+ : getServerTransportLabel(server.type);++ return (+ <div+ data-testid="mcp-server-item"+ data-server-id={server.id}+ className={cn(+ "flex items-start gap-3 rounded-xl",+ "border border-tertiary bg-base-secondary p-4",+ )}+ >+ <span+ aria-hidden="true"+ className="shrink-0 inline-flex items-center justify-center h-10 w-10 rounded-lg"+ style={{+ backgroundColor: catalog?.iconBg ?? "#3F4452",+ color: catalog?.iconColor ?? "#FFFFFF",+ }}+ >+ {catalog?.logo ?? <Puzzle className="h-5 w-5" strokeWidth={2.25} />}+ </span>++ <div className="flex flex-col min-w-0 flex-1 gap-0.5">+ <div className="flex items-center gap-2">+ <h3 className="text-sm font-semibold truncate" title={title}>+ {title}+ </h3>+ <span className="shrink-0 rounded-full bg-tertiary text-tertiary-alt text-[10px] font-medium px-2 py-0.5 uppercase">+ {transport}+ </span>+ </div>+ {subtitle && (+ <p+ className="text-xs text-content-2 italic truncate"+ title={subtitle}+ >+ {subtitle}+ </p>+ )}+ </div>++ <div className="flex items-center gap-3 shrink-0">+ <button+ data-testid="edit-mcp-server-button"+ type="button"+ onClick={onEdit}+ aria-label={t(I18nKey.MCP$EDIT_SERVER_ARIA, { name: title })}+ className="text-content-2 hover:text-content-1 transition-colors cursor-pointer"+ >+ <FaPencil size={14} />+ </button>+ <button+ data-testid="delete-mcp-server-button"+ type="button"+ onClick={onDelete}+ aria-label={t(I18nKey.MCP$DELETE_SERVER_ARIA, { name: title })}+ className="text-content-2 hover:text-red-500 transition-colors cursor-pointer"+ >+ <FaTrash size={14} />+ </button>+ </div>+ </div>+ );+}diff --git a/src/components/features/mcp-page/installed-servers-section.tsx b/src/components/features/mcp-page/installed-servers-section.tsxnew file mode 100644index 0000000000..72edaad90c--- /dev/null+++ b/src/components/features/mcp-page/installed-servers-section.tsx@@ -0,0 +1,96 @@+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { MCPServerConfig } from "#/types/mcp-server";+import { InstalledServerCard } from "./installed-server-card";++interface InstalledServersSectionProps {+ /** Already-filtered list β search filtering happens upstream. */+ servers: MCPServerConfig[];+ /**+ * Tavily has a virtual "installed" card when search_api_key is set+ * on the backend. Pass `true` when it matches the current search.+ */+ tavilyBuiltinInstalled?: boolean;+ /**+ * True iff there is at least one installed server (or the Tavily+ * builtin) before applying the search filter. Lets the section+ * differentiate "nothing installed yet" from "no installed servers+ * match the current search".+ */+ hasAnyInstalled: boolean;+ /** Current search query β empty string means no filter applied. */+ query?: string;+ onEdit: (server: MCPServerConfig) => void;+ onDelete: (serverId: string) => void;+ onConfigureTavilyBuiltin?: () => void;+ onRemoveTavilyBuiltin?: () => void;+}++export function InstalledServersSection({+ servers,+ tavilyBuiltinInstalled,+ hasAnyInstalled,+ query = "",+ onEdit,+ onDelete,+ onConfigureTavilyBuiltin,+ onRemoveTavilyBuiltin,+}: InstalledServersSectionProps) {+ const { t } = useTranslation("openhands");++ const isEmpty = servers.length === 0 && !tavilyBuiltinInstalled;++ if (isEmpty) {+ // Filter narrowed everything out β vs. nothing was installed in+ // the first place. Different copy in each case.+ if (hasAnyInstalled && query.trim().length > 0) {+ return (+ <div+ data-testid="mcp-installed-empty-search"+ className="rounded-xl border border-dashed border-tertiary p-6 text-center"+ >+ <p className="text-xs text-tertiary-alt">+ {t(I18nKey.MCP$SEARCH_EMPTY)}+ </p>+ </div>+ );+ }+ return (+ <div+ data-testid="mcp-installed-empty"+ className="rounded-xl border border-dashed border-tertiary p-8 text-center"+ >+ <p className="text-sm text-content-2">+ {t(I18nKey.MCP$INSTALLED_EMPTY_TITLE)}+ </p>+ <p className="text-xs text-tertiary-alt mt-1">+ {t(I18nKey.MCP$INSTALLED_EMPTY_HINT)}+ </p>+ </div>+ );+ }++ return (+ <div+ data-testid="mcp-installed-list"+ className="grid gap-3 grid-cols-1 md:grid-cols-2"+ >+ {tavilyBuiltinInstalled && (+ <InstalledServerCard+ catalogIdOverride="tavily"+ server={{ id: "tavily-builtin", type: "shttp" }}+ onEdit={() => onConfigureTavilyBuiltin?.()}+ onDelete={() => onRemoveTavilyBuiltin?.()}+ />+ )}+ {servers.map((server) => (+ <InstalledServerCard+ key={server.id}+ server={server}+ onEdit={() => onEdit(server)}+ onDelete={() => onDelete(server.id)}+ />+ ))}+ </div>+ );+}diff --git a/src/components/features/mcp-page/marketplace-card.tsx b/src/components/features/mcp-page/marketplace-card.tsxnew file mode 100644index 0000000000..b6efd69845--- /dev/null+++ b/src/components/features/mcp-page/marketplace-card.tsx@@ -0,0 +1,81 @@+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { MarketplaceEntry } from "#/constants/mcp-marketplace";+import { cn } from "#/utils/utils";++interface MarketplaceCardProps {+ entry: MarketplaceEntry;+ installed: boolean;+ onClick: () => void;+}++export function MarketplaceCard({+ entry,+ installed,+ onClick,+}: MarketplaceCardProps) {+ const { t } = useTranslation("openhands");++ const transportLabel = (() => {+ switch (entry.template.kind) {+ case "stdio":+ return "stdio";+ case "shttp":+ return "HTTP";+ case "sse":+ return "SSE";+ case "tavily-builtin":+ return t(I18nKey.MCP$TRANSPORT_BUILTIN);+ default:+ return "";+ }+ })();++ return (+ <button+ type="button"+ onClick={onClick}+ data-testid={`mcp-marketplace-card-${entry.id}`}+ className={cn(+ "group flex flex-col text-left",+ "rounded-xl border border-tertiary bg-base-secondary",+ "p-4 gap-3 cursor-pointer",+ "hover:border-primary/60 hover:bg-base-tertiary/30 transition-colors",+ "focus:outline-none focus:ring-2 focus:ring-primary/60",+ )}+ >+ <div className="flex items-start gap-3">+ <span+ aria-hidden="true"+ className={cn(+ "shrink-0 inline-flex items-center justify-center",+ "h-10 w-10 rounded-lg",+ )}+ style={{+ backgroundColor: entry.iconBg,+ color: entry.iconColor ?? "#FFFFFF",+ }}+ >+ {entry.logo}+ </span>+ <div className="flex flex-col min-w-0 flex-1">+ <div className="flex items-center gap-2">+ <h3 className="text-sm font-semibold truncate">{entry.name}</h3>+ {installed && (+ <span+ data-testid={`mcp-marketplace-installed-${entry.id}`}+ className="shrink-0 rounded-full bg-primary/15 text-primary text-[10px] font-medium px-2 py-0.5 uppercase tracking-wide"+ >+ {t(I18nKey.MCP$INSTALLED_BADGE)}+ </span>+ )}+ </div>+ <p className="text-xs text-tertiary-alt mt-0.5">{transportLabel}</p>+ </div>+ </div>+ <p className="text-xs text-content-2 leading-relaxed line-clamp-3">+ {entry.description}+ </p>+ </button>+ );+}diff --git a/src/components/features/mcp-page/marketplace-search.tsx b/src/components/features/mcp-page/marketplace-search.tsxnew file mode 100644index 0000000000..1142b46d3e--- /dev/null+++ b/src/components/features/mcp-page/marketplace-search.tsx@@ -0,0 +1,58 @@+import { Search, X } from "lucide-react";+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { cn } from "#/utils/utils";++interface MarketplaceSearchProps {+ value: string;+ onChange: (next: string) => void;+}++/**+ * Single search input that filters both the Installed and Marketplace+ * sections on the MCP page.+ */+export function MarketplaceSearch({ value, onChange }: MarketplaceSearchProps) {+ const { t } = useTranslation("openhands");++ return (+ <div+ data-testid="mcp-search"+ className={cn(+ "relative flex items-center w-full",+ "rounded-lg border border-tertiary bg-base-secondary",+ "focus-within:border-primary/60 focus-within:ring-1 focus-within:ring-primary/40",+ "transition-colors",+ )}+ >+ <Search+ className="ml-3 h-4 w-4 text-tertiary-alt shrink-0"+ aria-hidden="true"+ />+ <input+ type="search"+ value={value}+ onChange={(e) => onChange(e.target.value)}+ placeholder={t(I18nKey.MCP$SEARCH_PLACEHOLDER)}+ aria-label={t(I18nKey.MCP$SEARCH_PLACEHOLDER)}+ data-testid="mcp-search-input"+ className={cn(+ "flex-1 min-w-0 bg-transparent border-0 outline-none",+ "px-3 py-2 text-sm placeholder:text-tertiary-alt",+ "[&::-webkit-search-cancel-button]:hidden",+ )}+ />+ {value && (+ <button+ type="button"+ onClick={() => onChange("")}+ aria-label={t(I18nKey.MCP$SEARCH_CLEAR)}+ data-testid="mcp-search-clear"+ className="mr-2 p-1 rounded text-tertiary-alt hover:text-content-1 cursor-pointer"+ >+ <X className="h-4 w-4" aria-hidden="true" />+ </button>+ )}+ </div>+ );+}diff --git a/src/components/features/mcp-page/marketplace-section.tsx b/src/components/features/mcp-page/marketplace-section.tsxnew file mode 100644index 0000000000..dad254461a--- /dev/null+++ b/src/components/features/mcp-page/marketplace-section.tsx@@ -0,0 +1,72 @@+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { MCP_MARKETPLACE, MarketplaceEntry } from "#/constants/mcp-marketplace";+import {+ isMarketplaceEntryAvailable,+ marketplaceEntryMatchesQuery,+} from "#/utils/mcp-marketplace-utils";+import { MarketplaceCard } from "./marketplace-card";++interface MarketplaceSectionProps {+ isInstalled: (entry: MarketplaceEntry) => boolean;+ backendKind: "local" | "cloud";+ onSelect: (entry: MarketplaceEntry) => void;+ /** Empty string = no filter. */+ query?: string;+}++export function MarketplaceSection({+ isInstalled,+ backendKind,+ onSelect,+ query = "",+}: MarketplaceSectionProps) {+ const { t } = useTranslation("openhands");++ const visibleEntries = MCP_MARKETPLACE.filter(+ (entry) =>+ isMarketplaceEntryAvailable(entry, backendKind) &&+ marketplaceEntryMatchesQuery(entry, query),+ );++ return (+ <section+ data-testid="mcp-marketplace-section"+ className="flex flex-col gap-3"+ >+ <div className="flex flex-col gap-1">+ <h2 className="text-base font-semibold">+ {t(I18nKey.MCP$MARKETPLACE_TITLE)}+ </h2>+ <p className="text-xs text-tertiary-alt">+ {t(I18nKey.MCP$MARKETPLACE_DESCRIPTION)}+ </p>+ </div>++ {visibleEntries.length === 0 ? (+ <div+ data-testid="mcp-marketplace-empty"+ className="rounded-xl border border-dashed border-tertiary p-6 text-center"+ >+ <p className="text-xs text-tertiary-alt">+ {t(I18nKey.MCP$SEARCH_EMPTY)}+ </p>+ </div>+ ) : (+ <div+ data-testid="mcp-marketplace-grid"+ className="grid gap-3 grid-cols-1 md:grid-cols-2 lg:grid-cols-3"+ >+ {visibleEntries.map((entry) => (+ <MarketplaceCard+ key={entry.id}+ entry={entry}+ installed={isInstalled(entry)}+ onClick={() => onSelect(entry)}+ />+ ))}+ </div>+ )}+ </section>+ );+}diff --git a/src/components/features/sidebar/sidebar.tsx b/src/components/features/sidebar/sidebar.tsxindex 801492b1e8..f653598487 100644--- a/src/components/features/sidebar/sidebar.tsx+++ b/src/components/features/sidebar/sidebar.tsx@@ -18,6 +18,7 @@ import { useSidebarCollapsedState } from "#/hooks/use-sidebar-collapsed";import MessageIcon from "#/icons/message.svg?react";import AutomationsIcon from "#/icons/automations.svg?react";import SparkleIcon from "#/icons/sparkle.svg?react";+import PuzzleIcon from "#/icons/puzzle.svg?react";import CogIcon from "#/icons/cog.svg?react";// The LLM settings modal is only mounted when the settings query 404s and@@ -226,6 +227,14 @@ export function Sidebar() {collapsed={collapsed}icon={<SparkleIcon width={ICON_SIZE} height={ICON_SIZE} />}/>+ <SidebarNavLink+ to="/mcp"+ label={t(I18nKey.SIDEBAR$INTEGRATIONS)}+ testId="sidebar-mcp-link"+ disabled={linkDisabled}+ collapsed={collapsed}+ icon={<PuzzleIcon width={ICON_SIZE} height={ICON_SIZE} />}+ /><SidebarNavLinkto="/automations"label={t(I18nKey.SIDEBAR$AUTOMATIONS)}diff --git a/src/components/shared/modals/confirmation-modal.tsx b/src/components/shared/modals/confirmation-modal.tsxindex 7f23b18dd4..e0b0423730 100644--- a/src/components/shared/modals/confirmation-modal.tsx+++ b/src/components/shared/modals/confirmation-modal.tsx@@ -7,16 +7,30 @@ interface ConfirmationModalProps {text: string;onConfirm: () => void;onCancel: () => void;+ /**+ * Disables both action buttons while an asynchronous confirm+ * mutation is in flight. Defaults to false to preserve existing+ * call sites that don't track mutation state.+ */+ isConfirming?: boolean;}export function ConfirmationModal({text,onConfirm,onCancel,+ isConfirming = false,}: ConfirmationModalProps) {const { t } = useTranslation("openhands");+ // Suppress the backdrop's click / Escape close handler while the+ // confirm mutation is in flight; otherwise the user could dismiss+ // the modal mid-request and never see the result (the buttons are+ // already disabled, but the backdrop wasn't).return (- <ModalBackdrop onClose={onCancel}>+ <ModalBackdrop+ onClose={isConfirming ? undefined : onCancel}+ closeOnEscape={!isConfirming}+ ><divdata-testid="confirmation-modal"className="bg-base-secondary p-4 rounded-xl flex flex-col gap-4 border border-tertiary"@@ -29,6 +43,7 @@ export function ConfirmationModal({onClick={onCancel}variant="secondary"className="grow"+ isDisabled={isConfirming}>{t(I18nKey.BUTTON$CANCEL)}</BrandButton>@@ -38,6 +53,7 @@ export function ConfirmationModal({onClick={onConfirm}variant="primary"className="grow"+ isDisabled={isConfirming}>{t(I18nKey.BUTTON$CONFIRM)}</BrandButton>diff --git a/src/constants/mcp-marketplace.tsx b/src/constants/mcp-marketplace.tsxnew file mode 100644index 0000000000..16aa4eecb4--- /dev/null+++ b/src/constants/mcp-marketplace.tsx@@ -0,0 +1,1251 @@+// Curated catalog of well-known MCP servers exposed in the marketplace+// section of the MCP settings page. Order matters β GitHub is the most+// commonly-installed entry per product design, with Slack and Tavily+// pinned right after.+//+// Cloud vs Agent Server differences are expressed via `availability`:+// most entries are "all", but a small subset that only makes sense+// against a local runtime (filesystem, host postgres, host sqlite) is+// gated to "local".+//+// The catalog is intentionally a flat array of `MarketplaceEntry`+// values rather than something more dynamic β it doubles as the data+// source for the marketplace search bar, and keeping it static keeps+// the search trivially fast even with 50+ entries.++import type { ReactNode } from "react";+import {+ BookOpen,+ Bot,+ Brain,+ Clock,+ Database,+ Flame,+ Folder,+ GitBranch,+ Globe,+ Image as ImageIcon,+ ListTree,+ MousePointerClick,+ Search,+ Sparkles,+ Telescope,+ TestTube,+} from "lucide-react";+import {+ SiAirtable,+ SiAtlassian,+ SiBrave,+ SiClickhouse,+ SiCloudflare,+ SiElevenlabs,+ SiFigma,+ SiGithub,+ SiGitlab,+ SiGooglemaps,+ SiHuggingface,+ SiKagi,+ SiLinear,+ SiMattermost,+ SiMongodb,+ SiNotion,+ SiObsidian,+ SiPaypal,+ SiPostgresql,+ SiPuppeteer,+ SiRedis,+ SiResend,+ SiSentry,+ SiSlack,+ SiSqlite,+ SiStripe,+ SiSupabase,+} from "react-icons/si";++export type MarketplaceFieldType = "text" | "password";++export interface MarketplaceField {+ key: string;+ label: string;+ type?: MarketplaceFieldType;+ placeholder?: string;+ helperText?: string;+ required?: boolean;+}++export type MarketplaceTemplate =+ | {+ kind: "tavily-builtin";+ // Tavily has first-class support inside the agent server: it+ // reads `search_api_key` and registers a Tavily MCP server+ // automatically. The marketplace card maps to that flow rather+ // than a manual MCP entry to keep it consistent with the legacy+ // "Built-in search" setting.+ }+ | {+ kind: "shttp";+ url: string;+ apiKeyOptional?: boolean;+ }+ | {+ kind: "sse";+ url: string;+ apiKeyOptional?: boolean;+ }+ | {+ kind: "stdio";+ // Stable name persisted into the SDK mcp_config map.+ serverName: string;+ command: string;+ args: string[];+ envFields?: MarketplaceField[];+ /**+ * Fields whose values are appended to `args` at install time+ * (each non-empty whitespace-separated token becomes its own+ * arg). Useful for templates like Postgres / Filesystem where+ * the user input is a positional argument, not an env var.+ */+ argFields?: MarketplaceField[];+ };++export interface MarketplaceEntry {+ id: string;+ name: string;+ description: string;+ /** URL pointing at upstream docs/setup instructions. */+ docsUrl?: string;+ /**+ * Brand-correct logo rendered inside the icon tile. Sized to fit+ * the 40Γ40 tile (rendered at h-5/w-5 inside it). Use+ * `currentColor` where possible so the parent's `iconColor`+ * controls the fill.+ */+ logo: ReactNode;+ /** Background color for the icon tile. */+ iconBg: string;+ /**+ * Foreground color for the logo when the icon supports+ * `currentColor`. Defaults to white; tiles on light brand colors+ * (e.g. Notion, HuggingFace) override this.+ */+ iconColor?: string;+ /**+ * Extra free-text keywords used by the search bar in addition to+ * `name` and `description`. Lower-case only.+ */+ keywords?: string[];+ /** "all" by default; "local" hides the entry on cloud backends. */+ availability?: "all" | "local";+ /** Short helpful prose shown in the install modal under the title. */+ installHint?: string;+ template: MarketplaceTemplate;+}++const LOGO = "h-5 w-5";++// ---------------------------------------------------------------------+// Order in this array IS the order users see in the marketplace grid.+// GitHub, Slack, and Tavily are pinned to the front intentionally.+// ---------------------------------------------------------------------++export const MCP_MARKETPLACE: MarketplaceEntry[] = [+ // -- Pinned ----------------------------------------------------------+ {+ id: "github",+ name: "GitHub",+ description:+ "Search code, manage issues and pull requests, and inspect repos via the GitHub API.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/github",+ logo: <SiGithub className={LOGO} />,+ iconBg: "#24292F",+ keywords: ["git", "pr", "repo", "issues", "code"],+ template: {+ kind: "stdio",+ serverName: "github",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-github"],+ envFields: [+ {+ key: "GITHUB_PERSONAL_ACCESS_TOKEN",+ label: "Personal access token",+ type: "password",+ placeholder: "github_pat_...",+ required: true,+ },+ ],+ },+ },+ {+ id: "slack",+ name: "Slack",+ description:+ "Read channels, post messages, and search workspace history from your agent.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/slack",+ logo: <SiSlack className={LOGO} />,+ iconBg: "#4A154B",+ keywords: ["chat", "messaging", "team"],+ installHint:+ "Create a Slack app with the required scopes, then paste its bot token below.",+ template: {+ kind: "stdio",+ serverName: "slack",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-slack"],+ envFields: [+ {+ key: "SLACK_BOT_TOKEN",+ label: "Bot token",+ type: "password",+ placeholder: "xoxb-...",+ required: true,+ },+ {+ key: "SLACK_TEAM_ID",+ label: "Team / Workspace ID",+ type: "text",+ placeholder: "T01234567",+ helperText:+ "Find this in Slack under Workspace settings β About this workspace.",+ required: true,+ },+ ],+ },+ },+ {+ id: "tavily",+ name: "Tavily",+ description:+ "Production-grade web search optimized for LLM agents. Free tier available.",+ docsUrl: "https://tavily.com/",+ // Tavily isn't in the simple-icons set; use a search glyph on+ // their brand blue tile so the marketplace stays icon-consistent.+ logo: <Search className={LOGO} strokeWidth={2.5} />,+ iconBg: "#2563EB",+ keywords: ["search", "web", "browsing", "research"],+ installHint:+ "Paste your Tavily API key. OpenHands wires up the Tavily MCP server automatically.",+ template: { kind: "tavily-builtin" },+ },++ // -- Hosted, first-party --------------------------------------------+ {+ id: "linear",+ name: "Linear",+ description:+ "Browse and update Linear issues, cycles, and projects from the agent.",+ docsUrl: "https://linear.app/changelog/2025-05-01-mcp",+ logo: <SiLinear className={LOGO} />,+ iconBg: "#5E6AD2",+ keywords: ["issues", "project management", "tasks", "tickets"],+ installHint:+ "Linear's hosted MCP server uses your Linear OAuth login β no key required.",+ template: {+ kind: "sse",+ url: "https://mcp.linear.app/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "notion",+ name: "Notion",+ description:+ "Read and edit Notion pages, databases, and blocks via Notion's MCP server.",+ docsUrl: "https://developers.notion.com/docs/mcp",+ logo: <SiNotion className={LOGO} />,+ iconBg: "#FFFFFF",+ iconColor: "#000000",+ keywords: ["docs", "notes", "wiki", "knowledge base"],+ template: {+ kind: "stdio",+ serverName: "notion",+ command: "npx",+ args: ["-y", "@notionhq/notion-mcp-server"],+ envFields: [+ {+ key: "NOTION_API_KEY",+ label: "Internal integration token",+ type: "password",+ placeholder: "ntn_...",+ required: true,+ },+ ],+ },+ },+ {+ id: "atlassian",+ name: "Atlassian (Jira & Confluence)",+ description:+ "Search Jira issues and Confluence pages via Atlassian's hosted MCP server.",+ docsUrl: "https://www.atlassian.com/platform/remote-mcp-server",+ logo: <SiAtlassian className={LOGO} />,+ iconBg: "#0052CC",+ keywords: ["jira", "confluence", "tickets", "wiki", "issues"],+ template: {+ kind: "sse",+ url: "https://mcp.atlassian.com/v1/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "sentry",+ name: "Sentry",+ description:+ "Triage issues, inspect events, and run Seer fixes against your Sentry org.",+ docsUrl: "https://docs.sentry.io/product/sentry-mcp/",+ logo: <SiSentry className={LOGO} />,+ iconBg: "#362D59",+ keywords: ["errors", "observability", "monitoring", "crash"],+ template: {+ kind: "shttp",+ url: "https://mcp.sentry.dev/mcp",+ apiKeyOptional: true,+ },+ },+ {+ id: "stripe",+ name: "Stripe",+ description:+ "Query customers, payments, subscriptions, and invoices via Stripe's hosted MCP server.",+ docsUrl: "https://stripe.com/docs/mcp",+ logo: <SiStripe className={LOGO} />,+ iconBg: "#635BFF",+ keywords: ["payments", "billing", "subscriptions", "finance"],+ template: {+ kind: "shttp",+ url: "https://mcp.stripe.com/",+ apiKeyOptional: true,+ },+ },+ {+ id: "paypal",+ name: "PayPal",+ description:+ "Manage transactions and merchant data via PayPal's MCP server.",+ docsUrl: "https://developer.paypal.com/tools/mcp-server/",+ logo: <SiPaypal className={LOGO} />,+ iconBg: "#003087",+ keywords: ["payments", "billing", "finance"],+ template: {+ kind: "sse",+ url: "https://mcp.paypal.com/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "cloudflare-docs",+ name: "Cloudflare Docs",+ description:+ "Search and reference Cloudflare's developer documentation directly from the agent.",+ docsUrl: "https://developers.cloudflare.com/agents/model-context-protocol/",+ logo: <SiCloudflare className={LOGO} />,+ iconBg: "#F38020",+ keywords: ["cloudflare", "docs", "reference", "workers"],+ template: {+ kind: "sse",+ url: "https://docs.mcp.cloudflare.com/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "cloudflare-bindings",+ name: "Cloudflare Workers Bindings",+ description:+ "Inspect and manage KV, D1, R2, and Durable Object bindings on your Cloudflare account.",+ docsUrl: "https://developers.cloudflare.com/agents/model-context-protocol/",+ logo: <SiCloudflare className={LOGO} />,+ iconBg: "#F38020",+ keywords: ["cloudflare", "workers", "kv", "d1", "r2", "durable objects"],+ template: {+ kind: "sse",+ url: "https://bindings.mcp.cloudflare.com/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "cloudflare-observability",+ name: "Cloudflare Observability",+ description:+ "Tail Workers logs and query observability data from your Cloudflare account.",+ docsUrl: "https://developers.cloudflare.com/agents/model-context-protocol/",+ logo: <SiCloudflare className={LOGO} />,+ iconBg: "#F38020",+ keywords: ["cloudflare", "logs", "tail", "observability", "workers"],+ template: {+ kind: "sse",+ url: "https://observability.mcp.cloudflare.com/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "huggingface",+ name: "Hugging Face",+ description:+ "Search models, datasets, and Spaces on the Hugging Face Hub from your agent.",+ docsUrl: "https://huggingface.co/docs/hub/en/mcp",+ logo: <SiHuggingface className={LOGO} />,+ iconBg: "#FFD21E",+ iconColor: "#000000",+ keywords: ["ml", "models", "datasets", "ai", "hub"],+ template: {+ kind: "shttp",+ url: "https://huggingface.co/mcp",+ apiKeyOptional: true,+ },+ },+ {+ id: "deepwiki",+ name: "DeepWiki",+ description:+ "Ask grounded questions about any public GitHub repository via Devin's DeepWiki MCP.",+ docsUrl: "https://docs.devin.ai/work-with-devin/deepwiki-mcp",+ logo: <BookOpen className={LOGO} />,+ iconBg: "#0B0E14",+ keywords: ["devin", "code", "wiki", "github", "docs", "qa"],+ template: {+ kind: "sse",+ url: "https://mcp.deepwiki.com/sse",+ apiKeyOptional: true,+ },+ },++ // -- Source control & code intelligence ------------------------------+ {+ id: "gitlab",+ name: "GitLab",+ description:+ "Search projects, browse merge requests, and update issues on GitLab.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/gitlab",+ logo: <SiGitlab className={LOGO} />,+ iconBg: "#FC6D26",+ keywords: ["git", "mr", "repo", "issues", "code"],+ template: {+ kind: "stdio",+ serverName: "gitlab",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-gitlab"],+ envFields: [+ {+ key: "GITLAB_PERSONAL_ACCESS_TOKEN",+ label: "Personal access token",+ type: "password",+ required: true,+ },+ {+ key: "GITLAB_API_URL",+ label: "API URL (optional)",+ type: "text",+ placeholder: "https://gitlab.example.com/api/v4",+ helperText: "Leave blank to use gitlab.com.",+ },+ ],+ },+ },+ {+ id: "git",+ name: "Git",+ description:+ "Local git repository operations: log, diff, blame, status, and more.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/git",+ logo: <GitBranch className={LOGO} strokeWidth={2.25} />,+ iconBg: "#F1502F",+ availability: "local",+ keywords: ["version control", "log", "diff", "blame"],+ installHint:+ "Runs the official Python server via uvx β no setup beyond the path.",+ template: {+ kind: "stdio",+ serverName: "git",+ command: "uvx",+ // The repo path is appended as the value of `--repository`; the+ // flag belongs on the base command so it lands immediately+ // before the user-supplied path when the modal concatenates+ // them.+ args: ["mcp-server-git", "--repository"],+ argFields: [+ {+ key: "repo_path",+ label: "Repository path",+ type: "text",+ placeholder: "/Users/me/code/my-repo",+ required: true,+ helperText: "Appended as --repository <path>.",+ },+ ],+ },+ },++ // -- Search & browsing -----------------------------------------------+ {+ id: "brave-search",+ name: "Brave Search",+ description:+ "Privacy-first web and local search using the Brave Search API.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search",+ logo: <SiBrave className={LOGO} />,+ iconBg: "#FB542B",+ keywords: ["search", "web"],+ template: {+ kind: "stdio",+ serverName: "brave_search",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-brave-search"],+ envFields: [+ {+ key: "BRAVE_API_KEY",+ label: "Brave API key",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "exa",+ name: "Exa",+ description:+ "Neural web search with semantic ranking, content extraction, and similar-page lookup.",+ docsUrl: "https://docs.exa.ai/reference/exa-mcp",+ logo: <Telescope className={LOGO} strokeWidth={2.25} />,+ iconBg: "#1F1F1F",+ keywords: ["search", "web", "research", "neural"],+ template: {+ kind: "stdio",+ serverName: "exa",+ command: "npx",+ args: ["-y", "exa-mcp-server"],+ envFields: [+ {+ key: "EXA_API_KEY",+ label: "Exa API key",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "firecrawl",+ name: "Firecrawl",+ description:+ "Crawl any site and return clean markdown, structured data, or screenshots.",+ docsUrl: "https://docs.firecrawl.dev/mcp",+ logo: <Flame className={LOGO} strokeWidth={2.25} />,+ iconBg: "#F97316",+ keywords: ["scraping", "crawl", "web", "markdown"],+ template: {+ kind: "stdio",+ serverName: "firecrawl",+ command: "npx",+ args: ["-y", "firecrawl-mcp"],+ envFields: [+ {+ key: "FIRECRAWL_API_KEY",+ label: "Firecrawl API key",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "apify",+ name: "Apify Actors",+ description:+ "Run any of Apify's 5,000+ Actors (scrapers, automations) from the agent.",+ docsUrl: "https://docs.apify.com/platform/integrations/mcp",+ logo: <Bot className={LOGO} strokeWidth={2.25} />,+ iconBg: "#10b981",+ keywords: ["scraping", "automation", "crawl", "actors"],+ template: {+ kind: "stdio",+ serverName: "apify",+ command: "npx",+ args: ["-y", "@apify/actors-mcp-server"],+ envFields: [+ {+ key: "APIFY_TOKEN",+ label: "Apify token",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "fetch",+ name: "Fetch",+ description:+ "Plain HTTP fetcher: download a URL and convert HTML to readable markdown.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/fetch",+ logo: <Globe className={LOGO} strokeWidth={2.25} />,+ iconBg: "#4B5563",+ keywords: ["http", "web", "url", "scrape"],+ template: {+ kind: "stdio",+ serverName: "fetch",+ command: "uvx",+ args: ["mcp-server-fetch"],+ },+ },+ {+ id: "browser-mcp",+ name: "Browser MCP",+ description:+ "Control your local browser tab β navigate, click, type, and read DOM contents.",+ docsUrl: "https://browsermcp.io/",+ logo: <MousePointerClick className={LOGO} strokeWidth={2.25} />,+ iconBg: "#0EA5E9",+ availability: "local",+ keywords: ["browser", "automation", "chrome", "playwright"],+ template: {+ kind: "stdio",+ serverName: "browser_mcp",+ command: "npx",+ args: ["-y", "@browsermcp/mcp"],+ },+ },+ {+ id: "playwright",+ name: "Playwright",+ description: "Headless-browser automation backed by Microsoft Playwright.",+ docsUrl: "https://github.com/microsoft/playwright-mcp",+ logo: <TestTube className={LOGO} strokeWidth={2.25} />,+ iconBg: "#2EAD33",+ keywords: ["browser", "automation", "e2e", "testing", "scrape"],+ template: {+ kind: "stdio",+ serverName: "playwright",+ command: "npx",+ args: ["-y", "@playwright/mcp"],+ },+ },+ {+ id: "puppeteer",+ name: "Puppeteer",+ description:+ "Headless Chrome via Puppeteer β navigate, screenshot, and scrape pages.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/puppeteer",+ logo: <SiPuppeteer className={LOGO} />,+ iconBg: "#40B5A4",+ keywords: ["browser", "automation", "scrape", "chrome"],+ template: {+ kind: "stdio",+ serverName: "puppeteer",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-puppeteer"],+ },+ },+ {+ id: "google-maps",+ name: "Google Maps",+ description:+ "Geocoding, directions, places search, and distance matrix lookups.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/google-maps",+ logo: <SiGooglemaps className={LOGO} />,+ iconBg: "#4285F4",+ keywords: ["maps", "geocode", "directions", "places"],+ template: {+ kind: "stdio",+ serverName: "google_maps",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-google-maps"],+ envFields: [+ {+ key: "GOOGLE_MAPS_API_KEY",+ label: "Google Maps API key",+ type: "password",+ required: true,+ },+ ],+ },+ },++ // -- Databases -------------------------------------------------------+ {+ id: "postgres",+ name: "Postgres",+ description:+ "Read-only SQL queries and schema introspection against any Postgres database.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/postgres",+ logo: <SiPostgresql className={LOGO} />,+ iconBg: "#336791",+ availability: "local",+ keywords: ["sql", "database", "postgresql"],+ template: {+ kind: "stdio",+ serverName: "postgres",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-postgres"],+ argFields: [+ {+ key: "connection_string",+ label: "Connection string",+ type: "password",+ placeholder: "postgresql://user:pass@host:5432/dbname",+ required: true,+ helperText: "Passed to the server as a single positional argument.",+ },+ ],+ },+ },+ {+ id: "supabase",+ name: "Supabase",+ description:+ "Query and manage your Supabase project, including database, auth, and storage.",+ docsUrl: "https://supabase.com/docs/guides/getting-started/mcp",+ logo: <SiSupabase className={LOGO} />,+ iconBg: "#3ECF8E",+ keywords: ["database", "auth", "storage", "postgres"],+ template: {+ kind: "stdio",+ serverName: "supabase",+ command: "npx",+ args: ["-y", "@supabase/mcp-server-supabase@latest"],+ envFields: [+ {+ key: "SUPABASE_ACCESS_TOKEN",+ label: "Supabase access token",+ type: "password",+ required: true,+ helperText: "Personal access token from your Supabase dashboard.",+ },+ ],+ },+ },+ {+ id: "neon",+ name: "Neon",+ description:+ "Serverless Postgres: list projects, run queries, manage branches.",+ docsUrl: "https://neon.com/docs/ai/neon-mcp-server",+ logo: <Database className={LOGO} strokeWidth={2.25} />,+ iconBg: "#00E599",+ iconColor: "#0A0A0A",+ keywords: ["database", "postgres", "serverless"],+ template: {+ kind: "stdio",+ serverName: "neon",+ command: "npx",+ args: ["-y", "@neondatabase/mcp-server-neon", "start"],+ envFields: [+ {+ key: "NEON_API_KEY",+ label: "Neon API key",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "mongodb",+ name: "MongoDB",+ description:+ "Query MongoDB collections, inspect schemas, and run aggregation pipelines.",+ docsUrl: "https://www.mongodb.com/docs/mcp-server/",+ logo: <SiMongodb className={LOGO} />,+ iconBg: "#00684A",+ keywords: ["database", "nosql", "atlas"],+ template: {+ kind: "stdio",+ serverName: "mongodb",+ command: "npx",+ args: ["-y", "mongodb-mcp-server"],+ envFields: [+ {+ key: "MDB_MCP_CONNECTION_STRING",+ label: "MongoDB connection string",+ type: "password",+ placeholder: "mongodb+srv://user:[email protected]",+ required: true,+ },+ ],+ },+ },+ {+ id: "redis",+ name: "Redis",+ description:+ "Get, set, scan, and inspect data on a Redis or Redis-compatible instance.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/redis",+ logo: <SiRedis className={LOGO} />,+ iconBg: "#DC382D",+ availability: "local",+ keywords: ["cache", "kv", "database"],+ template: {+ kind: "stdio",+ serverName: "redis",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-redis"],+ argFields: [+ {+ key: "redis_url",+ label: "Redis URL",+ type: "password",+ placeholder: "redis://localhost:6379",+ required: true,+ helperText: "Passed as a single positional argument.",+ },+ ],+ },+ },+ {+ id: "sqlite",+ name: "SQLite",+ description:+ "Open a SQLite database file and run queries, schema dumps, and explorations.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite",+ logo: <SiSqlite className={LOGO} />,+ iconBg: "#003B57",+ availability: "local",+ keywords: ["database", "sql", "local"],+ template: {+ kind: "stdio",+ serverName: "sqlite",+ command: "uvx",+ // `--db-path` is the flag the official mcp-server-sqlite expects+ // before the user-supplied path; keeping it on the base command+ // means the modal can concatenate the path verbatim.+ args: ["mcp-server-sqlite", "--db-path"],+ argFields: [+ {+ key: "db_path",+ label: "Database file path",+ type: "text",+ placeholder: "/Users/me/my.db",+ required: true,+ helperText: "Appended as --db-path <path>.",+ },+ ],+ },+ },++ // -- Agent toolbelt --------------------------------------------------+ {+ id: "filesystem",+ name: "Filesystem",+ description:+ "Give the agent secure, scoped filesystem access outside the workspace.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem",+ logo: <Folder className={LOGO} strokeWidth={2.25} />,+ iconBg: "#525B6F",+ availability: "local",+ keywords: ["files", "local", "disk"],+ installHint:+ "Each path is exposed read/write. Add as many as you need, separated by spaces.",+ template: {+ kind: "stdio",+ serverName: "filesystem",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-filesystem"],+ argFields: [+ {+ key: "paths",+ label: "Paths (space separated)",+ type: "text",+ placeholder: "/Users/me/Documents /Users/me/Projects",+ required: true,+ helperText:+ "Each whitespace-separated token is appended as its own argument.",+ },+ ],+ },+ },+ {+ id: "memory",+ name: "Memory",+ description:+ "Persistent key-value memory for the agent across conversations.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/memory",+ logo: <Brain className={LOGO} strokeWidth={2.25} />,+ iconBg: "#7C3AED",+ keywords: ["memory", "kv", "state", "persistence"],+ template: {+ kind: "stdio",+ serverName: "memory",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-memory"],+ },+ },+ {+ id: "sequential-thinking",+ name: "Sequential Thinking",+ description:+ "Lets the agent emit and revise a chain of structured thoughts.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking",+ logo: <ListTree className={LOGO} strokeWidth={2.25} />,+ iconBg: "#0F172A",+ keywords: ["reasoning", "planning", "thoughts"],+ template: {+ kind: "stdio",+ serverName: "sequential_thinking",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-sequential-thinking"],+ },+ },+ {+ id: "time",+ name: "Time",+ description:+ "Timezone-aware current time, conversions, and timestamp formatting.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/time",+ logo: <Clock className={LOGO} strokeWidth={2.25} />,+ iconBg: "#1F2937",+ keywords: ["clock", "timezone", "date"],+ template: {+ kind: "stdio",+ serverName: "time",+ command: "uvx",+ args: ["mcp-server-time"],+ },+ },+ {+ id: "everart",+ name: "EverArt",+ description: "Generate AI images via EverArt's image models.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/everart",+ logo: <ImageIcon className={LOGO} strokeWidth={2.25} />,+ iconBg: "#EC4899",+ keywords: ["image", "ai", "generation"],+ template: {+ kind: "stdio",+ serverName: "everart",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-everart"],+ envFields: [+ {+ key: "EVERART_API_KEY",+ label: "EverArt API key",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "everything",+ name: "Everything (demo)",+ description:+ "Reference server exercising every MCP capability β useful for testing.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/everything",+ logo: <Sparkles className={LOGO} strokeWidth={2.25} />,+ iconBg: "#6366F1",+ keywords: ["demo", "test", "reference"],+ template: {+ kind: "stdio",+ serverName: "everything",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-everything"],+ },+ },+ {+ id: "aws-kb",+ name: "AWS Knowledge Base",+ description:+ "Retrieval-augmented search against AWS Bedrock knowledge bases.",+ docsUrl:+ "https://github.com/modelcontextprotocol/servers/tree/main/src/aws-kb-retrieval-server",+ logo: <BookOpen className={LOGO} strokeWidth={2.25} />,+ iconBg: "#FF9900",+ iconColor: "#0A0A0A",+ keywords: ["aws", "bedrock", "rag", "knowledge"],+ template: {+ kind: "stdio",+ serverName: "aws_kb_retrieval",+ command: "npx",+ args: ["-y", "@modelcontextprotocol/server-aws-kb-retrieval"],+ envFields: [+ {+ key: "AWS_ACCESS_KEY_ID",+ label: "AWS access key ID",+ type: "password",+ required: true,+ },+ {+ key: "AWS_SECRET_ACCESS_KEY",+ label: "AWS secret access key",+ type: "password",+ required: true,+ },+ {+ key: "AWS_REGION",+ label: "AWS region",+ type: "text",+ placeholder: "us-east-1",+ required: true,+ },+ ],+ },+ },++ // -- Productivity / design / media -----------------------------------+ {+ id: "figma",+ name: "Figma",+ description:+ "Read Figma frames, components, and styles to ground UI work in your designs.",+ docsUrl: "https://github.com/GLips/Figma-Context-MCP",+ logo: <SiFigma className={LOGO} />,+ iconBg: "#1E1E1E",+ keywords: ["design", "ui", "frames", "components"],+ template: {+ kind: "stdio",+ serverName: "figma",+ command: "npx",+ args: ["-y", "figma-developer-mcp", "--stdio"],+ envFields: [+ {+ key: "FIGMA_API_KEY",+ label: "Figma personal access token",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "airtable",+ name: "Airtable",+ description:+ "List bases, query records, and update fields across your Airtable workspace.",+ docsUrl: "https://github.com/domdomegg/airtable-mcp-server",+ logo: <SiAirtable className={LOGO} />,+ iconBg: "#FCB400",+ iconColor: "#0A0A0A",+ keywords: ["spreadsheet", "database", "records", "bases"],+ template: {+ kind: "stdio",+ serverName: "airtable",+ command: "npx",+ args: ["-y", "airtable-mcp-server"],+ envFields: [+ {+ key: "AIRTABLE_API_KEY",+ label: "Airtable personal access token",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "obsidian",+ name: "Obsidian",+ description:+ "Read and edit Markdown notes inside an Obsidian vault on the local disk.",+ docsUrl: "https://github.com/MarkusPfundstein/mcp-obsidian",+ logo: <SiObsidian className={LOGO} />,+ iconBg: "#7C3AED",+ availability: "local",+ keywords: ["notes", "knowledge", "markdown", "vault"],+ template: {+ kind: "stdio",+ serverName: "obsidian",+ command: "uvx",+ args: ["mcp-obsidian"],+ envFields: [+ {+ key: "OBSIDIAN_API_KEY",+ label: "Local REST API key",+ type: "password",+ required: true,+ helperText: "From the Obsidian 'Local REST API' community plugin.",+ },+ ],+ },+ },+ {+ id: "elevenlabs",+ name: "ElevenLabs",+ description:+ "Generate speech, clone voices, and transcribe audio via ElevenLabs.",+ docsUrl: "https://elevenlabs.io/docs/api-reference/mcp",+ logo: <SiElevenlabs className={LOGO} />,+ iconBg: "#0F0F0F",+ keywords: ["tts", "speech", "voice", "audio"],+ template: {+ kind: "stdio",+ serverName: "elevenlabs",+ command: "uvx",+ args: ["elevenlabs-mcp"],+ envFields: [+ {+ key: "ELEVENLABS_API_KEY",+ label: "ElevenLabs API key",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "resend",+ name: "Resend",+ description: "Send transactional and marketing emails via the Resend API.",+ docsUrl: "https://resend.com/docs/send-with-mcp",+ logo: <SiResend className={LOGO} />,+ iconBg: "#0A0A0A",+ keywords: ["email", "transactional", "smtp"],+ template: {+ kind: "stdio",+ serverName: "resend",+ command: "npx",+ args: ["-y", "mcp-send-email"],+ envFields: [+ {+ key: "RESEND_API_KEY",+ label: "Resend API key",+ type: "password",+ required: true,+ },+ {+ key: "SENDER_EMAIL_ADDRESS",+ label: "From address",+ type: "text",+ placeholder: "[email protected]",+ required: true,+ },+ ],+ },+ },+ {+ id: "cloudflare-builds",+ name: "Cloudflare Builds",+ description:+ "Inspect Workers Builds β logs, statuses, and rerun failed deploys.",+ docsUrl: "https://developers.cloudflare.com/agents/model-context-protocol/",+ logo: <SiCloudflare className={LOGO} />,+ iconBg: "#F38020",+ keywords: ["cloudflare", "workers", "ci", "builds", "deploys"],+ template: {+ kind: "sse",+ url: "https://builds.mcp.cloudflare.com/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "cloudflare-browser-rendering",+ name: "Cloudflare Browser Rendering",+ description:+ "Fetch and screenshot pages using Cloudflare's hosted browser rendering.",+ docsUrl: "https://developers.cloudflare.com/agents/model-context-protocol/",+ logo: <SiCloudflare className={LOGO} />,+ iconBg: "#F38020",+ keywords: ["cloudflare", "browser", "rendering", "screenshots"],+ template: {+ kind: "sse",+ url: "https://browser.mcp.cloudflare.com/sse",+ apiKeyOptional: true,+ },+ },+ {+ id: "kagi",+ name: "Kagi Search",+ description:+ "Paid, privacy-first search with high signal-to-noise β great for research.",+ docsUrl: "https://help.kagi.com/kagi/api/mcp.html",+ logo: <SiKagi className={LOGO} />,+ iconBg: "#FFB319",+ iconColor: "#0A0A0A",+ keywords: ["search", "web", "privacy"],+ template: {+ kind: "stdio",+ serverName: "kagi",+ command: "uvx",+ args: ["kagimcp"],+ envFields: [+ {+ key: "KAGI_API_KEY",+ label: "Kagi API key",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "clickhouse",+ name: "ClickHouse",+ description: "Run analytical SQL queries against a ClickHouse cluster.",+ docsUrl: "https://github.com/ClickHouse/mcp-clickhouse",+ logo: <SiClickhouse className={LOGO} />,+ iconBg: "#FFFF00",+ iconColor: "#0A0A0A",+ keywords: ["analytics", "olap", "database", "sql"],+ template: {+ kind: "stdio",+ serverName: "clickhouse",+ command: "uvx",+ args: ["mcp-clickhouse"],+ envFields: [+ {+ key: "CLICKHOUSE_HOST",+ label: "Host",+ type: "text",+ placeholder: "clickhouse.example.com",+ required: true,+ },+ {+ key: "CLICKHOUSE_USER",+ label: "Username",+ type: "text",+ required: true,+ },+ {+ key: "CLICKHOUSE_PASSWORD",+ label: "Password",+ type: "password",+ required: true,+ },+ ],+ },+ },+ {+ id: "mattermost",+ name: "Mattermost",+ description: "Post and read messages in self-hosted Mattermost workspaces.",+ docsUrl: "https://github.com/EvilFreelancer/mattermost-mcp-server",+ logo: <SiMattermost className={LOGO} />,+ iconBg: "#0058CC",+ keywords: ["chat", "messaging", "team", "open source"],+ template: {+ kind: "stdio",+ serverName: "mattermost",+ command: "npx",+ args: ["-y", "mattermost-mcp-server"],+ envFields: [+ {+ key: "MATTERMOST_URL",+ label: "Server URL",+ type: "text",+ placeholder: "https://mattermost.example.com",+ required: true,+ },+ {+ key: "MATTERMOST_TOKEN",+ label: "Personal access token",+ type: "password",+ required: true,+ },+ ],+ },+ },+];diff --git a/src/constants/settings-nav.tsx b/src/constants/settings-nav.tsxindex 5473228a62..656029c31c 100644--- a/src/constants/settings-nav.tsx+++ b/src/constants/settings-nav.tsx@@ -1,7 +1,6 @@import KeyIcon from "#/icons/key.svg?react";import LockIcon from "#/icons/lock.svg?react";import MemoryIcon from "#/icons/memory_icon.svg?react";-import ServerProcessIcon from "#/icons/server-process.svg?react";import SettingsGearIcon from "#/icons/settings-gear.svg?react";import CircuitIcon from "#/icons/u-circuit.svg?react";@@ -27,11 +26,6 @@ export const OSS_NAV_ITEMS: SettingsNavItem[] = [to: "/settings/verification",text: "SETTINGS$NAV_VERIFICATION",},- {- icon: <ServerProcessIcon width={22} height={22} />,- to: "/settings/mcp",- text: "SETTINGS$NAV_MCP",- },{icon: <SettingsGearIcon width={22} height={22} />,to: "/settings/app",diff --git a/src/hooks/mutation/use-delete-mcp-server.ts b/src/hooks/mutation/use-delete-mcp-server.tsindex baf72f0ad2..08860b9594 100644--- a/src/hooks/mutation/use-delete-mcp-server.ts+++ b/src/hooks/mutation/use-delete-mcp-server.ts@@ -2,15 +2,27 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";import { useSettings } from "#/hooks/query/use-settings";import SettingsService from "#/api/settings-service/settings-service.api";import { MCPConfig } from "#/types/settings";+import { MCPServerConfig } from "#/types/mcp-server";import { parseMcpConfig, toSdkMcpConfig } from "#/utils/mcp-config";import { SETTINGS_QUERY_KEYS } from "#/hooks/query/query-keys";+/**+ * Delete an installed MCP server.+ *+ * We accept the full server config (not just a synthetic id like+ * `stdio-2`) and re-resolve its position inside the freshly-read+ * settings at mutation time. This eliminates the race between the+ * user clicking "Delete" and confirming the dialog: if the underlying+ * `mcp_config` changes (background refresh, multi-tab activity,+ * another mutation) the index encoded in a synthetic id can drift,+ * and we would otherwise splice the wrong server.+ */export function useDeleteMcpServer() {const queryClient = useQueryClient();const { data: settings } = useSettings();return useMutation({- mutationFn: async (serverId: string): Promise<void> => {+ mutationFn: async (target: MCPServerConfig): Promise<void> => {const currentConfig = parseMcpConfig(settings?.agent_settings?.mcp_config,);@@ -20,15 +32,45 @@ export function useDeleteMcpServer() {stdio_servers: [...currentConfig.stdio_servers],shttp_servers: [...currentConfig.shttp_servers],};- const [serverType, indexStr] = serverId.split("-");- const index = parseInt(indexStr, 10);- if (serverType === "sse") {- newConfig.sse_servers.splice(index, 1);- } else if (serverType === "stdio") {- newConfig.stdio_servers.splice(index, 1);- } else if (serverType === "shttp") {- newConfig.shttp_servers.splice(index, 1);+ const extractUrl = (s: unknown): string | undefined => {+ if (typeof s === "string") return s;+ if (s && typeof s === "object" && "url" in s) {+ const v = (s as { url?: unknown }).url;+ return typeof v === "string" ? v : undefined;+ }+ return undefined;+ };++ // Each branch guards on the discriminating field(s) it relies+ // on. `MCPServerConfig` marks url/name/command optional for+ // historical reasons, so without these guards an entry with+ // undefined identifiers could accidentally match another entry+ // that's also missing the same field (e.g. two stdio servers+ // both lacking `name`).+ if (target.type === "sse") {+ if (!target.url) return;+ const idx = newConfig.sse_servers.findIndex(+ (s) => extractUrl(s) === target.url,+ );+ if (idx >= 0) newConfig.sse_servers.splice(idx, 1);+ } else if (target.type === "shttp") {+ if (!target.url) return;+ const idx = newConfig.shttp_servers.findIndex(+ (s) => extractUrl(s) === target.url,+ );+ if (idx >= 0) newConfig.shttp_servers.splice(idx, 1);+ } else if (target.type === "stdio") {+ if (!target.name || !target.command) return;+ const idx = newConfig.stdio_servers.findIndex(+ (s) =>+ s.name === target.name &&+ s.command === target.command &&+ JSON.stringify(s.args ?? []) === JSON.stringify(target.args ?? []),+ );+ if (idx >= 0) newConfig.stdio_servers.splice(idx, 1);+ } else {+ return;}await SettingsService.saveSettings({diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex d4c084a6d2..98d1a64c91 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -11848,6 +11848,72 @@"tr": "Entegrasyonlar","uk": "ΠΠ½ΡΠ΅Π³ΡΠ°ΡΡΡ"},+ "MCP$PAGE_DESCRIPTION": {+ "en": "Add Model Context Protocol servers to expand what your agent can do. Click any server below to install it."+ },+ "MCP$INSTALLED_TITLE": {+ "en": "Installed"+ },+ "MCP$INSTALLED_EMPTY_TITLE": {+ "en": "No MCP servers installed yet."+ },+ "MCP$INSTALLED_EMPTY_HINT": {+ "en": "Pick one from the marketplace below to get started."+ },+ "MCP$MARKETPLACE_TITLE": {+ "en": "Marketplace"+ },+ "MCP$MARKETPLACE_DESCRIPTION": {+ "en": "Well-known MCP servers, ready to install with a single click."+ },+ "MCP$SEARCH_PLACEHOLDER": {+ "en": "Search MCP servers"+ },+ "MCP$SEARCH_CLEAR": {+ "en": "Clear search"+ },+ "MCP$SEARCH_EMPTY": {+ "en": "No matches for your search."+ },+ "MCP$INSTALLED_BADGE": {+ "en": "Installed"+ },+ "MCP$INSTALL_BUTTON": {+ "en": "Install"+ },+ "MCP$VIEW_DOCS": {+ "en": "View documentation β"+ },+ "MCP$INSTALL_SUCCESS": {+ "en": "MCP server saved."+ },+ "MCP$REMOVE_SUCCESS": {+ "en": "MCP server removed."+ },+ "MCP$EDIT_SERVER_ARIA": {+ "en": "Edit {{name}}"+ },+ "MCP$DELETE_SERVER_ARIA": {+ "en": "Remove {{name}}"+ },+ "MCP$ERROR_FIELD_REQUIRED": {+ "en": "This field is required."+ },+ "MCP$ADD_CUSTOM": {+ "en": "Add custom server"+ },+ "MCP$ADD_CUSTOM_TITLE": {+ "en": "Add custom MCP server"+ },+ "MCP$EDIT_CUSTOM_TITLE": {+ "en": "Edit MCP server"+ },+ "MCP$COMMAND_LABEL": {+ "en": "Command"+ },+ "MCP$TRANSPORT_BUILTIN": {+ "en": "Built-in"+ },"SIDEBAR$NEW_CONVERSATION": {"en": "New Conversation","ja": "ζ°γγδΌθ©±",diff --git a/src/routes.ts b/src/routes.tsindex e8bde742cd..5672ef104b 100644--- a/src/routes.ts+++ b/src/routes.ts@@ -12,12 +12,14 @@ export default [route("conversations/:conversationId", "routes/conversation.tsx"),route("launch", "routes/launch.tsx"),route("skills", "routes/skills-settings.tsx"),+ route("mcp", "routes/mcp.tsx"),route("integrations", "routes/git-settings.tsx"),route("settings", "routes/settings.tsx", [index("routes/llm-settings.tsx"),route("condenser", "routes/condenser-settings.tsx"),route("verification", "routes/verification-settings.tsx"),- route("mcp", "routes/mcp-settings.tsx"),+ // Legacy entry: redirects to /mcp (preserves old bookmarks).+ route("mcp", "routes/mcp-settings-redirect.tsx"),route("app", "routes/app-settings.tsx"),route("secrets", "routes/secrets-settings.tsx"),]),diff --git a/src/routes/mcp-settings-redirect.tsx b/src/routes/mcp-settings-redirect.tsxnew file mode 100644index 0000000000..d351d0c1f5--- /dev/null+++ b/src/routes/mcp-settings-redirect.tsx@@ -0,0 +1,10 @@+import { redirect } from "react-router";++// MCP settings used to live at /settings/mcp. It now has a dedicated+// top-level entry under the main left-hand navigation, so this route+// just redirects to keep old links working.+export const clientLoader = async () => redirect("/mcp");++export default function MCPSettingsRedirect() {+ return null;+}diff --git a/src/routes/mcp-settings.tsx b/src/routes/mcp-settings.tsxindex 9f4186ca47..ed1d9f761e 100644--- a/src/routes/mcp-settings.tsx+++ b/src/routes/mcp-settings.tsx@@ -1,284 +1,10 @@-import React, { useEffect, useState } from "react";-import { AxiosError } from "axios";-import { useTranslation } from "react-i18next";-import { useSettings } from "#/hooks/query/use-settings";-import { useSaveSettings } from "#/hooks/mutation/use-save-settings";-import { useDeleteMcpServer } from "#/hooks/mutation/use-delete-mcp-server";-import { useAddMcpServer } from "#/hooks/mutation/use-add-mcp-server";-import { useUpdateMcpServer } from "#/hooks/mutation/use-update-mcp-server";-import { I18nKey } from "#/i18n/declaration";+// The MCP page now lives at the top-level /mcp route. This file is+// kept for backward-compatibility so the published `MCPSettings`+// library export (see `src/components/settings/index.ts`) and any+// remaining `routes/mcp-settings` import paths keep working.-import { MCPServerList } from "#/components/features/settings/mcp-settings/mcp-server-list";-import { MCPServerForm } from "#/components/features/settings/mcp-settings/mcp-server-form";-import { KeyStatusIcon } from "#/components/features/settings/key-status-icon";-import { SettingsInput } from "#/components/features/settings/settings-input";-import { ConfirmationModal } from "#/components/shared/modals/confirmation-modal";-import { BrandButton } from "#/components/features/settings/brand-button";-import { HelpLink } from "#/ui/help-link";-import { MCPConfig } from "#/types/settings";-import {- displayErrorToast,- displaySuccessToast,-} from "#/utils/custom-toast-handlers";-import { parseMcpConfig } from "#/utils/mcp-config";-import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";-import { Typography } from "#/ui/typography";-import { BackendSyncedSettingsBadge } from "#/components/features/settings/backend-synced-settings-badge";+import MCPPage from "./mcp";-export const handle = { hideTitle: true };+export const MCPSettingsScreen = MCPPage;-type MCPServerType = "sse" | "stdio" | "shttp";--interface MCPServerConfig {- id: string;- type: MCPServerType;- name?: string;- url?: string;- api_key?: string;- timeout?: number;- command?: string;- args?: string[];- env?: Record<string, string>;-}--export function MCPSettingsScreen() {- const { t } = useTranslation("openhands");- const { data: settings, isLoading } = useSettings();- const { mutate: saveSettings, isPending: isSavingSearchApiKey } =- useSaveSettings();- const { mutate: deleteMcpServer } = useDeleteMcpServer();- const { mutate: addMcpServer } = useAddMcpServer();- const { mutate: updateMcpServer } = useUpdateMcpServer();-- const [view, setView] = useState<"list" | "add" | "edit">("list");- const [editingServer, setEditingServer] = useState<MCPServerConfig | null>(- null,- );- const [searchApiKey, setSearchApiKey] = useState("");- const [searchApiKeyDirty, setSearchApiKeyDirty] = useState(false);- const [confirmationModalIsVisible, setConfirmationModalIsVisible] =- useState(false);- const [serverToDelete, setServerToDelete] = useState<string | null>(null);-- const mcpConfig: MCPConfig = parseMcpConfig(- settings?.agent_settings?.mcp_config,- );-- const allServers: MCPServerConfig[] = [- ...mcpConfig.sse_servers.map((server, index) => ({- id: `sse-${index}`,- type: "sse" as const,- url: typeof server === "string" ? server : server.url,- api_key: typeof server === "object" ? server.api_key : undefined,- })),- ...mcpConfig.stdio_servers.map((server, index) => ({- id: `stdio-${index}`,- type: "stdio" as const,- name: server.name,- command: server.command,- args: server.args,- env: server.env,- })),- ...mcpConfig.shttp_servers.map((server, index) => ({- id: `shttp-${index}`,- type: "shttp" as const,- url: typeof server === "string" ? server : server.url,- api_key: typeof server === "object" ? server.api_key : undefined,- timeout: typeof server === "object" ? server.timeout : undefined,- })),- ];-- useEffect(() => {- setSearchApiKey(settings?.search_api_key ?? "");- setSearchApiKeyDirty(false);- }, [settings?.search_api_key]);-- const handleAddServer = (serverConfig: MCPServerConfig) => {- addMcpServer(serverConfig, {- onSuccess: () => {- setView("list");- },- });- };-- const handleEditServer = (serverConfig: MCPServerConfig) => {- updateMcpServer(- {- serverId: serverConfig.id,- server: serverConfig,- },- {- onSuccess: () => {- setView("list");- },- },- );- };-- const handleDeleteServer = (serverId: string) => {- deleteMcpServer(serverId, {- onSuccess: () => {- setConfirmationModalIsVisible(false);- },- });- };-- const handleEditClick = (server: MCPServerConfig) => {- setEditingServer(server);- setView("edit");- };-- const handleDeleteClick = (serverId: string) => {- setServerToDelete(serverId);- setConfirmationModalIsVisible(true);- };-- const handleConfirmDelete = () => {- if (serverToDelete) {- handleDeleteServer(serverToDelete);- }- };-- const handleCancelDelete = () => {- setConfirmationModalIsVisible(false);- setServerToDelete(null);- };-- const handleSaveSearchApiKey = () => {- saveSettings(- { search_api_key: searchApiKey },- {- onError: (error) => {- const message = retrieveAxiosErrorMessage(error as AxiosError);- displayErrorToast(message || t(I18nKey.ERROR$GENERIC));- },- onSuccess: () => {- displaySuccessToast(t(I18nKey.SETTINGS$SAVED_WARNING));- setSearchApiKeyDirty(false);- },- },- );- };-- if (isLoading || !settings) {- return null;- }-- if (view === "add") {- return (- <MCPServerForm- mode="add"- existingServers={allServers}- onSubmit={handleAddServer}- onCancel={() => setView("list")}- />- );- }-- if (view === "edit" && editingServer) {- return (- <MCPServerForm- mode="edit"- server={editingServer}- existingServers={allServers}- onSubmit={handleEditServer}- onCancel={() => {- setEditingServer(null);- setView("list");- }}- />- );- }-- return (- <div className="h-full flex flex-col gap-6 pb-8">- <div className="flex justify-between items-center">- <div>- <div className="flex flex-col items-start gap-2 mb-2">- <Typography.H2>{t(I18nKey.SETTINGS$MCP_TITLE)}</Typography.H2>- <BackendSyncedSettingsBadge />- </div>- <Typography.Paragraph className="text-sm text-[#A3A3A3]">- {t(I18nKey.SETTINGS$MCP_DESCRIPTION)}- </Typography.Paragraph>- </div>- <BrandButton- type="button"- variant="primary"- onClick={() => setView("add")}- >- {t(I18nKey.SETTINGS$MCP_ADD_SERVER)}- </BrandButton>- </div>-- <MCPServerList- servers={allServers}- onEdit={handleEditClick}- onDelete={handleDeleteClick}- />-- <section- data-testid="mcp-search-settings-section"- className="flex flex-col gap-4 rounded-2xl border border-tertiary p-5"- >- <div className="flex flex-col gap-2">- <Typography.H3>{t(I18nKey.SETTINGS$MCP_SEARCH_TITLE)}</Typography.H3>- <Typography.Paragraph className="text-sm text-[#A3A3A3]">- {t(I18nKey.SETTINGS$MCP_SEARCH_DESCRIPTION)}- </Typography.Paragraph>- </div>-- <div className="max-w-xl flex flex-col gap-4">- <SettingsInput- testId="search-api-key-input"- label={t(I18nKey.SETTINGS$SEARCH_API_KEY)}- type="password"- className="w-full"- value={searchApiKey}- placeholder={t(I18nKey.API$TVLY_KEY_EXAMPLE)}- onChange={(value) => {- setSearchApiKey(value);- setSearchApiKeyDirty(value !== (settings.search_api_key ?? ""));- }}- startContent={- settings.search_api_key_set ? (- <KeyStatusIcon isSet={settings.search_api_key_set} />- ) : undefined- }- />-- <HelpLink- testId="search-api-key-help-anchor"- text={t(I18nKey.SETTINGS$SEARCH_API_KEY_OPTIONAL)}- linkText={t(I18nKey.SETTINGS$SEARCH_API_KEY_INSTRUCTIONS)}- href="https://tavily.com/"- />-- <div>- <BrandButton- testId="save-search-api-key-button"- type="button"- variant="primary"- isDisabled={isSavingSearchApiKey || !searchApiKeyDirty}- onClick={handleSaveSearchApiKey}- >- {isSavingSearchApiKey- ? t(I18nKey.SETTINGS$SAVING)- : t(I18nKey.SETTINGS$SAVE_CHANGES)}- </BrandButton>- </div>- </div>- </section>-- {confirmationModalIsVisible && serverToDelete && (- <ConfirmationModal- text={t(I18nKey.SETTINGS$MCP_CONFIRM_DELETE)}- onCancel={handleCancelDelete}- onConfirm={handleConfirmDelete}- />- )}- </div>- );-}--export default MCPSettingsScreen;+export default MCPPage;diff --git a/src/routes/mcp.tsx b/src/routes/mcp.tsxnew file mode 100644index 0000000000..84fff72cfe--- /dev/null+++ b/src/routes/mcp.tsx@@ -0,0 +1,259 @@+import React from "react";+import { AxiosError } from "axios";+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { Typography } from "#/ui/typography";+import { BrandButton } from "#/components/features/settings/brand-button";+import { BackendSyncedSettingsBadge } from "#/components/features/settings/backend-synced-settings-badge";+import { ConfirmationModal } from "#/components/shared/modals/confirmation-modal";+import { useSettings } from "#/hooks/query/use-settings";+import { useDeleteMcpServer } from "#/hooks/mutation/use-delete-mcp-server";+import { useSaveSettings } from "#/hooks/mutation/use-save-settings";+import { useActiveBackend } from "#/contexts/active-backend-context";+import { parseMcpConfig } from "#/utils/mcp-config";+import {+ displayErrorToast,+ displaySuccessToast,+} from "#/utils/custom-toast-handlers";+import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";+import {+ findCatalogEntryForServer,+ findInstalledMatch,+ installedServerMatchesQuery,+ marketplaceEntryMatchesQuery,+} from "#/utils/mcp-marketplace-utils";+import { MCP_MARKETPLACE, MarketplaceEntry } from "#/constants/mcp-marketplace";+import { MCPConfig } from "#/types/settings";+import { ExistingInstall, MCPServerConfig } from "#/types/mcp-server";+import {+ InstalledServersSection,+ MarketplaceSearch,+ MarketplaceSection,+ InstallServerModal,+ CustomServerEditor,+} from "#/components/features/mcp-page";++function flattenMcpConfig(config: MCPConfig): MCPServerConfig[] {+ return [+ ...config.sse_servers.map((server, index) => ({+ id: `sse-${index}`,+ type: "sse" as const,+ url: typeof server === "string" ? server : server.url,+ api_key: typeof server === "object" ? server.api_key : undefined,+ })),+ ...config.stdio_servers.map((server, index) => ({+ id: `stdio-${index}`,+ type: "stdio" as const,+ name: server.name,+ command: server.command,+ args: server.args,+ env: server.env,+ })),+ ...config.shttp_servers.map((server, index) => ({+ id: `shttp-${index}`,+ type: "shttp" as const,+ url: typeof server === "string" ? server : server.url,+ api_key: typeof server === "object" ? server.api_key : undefined,+ timeout: typeof server === "object" ? server.timeout : undefined,+ })),+ ];+}++// Looked up lazily inside the component so we don't crash at module+// load if the catalog ever drops Tavily.+function getTavilyEntry(): MarketplaceEntry | undefined {+ return MCP_MARKETPLACE.find((e) => e.id === "tavily");+}++export default function MCPPage() {+ const { t } = useTranslation("openhands");+ const { data: settings, isLoading } = useSettings();+ const { mutate: deleteMcpServer, isPending: isDeleting } =+ useDeleteMcpServer();+ const { mutate: saveSettings, isPending: isSavingSettings } =+ useSaveSettings();+ const activeBackend = useActiveBackend();+ const backendKind = activeBackend.backend.kind;++ const [installEntry, setInstallEntry] =+ React.useState<MarketplaceEntry | null>(null);+ const [editingServer, setEditingServer] =+ React.useState<MCPServerConfig | null>(null);+ const [serverToDelete, setServerToDelete] =+ React.useState<ExistingInstall | null>(null);+ const [searchQuery, setSearchQuery] = React.useState("");++ const tavilyEntry = getTavilyEntry();+ const mcpConfig = parseMcpConfig(settings?.agent_settings?.mcp_config);+ const allServers = flattenMcpConfig(mcpConfig);+ const tavilyBuiltinInstalled = !!settings?.search_api_key_set;++ const isInstalled = (entry: MarketplaceEntry) =>+ !!findInstalledMatch(entry.template, allServers, settings);++ // Filter installed servers by the search query. We pair each server+ // with its catalog entry (if any) so the search can match friendly+ // names like "Slack" against a stdio server whose own `.name` is+ // just "slack".+ const filteredInstalledServers = allServers.filter((server) =>+ installedServerMatchesQuery(+ server,+ findCatalogEntryForServer(server, MCP_MARKETPLACE),+ searchQuery,+ ),+ );+ const tavilyVisibleAfterSearch =+ tavilyBuiltinInstalled &&+ !!tavilyEntry &&+ marketplaceEntryMatchesQuery(tavilyEntry, searchQuery);++ const handleMarketplaceClick = (entry: MarketplaceEntry) => {+ setInstallEntry(entry);+ };++ const handleEdit = (server: MCPServerConfig) => {+ setEditingServer(server);+ };++ const handleDeleteClick = (serverId: string) => {+ const target = allServers.find((s) => s.id === serverId);+ if (target) setServerToDelete({ kind: "mcp", server: target });+ };++ const handleConfirmDelete = () => {+ if (!serverToDelete) return;+ if (serverToDelete.kind === "tavily-builtin") {+ saveSettings(+ { search_api_key: "" },+ {+ onSuccess: () => {+ displaySuccessToast(t(I18nKey.MCP$REMOVE_SUCCESS));+ setServerToDelete(null);+ },+ onError: (err) => {+ const message = retrieveAxiosErrorMessage(err as AxiosError);+ displayErrorToast(message || t(I18nKey.ERROR$GENERIC));+ },+ },+ );+ return;+ }+ // Pass the full server config β useDeleteMcpServer re-resolves its+ // position against the fresh settings at mutation time, so a+ // background refresh between this click and confirm cannot point+ // us at the wrong index.+ deleteMcpServer(serverToDelete.server, {+ onSuccess: () => {+ displaySuccessToast(t(I18nKey.MCP$REMOVE_SUCCESS));+ setServerToDelete(null);+ },+ onError: (err) => {+ const message = retrieveAxiosErrorMessage(err as AxiosError);+ displayErrorToast(message || t(I18nKey.ERROR$GENERIC));+ },+ });+ };++ if (isLoading || !settings) {+ return (+ <main+ data-testid="mcp-page"+ className="h-full flex items-center justify-center"+ >+ <div className="h-8 w-8 rounded-full border-2 border-tertiary border-t-primary animate-spin" />+ </main>+ );+ }++ // Existing match for the install modal β drives Add vs Edit and the+ // optional "Remove" affordance for already-installed catalog entries.+ const installExisting = installEntry+ ? findInstalledMatch(installEntry.template, allServers, settings)+ : null;++ return (+ <main+ data-testid="mcp-page"+ className="h-full overflow-auto custom-scrollbar-always px-6 md:px-10 pt-8 pb-12"+ >+ <div className="max-w-5xl mx-auto flex flex-col gap-8">+ <header className="flex flex-col gap-2">+ <div className="flex items-end justify-between gap-4">+ <div className="flex flex-col gap-2">+ <Typography.H2>{t(I18nKey.SETTINGS$MCP_TITLE)}</Typography.H2>+ <BackendSyncedSettingsBadge />+ </div>+ <BrandButton+ type="button"+ variant="secondary"+ testId="mcp-add-custom-server"+ onClick={() => setEditingServer({ id: "", type: "sse" })}+ >+ {t(I18nKey.MCP$ADD_CUSTOM)}+ </BrandButton>+ </div>+ <Typography.Paragraph className="text-sm text-tertiary-alt">+ {t(I18nKey.MCP$PAGE_DESCRIPTION)}+ </Typography.Paragraph>+ </header>++ <MarketplaceSearch value={searchQuery} onChange={setSearchQuery} />++ <section className="flex flex-col gap-3">+ <h2 className="text-base font-semibold">+ {t(I18nKey.MCP$INSTALLED_TITLE)}+ </h2>+ <InstalledServersSection+ servers={filteredInstalledServers}+ tavilyBuiltinInstalled={tavilyVisibleAfterSearch}+ hasAnyInstalled={allServers.length > 0 || tavilyBuiltinInstalled}+ query={searchQuery}+ onEdit={handleEdit}+ onDelete={handleDeleteClick}+ onConfigureTavilyBuiltin={+ tavilyEntry ? () => setInstallEntry(tavilyEntry) : undefined+ }+ onRemoveTavilyBuiltin={() =>+ setServerToDelete({ kind: "tavily-builtin" })+ }+ />+ </section>++ <MarketplaceSection+ isInstalled={isInstalled}+ backendKind={backendKind}+ onSelect={handleMarketplaceClick}+ query={searchQuery}+ />+ </div>++ {installEntry && (+ <InstallServerModal+ entry={installEntry}+ existing={installExisting}+ onClose={() => setInstallEntry(null)}+ />+ )}++ {/* Custom (or non-marketplace) server editor β falls back to the+ legacy MCPServerForm for full control. The empty-id sentinel+ (`{ id: "", type: "sse" }`) means "add new". */}+ {editingServer && (+ <CustomServerEditor+ server={editingServer}+ existingServers={allServers}+ onClose={() => setEditingServer(null)}+ />+ )}++ {serverToDelete && (+ <ConfirmationModal+ text={t(I18nKey.SETTINGS$MCP_CONFIRM_DELETE)}+ onCancel={() => setServerToDelete(null)}+ onConfirm={handleConfirmDelete}+ isConfirming={isDeleting || isSavingSettings}+ />+ )}+ </main>+ );+}diff --git a/src/types/mcp-server.ts b/src/types/mcp-server.tsnew file mode 100644index 0000000000..6f34df04b5--- /dev/null+++ b/src/types/mcp-server.ts@@ -0,0 +1,34 @@+// Shared MCPServerConfig shape used by the MCP page UI components.+//+// Historically each component duplicated this interface. Centralizing+// it here keeps the marketplace utilities, hooks, and form in sync.++export type MCPServerType = "sse" | "stdio" | "shttp";++export interface MCPServerConfig {+ id: string;+ type: MCPServerType;+ name?: string;+ url?: string;+ api_key?: string;+ timeout?: number;+ command?: string;+ args?: string[];+ env?: Record<string, string>;+}++/**+ * Discriminated union describing the "existing install" referenced+ * from various MCP UI surfaces (install modal, delete confirmation,+ * etc.). Previously these surfaces juggled+ * `MCPServerConfig | "tavily-builtin" | null`, which made the+ * Tavily-builtin case look like an arbitrary string and required+ * the same string check at every callsite.+ */+export type ExistingInstall =+ | { kind: "mcp"; server: MCPServerConfig }+ | { kind: "tavily-builtin" };++export const isMcpInstall = (+ i: ExistingInstall | null | undefined,+): i is { kind: "mcp"; server: MCPServerConfig } => i?.kind === "mcp";diff --git a/src/utils/mcp-marketplace-utils.ts b/src/utils/mcp-marketplace-utils.tsnew file mode 100644index 0000000000..4b9c5d27a7--- /dev/null+++ b/src/utils/mcp-marketplace-utils.ts@@ -0,0 +1,173 @@+import { ExistingInstall, MCPServerConfig } from "#/types/mcp-server";+import {+ MarketplaceEntry,+ MarketplaceTemplate,+} from "#/constants/mcp-marketplace";+import { Settings } from "#/types/settings";++const tryUrl = (raw: string): URL | null => {+ try {+ return new URL(raw);+ } catch {+ return null;+ }+};++/**+ * Loose URL match that ignores query strings, trailing slashes, and+ * default ports. We want clicking "Linear" to flag the entry as+ * installed even if the user pasted the URL with extra trailing slash+ * or a different port-equivalent variant.+ *+ * Defensive against runtime data that doesn't match the static type:+ * if either input is not a string (e.g. parsed from an older settings+ * blob), we fall through the URL parsing path and the safe trim+ * fallback below, never calling `.replace` on undefined.+ */+export function urlsMatch(a: unknown, b: unknown): boolean {+ const aStr = typeof a === "string" ? a : "";+ const bStr = typeof b === "string" ? b : "";+ if (!aStr || !bStr) return false;+ const left = tryUrl(aStr);+ const right = tryUrl(bStr);+ if (!left || !right) {+ return aStr.replace(/\/+$/, "") === bStr.replace(/\/+$/, "");+ }+ return (+ left.protocol === right.protocol &&+ left.host === right.host &&+ left.pathname.replace(/\/+$/, "") === right.pathname.replace(/\/+$/, "")+ );+}++/**+ * Decide whether a marketplace template is already represented by one+ * of the installed MCP servers. Used to render an "Installed" badge on+ * the marketplace tile.+ */+export function findInstalledMatch(+ template: MarketplaceTemplate,+ servers: MCPServerConfig[],+ settings?: Pick<Settings, "search_api_key_set">,+): ExistingInstall | null {+ if (template.kind === "tavily-builtin") {+ return settings?.search_api_key_set ? { kind: "tavily-builtin" } : null;+ }++ if (template.kind === "shttp") {+ const tplUrl = template.url;+ if (!tplUrl) return null;+ const match = servers.find(+ (s) => s.type === "shttp" && !!s.url && urlsMatch(s.url, tplUrl),+ );+ return match ? { kind: "mcp", server: match } : null;+ }++ if (template.kind === "sse") {+ const tplUrl = template.url;+ if (!tplUrl) return null;+ const match = servers.find(+ (s) => s.type === "sse" && !!s.url && urlsMatch(s.url, tplUrl),+ );+ return match ? { kind: "mcp", server: match } : null;+ }++ // stdio: match on the registered server name.+ const match = servers.find(+ (s) => s.type === "stdio" && s.name === template.serverName,+ );+ return match ? { kind: "mcp", server: match } : null;+}++export function isMarketplaceEntryAvailable(+ entry: MarketplaceEntry,+ backendKind: "local" | "cloud",+): boolean {+ if (!entry.availability || entry.availability === "all") return true;+ return entry.availability === backendKind;+}++function normalize(query: string): string {+ return query.trim().toLowerCase();+}++/**+ * Case-insensitive substring match against the catalog entry's+ * user-visible identity (name, description, id, keywords). Empty+ * queries always match.+ */+export function marketplaceEntryMatchesQuery(+ entry: MarketplaceEntry,+ rawQuery: string,+): boolean {+ const q = normalize(rawQuery);+ if (!q) return true;+ const haystack = [+ entry.name,+ entry.description,+ entry.id,+ ...(entry.keywords ?? []),+ ]+ .join(" ")+ .toLowerCase();+ return haystack.includes(q);+}++/**+ * Search match for an installed (already-configured) server. We+ * search the server's own identifying fields and β if it's a catalog+ * entry β its catalog name/keywords too, so typing "Slack" matches+ * the installed Slack tile even though the persisted server is just+ * `{ type: "stdio", name: "slack", ... }`.+ */+export function installedServerMatchesQuery(+ server: MCPServerConfig,+ catalogEntry: MarketplaceEntry | undefined,+ rawQuery: string,+): boolean {+ const q = normalize(rawQuery);+ if (!q) return true;+ const haystack = [+ server.type,+ "name" in server ? server.name : undefined,+ "command" in server ? server.command : undefined,+ "args" in server ? server.args?.join(" ") : undefined,+ "url" in server ? server.url : undefined,+ catalogEntry?.name,+ catalogEntry?.description,+ catalogEntry?.id,+ ...(catalogEntry?.keywords ?? []),+ ]+ .filter(Boolean)+ .join(" ")+ .toLowerCase();+ return haystack.includes(q);+}++/**+ * Look up the catalog entry that best matches an installed server.+ * Mirrors the lookup used in `installed-server-card.tsx` for+ * rendering the friendly icon.+ */+export function findCatalogEntryForServer(+ server: MCPServerConfig,+ catalog: MarketplaceEntry[],+): MarketplaceEntry | undefined {+ return catalog.find((entry) => {+ const tpl = entry.template;+ if (tpl.kind === "tavily-builtin") return false;+ if (tpl.kind === "stdio")+ return server.type === "stdio" && server.name === tpl.serverName;+ // Reuse the same loose URL match as `findInstalledMatch` so a+ // server whose URL was normalized by the backend (trailing slash+ // stripped, query string dropped, etc.) still gets paired with+ // its catalog tile β otherwise the installed-servers list would+ // render the generic icon while the marketplace shows the+ // entry as installed, which is confusing.+ if (tpl.kind === "shttp")+ return server.type === "shttp" && urlsMatch(server.url, tpl.url);+ if (tpl.kind === "sse")+ return server.type === "sse" && urlsMatch(server.url, tpl.url);+ return false;+ });+}diff --git a/src/utils/settings-utils.ts b/src/utils/settings-utils.tsindex 3de3b079fa..1ceaf92ecf 100644--- a/src/utils/settings-utils.ts+++ b/src/utils/settings-utils.ts@@ -71,7 +71,6 @@ export function getFirstAvailablePath(): string | null {const fallbackOrder = [{ path: "/settings", hidden: !!featureFlags?.hide_llm_settings },- { path: "/settings/mcp", hidden: false },{ path: "/settings/app", hidden: false },{ path: "/settings/secrets", hidden: false },];