Merge pull request #2087 from modelcontextprotocol/v2/fix/1914-surface-post-add-refresh-failure

fix(web): surface a failed post-write server-list reload
This commit is contained in:
Cliff Hall 2026-08-23 20:48:01 -04:00 • committed by GitHub
commit 8b9839cc93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 683 additions and 59 deletions

View file

@ -6,6 +6,7 @@ import {
} from "./useImportClientConfig";
import type { ImportSourceResult } from "@inspector/core/mcp/import/index.js";
import type { MCPConfig } from "@inspector/core/mcp/types.js";
import { ServerListReloadError } from "@inspector/core/react/useServers.js";
function config(...ids: string[]): MCPConfig {
const mcpServers: MCPConfig["mcpServers"] = {};
@ -207,6 +208,31 @@ describe("useImportClientConfig", () => {
expect(outcome.detail).toBe("add failed");
});
it("reports a reload failure as imported-with-a-warning, not failed (#1914)", async () => {
// A `ServerListReloadError` rejects *after* the write landed, so the entry
// really was added. A red "Failed" badge would contradict the error's own
// message and invite a retry that then collides with the row it claims
// wasn't created. The reason still shows, as `detail`.
const onAddServer = vi.fn(async () => {
throw new ServerListReloadError(
"The server was added, but the server list could not be reloaded: disk full",
);
});
const { result } = setup({
onFetchSource: vi.fn(async () => foundSource(config("alpha"))),
onAddServer,
});
await act(async () => {
await result.current.pickSource("claude");
});
await act(async () => {
await result.current.runImport();
});
const outcome = result.current.outcomes[0];
expect(outcome.status).toBe("added");
expect(outcome.detail).toMatch(/could not be reloaded: disk full/);
});
it("resolves conflicts by overwrite, skip, and rename", async () => {
const onAddServer = vi.fn(async () => {});
const onUpdateServer = vi.fn(async () => {});

View file

@ -8,6 +8,7 @@ import {
type ImportSourceResult,
} from "@inspector/core/mcp/import/index.js";
import { validateStoreId } from "@inspector/core/storage/store-id.js";
import { ServerListReloadError } from "@inspector/core/react/useServers.js";
import type { MCPConfig, MCPServerConfig } from "@inspector/core/mcp/types.js";
export type ImportPhase = "select" | "loading" | "review" | "summary";
@ -198,11 +199,17 @@ export function useImportClientConfig({
await write();
return { id, status: outcome };
} catch (err) {
return {
id,
status: "failed",
detail: err instanceof Error ? err.message : String(err),
};
const detail = err instanceof Error ? err.message : String(err);
// A `ServerListReloadError` means the write landed and only reading the
// list back failed, so this entry really was imported. Reporting it as
// `failed` would contradict the error's own message and invite a retry
// that then collides with the row it says wasn't created (#1914 r3).
// The status is the truth about the write; `detail` renders in red
// beneath it either way, so the reload failure is still visible.
if (err instanceof ServerListReloadError) {
return { id, status: outcome, detail };
}
return { id, status: "failed", detail };
}
}