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): publish Gemini-compatible optional array schema
t8y2c7a1b6df0f7d
diff --git a/crates/dbx-mcp/src/server.rs b/crates/dbx-mcp/src/server.rsindex d44398560e..827b36b16a 100644--- a/crates/dbx-mcp/src/server.rs+++ b/crates/dbx-mcp/src/server.rs@@ -142,6 +142,7 @@ pub struct SchemaContextRequest {pub database: Option<String>,pub schema: Option<String>,#[schemars(description = "Specific table names to include")]+ #[schemars(extend("type" = "array"))]pub tables: Option<Vec<String>>,#[schemars(description = "Maximum number of tables to include, from 1 to 20")]pub max_tables: Option<usize>,@@ -1477,6 +1478,44 @@ mod tests {assert!(names.contains(&"dbx_close_session"));}+ #[test]+ fn schema_context_tables_schema_is_gemini_compatible() {+ let server = DbxMcpServer::with_runtime_options(Arc::new(FakeBackend::default()), McpScope::default(), false);+ let tool = server+ .tool_router+ .list_all()+ .into_iter()+ .find(|tool| tool.name == "dbx_get_schema_context")+ .expect("schema context tool should be registered");+ let tables = tool+ .input_schema+ .get("properties")+ .and_then(serde_json::Value::as_object)+ .and_then(|properties| properties.get("tables"))+ .expect("tables property should be published");++ assert_eq!(tables.get("type"), Some(&serde_json::json!("array")));+ assert_eq!(tables.pointer("/items/type"), Some(&serde_json::json!("string")));+ assert!(!tool+ .input_schema+ .get("required")+ .and_then(serde_json::Value::as_array)+ .is_some_and(|required| required.iter().any(|field| field == "tables")));+ }++ #[test]+ fn schema_context_tables_preserve_optional_inputs() {+ let omitted: SchemaContextRequest = serde_json::from_str("{}").unwrap();+ let explicit_null: SchemaContextRequest = serde_json::from_str(r#"{"tables":null}"#).unwrap();+ let empty: SchemaContextRequest = serde_json::from_str(r#"{"tables":[]}"#).unwrap();+ let populated: SchemaContextRequest = serde_json::from_str(r#"{"tables":["users","orders"]}"#).unwrap();++ assert_eq!(omitted.tables, None);+ assert_eq!(explicit_null.tables, None);+ assert_eq!(empty.tables, Some(Vec::new()));+ assert_eq!(populated.tables, Some(vec!["users".to_string(), "orders".to_string()]));+ }+#[test]fn scoped_server_hides_mutating_and_desktop_tools() {let server = DbxMcpServer::with_runtime_options(