From faa51e3974a4417e8ff7c173de264fb25ee81165 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 26 Apr 2026 21:33:23 +0000 Subject: [PATCH] Add MCP broker access controls --- README.md | 56 +- app/api/mcp/broker/call/route.ts | 50 ++ app/api/mcp/broker/capabilities/route.ts | 54 ++ app/api/mcp/registry/route.ts | 154 ++++ app/api/mcp/route.ts | 70 ++ app/api/sandbox/[sandboxId]/mcp/route.ts | 67 ++ app/components/McpConfigurationPanel.tsx | 563 +++++++++++++++ app/components/SandboxList.tsx | 255 ++++++- app/components/Sidebar.tsx | 52 +- app/lib/mcpBrokerClient.ts | 83 +++ app/lib/mcpBrokerStore.ts | 98 +++ app/lib/mcpServerStore.ts | 263 +++++++ app/lib/sandboxMcpManifest.ts | 89 +++ app/page.tsx | 74 +- install.sh | 11 + package-lock.json | 872 ++++++++++++++++++++++- package.json | 2 + tests/mcp-configuration-page-check.mjs | 98 +++ 18 files changed, 2838 insertions(+), 73 deletions(-) create mode 100644 app/api/mcp/broker/call/route.ts create mode 100644 app/api/mcp/broker/capabilities/route.ts create mode 100644 app/api/mcp/registry/route.ts create mode 100644 app/api/mcp/route.ts create mode 100644 app/api/sandbox/[sandboxId]/mcp/route.ts create mode 100644 app/components/McpConfigurationPanel.tsx create mode 100644 app/lib/mcpBrokerClient.ts create mode 100644 app/lib/mcpBrokerStore.ts create mode 100644 app/lib/mcpServerStore.ts create mode 100644 app/lib/sandboxMcpManifest.ts create mode 100644 tests/mcp-configuration-page-check.mjs diff --git a/README.md b/README.md index 3b4da11..b2e27d9 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ It is currently built for active development and lab use. It includes a simple p - Approve or reject pending OpenShell network permission requests. - Configure per-sandbox inference routes for Ollama, NIM, vLLM, and external endpoints. - Poll Ollama for available models. +- Search the official MCP Registry, install MCP server definitions, and manage preconfigured/custom MCP servers. +- Enforce per-sandbox MCP access through a control-plane broker so sandboxes only see allowed capabilities. - Upload files into sandboxes and download files back out. - Open an operator terminal for the selected sandbox. - Simple local login, setup account, forgot password, and recovery token flow. @@ -41,7 +43,7 @@ Minimum expected versions: - Docker `24+` - OpenShell CLI and gateway compatible with OpenShell `0.0.24` -The app uses Next.js `14.2.15`, React `18.3.1`, TypeScript, Tailwind CSS, `ws`, and `node-pty`. +The app uses Next.js `14.2.35`, React `18.3.1`, TypeScript, Tailwind CSS, `ws`, `node-pty`, and the official MCP TypeScript SDK. ## Prerequisites @@ -54,6 +56,12 @@ docker ps openshell --version ``` +Optional, but useful for stdio MCP servers installed through the broker: + +```bash +uvx --version +``` + OpenShell must already be installed and able to reach its gateway. On this host the active gateway metadata lives under: ```bash @@ -77,6 +85,7 @@ The installer: - runs a non-blocking `npm audit` summary; - creates `.env.local` if needed; - generates a local dashboard password, signing secret, and recovery token if they are missing; +- adds MCP broker defaults for token TTL and request timeout; - runs `npm run build` as a verification step. It refuses to run as root unless `--allow-root` is supplied. It does not install or manage a systemd service. @@ -179,6 +188,47 @@ Supported provider categories in the UI: - vLLM - external HTTP-compatible endpoints +## MCP Access Broker + +OpenShell Control can install and broker MCP servers without disclosing the full MCP inventory to sandboxes. + +The MCP page supports: + +- registry search with paged results; +- preconfigured servers, including Blender MCP; +- custom stdio or HTTP MCP servers; +- global enable/disable state; +- per-sandbox `Disabled`, `Allow All`, and `Allow Only` access policy. + +The sandbox page shows an MCP indicator on each sandbox card. A sandbox lights up when at least one MCP server is allowed by policy. + +For sandbox handoff, OpenShell Control writes: + +```text +/sandbox/openshell_control_mcp.md +``` + +That file contains only the MCP broker endpoints and a sandbox-scoped token. It does not list denied servers, launch commands, credentials, or registry metadata. The broker validates the token and enforces access policy on every capabilities and tool-call request. + +Broker endpoints: + +```text +/api/mcp/broker/capabilities +/api/mcp/broker/call +``` + +Broker configuration keys: + +```bash +MCP_BROKER_TOKEN_TTL_HOURS=168 +MCP_BROKER_REQUEST_TIMEOUT_MS=45000 +OPENSHELL_CONTROL_MCP_BROKER_URL=http://localhost:3000/api/mcp/broker +``` + +`OPENSHELL_CONTROL_MCP_BROKER_URL` is optional. Set it when sandboxes need a routable URL that differs from the dashboard request origin. + +Stdio MCP servers run on the control host. Make sure their launch commands, such as `uvx`, `npx`, `node`, or `python`, are available to the dashboard process. + ## File Transfer The file transfer UI is scoped to safe sandbox paths: @@ -228,6 +278,8 @@ OPENSHELL_GATEWAY=nemoclaw OPENSHELL_CONTROL_PASSWORD=change-this-password OPENSHELL_CONTROL_AUTH_SECRET=change-this-random-secret OPENSHELL_CONTROL_RECOVERY_TOKEN=change-this-recovery-token +MCP_BROKER_TOKEN_TTL_HOURS=168 +MCP_BROKER_REQUEST_TIMEOUT_MS=45000 ``` ## Security Limitations @@ -243,6 +295,8 @@ Known limitations: - no audit log persistence beyond process/container logs; - local recovery token can reset the password; - assumes a trusted operator host and trusted local filesystem. +- MCP stdio servers run as child processes on the control host; only install trusted MCP servers. +- MCP broker tokens grant sandbox-scoped access until expiry or rotation. Before exposing this outside a trusted lab network, replace auth with a real identity provider, add role-based access control, add audit logging, use TLS, and review every shell-out path. diff --git a/app/api/mcp/broker/call/route.ts b/app/api/mcp/broker/call/route.ts new file mode 100644 index 0000000..643e44c --- /dev/null +++ b/app/api/mcp/broker/call/route.ts @@ -0,0 +1,50 @@ +import { NextResponse } from "next/server" +import { + listAllowedBrokerServers, + readBrokerToken, + verifySandboxMcpBrokerToken, +} from "@/app/lib/mcpBrokerStore" +import { callBrokerServerTool } from "@/app/lib/mcpBrokerClient" + +export async function POST(request: Request) { + try { + const token = readBrokerToken(request) + const session = token ? await verifySandboxMcpBrokerToken(token) : null + if (!session) { + return NextResponse.json({ ok: false, error: "MCP broker is unavailable for this sandbox." }, { status: 401 }) + } + + const body = await request.json().catch(() => ({})) + const requestedServerId = typeof body?.serverId === "string" ? body.serverId : "" + const toolName = typeof body?.toolName === "string" ? body.toolName : "" + const toolArguments = body?.arguments && typeof body.arguments === "object" && !Array.isArray(body.arguments) + ? body.arguments as Record + : {} + const allowedServers = await listAllowedBrokerServers(session) + const server = allowedServers.find((candidate) => candidate.id === requestedServerId) + if (!server) { + return NextResponse.json({ ok: false, error: "Requested MCP capability is unavailable." }, { status: 403 }) + } + if (!toolName) { + return NextResponse.json({ ok: false, error: "toolName is required." }, { status: 400 }) + } + + const result = await callBrokerServerTool(server, toolName, toolArguments) + + return NextResponse.json({ + ok: true, + server: { + id: server.id, + name: server.name, + transport: server.transport, + }, + toolName, + result, + }) + } catch (error) { + return NextResponse.json({ + ok: false, + error: error instanceof Error ? error.message : "MCP broker request failed.", + }, { status: 500 }) + } +} diff --git a/app/api/mcp/broker/capabilities/route.ts b/app/api/mcp/broker/capabilities/route.ts new file mode 100644 index 0000000..a077bd5 --- /dev/null +++ b/app/api/mcp/broker/capabilities/route.ts @@ -0,0 +1,54 @@ +import { NextResponse } from "next/server" +import { + listAllowedBrokerServers, + readBrokerToken, + verifySandboxMcpBrokerToken, +} from "@/app/lib/mcpBrokerStore" +import { listBrokerServerTools } from "@/app/lib/mcpBrokerClient" + +export async function GET(request: Request) { + try { + const token = readBrokerToken(request) + const session = token ? await verifySandboxMcpBrokerToken(token) : null + if (!session) { + return NextResponse.json({ ok: false, error: "MCP broker is unavailable for this sandbox." }, { status: 401 }) + } + + const allowedServers = await listAllowedBrokerServers(session) + const servers = await Promise.all(allowedServers.map(async (server) => { + try { + const tools = await listBrokerServerTools(server) + return { + id: server.id, + name: server.name, + transport: server.transport, + summary: server.summary, + available: true, + tools, + } + } catch (error) { + return { + id: server.id, + name: server.name, + transport: server.transport, + summary: server.summary, + available: false, + tools: [], + error: error instanceof Error ? error.message : "Failed to inspect MCP server", + } + } + })) + + return NextResponse.json({ + ok: true, + sandboxId: session.sandboxId, + servers, + }) + } catch { + return NextResponse.json({ ok: false, error: "MCP broker is unavailable for this sandbox." }, { status: 500 }) + } +} + +export async function POST(request: Request) { + return GET(request) +} diff --git a/app/api/mcp/registry/route.ts b/app/api/mcp/registry/route.ts new file mode 100644 index 0000000..43eae0f --- /dev/null +++ b/app/api/mcp/registry/route.ts @@ -0,0 +1,154 @@ +import { NextResponse } from "next/server" +import type { McpCatalogEntry } from "@/app/lib/mcpServerStore" + +const REGISTRY_BASE_URL = process.env.MCP_REGISTRY_BASE_URL || "https://registry.modelcontextprotocol.io" + +type RegistryArgument = { + value?: string + default?: string + name?: string +} + +type RegistryKeyValue = { + name?: string + value?: string + default?: string + placeholder?: string +} + +type RegistryPackage = { + registryType?: string + identifier?: string + version?: string + runtimeHint?: string + runtimeArguments?: RegistryArgument[] + packageArguments?: RegistryArgument[] + environmentVariables?: RegistryKeyValue[] +} + +type RegistryRemote = { + type?: string + url?: string + headers?: RegistryKeyValue[] +} + +type RegistryServer = { + name?: string + title?: string + description?: string + version?: string + repository?: { + url?: string + source?: string + } + packages?: RegistryPackage[] + remotes?: RegistryRemote[] +} + +type RegistryEntry = { + server?: RegistryServer +} + +function slugify(value: string) { + return value + .trim() + .toLowerCase() + .replace(/[^a-z0-9-]+/g, "-") + .replace(/^-+|-+$/g, "") + .slice(0, 64) +} + +function argumentValues(args?: RegistryArgument[] | null) { + return (args || []) + .map((arg) => arg.value || arg.default || "") + .filter(Boolean) +} + +function keyValueMap(values?: RegistryKeyValue[] | null) { + return Object.fromEntries( + (values || []) + .map((item) => [item.name || "", item.value || item.default || item.placeholder || ""]) + .filter(([name]) => Boolean(name)), + ) +} + +function packageInstall(server: RegistryServer, pkg: RegistryPackage): McpCatalogEntry | null { + if (!pkg.identifier) return null + + const runtime = pkg.runtimeHint?.trim() + const registryType = pkg.registryType?.toLowerCase() + const command = runtime || (registryType === "pypi" ? "uvx" : registryType === "npm" ? "npx" : "") + if (!command) return null + + const args = [ + ...argumentValues(pkg.runtimeArguments), + ...(command === "npx" ? ["-y"] : []), + pkg.identifier, + ...argumentValues(pkg.packageArguments), + ] + + return { + id: slugify(server.name || pkg.identifier), + name: server.title || server.name || pkg.identifier, + summary: server.description || `Install ${pkg.identifier} from the MCP registry.`, + transport: "stdio", + command, + args, + env: keyValueMap(pkg.environmentVariables), + tags: ["registry", registryType || "package", server.version || ""].filter(Boolean), + } +} + +function remoteInstall(server: RegistryServer, remote: RegistryRemote): McpCatalogEntry | null { + if (!remote.url) return null + return { + id: slugify(server.name || remote.url), + name: server.title || server.name || remote.url, + summary: server.description || `Connect to ${remote.url}.`, + transport: "http", + command: remote.url, + args: [], + env: keyValueMap(remote.headers), + tags: ["registry", remote.type || "remote", server.version || ""].filter(Boolean), + } +} + +function normalizeRegistryEntry(entry: RegistryEntry): McpCatalogEntry | null { + const server = entry.server + if (!server) return null + const packageCandidate = server.packages?.map((pkg) => packageInstall(server, pkg)).find(Boolean) + if (packageCandidate) return packageCandidate + return server.remotes?.map((remote) => remoteInstall(server, remote)).find(Boolean) || null +} + +export async function GET(request: Request) { + try { + const requestUrl = new URL(request.url) + const search = requestUrl.searchParams.get("search") || requestUrl.searchParams.get("q") || "" + const limit = Math.max(1, Math.min(Number.parseInt(requestUrl.searchParams.get("limit") || "12", 10) || 12, 30)) + const registryUrl = new URL("/v0/servers", REGISTRY_BASE_URL) + registryUrl.searchParams.set("limit", String(limit)) + registryUrl.searchParams.set("is_latest", "true") + if (search.trim()) registryUrl.searchParams.set("search", search.trim()) + + const response = await fetch(registryUrl, { + headers: { Accept: "application/json" }, + next: { revalidate: 60 }, + }) + const data = await response.json() + if (!response.ok) throw new Error(data?.detail || data?.error || "MCP registry request failed") + + const results = Array.isArray(data?.servers) + ? data.servers.map(normalizeRegistryEntry).filter(Boolean) + : [] + + return NextResponse.json({ + registryUrl: registryUrl.toString(), + results, + metadata: data?.metadata || null, + }) + } catch (error) { + const message = error instanceof Error ? error.message : "Failed to search MCP registry" + return NextResponse.json({ error: message }, { status: 502 }) + } +} diff --git a/app/api/mcp/route.ts b/app/api/mcp/route.ts new file mode 100644 index 0000000..6443621 --- /dev/null +++ b/app/api/mcp/route.ts @@ -0,0 +1,70 @@ +import { NextResponse } from "next/server" +import { + installMcpServer, + listMcpServers, + setMcpServerEnabled, + updateMcpServerAccess, + uninstallMcpServer, +} from "@/app/lib/mcpServerStore" + +export async function GET() { + try { + return NextResponse.json(await listMcpServers()) + } catch (error) { + const message = error instanceof Error ? error.message : "Failed to load MCP servers" + return NextResponse.json({ error: message }, { status: 500 }) + } +} + +export async function POST(request: Request) { + try { + const body = await request.json().catch(() => ({})) + const action = typeof body?.action === "string" ? body.action : "install" + + if (action === "uninstall") { + const serverId = typeof body?.serverId === "string" ? body.serverId : "" + return NextResponse.json({ server: await uninstallMcpServer(serverId), ...(await listMcpServers()) }) + } + + if (action === "enable" || action === "disable") { + const serverId = typeof body?.serverId === "string" ? body.serverId : "" + return NextResponse.json({ + server: await setMcpServerEnabled(serverId, action === "enable"), + ...(await listMcpServers()), + }) + } + + if (action === "update-access") { + const serverId = typeof body?.serverId === "string" ? body.serverId : "" + return NextResponse.json({ + server: await updateMcpServerAccess(serverId, { + enabled: typeof body?.enabled === "boolean" ? body.enabled : undefined, + accessMode: body?.accessMode, + allowedSandboxIds: Array.isArray(body?.allowedSandboxIds) ? body.allowedSandboxIds : undefined, + }), + ...(await listMcpServers()), + }) + } + + const server = await installMcpServer({ + id: body?.id, + name: body?.name, + summary: body?.summary, + websiteUrl: body?.websiteUrl, + transport: body?.transport, + command: body?.command, + args: body?.args, + env: body?.env, + tags: body?.tags, + source: body?.source, + enabled: body?.enabled, + accessMode: body?.accessMode, + allowedSandboxIds: body?.allowedSandboxIds, + }) + + return NextResponse.json({ server, ...(await listMcpServers()) }) + } catch (error) { + const message = error instanceof Error ? error.message : "Failed to update MCP servers" + return NextResponse.json({ error: message }, { status: 400 }) + } +} diff --git a/app/api/sandbox/[sandboxId]/mcp/route.ts b/app/api/sandbox/[sandboxId]/mcp/route.ts new file mode 100644 index 0000000..ad6e261 --- /dev/null +++ b/app/api/sandbox/[sandboxId]/mcp/route.ts @@ -0,0 +1,67 @@ +import { NextResponse } from "next/server" +import { syncSandboxMcpManifest } from "@/app/lib/sandboxMcpManifest" + +function readSandboxName(request: Request) { + const requestUrl = new URL(request.url) + return requestUrl.searchParams.get("sandboxName") || null +} + +function brokerBaseUrl(request: Request) { + const origin = new URL(request.url).origin + return process.env.OPENSHELL_CONTROL_MCP_BROKER_URL || `${origin}/api/mcp/broker` +} + +export async function GET( + request: Request, + { params }: { params: Promise<{ sandboxId: string }> }, +) { + try { + const { sandboxId } = await params + const sandboxName = readSandboxName(request) + const brokerUrl = brokerBaseUrl(request) + return NextResponse.json({ + ok: true, + sandboxId, + path: "/sandbox/openshell_control_mcp.md", + markdown: [ + "# OpenShell Control MCP Broker", + "", + `Sandbox: ${sandboxName || sandboxId}`, + `Sandbox ID: ${sandboxId}`, + "", + "This preview omits the broker token. Use POST to issue and write a live broker config.", + "", + `- Capabilities: \`${brokerUrl}/capabilities\``, + `- Call: \`${brokerUrl}/call\``, + "", + ].join("\n"), + }) + } catch (error) { + const message = error instanceof Error ? error.message : "Failed to build MCP broker handoff" + return NextResponse.json({ ok: false, error: message }, { status: 500 }) + } +} + +export async function POST( + request: Request, + { params }: { params: Promise<{ sandboxId: string }> }, +) { + try { + const { sandboxId } = await params + const body = await request.json().catch(() => ({})) + const sandboxName = typeof body?.sandboxName === "string" ? body.sandboxName : readSandboxName(request) + const synced = await syncSandboxMcpManifest( + { id: sandboxId, name: sandboxName }, + { brokerBaseUrl: brokerBaseUrl(request) }, + ) + return NextResponse.json({ + ok: true, + sandboxId, + synced, + note: `Issued MCP broker config at ${synced.path}.`, + }) + } catch (error) { + const message = error instanceof Error ? error.message : "Failed to issue MCP broker config" + return NextResponse.json({ ok: false, error: message }, { status: 500 }) + } +} diff --git a/app/components/McpConfigurationPanel.tsx b/app/components/McpConfigurationPanel.tsx new file mode 100644 index 0000000..4752be3 --- /dev/null +++ b/app/components/McpConfigurationPanel.tsx @@ -0,0 +1,563 @@ +"use client" + +import { useEffect, useMemo, useState } from "react" + +type McpTransport = "stdio" | "http" + +type McpCatalogEntry = { + id: string + name: string + summary: string + websiteUrl?: string + transport: McpTransport + command: string + args: string[] + env: Record + tags: string[] +} + +type McpServerInstall = McpCatalogEntry & { + installedAt: string + updatedAt: string + source: "catalog" | "custom" | "registry" + enabled: boolean + accessMode: "disabled" | "allow_all" | "allow_only" + allowedSandboxIds: string[] +} + +type McpResponse = { + catalog: McpCatalogEntry[] + servers: McpServerInstall[] + config: Record + error?: string +} + +type McpSandbox = { + id: string + name: string + status: string +} + +type McpConfigurationPanelProps = { + sandboxes?: McpSandbox[] +} + +const REGISTRY_PAGE_SIZE = 4 + +function FieldLabel({ children }: { children: React.ReactNode }) { + return +} + +function parseLines(value: string) { + return value + .split(/\r?\n/) + .map((line) => line.trim()) + .filter(Boolean) +} + +function parseEnv(value: string) { + return Object.fromEntries( + parseLines(value) + .map((line) => { + const [key, ...rest] = line.split("=") + return [key?.trim() || "", rest.join("=").trim()] + }) + .filter(([key]) => Boolean(key)), + ) +} + +export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurationPanelProps) { + const [loading, setLoading] = useState(true) + const [saving, setSaving] = useState(false) + const [message, setMessage] = useState("") + const [catalog, setCatalog] = useState([]) + const [servers, setServers] = useState([]) + const [config, setConfig] = useState>({ mcpServers: {} }) + const [customName, setCustomName] = useState("custom-tools") + const [customSummary, setCustomSummary] = useState("Custom MCP server") + const [customTransport, setCustomTransport] = useState("stdio") + const [customCommand, setCustomCommand] = useState("npx") + const [customArgs, setCustomArgs] = useState("-y\n@modelcontextprotocol/server-memory") + const [customEnv, setCustomEnv] = useState("") + const [registrySearch, setRegistrySearch] = useState("github") + const [registryResults, setRegistryResults] = useState([]) + const [registryLoading, setRegistryLoading] = useState(false) + const [registryPage, setRegistryPage] = useState(1) + const [lastRegistrySearch, setLastRegistrySearch] = useState("") + const [catalogOpen, setCatalogOpen] = useState(false) + const [customOpen, setCustomOpen] = useState(false) + + const installedIds = useMemo(() => new Set(servers.map((server) => server.id)), [servers]) + const enabledCount = servers.filter((server) => server.enabled).length + const configText = JSON.stringify(config, null, 2) + const registryPageCount = Math.max(1, Math.ceil(registryResults.length / REGISTRY_PAGE_SIZE)) + const pagedRegistryResults = registryResults.slice( + (registryPage - 1) * REGISTRY_PAGE_SIZE, + registryPage * REGISTRY_PAGE_SIZE, + ) + + async function load() { + try { + setLoading(true) + const response = await fetch("/api/mcp", { cache: "no-store" }) + const data = await response.json() as McpResponse + if (!response.ok) throw new Error(data.error || "Failed to load MCP configuration") + setCatalog(Array.isArray(data.catalog) ? data.catalog : []) + setServers(Array.isArray(data.servers) ? data.servers : []) + setConfig(data.config || { mcpServers: {} }) + setMessage("") + } catch (error) { + setMessage(error instanceof Error ? error.message : "Failed to load MCP configuration") + } finally { + setLoading(false) + } + } + + async function postUpdate(body: Record, success: string) { + try { + setSaving(true) + const response = await fetch("/api/mcp", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(body), + }) + const data = await response.json() as McpResponse + if (!response.ok) throw new Error(data.error || "Failed to update MCP configuration") + setCatalog(Array.isArray(data.catalog) ? data.catalog : catalog) + setServers(Array.isArray(data.servers) ? data.servers : []) + setConfig(data.config || { mcpServers: {} }) + setMessage(success) + } catch (error) { + setMessage(error instanceof Error ? error.message : "Failed to update MCP configuration") + } finally { + setSaving(false) + } + } + + function sandboxAllowed(server: McpServerInstall, sandbox: McpSandbox) { + return server.allowedSandboxIds.includes(sandbox.id) || server.allowedSandboxIds.includes(sandbox.name) + } + + function toggleServerSandbox(server: McpServerInstall, sandbox: McpSandbox, allowed: boolean) { + const current = new Set(server.allowedSandboxIds) + current.delete(sandbox.id) + current.delete(sandbox.name) + if (allowed) current.add(sandbox.id) + return postUpdate({ + action: "update-access", + serverId: server.id, + accessMode: "allow_only", + allowedSandboxIds: Array.from(current), + }, `${server.name} sandbox access updated.`) + } + + async function searchRegistry() { + const query = registrySearch.trim() + try { + setRegistryLoading(true) + setRegistryResults([]) + setRegistryPage(1) + setLastRegistrySearch(query) + const params = new URLSearchParams({ search: query, limit: "24" }) + const response = await fetch(`/api/mcp/registry?${params}`, { cache: "no-store" }) + const data = await response.json() + if (!response.ok) throw new Error(data.error || "Failed to search MCP registry") + const results = Array.isArray(data.results) ? data.results : [] + setRegistryResults(results) + setMessage(results.length > 0 ? `Found ${results.length} registry server${results.length === 1 ? "" : "s"}.` : "No registry servers matched that search.") + } catch (error) { + setRegistryResults([]) + setMessage(error instanceof Error ? error.message : "Failed to search MCP registry") + } finally { + setRegistryLoading(false) + } + } + + useEffect(() => { + load() + }, []) + + return ( +
+
+
+
+

