Skip to content

Commit d45672e

Browse files
committed
Add capability of disabling toolsa
1 parent 4edca8b commit d45672e

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/spark_history_mcp/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ServerConfig(BaseSettings):
2828
emr_cluster_arn: Optional[str] = None # EMR specific field
2929
use_proxy: bool = False
3030
timeout: int = 30 # HTTP request timeout in seconds
31-
include_plan_description: bool = False
31+
include_plan_description: Optional[bool] = None
3232

3333

3434
class McpConfig(BaseSettings):

src/spark_history_mcp/tools/tools.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,11 @@ def list_slowest_sql_queries(
944944
ctx = mcp.get_context()
945945
client = get_client_or_default(ctx, server, app_id)
946946

947-
# Use server config if include_plan_description not explicitly provided
948-
if include_plan_description is None:
947+
# Config takes priority: if config is set (True/False), use it; otherwise default to True
948+
if client.config.include_plan_description is not None:
949949
include_plan_description = client.config.include_plan_description
950+
else:
951+
include_plan_description = True
950952

951953
all_executions: List[ExecutionData] = []
952954
offset = 0

tests/unit/test_tools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ def test_list_slowest_sql_queries_uses_server_config_for_plan_description(
11271127
def test_list_slowest_sql_queries_explicit_override_server_config(
11281128
self, mock_get_client
11291129
):
1130-
"""Test that explicit include_plan_description parameter overrides server config"""
1130+
"""Test that server config overrides parameter when config is set"""
11311131
# Setup mock client with server config set to False
11321132
mock_client = MagicMock()
11331133
server_config = ServerConfig(
@@ -1150,11 +1150,11 @@ def test_list_slowest_sql_queries_explicit_override_server_config(
11501150
mock_client.get_sql_list.return_value = [sql]
11511151
mock_get_client.return_value = mock_client
11521152

1153-
# Call function with explicit include_plan_description=True (should override server config)
1153+
# Call function with explicit include_plan_description=True (config should override to False)
11541154
result = list_slowest_sql_queries(
11551155
"spark-app-123", include_plan_description=True
11561156
)
11571157

1158-
# Verify plan description is included despite server config being False
1158+
# Verify plan description is NOT included because server config is False
11591159
self.assertEqual(len(result), 1)
1160-
self.assertEqual(result[0].plan_description, "Sample plan description")
1160+
self.assertEqual(result[0].plan_description, "")

0 commit comments

Comments
 (0)