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:
@@ -182,19 +182,23 @@ const InstanceWelcomeView: Component<InstanceWelcomeViewProps> = (props) => {
|
|||||||
if (!status || typeof status !== "object") return []
|
if (!status || typeof status !== "object") return []
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Array.isArray(status)) {
|
const obj = status as Record<string, string>
|
||||||
return status.map((s) => ({
|
return Object.entries(obj).map(([name, statusValue]) => {
|
||||||
name: s.name || "Unknown",
|
let mappedStatus: "running" | "stopped" | "error"
|
||||||
status: s.status || "stopped",
|
|
||||||
}))
|
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 {
|
return {
|
||||||
name,
|
name,
|
||||||
status: (serverData?.status as "running" | "stopped" | "error") || "stopped",
|
status: mappedStatus,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user