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): fill resultType on forwarded plugin tool results
Rendegou851d99b86da2
diff --git a/crates/dbx-mcp/src/plugin_tools.rs b/crates/dbx-mcp/src/plugin_tools.rsindex f778f692fc..70e43064e2 100644--- a/crates/dbx-mcp/src/plugin_tools.rs+++ b/crates/dbx-mcp/src/plugin_tools.rs@@ -196,8 +196,14 @@ pub fn connection_selector_from(arguments: &Value) -> Option<&str> {/// into the rmcp wire type, degrading to a plain text payload for plugins/// that return something else.pub fn call_result_to_rmcp(value: Value) -> rmcp::model::CallToolResult {- use rmcp::model::{CallToolResult, ContentBlock};- if let Ok(result) = serde_json::from_value::<CallToolResult>(value.clone()) {+ use rmcp::model::{CallToolResult, ContentBlock, ResultType};+ if let Ok(mut result) = serde_json::from_value::<CallToolResult>(value.clone()) {+ // Deserialization bypasses the constructors, so a plugin answer+ // without `resultType` decodes to `None` and the field disappears on+ // the wire — but 2026-07-28 peers require it. Fill in `complete`+ // while keeping a discriminator the plugin set itself; the server+ // handler strips the field for legacy peers.+ result.result_type.get_or_insert(ResultType::COMPLETE);return result;}let text = if value.is_null() { "(the tool returned no output)".to_string() } else { value.to_string() };@@ -357,4 +363,29 @@ mod tests {assert_eq!(fallback.content.len(), 1);assert_eq!(fallback.is_error, None);}++ #[test]+ fn call_results_always_carry_a_result_type() {+ use rmcp::model::ResultType;+ // A plugin answer without `resultType` (legacy protocol) gets+ // `complete` filled in so 2026-07-28 clients accept the result.+ let filled = call_result_to_rmcp(json!({+ "content": [{ "type": "text", "text": "done" }]+ }));+ assert_eq!(filled.result_type, Some(ResultType::COMPLETE));+ let wire = serde_json::to_value(&filled).unwrap();+ assert_eq!(wire["resultType"], json!("complete"));+ // A discriminator the plugin set itself is preserved. (`input_required`+ // is not legal on CallToolResult: rmcp rejects it at deserialization,+ // so `complete` is the only value that can arrive through this path.)+ let explicit = call_result_to_rmcp(json!({+ "content": [{ "type": "text", "text": "done" }],+ "resultType": "complete"+ }));+ assert_eq!(explicit.result_type, Some(ResultType::COMPLETE));+ assert!(explicit.is_error.is_none(), "explicit complete keeps the plugin's other fields");+ // The constructor-built fallback carries `complete` too.+ let fallback = call_result_to_rmcp(json!({ "unexpected": "shape" }));+ assert_eq!(fallback.result_type, Some(ResultType::COMPLETE));+ }}