Fix MCP server status parsing to match API response

- Map server status values correctly: connected -> running, disabled -> stopped, failed -> error
- Remove array parsing logic as API returns Record<string, status>
- Fixes incorrect MCP server status display in instance welcome view
This commit is contained in:
Shantur Rathore
2025-10-24 18:41:26 +01:00
parent 2c9a29ebc4
commit 24237c25b9

View File

@@ -182,19 +182,23 @@ const InstanceWelcomeView: Component<InstanceWelcomeViewProps> = (props) => {
if (!status || typeof status !== "object") return []
try {
if (Array.isArray(status)) {
return status.map((s) => ({
name: s.name || "Unknown",
status: s.status || "stopped",
}))
}
const obj = status as Record<string, string>
return Object.entries(obj).map(([name, statusValue]) => {
let mappedStatus: "running" | "stopped" | "error"
if (statusValue === "connected") {
mappedStatus = "running"
} else if (statusValue === "disabled") {
mappedStatus = "stopped"
} else if (statusValue === "failed") {
mappedStatus = "error"
} else {
mappedStatus = "stopped"
}
const obj = status as Record<string, unknown>
return Object.entries(obj).map(([name, data]) => {
const serverData = data as { status?: string }
return {
name,
status: (serverData?.status as "running" | "stopped" | "error") || "stopped",
status: mappedStatus,
}
})
} catch {