From 2b5134632c5efdf21489e02f6aed9da9aff4152e Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Tue, 13 Jan 2026 16:17:00 +0000 Subject: [PATCH] Fix: Wrap tool results in TextContent format for MCP protocol compliance The MCP protocol requires tool call results to be wrapped in content items with type and text fields. This matches what other MCP servers do. Before: {"result": [{"name": "testdb", ...}]} After: {"result": [{"type": "text", "text": "[{\"name\": \"testdb\", ...}]"}]} This should fix the issue where Claude Code was timing out waiting for responses. --- scripts/mcp/proxysql_mcp_stdio_bridge.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/mcp/proxysql_mcp_stdio_bridge.py b/scripts/mcp/proxysql_mcp_stdio_bridge.py index 21bb9e75c..5ac29a645 100755 --- a/scripts/mcp/proxysql_mcp_stdio_bridge.py +++ b/scripts/mcp/proxysql_mcp_stdio_bridge.py @@ -471,17 +471,22 @@ class StdioMCPServer: debug_log(f"[tools/call] Unwrapped result:") debug_log(f" {json.dumps(actual_result, indent=4)}") log_separator("-") + # Wrap in TextContent for MCP protocol compliance + wrapped_result = [{"type": "text", "text": json.dumps(actual_result, indent=2)}] + debug_log(f"[tools/call] Wrapped in TextContent: {json.dumps(wrapped_result, indent=4)}") return { "jsonrpc": "2.0", - "result": actual_result, + "result": wrapped_result, "id": req_id } - # Fallback: return result as-is - debug_log(f"[tools/call] No wrapping detected, returning result as-is") + # Fallback: return result as-is, wrapped in TextContent + debug_log(f"[tools/call] No wrapping detected, wrapping result in TextContent") + wrapped_result = [{"type": "text", "text": json.dumps(proxysql_result, indent=2)}] + debug_log(f"[tools/call] Wrapped result: {json.dumps(wrapped_result, indent=4)}") return { "jsonrpc": "2.0", - "result": proxysql_result, + "result": wrapped_result, "id": req_id }