Refine MCP server install wizard flow

This commit is contained in:
Codex
2026-04-29 16:24:23 +00:00
parent fba5f64164
commit 4ece66c4e4
5 changed files with 555 additions and 175 deletions
+220 -39
View File
@@ -15,6 +15,7 @@ const UPLOAD_DIR = path.join(STORE_DIR, "mcp-server-uploads")
const MAX_UPLOAD_BYTES = Number.parseInt(process.env.MCP_SERVER_UPLOAD_MAX_BYTES || String(128 * 1024 * 1024), 10)
const INSTALL_TIMEOUT_MS = Number.parseInt(process.env.MCP_SERVER_DEPENDENCY_INSTALL_TIMEOUT_MS || String(5 * 60 * 1000), 10)
const ENTRY_MODES = new Set(["file", "python-module", "console-script"])
const UPLOAD_MODES = new Set(["stage", "preflight", "install-staged"])
function slugify(value: string) {
return value
@@ -48,6 +49,11 @@ function normalizeEntryMode(value: unknown) {
return ENTRY_MODES.has(mode) ? mode : "file"
}
function normalizeUploadMode(value: unknown) {
const mode = String(value || "").trim()
return UPLOAD_MODES.has(mode) ? mode : ""
}
function normalizeRelativePath(value: string) {
const normalized = path.posix.normalize(value.replace(/\\/g, "/")).replace(/^\/+/, "")
if (!normalized || normalized === "." || normalized.startsWith("../") || normalized.includes("/../")) {
@@ -85,6 +91,16 @@ async function pathExists(candidate: string) {
}
}
async function ensureUploadRoot(id: string) {
const root = path.resolve(UPLOAD_DIR, id)
const uploadRoot = path.resolve(UPLOAD_DIR)
if (root !== uploadRoot && !root.startsWith(`${uploadRoot}${path.sep}`)) {
throw new Error("staged upload id must stay inside the MCP upload directory")
}
if (!await pathExists(root)) throw new Error("staged MCP server upload was not found")
return root
}
async function findFileByName(root: string, fileName: string): Promise<string | null> {
const entries = await readdir(root, { withFileTypes: true }).catch(() => [])
for (const entry of entries) {
@@ -239,6 +255,67 @@ async function launchCommandForUpload(
return { command: bootstrap.command, args: [entrypointPath, ...extraArgs] }
}
async function buildUploadCandidate({
root,
id,
name,
summary,
runtime,
entryMode,
entrypoint,
args,
env,
}: {
root: string
id: string
name: string
summary: string
runtime: string
entryMode: string
entrypoint: string
args: string[]
env: Record<string, string>
}) {
const entrypointPath = entryMode === "file" ? await resolveEntryPath(root, entrypoint) : null
const projectRoot = await resolveProjectRoot(root, entrypointPath)
const bootstrap = await bootstrapUploadedServer(projectRoot, runtime, entrypoint)
const launch = await launchCommandForUpload(projectRoot, bootstrap, entryMode, entrypoint, entrypointPath, args)
const candidate = {
id,
name,
summary,
transport: "stdio",
command: launch.command,
args: launch.args,
env,
tags: ["uploaded", "custom"],
source: "custom",
enabled: true,
} satisfies {
id: string
name: string
summary: string
transport: "stdio"
command: string
args: string[]
env: Record<string, string>
tags: string[]
source: "custom"
enabled: boolean
}
return { candidate, projectRoot, bootstrap }
}
function installCandidateFrom(candidate: Awaited<ReturnType<typeof buildUploadCandidate>>["candidate"]): McpServerInstall {
return {
...candidate,
installedAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
accessMode: "disabled",
allowedSandboxIds: [],
}
}
async function writeDirectoryUpload(form: FormData, root: string) {
const files = form.getAll("files")
const paths = form.getAll("paths").map((item) => String(item || ""))
@@ -290,6 +367,7 @@ async function writeArchiveUpload(form: FormData, root: string) {
export async function POST(request: Request) {
try {
const form = await request.formData()
const mode = normalizeUploadMode(form.get("mode"))
const name = String(form.get("name") || "uploaded-server").trim()
const id = slugify(String(form.get("id") || name))
const summary = String(form.get("summary") || "Uploaded MCP server").trim()
@@ -303,48 +381,23 @@ export async function POST(request: Request) {
if (!runtime) throw new Error("runtime command is required")
if (!entrypoint) throw new Error("entrypoint is required")
await rm(root, { recursive: true, force: true })
await mkdir(root, { recursive: true, mode: 0o700 })
const uploadedDirectory = await writeDirectoryUpload(form, root)
const uploadedArchive = uploadedDirectory ? false : await writeArchiveUpload(form, root)
if (!uploadedDirectory && !uploadedArchive) throw new Error("choose a directory, .zip, .tgz, .tar.gz, or .tar server upload")
const entrypointPath = entryMode === "file" ? await resolveEntryPath(root, entrypoint) : null
const projectRoot = await resolveProjectRoot(root, entrypointPath)
const bootstrap = await bootstrapUploadedServer(projectRoot, runtime, entrypoint)
const launch = await launchCommandForUpload(projectRoot, bootstrap, entryMode, entrypoint, entrypointPath, parseLines(form.get("args")))
let candidate = {
if (mode === "preflight" || mode === "install-staged") {
const root = await ensureUploadRoot(id)
const { candidate: initialCandidate, projectRoot, bootstrap } = await buildUploadCandidate({
root,
id,
name,
summary,
transport: "stdio",
command: launch.command,
args: launch.args,
runtime,
entryMode,
entrypoint,
args: parseLines(form.get("args")),
env: parseEnv(form.get("env")),
tags: ["uploaded", "custom"],
source: "custom",
enabled: true,
} satisfies {
id: string
name: string
summary: string
transport: "stdio"
command: string
args: string[]
env: Record<string, string>
tags: string[]
source: "custom"
enabled: boolean
}
const installCandidate = (): McpServerInstall => ({
...candidate,
installedAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
accessMode: "disabled",
allowedSandboxIds: [],
})
let preflight = await preflightMcpServer(installCandidate())
let candidate = initialCandidate
if (mode === "preflight") {
let preflight = await preflightMcpServer(installCandidateFrom(candidate))
let repair: McpPreflightRepairResult | null = null
if (!preflight.ok && repairEnabled) {
@@ -352,7 +405,7 @@ export async function POST(request: Request) {
repair = await repairUploadedMcpServerWithLlm({
uploadRoot: root,
projectRoot,
server: installCandidate(),
server: installCandidateFrom(candidate),
preflight,
dependencyLogs: bootstrap.logs,
sandboxId: sandboxId || null,
@@ -366,7 +419,135 @@ export async function POST(request: Request) {
}
}
if (repair.ok) {
preflight = await preflightMcpServer(installCandidate())
preflight = await preflightMcpServer(installCandidateFrom(candidate))
}
} catch (error) {
repair = {
attempted: true,
ok: false,
provider: "openai-compatible",
model: "",
baseUrl: process.env.MCP_PREFLIGHT_LLM_BASE_URL || process.env.OPENAI_BASE_URL || process.env.VLLM_BASE_URL || "",
summary: "LLM-assisted repair could not complete.",
changes: [],
error: error instanceof Error ? error.message : "MCP repair failed",
}
}
}
return NextResponse.json({
ok: true,
stagedUpload: {
id,
name,
summary,
runtime,
entryMode,
entrypoint,
uploadRoot: root,
projectRoot,
},
candidate,
dependencyInstall: {
kind: bootstrap.kind,
logs: bootstrap.logs,
},
preflight,
repair,
})
}
const command = String(form.get("command") || candidate.command).trim()
const commandArgs = parseLines(form.get("commandArgs"))
const suppliedArgs = commandArgs.length > 0 ? commandArgs : candidate.args
const installEnvText = String(form.get("installEnv") || "")
const suppliedEnv = installEnvText ? parseEnv(installEnvText) : candidate.env
const preflightOk = String(form.get("preflightOk") || "true") !== "false"
const server = await installMcpServer({
...candidate,
command: command || candidate.command,
args: suppliedArgs,
env: suppliedEnv,
enabled: preflightOk,
tags: preflightOk ? candidate.tags : [...candidate.tags, "preflight-failed"],
})
return NextResponse.json({
ok: true,
server,
uploadRoot: root,
projectRoot,
dependencyInstall: {
kind: bootstrap.kind,
logs: bootstrap.logs,
},
...(await listMcpServers()),
})
}
await rm(root, { recursive: true, force: true })
await mkdir(root, { recursive: true, mode: 0o700 })
const uploadedDirectory = await writeDirectoryUpload(form, root)
const uploadedArchive = uploadedDirectory ? false : await writeArchiveUpload(form, root)
if (!uploadedDirectory && !uploadedArchive) throw new Error("choose a directory, .zip, .tgz, .tar.gz, or .tar server upload")
if (mode === "stage") {
const entrypointPath = entryMode === "file" ? await resolveEntryPath(root, entrypoint).catch(() => null) : null
const projectRoot = entrypointPath ? await resolveProjectRoot(root, entrypointPath) : await resolveProjectRoot(root, null)
return NextResponse.json({
ok: true,
stagedUpload: {
id,
name,
summary,
runtime,
entryMode,
entrypoint,
uploadRoot: root,
projectRoot,
selectedBundle: uploadedArchive ? "archive" : "directory",
},
})
}
const built = await buildUploadCandidate({
root,
id,
name,
summary,
runtime,
entryMode,
entrypoint,
args: parseLines(form.get("args")),
env: parseEnv(form.get("env")),
})
let candidate = built.candidate
const projectRoot = built.projectRoot
const bootstrap = built.bootstrap
let preflight = await preflightMcpServer(installCandidateFrom(candidate))
let repair: McpPreflightRepairResult | null = null
if (!preflight.ok && repairEnabled) {
try {
repair = await repairUploadedMcpServerWithLlm({
uploadRoot: root,
projectRoot,
server: installCandidateFrom(candidate),
preflight,
dependencyLogs: bootstrap.logs,
sandboxId: sandboxId || null,
})
if (repair.updatedServer) {
candidate = {
...candidate,
command: repair.updatedServer.command,
args: repair.updatedServer.args,
env: repair.updatedServer.env,
}
}
if (repair.ok) {
preflight = await preflightMcpServer(installCandidateFrom(candidate))
}
} catch (error) {
repair = {
+242 -132
View File
@@ -83,6 +83,18 @@ type McpInstallSuggestion = {
notes?: string
}
type StagedMcpUpload = {
id: string
name: string
summary: string
runtime: string
entryMode: "file" | "python-module" | "console-script"
entrypoint: string
uploadRoot: string
projectRoot: string
selectedBundle?: string
}
type McpSandbox = {
id: string
name: string
@@ -94,8 +106,14 @@ type McpConfigurationPanelProps = {
}
const REGISTRY_PAGE_SIZE = 4
const WIZARD_STEPS = ["basics", "launch", "upload", "review"] as const
const WIZARD_STEPS = ["upload", "preflight", "review", "install"] as const
type WizardStep = typeof WIZARD_STEPS[number]
const WIZARD_STEP_LABELS: Record<WizardStep, string> = {
upload: "Upload Server Files",
preflight: "Preflight Check",
review: "Review",
install: "Install",
}
function FieldLabel({ children }: { children: React.ReactNode }) {
return <label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">{children}</label>
@@ -157,6 +175,12 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
const [uploadEntrypoint, setUploadEntrypoint] = useState("server.py")
const [uploadRepair, setUploadRepair] = useState(true)
const [repairSandboxId, setRepairSandboxId] = useState("")
const [stagedUpload, setStagedUpload] = useState<StagedMcpUpload | null>(null)
const [wizardPreflight, setWizardPreflight] = useState<McpPreflightResult | null>(null)
const [wizardRepair, setWizardRepair] = useState<McpPreflightRepairResult | null>(null)
const [wizardCandidate, setWizardCandidate] = useState<McpCatalogEntry | null>(null)
const [wizardDependencyInstall, setWizardDependencyInstall] = useState<{ kind?: string; logs?: string[] } | null>(null)
const [wizardInstallResult, setWizardInstallResult] = useState<McpServerInstall | null>(null)
const [installPrompt, setInstallPrompt] = useState("")
const [installAssistNotes, setInstallAssistNotes] = useState("")
const [editingServerId, setEditingServerId] = useState<string | null>(null)
@@ -178,7 +202,7 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
const [repoOpen, setRepoOpen] = useState(true)
const [catalogOpen, setCatalogOpen] = useState(false)
const [customOpen, setCustomOpen] = useState(false)
const [wizardStep, setWizardStep] = useState<WizardStep>("basics")
const [wizardStep, setWizardStep] = useState<WizardStep>("upload")
const installedIds = useMemo(() => new Set(servers.map((server) => server.id)), [servers])
const enabledCount = servers.filter((server) => server.enabled).length
@@ -322,7 +346,7 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
const data = await response.json() as { suggestion?: McpInstallSuggestion; error?: string }
if (!response.ok || !data.suggestion) throw new Error(data.error || "Failed to draft MCP install")
applyInstallSuggestion(data.suggestion)
setWizardStep("launch")
setWizardStep("upload")
setMessage("Install wizard fields drafted from the running LLM endpoint.")
} catch (error) {
setMessage(error instanceof Error ? error.message : "Failed to draft MCP install")
@@ -501,6 +525,7 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
return withRelativePath.webkitRelativePath || file.name
}))
if (files.length > 0) setUploadArchive(null)
resetWizardPreflightState()
}
function chooseUploadArchive(file: File | null) {
@@ -509,6 +534,16 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
setUploadFiles([])
setUploadPaths([])
}
resetWizardPreflightState()
}
function resetWizardPreflightState() {
setStagedUpload(null)
setWizardPreflight(null)
setWizardRepair(null)
setWizardCandidate(null)
setWizardDependencyInstall(null)
setWizardInstallResult(null)
}
function summarizePreflight(preflight: McpPreflightResult) {
@@ -553,14 +588,7 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
}
}
async function uploadServer() {
try {
if (!uploadArchive && uploadFiles.length === 0) {
setMessage("Choose a server directory or archive before uploading.")
return
}
setSaving(true)
const form = new FormData()
function appendWizardMetadata(form: FormData) {
form.set("id", customName)
form.set("name", customName)
form.set("summary", customSummary)
@@ -571,6 +599,18 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
form.set("env", customEnv)
form.set("repair", uploadRepair ? "true" : "false")
if (repairSandboxId) form.set("sandboxId", repairSandboxId)
}
async function stageUploadServer() {
try {
if (!uploadArchive && uploadFiles.length === 0) {
setMessage("Choose a server directory or archive before uploading.")
return false
}
setSaving(true)
const form = new FormData()
form.set("mode", "stage")
appendWizardMetadata(form)
if (uploadArchive) {
form.set("archive", uploadArchive)
} else {
@@ -580,30 +620,113 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
})
}
const response = await fetch("/api/mcp/upload", { method: "POST", body: form })
const data = await response.json() as McpResponse & { dependencyInstall?: { kind?: string; logs?: string[] }; preflight?: McpPreflightResult; repair?: McpPreflightRepairResult; server?: McpServerInstall }
if (!response.ok) throw new Error(data.error || "Failed to upload MCP server")
const data = await response.json() as { stagedUpload?: StagedMcpUpload; error?: string }
if (!response.ok || !data.stagedUpload) throw new Error(data.error || "Failed to upload MCP server files")
setStagedUpload(data.stagedUpload)
setWizardPreflight(null)
setWizardRepair(null)
setWizardCandidate(null)
setWizardDependencyInstall(null)
setWizardInstallResult(null)
setMessage(`${data.stagedUpload.name} files uploaded. Continue to preflight when ready.`)
return true
} catch (error) {
setMessage(error instanceof Error ? error.message : "Failed to upload MCP server files")
return false
} finally {
setSaving(false)
}
}
async function startWizardPreflightChecks() {
try {
if (!stagedUpload) {
setMessage("Upload server files before starting preflight checks.")
return
}
setSaving(true)
const form = new FormData()
form.set("mode", "preflight")
appendWizardMetadata(form)
const response = await fetch("/api/mcp/upload", { method: "POST", body: form })
const data = await response.json() as {
stagedUpload?: StagedMcpUpload
candidate?: McpCatalogEntry
dependencyInstall?: { kind?: string; logs?: string[] }
preflight?: McpPreflightResult
repair?: McpPreflightRepairResult
error?: string
}
if (!response.ok || !data.preflight || !data.candidate) throw new Error(data.error || "Failed to preflight MCP server")
setStagedUpload(data.stagedUpload || stagedUpload)
setWizardCandidate(data.candidate)
setWizardDependencyInstall(data.dependencyInstall || null)
setWizardPreflight(data.preflight)
setWizardRepair(data.repair || null)
const installKind = data.dependencyInstall?.kind || "generic"
const installLogCount = data.dependencyInstall?.logs?.filter(Boolean).length || 0
setMessage(`Preflight ${data.preflight.ok ? "passed" : "found failures"}. ${installKind === "generic" ? "No dependency bootstrap was needed." : `${installKind} dependencies bootstrapped${installLogCount > 0 ? ` with ${installLogCount} install step${installLogCount === 1 ? "" : "s"}` : ""}.`}${summarizeRepair(data.repair)}\n${summarizePreflight(data.preflight)}`)
} catch (error) {
setMessage(error instanceof Error ? error.message : "Failed to preflight MCP server")
} finally {
setSaving(false)
}
}
async function installStagedUpload() {
try {
if (!stagedUpload || !wizardCandidate) {
setMessage("Run preflight before installing this MCP server.")
return
}
setSaving(true)
const form = new FormData()
form.set("mode", "install-staged")
appendWizardMetadata(form)
form.set("command", wizardCandidate.command)
form.set("commandArgs", wizardCandidate.args.join("\n"))
form.set("installEnv", envToText(wizardCandidate.env))
form.set("preflightOk", wizardPreflight?.ok ? "true" : "false")
const response = await fetch("/api/mcp/upload", { method: "POST", body: form })
const data = await response.json() as McpResponse & { server?: McpServerInstall; error?: string }
if (!response.ok || !data.server) throw new Error(data.error || "Failed to install staged MCP server")
setCatalog(Array.isArray(data.catalog) ? data.catalog : catalog)
setServers(Array.isArray(data.servers) ? data.servers : [])
setConfig(data.config || { mcpServers: {} })
if (data.preflight && data.server?.id) {
setPreflightResults((current) => ({ ...current, [data.server!.id]: data.preflight as McpPreflightResult }))
setWizardInstallResult(data.server)
if (wizardPreflight) {
setPreflightResults((current) => ({ ...current, [data.server!.id]: wizardPreflight }))
}
setUploadFiles([])
setUploadPaths([])
setUploadArchive(null)
const installKind = data.dependencyInstall?.kind || "generic"
const installLogCount = data.dependencyInstall?.logs?.filter(Boolean).length || 0
const preflightNote = data.preflight
? `\nPreflight ${data.preflight.ok ? "passed" : "failed; server saved disabled"}.\n${summarizePreflight(data.preflight)}`
: ""
setMessage(`${customName} uploaded. ${installKind === "generic" ? "No dependency bootstrap was needed." : `${installKind} dependencies bootstrapped${installLogCount > 0 ? ` with ${installLogCount} install step${installLogCount === 1 ? "" : "s"}` : ""}.`}${summarizeRepair(data.repair)}${preflightNote}`)
setMessage(`${data.server.name} installed${data.server.enabled ? "." : " disabled because preflight did not pass."}`)
} catch (error) {
setMessage(error instanceof Error ? error.message : "Failed to upload MCP server")
setMessage(error instanceof Error ? error.message : "Failed to install staged MCP server")
} finally {
setSaving(false)
}
}
async function handleWizardNext() {
if (wizardStep === "upload") {
const staged = stagedUpload ? true : await stageUploadServer()
if (staged) nextWizardStep()
return
}
if (wizardStep === "preflight") {
if (!wizardPreflight) {
setMessage("Start preflight checks before reviewing this MCP server.")
return
}
nextWizardStep()
return
}
if (wizardStep === "review") {
nextWizardStep()
}
}
function startEditingServer(server: McpServerInstall) {
setEditingServerId(server.id)
setEditorText(editableServerJson(server))
@@ -960,72 +1083,34 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
{customOpen && (
<div className="mt-5 border-t border-[var(--border-subtle)] pt-5">
<div className="mb-5 grid grid-cols-2 gap-2 md:grid-cols-4">
{(["basics", "launch", "upload", "review"] as const).map((step) => (
{WIZARD_STEPS.map((step) => (
<button
key={step}
type="button"
onClick={() => setWizardStep(step)}
className={`rounded-sm border px-3 py-2 text-xs font-mono uppercase tracking-wider ${wizardStep === step ? "border-[var(--nvidia-green)] bg-[var(--status-running-bg)] text-[var(--foreground)]" : "border-[var(--border-subtle)] bg-[var(--background)] text-[var(--foreground-dim)]"}`}
>
{step}
{WIZARD_STEP_LABELS[step]}
</button>
))}
</div>
{wizardStep === "basics" && (
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
<div className="space-y-2 md:col-span-2">
<div className="flex items-center gap-2"><FieldLabel>Assist Install</FieldLabel><FieldHint>Describe the MCP server and the running LLM endpoint will draft the install fields.</FieldHint></div>
<textarea value={installPrompt} onChange={(event) => setInstallPrompt(event.target.value)} rows={4} placeholder="Install the GitHub MCP server with npx, or prepare this uploaded Python MCP bundle." className="field-control w-full resize-y px-3 py-2 text-sm" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Name</FieldLabel><FieldHint>Stable display name and default id for this MCP server.</FieldHint></div>
<input value={customName} onChange={(event) => setCustomName(event.target.value)} className="field-control w-full px-3 py-2 text-sm font-mono" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Transport</FieldLabel><FieldHint>Use stdio for local commands, HTTP for remote streamable MCP endpoints.</FieldHint></div>
<select value={customTransport} onChange={(event) => setCustomTransport(event.target.value as McpTransport)} className="field-control w-full px-3 py-2 text-sm font-mono">
<option value="stdio">stdio</option>
<option value="http">http</option>
</select>
</div>
<div className="space-y-2 md:col-span-2">
<div className="flex items-center gap-2"><FieldLabel>Summary</FieldLabel><FieldHint>Short note shown in the installed server list.</FieldHint></div>
<input value={customSummary} onChange={(event) => setCustomSummary(event.target.value)} className="field-control w-full px-3 py-2 text-sm" />
</div>
{installAssistNotes && (
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3 text-xs text-[var(--foreground-dim)] md:col-span-2">
{installAssistNotes}
</div>
)}
</div>
)}
{wizardStep === "launch" && (
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
<div className="space-y-2 md:col-span-2">
<div className="flex items-center gap-2"><FieldLabel>{customTransport === "http" ? "URL" : "Command"}</FieldLabel><FieldHint>{customTransport === "http" ? "Full remote MCP endpoint URL." : "Executable available to the controller, such as npx, uvx, node, or python."}</FieldHint></div>
<input value={customCommand} onChange={(event) => 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" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Args</FieldLabel><FieldHint>One argument per line, passed to the command in order.</FieldHint></div>
<textarea value={customArgs} onChange={(event) => setCustomArgs(event.target.value)} rows={8} className="field-control w-full resize-y px-3 py-2 text-sm font-mono" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>{customTransport === "http" ? "Headers" : "Env"}</FieldLabel><FieldHint>KEY=value lines. HTTP entries become headers; stdio entries become environment variables.</FieldHint></div>
<textarea value={customEnv} onChange={(event) => setCustomEnv(event.target.value)} rows={8} placeholder={customTransport === "http" ? "Authorization=Bearer token" : "API_KEY=value\nBASE_URL=http://localhost:3000"} className="field-control w-full resize-y px-3 py-2 text-sm font-mono" />
</div>
</div>
)}
{wizardStep === "upload" && (
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Server Name</FieldLabel><FieldHint>Stable display name and default id for this uploaded MCP server.</FieldHint></div>
<input value={customName} onChange={(event) => { setCustomName(event.target.value); resetWizardPreflightState() }} className="field-control w-full px-3 py-2 text-sm font-mono" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Summary</FieldLabel><FieldHint>Short note shown in the installed server list.</FieldHint></div>
<input value={customSummary} onChange={(event) => { setCustomSummary(event.target.value); resetWizardPreflightState() }} className="field-control w-full px-3 py-2 text-sm" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Upload Runtime</FieldLabel><FieldHint>Runtime used to bootstrap uploaded bundles before preflight.</FieldHint></div>
<input value={uploadRuntime} onChange={(event) => setUploadRuntime(event.target.value)} placeholder="python3, node, uv, uvx" className="field-control w-full px-3 py-2 text-sm font-mono" />
<input value={uploadRuntime} onChange={(event) => { setUploadRuntime(event.target.value); resetWizardPreflightState() }} placeholder="python3, node, uv, uvx" className="field-control w-full px-3 py-2 text-sm font-mono" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Upload Launch Mode</FieldLabel><FieldHint>How the uploaded server should start after dependencies are installed.</FieldHint></div>
<select value={uploadEntryMode} onChange={(event) => setUploadEntryMode(event.target.value as "file" | "python-module" | "console-script")} className="field-control w-full px-3 py-2 text-sm font-mono">
<select value={uploadEntryMode} onChange={(event) => { setUploadEntryMode(event.target.value as "file" | "python-module" | "console-script"); resetWizardPreflightState() }} className="field-control w-full px-3 py-2 text-sm font-mono">
<option value="file">File</option>
<option value="python-module">Python module</option>
<option value="console-script">Console script</option>
@@ -1033,23 +1118,7 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
</div>
<div className="space-y-2 md:col-span-2">
<div className="flex items-center gap-2"><FieldLabel>Upload Entrypoint</FieldLabel><FieldHint>File path, Python module name, or installed console script to launch.</FieldHint></div>
<input value={uploadEntrypoint} onChange={(event) => setUploadEntrypoint(event.target.value)} placeholder={uploadEntryMode === "python-module" ? "isaac_mcp_poc.server" : uploadEntryMode === "console-script" ? "isaac-mcp-poc" : "server.py, src/server.py, index.js"} className="field-control w-full px-3 py-2 text-sm font-mono" />
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Preflight Repair</FieldLabel><FieldHint>When preflight fails, ask the running LLM endpoint for a bounded repair and run preflight again.</FieldHint></div>
<label className="flex min-h-10 items-center justify-between gap-3 rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs text-[var(--foreground)]">
<span>Use sandbox LLM on failed uploads</span>
<input type="checkbox" checked={uploadRepair} onChange={(event) => setUploadRepair(event.target.checked)} className="h-4 w-4 accent-[var(--nvidia-green)]" />
</label>
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Repair Route</FieldLabel><FieldHint>Optional sandbox whose configured model should be used for repair assistance.</FieldHint></div>
<select value={repairSandboxId} onChange={(event) => setRepairSandboxId(event.target.value)} disabled={!uploadRepair} className="field-control w-full px-3 py-2 text-sm font-mono">
<option value="">Default controller model</option>
{sandboxes.map((sandbox) => (
<option key={sandbox.id} value={sandbox.id}>{sandbox.name}</option>
))}
</select>
<input value={uploadEntrypoint} onChange={(event) => { setUploadEntrypoint(event.target.value); resetWizardPreflightState() }} placeholder={uploadEntryMode === "python-module" ? "isaac_mcp_poc.server" : uploadEntryMode === "console-script" ? "isaac-mcp-poc" : "server.py, src/server.py, index.js"} className="field-control w-full px-3 py-2 text-sm font-mono" />
</div>
<div className="flex flex-wrap items-center gap-3 md:col-span-2">
<label className="action-button cursor-pointer px-4 py-2">
@@ -1066,66 +1135,107 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
</span>
)}
</div>
{stagedUpload && (
<div className="rounded-sm border border-[var(--status-running)] bg-[var(--status-running-bg)] p-3 text-xs text-[var(--status-running)] md:col-span-2">
Uploaded to staged server workspace: {stagedUpload.name}
</div>
)}
</div>
)}
{wizardStep === "preflight" && (
<div className="space-y-4">
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>LLM Repair</FieldLabel><FieldHint>When preflight fails, ask the configured primary inference model for a bounded repair and run preflight again.</FieldHint></div>
<label className="flex min-h-10 items-center justify-between gap-3 rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs text-[var(--foreground)]">
<span>Attempt repairs on failures</span>
<input type="checkbox" checked={uploadRepair} onChange={(event) => setUploadRepair(event.target.checked)} className="h-4 w-4 accent-[var(--nvidia-green)]" />
</label>
</div>
<div className="space-y-2">
<div className="flex items-center gap-2"><FieldLabel>Inference Route</FieldLabel><FieldHint>Optional sandbox whose configured primary inference model should be used for preflight repair assistance.</FieldHint></div>
<select value={repairSandboxId} onChange={(event) => setRepairSandboxId(event.target.value)} disabled={!uploadRepair} className="field-control w-full px-3 py-2 text-sm font-mono">
<option value="">Default configured inference model</option>
{sandboxes.map((sandbox) => (
<option key={sandbox.id} value={sandbox.id}>{sandbox.name}</option>
))}
</select>
</div>
</div>
<button onClick={startWizardPreflightChecks} disabled={saving || !stagedUpload} className="rounded-sm bg-[var(--nvidia-green)] px-4 py-2 text-xs font-mono uppercase tracking-wider text-black disabled:opacity-50">
{saving ? "Running Preflight..." : "Start Preflight checks"}
</button>
{!stagedUpload && (
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 text-xs text-[var(--foreground-dim)]">
Upload server files before starting preflight checks.
</div>
)}
{wizardDependencyInstall && (
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4">
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Dependency Bootstrap</h3>
<p className="mt-2 text-xs text-[var(--foreground-dim)]">{wizardDependencyInstall.kind || "generic"} bootstrap{wizardDependencyInstall.logs?.length ? `, ${wizardDependencyInstall.logs.length} log item${wizardDependencyInstall.logs.length === 1 ? "" : "s"}` : ""}.</p>
</div>
)}
{wizardPreflight && (
<div className={`rounded-sm border p-4 text-xs ${wizardPreflight.ok ? "border-[var(--status-running)] bg-[var(--status-running-bg)] text-[var(--status-running)]" : "border-[var(--status-error)] bg-[var(--status-error-bg)] text-[var(--status-error)]"}`}>
<div className="font-mono uppercase tracking-wider">Preflight {wizardPreflight.ok ? "passed" : "found failures"} / {wizardPreflight.durationMs} ms</div>
<p className="mt-2 whitespace-pre-wrap text-[11px] leading-5">{summarizePreflight(wizardPreflight)}{summarizeRepair(wizardRepair)}</p>
</div>
)}
</div>
)}
{wizardStep === "review" && (
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4">
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Command Install</h3>
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Staged Upload</h3>
<pre className="mt-3 overflow-auto text-[11px] leading-5 text-[var(--foreground-dim)]">{JSON.stringify({
id: customName,
name: customName,
summary: customSummary,
transport: customTransport,
command: customCommand,
args: parseLines(customArgs),
env: parseEnv(customEnv),
selectedBundle: uploadArchive?.name || (uploadFiles.length > 0 ? `${uploadFiles.length} files` : stagedUpload?.selectedBundle || "staged"),
stagedUpload,
dependencyInstall: wizardDependencyInstall,
preflight: wizardPreflight ? {
ok: wizardPreflight.ok,
toolCount: wizardPreflight.toolCount,
tools: wizardPreflight.tools,
error: wizardPreflight.error || null,
} : null,
repair: wizardRepair,
}, null, 2)}</pre>
</div>
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4">
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Upload Install</h3>
<pre className="mt-3 overflow-auto text-[11px] leading-5 text-[var(--foreground-dim)]">{JSON.stringify({
selectedBundle: uploadArchive?.name || (uploadFiles.length > 0 ? `${uploadFiles.length} files` : "none"),
runtime: uploadRuntime,
entryMode: uploadEntryMode,
entrypoint: uploadEntrypoint,
repair: uploadRepair,
repairSandboxId: repairSandboxId || null,
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Broker Launch Definition</h3>
<pre className="mt-3 overflow-auto text-[11px] leading-5 text-[var(--foreground-dim)]">{JSON.stringify(wizardCandidate || {
status: "Run preflight checks to generate the launch definition.",
}, null, 2)}</pre>
</div>
</div>
)}
{wizardStep === "install" && (
<div className="space-y-4">
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-4">
<h3 className="text-xs font-semibold uppercase tracking-wider text-[var(--foreground)]">Ready To Install</h3>
<p className="mt-2 text-xs leading-5 text-[var(--foreground-dim)]">
{wizardCandidate
? `${wizardCandidate.name} will be installed ${wizardPreflight?.ok ? "enabled" : "disabled until preflight passes"}.`
: "Run preflight checks before installing this MCP server."}
</p>
</div>
<button onClick={installStagedUpload} disabled={saving || !wizardCandidate || Boolean(wizardInstallResult)} className="rounded-sm bg-[var(--nvidia-green)] px-4 py-2 text-xs font-mono uppercase tracking-wider text-black disabled:opacity-50">
{wizardInstallResult ? "Installed" : saving ? "Installing..." : "Install Server"}
</button>
{wizardInstallResult && (
<div className="rounded-sm border border-[var(--status-running)] bg-[var(--status-running-bg)] p-4 text-xs text-[var(--status-running)]">
{wizardInstallResult.name} installed successfully.
</div>
)}
</div>
)}
<div className="mt-5 flex flex-wrap items-center gap-3">
<button onClick={previousWizardStep} disabled={saving || wizardStepIndex === 0} className="action-button px-4 py-2">Back</button>
<button onClick={nextWizardStep} disabled={saving || wizardStepIndex === WIZARD_STEPS.length - 1} className="action-button px-4 py-2">Next</button>
<button onClick={assistInstall} disabled={saving || !installPrompt.trim()} className="action-button px-4 py-2">Assist Install</button>
<button
onClick={() => postUpdate({
action: "install",
id: customName,
name: customName,
summary: customSummary,
transport: customTransport,
command: customCommand,
args: parseLines(customArgs),
env: parseEnv(customEnv),
tags: ["custom"],
source: "custom",
}, `${customName} installed.`)}
disabled={saving}
className="rounded-sm bg-[var(--nvidia-green)] px-4 py-2 text-xs font-mono uppercase tracking-wider text-black disabled:opacity-50"
>
Install Server Command
</button>
<button
onClick={uploadServer}
disabled={saving || !hasUploadBundle}
className="action-button px-4 py-2"
>
Upload and Preflight
</button>
<button onClick={handleWizardNext} disabled={saving || wizardStepIndex === WIZARD_STEPS.length - 1 || (wizardStep === "upload" && !hasUploadBundle && !stagedUpload)} className="action-button px-4 py-2">Next</button>
</div>
</div>
)}
+16 -1
View File
@@ -47,6 +47,7 @@ const MAX_CONTEXT_FILE_BYTES = Number.parseInt(process.env.MCP_PREFLIGHT_REPAIR_
const MAX_CONTEXT_FILES = Number.parseInt(process.env.MCP_PREFLIGHT_REPAIR_MAX_FILES || "18", 10)
const MAX_REPAIR_FILE_BYTES = Number.parseInt(process.env.MCP_PREFLIGHT_REPAIR_MAX_OUTPUT_FILE_BYTES || String(512 * 1024), 10)
const REQUEST_TIMEOUT_MS = Number.parseInt(process.env.MCP_PREFLIGHT_REPAIR_TIMEOUT_MS || "60000", 10)
const MCP_SERVER_SPEC_PATH = path.join(process.cwd(), "mcp_server_specs.md")
function relativeInside(root: string, candidate: string) {
const fullPath = path.resolve(root, candidate)
@@ -104,6 +105,14 @@ async function readContextFiles(root: string) {
return context
}
async function readMcpServerSpec() {
return await readFile(MCP_SERVER_SPEC_PATH, "utf8").catch(() => [
"Uploaded MCP servers must initialize through the MCP broker and list tools successfully.",
"Python uploads must use a per-server .venv and local dependency installation.",
"Repairs must stay inside the uploaded server directory.",
].join("\n"))
}
async function resolveRepairRoute(sandboxId?: string | null) {
let explicitModel = ""
if (sandboxId) {
@@ -129,6 +138,7 @@ function extractJsonObject(value: string) {
async function requestRepairPlan(context: RepairContext, files: Awaited<ReturnType<typeof readContextFiles>>) {
const route = await resolveRepairRoute(context.sandboxId)
if (!route.model) throw new Error("No primary inference model is configured")
const mcpServerSpec = await readMcpServerSpec()
const controller = new AbortController()
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS)
try {
@@ -149,7 +159,11 @@ async function requestRepairPlan(context: RepairContext, files: Awaited<ReturnTy
{
role: "system",
content: [
"You repair uploaded Model Context Protocol stdio servers.",
"You are inspecting an MCP server to ensure it is going to function with the MCP broker.",
"Review the files, run a preflight check on them as they stand, and perform any tasks required in the returned repair plan.",
"If Python dependencies are required, use the per-server virtualenv described in mcp_server_specs.md.",
"If there are failures, advise that failures exist and whether they can be resolved.",
"Read mcp_server_specs.md in the user payload to understand the requirements.",
"Return only JSON with optional files and launch keys.",
"Only modify files that are included in the context.",
"Do not invent dependencies unless required by the observed error.",
@@ -166,6 +180,7 @@ async function requestRepairPlan(context: RepairContext, files: Awaited<ReturnTy
},
preflight: context.preflight,
dependencyLogs: context.dependencyLogs || [],
mcp_server_specs_md: mcpServerSpec,
files,
expectedJson: {
summary: "short explanation",
+60
View File
@@ -0,0 +1,60 @@
# Uploaded MCP Server Requirements
This file is read by the LLM-assisted MCP install preflight. Treat it as the contract for making an uploaded server work with the Nemoclaw MCP broker.
## Runtime Contract
- Uploaded MCP servers must expose a valid Model Context Protocol server.
- Stdio servers must start from the configured command and args, speak MCP over stdin/stdout, initialize cleanly, and respond to tool discovery.
- HTTP servers must expose a streamable HTTP MCP endpoint. Do not convert an uploaded stdio server into an HTTP server unless the project already clearly supports it.
- The server must not require an interactive terminal, browser login flow, or long-running manual setup during launch.
- Startup logs must go to stderr, not stdout, so stdout remains available for stdio MCP messages.
- Secrets must be passed through env vars or server-side headers, never embedded in files, args, generated client handoffs, or logs.
## Broker Expectations
- The broker launches local stdio servers on the controller host using the stored command, args, env, and working project files.
- The broker validates a server by initializing it through the official MCP SDK and listing tools.
- A server with zero tools can pass only if that is expected and clearly explained; otherwise treat zero tools as a warning that may indicate a broken entrypoint.
- The broker must not expose launch commands, env vars, headers, or secrets to sandboxes. Sandboxes receive only broker access instructions.
## Python Uploads
- Create and use a per-server virtual environment inside the uploaded project root at `.venv`.
- Install `requirements.txt` with `.venv/bin/pip install -r requirements.txt` when present.
- Install `pyproject.toml` projects with `.venv/bin/pip install -e .` when present.
- Prefer the installed console script or `python -m package.module` when direct file execution causes package-relative import failures.
- Use `.venv/bin/python` for Python file or module launches after dependency bootstrap.
- Do not install Python dependencies globally.
## Node Uploads
- If `package-lock.json` is present, use `npm ci`.
- If only `package.json` is present, use `npm install`.
- Use `node` for JavaScript entry files unless the package provides a documented executable script.
- Do not require global npm installs for uploaded servers.
## Safe Repair Rules
- Only inspect and modify files inside the uploaded MCP server directory.
- Do not delete unrelated files.
- Do not edit generated dependency directories such as `.venv`, `node_modules`, `dist`, `build`, or `__pycache__`.
- Keep changes minimal and explain every changed file.
- If a required dependency, credential, external service, or runtime is missing and cannot be inferred safely, report the failure and describe what the user must provide.
## Preflight Output
A successful preflight should produce:
- The final command and args the broker should launch.
- Any env keys required, without secret values.
- Dependency bootstrap logs or a note that no bootstrap was required.
- MCP initialization and tool discovery result.
- A concise summary of any fixes applied.
A failed preflight should produce:
- The observed failure.
- Likely causes.
- Suggested fixes.
- Whether LLM-assisted repair can reasonably attempt a fix.
+20 -6
View File
@@ -25,6 +25,7 @@ const sandboxMcpRoutePath = path.join(root, 'app/api/sandbox/[sandboxId]/mcp/rou
const brokerUrlPath = path.join(root, 'app/lib/mcpBrokerUrl.ts')
const preflightLibPath = path.join(root, 'app/lib/mcpPreflight.ts')
const preflightRepairLibPath = path.join(root, 'app/lib/mcpPreflightRepair.ts')
const mcpServerSpecsPath = path.join(root, 'mcp_server_specs.md')
const middlewarePath = path.join(root, 'middleware.ts')
const panelPath = path.join(root, 'app/components/McpConfigurationPanel.tsx')
const helpPath = path.join(root, 'app/components/HelpPanel.tsx')
@@ -32,7 +33,7 @@ const sidebarPath = path.join(root, 'app/components/Sidebar.tsx')
const sandboxListPath = path.join(root, 'app/components/SandboxList.tsx')
const pagePath = path.join(root, 'app/page.tsx')
const [storeSource, brokerStoreSource, brokerClientSource, manifestSource, privilegedFilesSource, routeSource, uploadRouteSource, preflightRouteSource, healthRouteSource, registryRouteSource, registriesRouteSource, registriesAssistRouteSource, installAssistRouteSource, registryStoreSource, inferenceModelSource, brokerCapabilitiesRouteSource, brokerCallRouteSource, sandboxMcpRouteSource, brokerUrlSource, preflightLibSource, preflightRepairLibSource, middlewareSource, panelSource, helpSource, sidebarSource, sandboxListSource, pageSource] = await Promise.all([
const [storeSource, brokerStoreSource, brokerClientSource, manifestSource, privilegedFilesSource, routeSource, uploadRouteSource, preflightRouteSource, healthRouteSource, registryRouteSource, registriesRouteSource, registriesAssistRouteSource, installAssistRouteSource, registryStoreSource, inferenceModelSource, brokerCapabilitiesRouteSource, brokerCallRouteSource, sandboxMcpRouteSource, brokerUrlSource, preflightLibSource, preflightRepairLibSource, mcpServerSpecsSource, middlewareSource, panelSource, helpSource, sidebarSource, sandboxListSource, pageSource] = await Promise.all([
readFile(storePath, 'utf8'),
readFile(brokerStorePath, 'utf8'),
readFile(brokerClientPath, 'utf8'),
@@ -54,6 +55,7 @@ const [storeSource, brokerStoreSource, brokerClientSource, manifestSource, privi
readFile(brokerUrlPath, 'utf8'),
readFile(preflightLibPath, 'utf8'),
readFile(preflightRepairLibPath, 'utf8'),
readFile(mcpServerSpecsPath, 'utf8'),
readFile(middlewarePath, 'utf8'),
readFile(panelPath, 'utf8'),
readFile(helpPath, 'utf8'),
@@ -121,6 +123,9 @@ assert.match(uploadRouteSource, /console-script/, 'MCP upload API must support i
assert.match(uploadRouteSource, /resolveProjectRoot/, 'MCP upload API must find project manifests inside uploaded directories')
assert.match(uploadRouteSource, /preflightMcpServer/, 'MCP upload API must preflight uploaded server bundles')
assert.match(uploadRouteSource, /repairUploadedMcpServerWithLlm/, 'MCP upload API must attempt bounded LLM repair when uploaded server preflight fails')
assert.match(uploadRouteSource, /mode"\).*"stage"/s, 'MCP upload API must support a file-staging mode')
assert.match(uploadRouteSource, /mode === "preflight"/, 'MCP upload API must support preflighting staged uploads')
assert.match(uploadRouteSource, /mode === "install-staged"/, 'MCP upload API must support installing staged uploads')
assert.match(uploadRouteSource, /form\.get\("sandboxId"\)/, 'MCP upload API must accept a sandbox id so repair can mirror that sandbox LLM route')
assert.match(uploadRouteSource, /preflight-failed/, 'MCP upload API must mark failed preflight installs')
assert.match(uploadRouteSource, /installMcpServer/, 'MCP upload API must install uploaded server bundles')
@@ -134,6 +139,10 @@ assert.match(preflightRepairLibSource, /chat\/completions/, 'MCP preflight repai
assert.match(preflightRepairLibSource, /response_format: \{ type: "json_object" \}/, 'MCP preflight repair must ask the model for structured JSON')
assert.match(preflightRepairLibSource, /repair path must stay inside the uploaded server/, 'MCP preflight repair must confine edits to the uploaded server')
assert.match(preflightRepairLibSource, /provided context/, 'MCP preflight repair must only edit files shown to the model')
assert.match(preflightRepairLibSource, /mcp_server_specs\.md/, 'MCP preflight repair must read the uploaded-server requirements spec')
assert.match(preflightRepairLibSource, /You are inspecting an MCP server/, 'MCP preflight repair must use the dedicated inspection prompt')
assert.match(mcpServerSpecsSource, /per-server virtual environment/, 'MCP server spec must document isolated Python virtualenvs')
assert.match(mcpServerSpecsSource, /Broker Expectations/, 'MCP server spec must document broker preflight expectations')
assert.match(healthRouteSource, /listBrokerServerTools/, 'MCP health API must inspect server tools through the broker client')
assert.match(healthRouteSource, /enabledServers/, 'MCP health API must check enabled MCP servers')
assert.match(registryRouteSource, /registry\.modelcontextprotocol\.io/, 'MCP registry search should default to the official registry')
@@ -158,9 +167,11 @@ assert.match(inferenceModelSource, /\["inference", "get"\]/, 'MCP LLM assistants
assert.match(inferenceModelSource, /Gateway inference/, 'MCP LLM assistants must prefer gateway inference model resolution')
assert.match(inferenceModelSource, /System inference/, 'MCP LLM assistants may fall back to system inference model resolution')
assert.doesNotMatch(inferenceModelSource, /gpt-4o-mini/, 'MCP LLM assistants must not hardcode a ChatGPT model fallback')
assert.match(panelSource, /Install Server Command/, 'MCP page must expose a server command install action')
assert.match(panelSource, /Server Install Wizard/, 'MCP page must present custom installation as a wizard')
assert.match(panelSource, /Upload and Preflight/, 'MCP custom server accordion must support uploaded server bundles')
assert.match(panelSource, /Upload Server Files/, 'MCP server install wizard must use a clear upload step')
assert.match(panelSource, /Preflight Check/, 'MCP server install wizard must use a clear preflight step')
assert.match(panelSource, /Review/, 'MCP server install wizard must use a clear review step')
assert.match(panelSource, /Install/, 'MCP server install wizard must use a clear install step')
assert.match(panelSource, /Choose Directory/, 'MCP custom server upload must accept directories')
assert.match(panelSource, /Choose Archive/, 'MCP custom server upload must accept archives')
assert.match(panelSource, /\/api\/mcp\/upload/, 'MCP custom server upload must call the upload API')
@@ -174,11 +185,14 @@ assert.match(panelSource, /repairSandboxId/, 'MCP custom server upload must let
assert.match(panelSource, /LLM repair/, 'MCP custom server upload must summarize LLM-assisted repair results')
assert.match(panelSource, /FieldHint/, 'MCP server install wizard fields must include tooltips')
assert.match(panelSource, /wizardStep/, 'MCP server install wizard must expose install workflow steps')
assert.match(panelSource, /assistInstall/, 'MCP server install wizard must let the LLM draft install fields')
assert.match(panelSource, /Assist Install/, 'MCP server install wizard must expose an assist install action')
assert.match(panelSource, /Back/, 'MCP server install wizard must expose back navigation')
assert.match(panelSource, /Next/, 'MCP server install wizard must expose next navigation')
assert.match(panelSource, /Upload and Preflight/, 'MCP server install wizard must expose upload preflight as the upload action')
assert.match(panelSource, /Start Preflight checks/, 'MCP server install wizard must expose a preflight-step action')
assert.match(panelSource, /Install Server/, 'MCP server install wizard must expose an install-step action')
assert.match(panelSource, /stageUploadServer/, 'MCP server install wizard must stage uploads before preflight')
assert.match(panelSource, /startWizardPreflightChecks/, 'MCP server install wizard must run preflight separately from upload')
assert.match(panelSource, /installStagedUpload/, 'MCP server install wizard must install only after review')
assert.doesNotMatch(panelSource, /Upload and Preflight/, 'MCP server install wizard must not collapse upload and preflight into one action')
assert.match(panelSource, /preflightServer/, 'MCP page must let operators preflight installed servers')
assert.match(panelSource, /Preflight/, 'MCP page must show preflight controls and results')
assert.match(panelSource, /serverPayloadFromJson/, 'MCP page must parse edited server JSON')