Model Context Protocol

+

MCP CONFIGURATION

+

+ Install MCP server definitions for local tools, files, and remote context providers. +

+
+ +
+
+
+

Installed

+

{servers.length} servers

+
+
+

Enabled

+

{enabledCount} active

+
+
+

Catalog

+

{catalog.length} presets

+
+
+
+ + {message && ( +
+ {message} +
+ )} + + {loading ? ( +
Loading MCP servers...
+ ) : ( +
+
+
+
+

MCP Security

+

Control which installed MCP servers are available to sandboxes.

+
+
+ {servers.length === 0 ? ( +
+ Install an MCP server before configuring sandbox access. +
+ ) : servers.map((server) => ( +
+
+
+
+

{server.name}

+ + {server.enabled ? "enabled" : "disabled"} + +
+

{server.command} {server.args.join(" ")}

+
+
+ + +
+
+ +
+
+ Availability + +
+
+ Allowed Sandboxes + {sandboxes.length === 0 ? ( +
+ No sandboxes detected. +
+ ) : ( +
+ {sandboxes.map((sandbox) => ( + + ))} +
+ )} +
+
+
+ ))} +
+
+ +
+
+
+

Registry Search

+

Search the Official MCP Registry and install compatible stdio or remote HTTP servers.

+
+ + Open Registry + +
+
+ setRegistrySearch(event.target.value)} + onKeyDown={(event) => { + if (event.key === "Enter") searchRegistry() + }} + placeholder="Search GitHub, Slack, filesystem, Postgres..." + className="field-control min-w-0 flex-1 px-3 py-2 text-sm" + /> + +
+ {registryResults.length > 0 && ( + <> +
+

+ Showing {((registryPage - 1) * REGISTRY_PAGE_SIZE) + 1}-{Math.min(registryPage * REGISTRY_PAGE_SIZE, registryResults.length)} of {registryResults.length} + {lastRegistrySearch ? ` for "${lastRegistrySearch}"` : ""} +

+
+ + + {registryPage} / {registryPageCount} + + +
+
+
+ {pagedRegistryResults.map((entry) => { + const installed = installedIds.has(entry.id) + return ( +
+
+
+

{entry.name}

+

{entry.summary}

+
+ {entry.transport} +
+
+ {entry.command} {entry.args.join(" ")} +
+
+

{entry.tags.join(" / ")}

+ +
+
+ ) + })} +
+ + )} +
+ +
+ + {catalogOpen && ( +
+ {catalog.map((entry) => { + const installed = installedIds.has(entry.id) + return ( +
+
+
+

{entry.name}

+

{entry.summary}

+ {entry.websiteUrl && ( + + Setup Guide + + )} +
+ {entry.transport} +
+
+ {entry.command} {entry.args.join(" ")} +
+
+

{entry.tags.join(" / ")}

+ +
+
+ ) + })} +
+ )} +
+ +
+ + {customOpen && ( +
+
+
+ Name + setCustomName(event.target.value)} className="field-control w-full px-3 py-2 text-sm font-mono" /> +
+
+ Transport + +
+
+ Summary + setCustomSummary(event.target.value)} className="field-control w-full px-3 py-2 text-sm" /> +
+
+ {customTransport === "http" ? "URL" : "Command"} + setCustomCommand(event.target.value)} placeholder={customTransport === "http" ? "https://mcp.example.com/mcp" : "npx, uvx, node, python"} className="field-control w-full px-3 py-2 text-sm font-mono" /> +
+
+ Args +