feat(mcp): add native installs and resource discovery

This commit is contained in:
t8y2 committed 2026-09-25 12:37:26 +08:00
1 parent 3144762194
commit b8274363b8
36 files changed
+1934 -103

No files matched your search

@@ -1,7 +1,35 @@
import { describe, expect, it } from "vitest";
import { buildMcpCherryStudioConfig, buildMcpCodexConfig, buildMcpDeepSeekHarnessConfig, buildMcpJsonConfig, buildMcpOpenCodeConfig, buildMcpPiConfig, buildMcpQoderConfig, buildMcpTraeConfig, buildMcpVsCodeConfig, buildMcpWorkBuddyConfig, mcpWebBackendUrl } from "@/lib/mcp/mcpConfigTemplates";
import {
buildMcpCherryStudioConfig,
buildMcpCodexConfig,
buildMcpDeepSeekHarnessConfig,
buildMcpJsonConfig,
buildMcpOpenCodeConfig,
buildMcpPiConfig,
buildMcpQoderConfig,
buildMcpTraeConfig,
buildMcpVsCodeConfig,
buildMcpWorkBuddyConfig,
mcpWebBackendUrl,
preferMcpNativeLaunch,
} from "@/lib/mcp/mcpConfigTemplates";
describe("MCP config templates", () => {
it.each(["/Users/DBX User/.dbx/bin/dbx-mcp", "/home/dbx/.dbx/bin/dbx-mcp", "C:\\Users\\DBX User\\.dbx\\bin\\dbx-mcp.exe"])("prefers native launch for every client: %s", (binary) => {
const shim = { command: "node", args: ["/old/shim.js"], env: { DBX_DATA_DIR: "/custom/data" } };
const native = preferMcpNativeLaunch(shim, binary);
expect(native).toEqual({ command: binary, env: shim.env });
for (const builder of [buildMcpJsonConfig, buildMcpTraeConfig, buildMcpQoderConfig, buildMcpVsCodeConfig, buildMcpCherryStudioConfig, buildMcpCodexConfig, buildMcpDeepSeekHarnessConfig, buildMcpOpenCodeConfig, buildMcpPiConfig, buildMcpWorkBuddyConfig]) {
const result = builder(native);
expect(result).toContain(JSON.stringify(binary));
expect(result).toContain("DBX_DATA_DIR");
expect(result).not.toContain("shim.js");
}
expect(preferMcpNativeLaunch(shim)).toBe(shim);
expect(preferMcpNativeLaunch(shim, "")).toBe(shim);
expect(preferMcpNativeLaunch()).toBeUndefined();
});
it("builds the standard mcpServers JSON used by Claude, Cursor, TRAE, and Windsurf", () => {
const config = JSON.parse(buildMcpJsonConfig());
@@ -6,6 +6,20 @@ const tauriBackendSource = readFileSync(new URL("../../../lib/backend/tauri.ts",
const httpBackendSource = readFileSync(new URL("../../../lib/backend/http.ts", import.meta.url), "utf8");
describe("MCP server management", () => {
it("makes native installation the default while preserving npm as a migration fallback", () => {
expect(settingsDialogSource).toContain('mcpStatus.value?.installation_source === "npm"');
expect(settingsDialogSource).toContain('t("settings.mcpSwitchToNativeButton")');
expect(settingsDialogSource).toContain('t("settings.mcpNativeMigrationHint")');
expect(settingsDialogSource).toContain("await installNativeMcpServer()");
expect(settingsDialogSource).toContain("await uninstallNpmMcpServer()");
expect(settingsDialogSource).toContain("mcpStatus?.installation_source !== 'npm' && mcpStatus?.npm_installed");
expect(settingsDialogSource).toContain(':disabled="mcpInstallDisabled"');
expect(settingsDialogSource).not.toContain("!mcpStatus?.npm_available");
expect(tauriBackendSource).toContain('installation_source: "native" | "homebrew" | "npm" | null');
expect(tauriBackendSource).toContain('invoke("install_native_mcp_server")');
expect(tauriBackendSource).toContain('invoke("uninstall_npm_mcp_server")');
});
it("exposes a confirmed uninstall action only for an installed desktop server", () => {
expect(settingsDialogSource).toContain('v-if="!isWeb && mcpStatus?.installed"');
expect(settingsDialogSource).toContain('window.confirm(t("settings.mcpUninstallConfirm"))');