25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(mcp): use node entry for Windows configs
t8y2d88e1b1e6a43
diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vueindex 62f2ad1f29..f3ebb35e71 100644--- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue+++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue@@ -67,7 +67,8 @@ import { SHORTCUT_DEFINITIONS, findShortcutConflict, normalizeShortcutSettings,import { normalizeSidebarHiddenTablePrefixes } from "@/lib/sidebarTableNameDisplay";import { normalizeSqlFormatterSettings, type SqlFormatterSettings } from "@/lib/sqlFormatterConfig";import { EMPTY_TABLE_COLUMN_TEMPLATE_DATA_TYPE, parseTableColumnTemplateFields, TABLE_COLUMN_TEMPLATE_DATABASE_TYPES } from "@/lib/tableColumnTemplates";-import { buildMcpCodexConfig, buildMcpJsonConfig, buildMcpOpenCodeConfig, buildMcpVsCodeConfig, type McpEnvEntry } from "@/lib/mcpConfigTemplates";+import { buildMcpCodexConfig, buildMcpJsonConfig, buildMcpOpenCodeConfig, buildMcpVsCodeConfig, type McpEnvEntry, type McpLaunchConfig } from "@/lib/mcpConfigTemplates";+import { isWindows } from "@/lib/platform";import { combineDataTypeForDatabase, dataTypeLengthInputValue, getDataTypeOptions, getDefaultLengthForType, isDataTypeLengthDisabled, splitDataType } from "@/lib/tableStructureEditorState";import type { DatabaseType, SqlSnippet } from "@/types/database";import { uuid } from "@/lib/utils";@@ -1114,13 +1115,21 @@ const mcpEnvEntries = computed<McpEnvEntry[]>(() => {return entries;});-const mcpJsonRecommendedConfig = computed(() => buildMcpJsonConfig(mcpEnvEntries.value));+const mcpLaunchConfig = computed<McpLaunchConfig | undefined>(() => {+ if (!isWindows() || !mcpStatus.value?.script_path) return undefined;+ return {+ command: mcpStatus.value.node_path || "node",+ args: [mcpStatus.value.script_path],+ };+});++const mcpJsonRecommendedConfig = computed(() => buildMcpJsonConfig(mcpEnvEntries.value, mcpLaunchConfig.value));-const mcpVsCodeRecommendedConfig = computed(() => buildMcpVsCodeConfig(mcpEnvEntries.value));+const mcpVsCodeRecommendedConfig = computed(() => buildMcpVsCodeConfig(mcpEnvEntries.value, mcpLaunchConfig.value));-const mcpCodexRecommendedConfig = computed(() => buildMcpCodexConfig(mcpEnvEntries.value));+const mcpCodexRecommendedConfig = computed(() => buildMcpCodexConfig(mcpEnvEntries.value, mcpLaunchConfig.value));-const mcpOpenCodeRecommendedConfig = computed(() => buildMcpOpenCodeConfig(mcpEnvEntries.value));+const mcpOpenCodeRecommendedConfig = computed(() => buildMcpOpenCodeConfig(mcpEnvEntries.value, mcpLaunchConfig.value));const mcpStatusTone = computed<"ok" | "warning" | "muted">(() => {if (!mcpStatus.value) return "muted";diff --git a/apps/desktop/src/lib/__tests__/mcpConfigTemplates.spec.ts b/apps/desktop/src/lib/__tests__/mcpConfigTemplates.spec.tsindex 5f95b04b75..36ad21f1b7 100644--- a/apps/desktop/src/lib/__tests__/mcpConfigTemplates.spec.ts+++ b/apps/desktop/src/lib/__tests__/mcpConfigTemplates.spec.ts@@ -27,6 +27,19 @@ describe("MCP config templates", () => {});});+ it("builds standard JSON configs with a direct node launch command", () => {+ const config = JSON.parse(buildMcpJsonConfig([], { command: "C:\\Program Files\\nodejs\\node.exe", args: ["C:\\Users\\zhiyo\\AppData\\Roaming\\npm\\node_modules\\@dbx-app\\mcp-server\\dist\\index.js"] }));++ expect(config).toEqual({+ mcpServers: {+ dbx: {+ command: "C:\\Program Files\\nodejs\\node.exe",+ args: ["C:\\Users\\zhiyo\\AppData\\Roaming\\npm\\node_modules\\@dbx-app\\mcp-server\\dist\\index.js"],+ },+ },+ });+ });+it("builds VS Code MCP config with the servers root", () => {const config = JSON.parse(buildMcpVsCodeConfig([["DBX_MCP_ALLOW_WRITES", "0"]]));@@ -43,10 +56,31 @@ describe("MCP config templates", () => {});});+ it("builds VS Code config with a direct node launch command", () => {+ const config = JSON.parse(buildMcpVsCodeConfig([["DBX_MCP_ALLOW_WRITES", "0"]], { command: "node", args: ["C:\\dbx\\mcp\\dist\\index.js"] }));++ expect(config).toEqual({+ servers: {+ dbx: {+ type: "stdio",+ command: "node",+ args: ["C:\\dbx\\mcp\\dist\\index.js"],+ env: {+ DBX_MCP_ALLOW_WRITES: "0",+ },+ },+ },+ });+ });+it("builds Codex TOML config with env entries", () => {expect(buildMcpCodexConfig([["DBX_MCP_ALLOW_WRITES", "0"]])).toBe(["[mcp_servers.dbx]", 'command = "dbx-mcp-server"', "", "[mcp_servers.dbx.env]", 'DBX_MCP_ALLOW_WRITES = "0"'].join("\n"));});+ it("builds Codex TOML config with a direct node launch command", () => {+ expect(buildMcpCodexConfig([["DBX_MCP_ALLOW_WRITES", "0"]], { command: "node", args: ["C:\\dbx\\mcp\\dist\\index.js"] })).toBe(["[mcp_servers.dbx]", 'command = "node"', 'args = ["C:\\\\dbx\\\\mcp\\\\dist\\\\index.js"]', "", "[mcp_servers.dbx.env]", 'DBX_MCP_ALLOW_WRITES = "0"'].join("\n"));+ });+it("builds OpenCode config using environment entries", () => {const config = JSON.parse(buildMcpOpenCodeConfig([["DBX_MCP_ALLOW_DANGEROUS_SQL", "1"]]));@@ -62,4 +96,17 @@ describe("MCP config templates", () => {},});});++ it("builds OpenCode config with a direct node launch command", () => {+ const config = JSON.parse(buildMcpOpenCodeConfig([], { command: "node", args: ["C:\\dbx\\mcp\\dist\\index.js"] }));++ expect(config).toEqual({+ mcp: {+ dbx: {+ type: "local",+ command: ["node", "C:\\dbx\\mcp\\dist\\index.js"],+ },+ },+ });+ });});diff --git a/apps/desktop/src/lib/http.ts b/apps/desktop/src/lib/http.tsindex 715aff32c9..4106b9dd7c 100644--- a/apps/desktop/src/lib/http.ts+++ b/apps/desktop/src/lib/http.ts@@ -1849,11 +1849,13 @@ export async function checkMcpServerStatus(): Promise<import("./tauri").McpServereturn {installed: false,npm_available: false,+ node_path: null,node_version: null,current_version: null,latest_version: null,update_available: false,bin_path: null,+ script_path: null,install_command: "npm install -g @dbx-app/mcp-server@latest --registry=https://registry.npmjs.org",update_command: "npm install -g @dbx-app/mcp-server@latest --registry=https://registry.npmjs.org",error: "MCP Server status is only available in the desktop app.",diff --git a/apps/desktop/src/lib/mcpConfigTemplates.ts b/apps/desktop/src/lib/mcpConfigTemplates.tsindex 607a8dad21..595773fdaf 100644--- a/apps/desktop/src/lib/mcpConfigTemplates.ts+++ b/apps/desktop/src/lib/mcpConfigTemplates.ts@@ -1,12 +1,38 @@export type McpEnvEntry = readonly [key: string, value: string];+export interface McpLaunchConfig {+ command: string;+ args?: readonly string[];+}++const DEFAULT_MCP_LAUNCH_CONFIG: McpLaunchConfig = {+ command: "dbx-mcp-server",+};+function envObject(envEntries: readonly McpEnvEntry[]): Record<string, string> {return Object.fromEntries(envEntries);}-export function buildMcpJsonConfig(envEntries: readonly McpEnvEntry[] = []): string {+function launchConfig(config?: McpLaunchConfig): McpLaunchConfig {+ return config ?? DEFAULT_MCP_LAUNCH_CONFIG;+}++function withLaunchConfig(dbx: Record<string, unknown>, config?: McpLaunchConfig): Record<string, unknown> {+ const launch = launchConfig(config);+ dbx.command = launch.command;+ if (launch.args && launch.args.length > 0) {+ dbx.args = [...launch.args];+ }+ return dbx;+}++function tomlStringArray(values: readonly string[]): string {+ return `[${values.map((value) => JSON.stringify(value)).join(", ")}]`;+}++export function buildMcpJsonConfig(envEntries: readonly McpEnvEntry[] = [], config?: McpLaunchConfig): string {const dbx: Record<string, unknown> = {- command: "dbx-mcp-server",+ ...withLaunchConfig({}, config),};if (envEntries.length > 0) {@@ -16,10 +42,10 @@ export function buildMcpJsonConfig(envEntries: readonly McpEnvEntry[] = []): strreturn JSON.stringify({ mcpServers: { dbx } }, null, 2);}-export function buildMcpVsCodeConfig(envEntries: readonly McpEnvEntry[] = []): string {+export function buildMcpVsCodeConfig(envEntries: readonly McpEnvEntry[] = [], config?: McpLaunchConfig): string {const dbx: Record<string, unknown> = {type: "stdio",- command: "dbx-mcp-server",+ ...withLaunchConfig({}, config),};if (envEntries.length > 0) {@@ -29,8 +55,13 @@ export function buildMcpVsCodeConfig(envEntries: readonly McpEnvEntry[] = []): sreturn JSON.stringify({ servers: { dbx } }, null, 2);}-export function buildMcpCodexConfig(envEntries: readonly McpEnvEntry[] = []): string {- const lines = ["[mcp_servers.dbx]", 'command = "dbx-mcp-server"'];+export function buildMcpCodexConfig(envEntries: readonly McpEnvEntry[] = [], config?: McpLaunchConfig): string {+ const launch = launchConfig(config);+ const lines = ["[mcp_servers.dbx]", `command = ${JSON.stringify(launch.command)}`];++ if (launch.args && launch.args.length > 0) {+ lines.push(`args = ${tomlStringArray(launch.args)}`);+ }if (envEntries.length > 0) {lines.push("");@@ -43,10 +74,11 @@ export function buildMcpCodexConfig(envEntries: readonly McpEnvEntry[] = []): streturn lines.join("\n");}-export function buildMcpOpenCodeConfig(envEntries: readonly McpEnvEntry[] = []): string {+export function buildMcpOpenCodeConfig(envEntries: readonly McpEnvEntry[] = [], config?: McpLaunchConfig): string {+ const launch = launchConfig(config);const dbx: Record<string, unknown> = {type: "local",- command: ["dbx-mcp-server"],+ command: [launch.command, ...(launch.args ?? [])],};if (envEntries.length > 0) {diff --git a/apps/desktop/src/lib/tauri.ts b/apps/desktop/src/lib/tauri.tsindex b902498bfa..751e7d134a 100644--- a/apps/desktop/src/lib/tauri.ts+++ b/apps/desktop/src/lib/tauri.ts@@ -1141,11 +1141,13 @@ export interface UpdateDownloadProgress {export interface McpServerStatus {installed: boolean;npm_available: boolean;+ node_path: string | null;node_version: string | null;current_version: string | null;latest_version: string | null;update_available: boolean;bin_path: string | null;+ script_path: string | null;install_command: string;update_command: string;error: string | null;diff --git a/src-tauri/src/commands/mcp.rs b/src-tauri/src/commands/mcp.rsindex aacef7b782..18f3e15df3 100644--- a/src-tauri/src/commands/mcp.rs+++ b/src-tauri/src/commands/mcp.rs@@ -17,11 +17,13 @@ const CREATE_NO_WINDOW: u32 = 0x08000000;pub struct McpServerStatus {pub installed: bool,pub npm_available: bool,+ pub node_path: Option<String>,pub node_version: Option<String>,pub current_version: Option<String>,pub latest_version: Option<String>,pub update_available: bool,pub bin_path: Option<String>,+ pub script_path: Option<String>,pub install_command: String,pub update_command: String,pub error: Option<String>,@@ -36,14 +38,18 @@ struct NpmLatestPackage {pub async fn check_mcp_server_status() -> Result<McpServerStatus, String> {let local_status = tauri::async_runtime::spawn_blocking(|| {let npm_available = command_success("npm", &["--version"]);- let node_version = command_stdout("node", &["--version"]).ok().and_then(first_non_empty_line);+ let node_path = locate_command("node");+ let node_command = node_path.as_deref().unwrap_or("node");+ let node_version = command_stdout(node_command, &["--version"]).ok().and_then(first_non_empty_line);let current_version = if npm_available { installed_mcp_version() } else { None };let bin_path = locate_mcp_bin();- (npm_available, node_version, current_version, bin_path)+ let script_path = if npm_available { installed_mcp_bin_script() } else { None };+ (npm_available, node_path, node_version, current_version, bin_path, script_path)});let latest_version = fetch_latest_mcp_version();let (local_status, latest_version) = tokio::join!(local_status, latest_version);- let (npm_available, node_version, current_version, bin_path) = local_status.map_err(|err| err.to_string())?;+ let (npm_available, node_path, node_version, current_version, bin_path, script_path) =+ local_status.map_err(|err| err.to_string())?;let latest_version = latest_version.ok();let update_available = current_version.as_deref()@@ -52,13 +58,15 @@ pub async fn check_mcp_server_status() -> Result<McpServerStatus, String> {let error = if npm_available { None } else { Some("npm is not available in PATH.".to_string()) };Ok(McpServerStatus {- installed: current_version.is_some() || bin_path.is_some(),+ installed: current_version.is_some() || bin_path.is_some() || script_path.is_some(),npm_available,+ node_path,node_version,current_version,latest_version,update_available,bin_path,+ script_path,install_command: MCP_INSTALL_COMMAND.to_string(),update_command: MCP_INSTALL_COMMAND.to_string(),error,@@ -115,9 +123,21 @@ fn installed_mcp_version() -> Option<String> {}pub(crate) fn resolve_mcp_server_command() -> Option<(String, Vec<String>)> {- locate_mcp_bin()- .map(|path| (path, Vec::new()))- .or_else(|| installed_mcp_bin_script().map(|script| ("node".to_string(), vec![script])))+ #[cfg(windows)]+ {+ // Node.js 18.20.2+ rejects direct spawn of .cmd/.bat files without a shell+ // on Windows. Prefer the package's real JS entry point for Codex CLI.+ return installed_mcp_bin_script()+ .map(|script| (locate_command("node").unwrap_or_else(|| "node".to_string()), vec![script]))+ .or_else(|| locate_mcp_bin().map(|path| (path, Vec::new())));+ }++ #[cfg(not(windows))]+ {+ locate_mcp_bin()+ .map(|path| (path, Vec::new()))+ .or_else(|| installed_mcp_bin_script().map(|script| ("node".to_string(), vec![script])))+ }}pub(crate) fn locate_command(command: &str) -> Option<String> {