Add MCP registry wizard preflight flow

This commit is contained in:
Codex
2026-04-29 15:32:28 +00:00
parent 42561a7eff
commit ce4303a602
8 changed files with 955 additions and 223 deletions
+34
View File
@@ -0,0 +1,34 @@
import { NextResponse } from "next/server"
import { deleteMcpRegistry, listMcpRegistries, saveMcpRegistry } from "@/app/lib/mcpRegistryStore"
export async function GET() {
try {
return NextResponse.json({ registries: await listMcpRegistries() })
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to load MCP registries"
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 : "save"
if (action === "delete") {
const registryId = typeof body?.registryId === "string" ? body.registryId : ""
return NextResponse.json({ deleted: await deleteMcpRegistry(registryId), registries: await listMcpRegistries() })
}
const registry = await saveMcpRegistry({
id: body?.id,
name: body?.name,
baseUrl: body?.baseUrl,
description: body?.description,
})
return NextResponse.json({ registry, registries: await listMcpRegistries() })
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to update MCP registries"
return NextResponse.json({ error: message }, { status: /required|URL|delete/.test(message) ? 400 : 500 })
}
}