Complete MCP install wizard
This commit is contained in:
@@ -0,0 +1,99 @@
|
|||||||
|
import { NextResponse } from "next/server"
|
||||||
|
|
||||||
|
const REQUEST_TIMEOUT_MS = Number.parseInt(process.env.MCP_INSTALL_ASSIST_TIMEOUT_MS || "45000", 10)
|
||||||
|
const MODEL = process.env.MCP_PREFLIGHT_LLM_MODEL || process.env.OPENAI_MODEL || "gpt-4o-mini"
|
||||||
|
const BASE_URL = (process.env.MCP_PREFLIGHT_LLM_BASE_URL || process.env.OPENAI_BASE_URL || process.env.VLLM_BASE_URL || "http://localhost:8000/v1").replace(/\/+$/, "")
|
||||||
|
|
||||||
|
function extractJsonObject(value: string) {
|
||||||
|
const trimmed = value.trim()
|
||||||
|
if (trimmed.startsWith("{")) return trimmed
|
||||||
|
const match = trimmed.match(/\{[\s\S]*\}/)
|
||||||
|
if (!match) throw new Error("install assistant did not return JSON")
|
||||||
|
return match[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
function stringArray(value: unknown) {
|
||||||
|
return Array.isArray(value)
|
||||||
|
? value.map((item) => String(item ?? "").trim()).filter(Boolean)
|
||||||
|
: []
|
||||||
|
}
|
||||||
|
|
||||||
|
function stringMap(value: unknown) {
|
||||||
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {}
|
||||||
|
return Object.fromEntries(
|
||||||
|
Object.entries(value)
|
||||||
|
.map(([key, item]) => [key.trim(), String(item ?? "").trim()])
|
||||||
|
.filter(([key]) => Boolean(key)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(request: Request) {
|
||||||
|
const controller = new AbortController()
|
||||||
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS)
|
||||||
|
try {
|
||||||
|
const body = await request.json().catch(() => ({}))
|
||||||
|
const prompt = typeof body?.prompt === "string" ? body.prompt.trim() : ""
|
||||||
|
if (!prompt) throw new Error("install prompt is required")
|
||||||
|
|
||||||
|
const response = await fetch(`${BASE_URL}/chat/completions`, {
|
||||||
|
method: "POST",
|
||||||
|
signal: controller.signal,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...(process.env.MCP_PREFLIGHT_LLM_API_KEY || process.env.OPENAI_API_KEY
|
||||||
|
? { Authorization: `Bearer ${process.env.MCP_PREFLIGHT_LLM_API_KEY || process.env.OPENAI_API_KEY}` }
|
||||||
|
: {}),
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
model: MODEL,
|
||||||
|
temperature: 0.1,
|
||||||
|
response_format: { type: "json_object" },
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
role: "system",
|
||||||
|
content: [
|
||||||
|
"You draft install metadata for Model Context Protocol servers.",
|
||||||
|
"Return only JSON with name, summary, transport, command, args, env, uploadRuntime, uploadEntryMode, uploadEntrypoint, and notes.",
|
||||||
|
"Use transport stdio for local commands and http for streamable HTTP endpoints.",
|
||||||
|
"Args must be an array of strings; env must be an object.",
|
||||||
|
"If the user describes an uploaded bundle, set upload fields but still provide the most likely runtime and entrypoint.",
|
||||||
|
].join(" "),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: JSON.stringify({
|
||||||
|
prompt,
|
||||||
|
current: body?.current || {},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
const data = await response.json().catch(() => null)
|
||||||
|
if (!response.ok) throw new Error(data?.error?.message || data?.error || `install assistant failed (${response.status})`)
|
||||||
|
const content = data?.choices?.[0]?.message?.content
|
||||||
|
if (typeof content !== "string" || !content.trim()) throw new Error("install assistant returned an empty response")
|
||||||
|
const suggestion = JSON.parse(extractJsonObject(content))
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
suggestion: {
|
||||||
|
name: typeof suggestion?.name === "string" ? suggestion.name : "",
|
||||||
|
summary: typeof suggestion?.summary === "string" ? suggestion.summary : "",
|
||||||
|
transport: suggestion?.transport === "http" ? "http" : "stdio",
|
||||||
|
command: typeof suggestion?.command === "string" ? suggestion.command : "",
|
||||||
|
args: stringArray(suggestion?.args),
|
||||||
|
env: stringMap(suggestion?.env),
|
||||||
|
uploadRuntime: typeof suggestion?.uploadRuntime === "string" ? suggestion.uploadRuntime : "",
|
||||||
|
uploadEntryMode: ["file", "python-module", "console-script"].includes(suggestion?.uploadEntryMode) ? suggestion.uploadEntryMode : "",
|
||||||
|
uploadEntrypoint: typeof suggestion?.uploadEntrypoint === "string" ? suggestion.uploadEntrypoint : "",
|
||||||
|
notes: typeof suggestion?.notes === "string" ? suggestion.notes : "",
|
||||||
|
},
|
||||||
|
model: MODEL,
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : "Failed to assist MCP install"
|
||||||
|
return NextResponse.json({ error: message }, { status: /required/.test(message) ? 400 : 502 })
|
||||||
|
} finally {
|
||||||
|
clearTimeout(timeout)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -70,6 +70,19 @@ type McpPreflightRepairResult = {
|
|||||||
error?: string
|
error?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type McpInstallSuggestion = {
|
||||||
|
name?: string
|
||||||
|
summary?: string
|
||||||
|
transport?: McpTransport
|
||||||
|
command?: string
|
||||||
|
args?: string[]
|
||||||
|
env?: Record<string, string>
|
||||||
|
uploadRuntime?: string
|
||||||
|
uploadEntryMode?: "file" | "python-module" | "console-script" | ""
|
||||||
|
uploadEntrypoint?: string
|
||||||
|
notes?: string
|
||||||
|
}
|
||||||
|
|
||||||
type McpSandbox = {
|
type McpSandbox = {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
@@ -81,6 +94,8 @@ type McpConfigurationPanelProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const REGISTRY_PAGE_SIZE = 4
|
const REGISTRY_PAGE_SIZE = 4
|
||||||
|
const WIZARD_STEPS = ["basics", "launch", "upload", "review"] as const
|
||||||
|
type WizardStep = typeof WIZARD_STEPS[number]
|
||||||
|
|
||||||
function FieldLabel({ children }: { children: React.ReactNode }) {
|
function FieldLabel({ children }: { children: React.ReactNode }) {
|
||||||
return <label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">{children}</label>
|
return <label className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">{children}</label>
|
||||||
@@ -115,6 +130,12 @@ function parseEnv(value: string) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function envToText(value: Record<string, string>) {
|
||||||
|
return Object.entries(value)
|
||||||
|
.map(([key, item]) => `${key}=${item}`)
|
||||||
|
.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurationPanelProps) {
|
export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurationPanelProps) {
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [saving, setSaving] = useState(false)
|
const [saving, setSaving] = useState(false)
|
||||||
@@ -136,6 +157,8 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
|
|||||||
const [uploadEntrypoint, setUploadEntrypoint] = useState("server.py")
|
const [uploadEntrypoint, setUploadEntrypoint] = useState("server.py")
|
||||||
const [uploadRepair, setUploadRepair] = useState(true)
|
const [uploadRepair, setUploadRepair] = useState(true)
|
||||||
const [repairSandboxId, setRepairSandboxId] = useState("")
|
const [repairSandboxId, setRepairSandboxId] = useState("")
|
||||||
|
const [installPrompt, setInstallPrompt] = useState("")
|
||||||
|
const [installAssistNotes, setInstallAssistNotes] = useState("")
|
||||||
const [editingServerId, setEditingServerId] = useState<string | null>(null)
|
const [editingServerId, setEditingServerId] = useState<string | null>(null)
|
||||||
const [editorText, setEditorText] = useState("")
|
const [editorText, setEditorText] = useState("")
|
||||||
const [registrySearch, setRegistrySearch] = useState("github")
|
const [registrySearch, setRegistrySearch] = useState("github")
|
||||||
@@ -155,7 +178,7 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
|
|||||||
const [repoOpen, setRepoOpen] = useState(true)
|
const [repoOpen, setRepoOpen] = useState(true)
|
||||||
const [catalogOpen, setCatalogOpen] = useState(false)
|
const [catalogOpen, setCatalogOpen] = useState(false)
|
||||||
const [customOpen, setCustomOpen] = useState(false)
|
const [customOpen, setCustomOpen] = useState(false)
|
||||||
const [wizardStep, setWizardStep] = useState<"basics" | "launch" | "upload" | "review">("basics")
|
const [wizardStep, setWizardStep] = useState<WizardStep>("basics")
|
||||||
|
|
||||||
const installedIds = useMemo(() => new Set(servers.map((server) => server.id)), [servers])
|
const installedIds = useMemo(() => new Set(servers.map((server) => server.id)), [servers])
|
||||||
const enabledCount = servers.filter((server) => server.enabled).length
|
const enabledCount = servers.filter((server) => server.enabled).length
|
||||||
@@ -166,6 +189,8 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
|
|||||||
(registryPage - 1) * REGISTRY_PAGE_SIZE,
|
(registryPage - 1) * REGISTRY_PAGE_SIZE,
|
||||||
registryPage * REGISTRY_PAGE_SIZE,
|
registryPage * REGISTRY_PAGE_SIZE,
|
||||||
)
|
)
|
||||||
|
const wizardStepIndex = WIZARD_STEPS.indexOf(wizardStep)
|
||||||
|
const hasUploadBundle = Boolean(uploadArchive || uploadFiles.length > 0)
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
try {
|
try {
|
||||||
@@ -260,6 +285,60 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyInstallSuggestion(suggestion: McpInstallSuggestion) {
|
||||||
|
if (suggestion.name) setCustomName(suggestion.name)
|
||||||
|
if (suggestion.summary) setCustomSummary(suggestion.summary)
|
||||||
|
if (suggestion.transport) setCustomTransport(suggestion.transport)
|
||||||
|
if (suggestion.command) setCustomCommand(suggestion.command)
|
||||||
|
if (Array.isArray(suggestion.args)) setCustomArgs(suggestion.args.join("\n"))
|
||||||
|
if (suggestion.env) setCustomEnv(envToText(suggestion.env))
|
||||||
|
if (suggestion.uploadRuntime) setUploadRuntime(suggestion.uploadRuntime)
|
||||||
|
if (suggestion.uploadEntryMode) setUploadEntryMode(suggestion.uploadEntryMode)
|
||||||
|
if (suggestion.uploadEntrypoint) setUploadEntrypoint(suggestion.uploadEntrypoint)
|
||||||
|
if (suggestion.notes) setInstallAssistNotes(suggestion.notes)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function assistInstall() {
|
||||||
|
try {
|
||||||
|
setSaving(true)
|
||||||
|
const response = await fetch("/api/mcp/install-assist", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
prompt: installPrompt,
|
||||||
|
current: {
|
||||||
|
name: customName,
|
||||||
|
summary: customSummary,
|
||||||
|
transport: customTransport,
|
||||||
|
command: customCommand,
|
||||||
|
args: parseLines(customArgs),
|
||||||
|
env: parseEnv(customEnv),
|
||||||
|
uploadRuntime,
|
||||||
|
uploadEntryMode,
|
||||||
|
uploadEntrypoint,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
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")
|
||||||
|
setMessage("Install wizard fields drafted from the running LLM endpoint.")
|
||||||
|
} catch (error) {
|
||||||
|
setMessage(error instanceof Error ? error.message : "Failed to draft MCP install")
|
||||||
|
} finally {
|
||||||
|
setSaving(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextWizardStep() {
|
||||||
|
setWizardStep(WIZARD_STEPS[Math.min(WIZARD_STEPS.length - 1, wizardStepIndex + 1)])
|
||||||
|
}
|
||||||
|
|
||||||
|
function previousWizardStep() {
|
||||||
|
setWizardStep(WIZARD_STEPS[Math.max(0, wizardStepIndex - 1)])
|
||||||
|
}
|
||||||
|
|
||||||
async function postUpdate(body: Record<string, unknown>, success: string) {
|
async function postUpdate(body: Record<string, unknown>, success: string) {
|
||||||
try {
|
try {
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
@@ -892,78 +971,136 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
|
|||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
{wizardStep === "basics" && (
|
||||||
<div className="space-y-2">
|
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
<div className="flex items-center gap-2"><FieldLabel>Name</FieldLabel><FieldHint>Stable display name and default id for this MCP server.</FieldHint></div>
|
<div className="space-y-2 md:col-span-2">
|
||||||
<input value={customName} onChange={(event) => setCustomName(event.target.value)} className="field-control w-full px-3 py-2 text-sm font-mono" />
|
<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>
|
</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">
|
{wizardStep === "launch" && (
|
||||||
<option value="stdio">stdio</option>
|
<div className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
<option value="http">http</option>
|
<div className="space-y-2 md:col-span-2">
|
||||||
</select>
|
<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>
|
</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" />
|
{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>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" />
|
||||||
|
</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">
|
||||||
|
<option value="file">File</option>
|
||||||
|
<option value="python-module">Python module</option>
|
||||||
|
<option value="console-script">Console script</option>
|
||||||
|
</select>
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap items-center gap-3 md:col-span-2">
|
||||||
|
<label className="action-button cursor-pointer px-4 py-2">
|
||||||
|
Choose Directory
|
||||||
|
<input type="file" multiple onChange={(event) => chooseUploadDirectory(event.target.files)} className="sr-only" {...({ webkitdirectory: "", directory: "" } as Record<string, string>)} />
|
||||||
|
</label>
|
||||||
|
<label className="action-button cursor-pointer px-4 py-2">
|
||||||
|
Choose Archive
|
||||||
|
<input type="file" accept=".zip,.tgz,.tar.gz,.tar,application/zip,application/gzip,application/x-tar" onChange={(event) => chooseUploadArchive(event.target.files?.[0] || null)} className="sr-only" />
|
||||||
|
</label>
|
||||||
|
{(uploadArchive || uploadFiles.length > 0) && (
|
||||||
|
<span className="text-xs font-mono text-[var(--foreground-dim)]">
|
||||||
|
{uploadArchive ? uploadArchive.name : `${uploadFiles.length} file${uploadFiles.length === 1 ? "" : "s"}`}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<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" />
|
{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>
|
||||||
|
<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),
|
||||||
|
}, 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,
|
||||||
|
}, null, 2)}</pre>
|
||||||
|
</div>
|
||||||
</div>
|
</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={6} 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={6} 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 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" />
|
|
||||||
</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">
|
|
||||||
<option value="file">File</option>
|
|
||||||
<option value="python-module">Python module</option>
|
|
||||||
<option value="console-script">Console script</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-5 flex flex-wrap items-center gap-3">
|
<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
|
<button
|
||||||
onClick={() => postUpdate({
|
onClick={() => postUpdate({
|
||||||
action: "install",
|
action: "install",
|
||||||
@@ -982,37 +1119,13 @@ export default function McpConfigurationPanel({ sandboxes = [] }: McpConfigurati
|
|||||||
>
|
>
|
||||||
Install Server Command
|
Install Server Command
|
||||||
</button>
|
</button>
|
||||||
<label className="action-button cursor-pointer px-4 py-2">
|
|
||||||
Choose Directory
|
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
multiple
|
|
||||||
onChange={(event) => chooseUploadDirectory(event.target.files)}
|
|
||||||
className="sr-only"
|
|
||||||
{...({ webkitdirectory: "", directory: "" } as Record<string, string>)}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<label className="action-button cursor-pointer px-4 py-2">
|
|
||||||
Choose Archive
|
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
accept=".zip,.tgz,.tar.gz,.tar,application/zip,application/gzip,application/x-tar"
|
|
||||||
onChange={(event) => chooseUploadArchive(event.target.files?.[0] || null)}
|
|
||||||
className="sr-only"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<button
|
<button
|
||||||
onClick={uploadServer}
|
onClick={uploadServer}
|
||||||
disabled={saving || (!uploadArchive && uploadFiles.length === 0)}
|
disabled={saving || !hasUploadBundle}
|
||||||
className="action-button px-4 py-2"
|
className="action-button px-4 py-2"
|
||||||
>
|
>
|
||||||
Upload Server
|
Upload and Preflight
|
||||||
</button>
|
</button>
|
||||||
{(uploadArchive || uploadFiles.length > 0) && (
|
|
||||||
<span className="text-xs font-mono text-[var(--foreground-dim)]">
|
|
||||||
{uploadArchive ? uploadArchive.name : `${uploadFiles.length} file${uploadFiles.length === 1 ? "" : "s"}`}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const healthRoutePath = path.join(root, 'app/api/mcp/health/route.ts')
|
|||||||
const registryRoutePath = path.join(root, 'app/api/mcp/registry/route.ts')
|
const registryRoutePath = path.join(root, 'app/api/mcp/registry/route.ts')
|
||||||
const registriesRoutePath = path.join(root, 'app/api/mcp/registries/route.ts')
|
const registriesRoutePath = path.join(root, 'app/api/mcp/registries/route.ts')
|
||||||
const registriesAssistRoutePath = path.join(root, 'app/api/mcp/registries/assist/route.ts')
|
const registriesAssistRoutePath = path.join(root, 'app/api/mcp/registries/assist/route.ts')
|
||||||
|
const installAssistRoutePath = path.join(root, 'app/api/mcp/install-assist/route.ts')
|
||||||
const registryStorePath = path.join(root, 'app/lib/mcpRegistryStore.ts')
|
const registryStorePath = path.join(root, 'app/lib/mcpRegistryStore.ts')
|
||||||
const brokerCapabilitiesRoutePath = path.join(root, 'app/api/mcp/broker/capabilities/route.ts')
|
const brokerCapabilitiesRoutePath = path.join(root, 'app/api/mcp/broker/capabilities/route.ts')
|
||||||
const brokerCallRoutePath = path.join(root, 'app/api/mcp/broker/call/route.ts')
|
const brokerCallRoutePath = path.join(root, 'app/api/mcp/broker/call/route.ts')
|
||||||
@@ -30,7 +31,7 @@ const sidebarPath = path.join(root, 'app/components/Sidebar.tsx')
|
|||||||
const sandboxListPath = path.join(root, 'app/components/SandboxList.tsx')
|
const sandboxListPath = path.join(root, 'app/components/SandboxList.tsx')
|
||||||
const pagePath = path.join(root, 'app/page.tsx')
|
const pagePath = path.join(root, 'app/page.tsx')
|
||||||
|
|
||||||
const [storeSource, brokerStoreSource, brokerClientSource, manifestSource, privilegedFilesSource, routeSource, uploadRouteSource, preflightRouteSource, healthRouteSource, registryRouteSource, registriesRouteSource, registriesAssistRouteSource, registryStoreSource, 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, brokerCapabilitiesRouteSource, brokerCallRouteSource, sandboxMcpRouteSource, brokerUrlSource, preflightLibSource, preflightRepairLibSource, middlewareSource, panelSource, helpSource, sidebarSource, sandboxListSource, pageSource] = await Promise.all([
|
||||||
readFile(storePath, 'utf8'),
|
readFile(storePath, 'utf8'),
|
||||||
readFile(brokerStorePath, 'utf8'),
|
readFile(brokerStorePath, 'utf8'),
|
||||||
readFile(brokerClientPath, 'utf8'),
|
readFile(brokerClientPath, 'utf8'),
|
||||||
@@ -43,6 +44,7 @@ const [storeSource, brokerStoreSource, brokerClientSource, manifestSource, privi
|
|||||||
readFile(registryRoutePath, 'utf8'),
|
readFile(registryRoutePath, 'utf8'),
|
||||||
readFile(registriesRoutePath, 'utf8'),
|
readFile(registriesRoutePath, 'utf8'),
|
||||||
readFile(registriesAssistRoutePath, 'utf8'),
|
readFile(registriesAssistRoutePath, 'utf8'),
|
||||||
|
readFile(installAssistRoutePath, 'utf8'),
|
||||||
readFile(registryStorePath, 'utf8'),
|
readFile(registryStorePath, 'utf8'),
|
||||||
readFile(brokerCapabilitiesRoutePath, 'utf8'),
|
readFile(brokerCapabilitiesRoutePath, 'utf8'),
|
||||||
readFile(brokerCallRoutePath, 'utf8'),
|
readFile(brokerCallRoutePath, 'utf8'),
|
||||||
@@ -145,9 +147,12 @@ assert.match(registriesRouteSource, /saveMcpRegistry/, 'MCP registries API must
|
|||||||
assert.match(registriesRouteSource, /deleteMcpRegistry/, 'MCP registries API must delete registries')
|
assert.match(registriesRouteSource, /deleteMcpRegistry/, 'MCP registries API must delete registries')
|
||||||
assert.match(registriesAssistRouteSource, /chat\/completions/, 'MCP registry assistant must use the running OpenAI-compatible LLM endpoint')
|
assert.match(registriesAssistRouteSource, /chat\/completions/, 'MCP registry assistant must use the running OpenAI-compatible LLM endpoint')
|
||||||
assert.match(registriesAssistRouteSource, /response_format: \{ type: "json_object" \}/, 'MCP registry assistant must request structured JSON')
|
assert.match(registriesAssistRouteSource, /response_format: \{ type: "json_object" \}/, 'MCP registry assistant must request structured JSON')
|
||||||
|
assert.match(installAssistRouteSource, /chat\/completions/, 'MCP install wizard assistant must use the running OpenAI-compatible LLM endpoint')
|
||||||
|
assert.match(installAssistRouteSource, /uploadRuntime/, 'MCP install wizard assistant must draft upload metadata')
|
||||||
|
assert.match(installAssistRouteSource, /response_format: \{ type: "json_object" \}/, 'MCP install wizard assistant must request structured JSON')
|
||||||
assert.match(panelSource, /Install Server Command/, 'MCP page must expose a server command install action')
|
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, /Server Install Wizard/, 'MCP page must present custom installation as a wizard')
|
||||||
assert.match(panelSource, /Upload Server/, 'MCP custom server accordion must support uploaded server bundles')
|
assert.match(panelSource, /Upload and Preflight/, 'MCP custom server accordion must support uploaded server bundles')
|
||||||
assert.match(panelSource, /Choose Directory/, 'MCP custom server upload must accept directories')
|
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, /Choose Archive/, 'MCP custom server upload must accept archives')
|
||||||
assert.match(panelSource, /\/api\/mcp\/upload/, 'MCP custom server upload must call the upload API')
|
assert.match(panelSource, /\/api\/mcp\/upload/, 'MCP custom server upload must call the upload API')
|
||||||
@@ -161,6 +166,11 @@ 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, /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, /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, /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, /preflightServer/, 'MCP page must let operators preflight installed servers')
|
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, /Preflight/, 'MCP page must show preflight controls and results')
|
||||||
assert.match(panelSource, /serverPayloadFromJson/, 'MCP page must parse edited server JSON')
|
assert.match(panelSource, /serverPayloadFromJson/, 'MCP page must parse edited server JSON')
|
||||||
|
|||||||
Reference in New Issue
Block a user