Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix(mcp): install rustls crypto provider for TLS connections

zipg10bce698ae8f
diff --git a/crates/dbx-mcp/Cargo.toml b/crates/dbx-mcp/Cargo.toml
index 152af9dfbe..0d86c5d22b 100644
--- a/crates/dbx-mcp/Cargo.toml
+++ b/crates/dbx-mcp/Cargo.toml
@@ -19,6 +19,7 @@ dbx-core = { path = "../dbx-core", default-features = false, features = ["sqlite
dirs = "6"
rmcp = { version = "2.2.0", features = ["client", "transport-io"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "socks"] }
+rustls = { version = "0.23", features = ["aws-lc-rs"] }
schemars = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
@@ -27,7 +28,6 @@ uuid = { version = "1", features = ["v4"] }
url = "2"
[dev-dependencies]
-rustls = { version = "0.23", features = ["aws-lc-rs"] }
rustls-pemfile = "2.2"
tempfile = "3"
tokio = { version = "1", features = ["net", "io-util"] }
diff --git a/crates/dbx-mcp/src/server.rs b/crates/dbx-mcp/src/server.rs
index 1b07498ca3..12af497d3b 100644
--- a/crates/dbx-mcp/src/server.rs
+++ b/crates/dbx-mcp/src/server.rs
@@ -247,6 +247,10 @@ impl DbxMcpServer {
}
pub fn with_runtime_options(backend: Arc<dyn DbxBackend>, scope: McpScope, web_mode: bool) -> Self {
+ // The workspace enables more than one rustls crypto feature through
+ // transitive dependencies. Native MCP runs outside the desktop/web
+ // startup paths, so select the same provider before any TLS tool call.
+ let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
let mut tool_router = Self::tool_router();
if scope.enabled() {
tool_router.disable_route("dbx_add_connection");
diff --git a/crates/dbx-mcp/tests/live_mysql_tls.rs b/crates/dbx-mcp/tests/live_mysql_tls.rs
new file mode 100644
index 0000000000..1c21edee6e
--- /dev/null
+++ b/crates/dbx-mcp/tests/live_mysql_tls.rs
@@ -0,0 +1,39 @@
+use std::{path::Path, sync::Arc};
+
+use dbx_mcp::{DbxMcpServer, LocalBackend, McpScope};
+use rmcp::{model::CallToolRequestParams, ServiceExt};
+use serde_json::{json, Map};
+
+#[tokio::test]
+#[ignore = "requires DBX_LIVE_MCP_DATA_DIR with a MySQL connection using ssl-mode=preferred"]
+async fn mysql_preferred_tls_with_self_signed_certificate_keeps_mcp_alive() {
+ let data_dir = std::env::var("DBX_LIVE_MCP_DATA_DIR").expect("set DBX_LIVE_MCP_DATA_DIR");
+ let connection_name = std::env::var("DBX_LIVE_MCP_CONNECTION").expect("set DBX_LIVE_MCP_CONNECTION");
+ let database = std::env::var("DBX_LIVE_MCP_DATABASE").expect("set DBX_LIVE_MCP_DATABASE");
+ let backend =
+ Arc::new(LocalBackend::open(&Path::new(&data_dir).join("dbx.db")).await.expect("open copied DBX storage"));
+ let server = DbxMcpServer::with_runtime_options(backend, McpScope::default(), false);
+ let (server_transport, client_transport) = tokio::io::duplex(16 * 1024);
+ let server_task = tokio::spawn(async move { server.serve(server_transport).await });
+ let client = ().serve(client_transport).await.expect("initialize MCP client");
+ let arguments = json!({
+ "connection_name": connection_name,
+ "database": database,
+ "sql": "SELECT 1 AS tls_probe",
+ })
+ .as_object()
+ .cloned()
+ .unwrap_or_else(Map::new);
+
+ let result = client
+ .peer()
+ .call_tool(CallToolRequestParams::new("dbx_execute_query").with_arguments(arguments))
+ .await
+ .expect("MCP server must stay alive while executing the TLS query");
+ let text = result.content[0].as_text().expect("text query result").text.clone();
+ assert_ne!(result.is_error, Some(true), "preferred TLS query failed: {text}");
+ assert!(text.contains("tls_probe") && text.contains('1'), "unexpected query result: {text}");
+
+ client.cancel().await.expect("close MCP client");
+ server_task.abort();
+}