3535)
3636
3737
38- def __execute_sql_unified (
38+ async def __execute_sql_unified (
3939 ctx : Context ,
4040 target : WorkspaceTarget ,
4141 sql_query : str ,
@@ -69,7 +69,7 @@ def __execute_sql_unified(
6969 )
7070
7171 workspace_type = "shared/virtual" if target .is_shared else "dedicated"
72- ctx .report_progress (
72+ await ctx .info (
7373 f"Executing SQL query on { workspace_type } workspace '{ target .name } ' with database '{ database_name } ': { sql_query } "
7474 "This query may take some time depending on the complexity and size of the data."
7575 )
@@ -556,7 +556,7 @@ def __complete_database_migration(
556556 }
557557
558558
559- def get_user_id (ctx : Context ) -> str :
559+ def get_user_id (ctx : Context ) -> Dict [ str , Any ] :
560560 """
561561 Retrieve the current user's unique identifier.
562562
@@ -583,15 +583,15 @@ def get_user_id(ctx: Context) -> str:
583583 return {
584584 "status" : "success" ,
585585 "message" : "Retrieved user ID successfully" ,
586- "data" : {"user_id " : retrieved_user_id },
586+ "data" : {"result " : retrieved_user_id },
587587 "metadata" : {
588588 "execution_time_ms" : round (execution_time , 2 ),
589589 "timestamp" : datetime .now (timezone .utc ).isoformat (),
590590 },
591591 }
592592
593593
594- def prepare_database_migration (
594+ async def prepare_database_migration (
595595 ctx : Context ,
596596 migration_sql : str ,
597597 workspace_id : str ,
@@ -675,7 +675,7 @@ def prepare_database_migration(
675675 - Isolated: Changes don't impact production performance
676676 - Exact replica: Contains all production data and structure
677677 """
678- ctx .info (
678+ await ctx .info (
679679 "Preparing database migration with the following parameters: "
680680 f"workspace_id={ workspace_id } , database={ database } , description={ description } "
681681 "This operation can take some time depending on the size of the database."
@@ -743,7 +743,7 @@ def complete_database_migration(
743743 )
744744
745745
746- def run_sql (
746+ async def run_sql (
747747 ctx : Context , sql_query : str , id : str , database : Optional [str ] = None
748748) -> Dict [str , Any ]:
749749 """
@@ -767,7 +767,7 @@ def run_sql(
767767 # Validate workspace ID format
768768 validated_id = validate_workspace_id (id )
769769
770- ctx .info (
770+ await ctx .info (
771771 f"Running SQL query on workspace ID '{ validated_id } ' with database '{ database } ': { sql_query } "
772772 )
773773
@@ -786,14 +786,21 @@ def run_sql(
786786
787787 # Execute the SQL query
788788 start_time = time .time ()
789- result = __execute_sql_unified (
789+ result = await __execute_sql_unified (
790790 ctx = ctx ,
791791 target = target ,
792792 sql_query = sql_query ,
793793 username = username ,
794794 password = password ,
795795 database = database_name ,
796796 )
797+
798+ results_data = result .get ("data" , [])
799+
800+ logger .debug (
801+ f"result: { results_data } , type: { type (results_data )} , id: { id } , database_name: { database_name } "
802+ )
803+
797804 execution_time_ms = int ((time .time () - start_time ) * 1000 )
798805
799806 # Track analytics
@@ -809,19 +816,16 @@ def run_sql(
809816
810817 # Build standardized response
811818 workspace_type = "shared" if target .is_shared else "dedicated"
812- row_count = (
813- len (result .get ("results" , [])) if isinstance (result .get ("results" ), list ) else 0
814- )
819+ row_count = len (results_data )
815820
816821 return {
817822 "status" : "success" ,
818823 "message" : f"Query executed successfully. { row_count } rows returned." ,
819824 "data" : {
820- "results " : result . get ( "results" , []) ,
825+ "result " : results_data ,
821826 "row_count" : row_count ,
822827 "workspace_id" : id ,
823828 "workspace_name" : target .name ,
824- "workspace_type" : workspace_type ,
825829 "database" : database_name ,
826830 "status" : result .get ("status" , "Success" ),
827831 },
@@ -1208,7 +1212,7 @@ def __get_notebook_path_by_name(notebook_name: str, location: str = "personal")
12081212 return notebook_path
12091213
12101214
1211- def workspace_groups_info () -> List [ Dict [str , Any ] ]:
1215+ def workspace_groups_info () -> Dict [str , Any ]:
12121216 """
12131217 List all workspace groups accessible to the user in SingleStore.
12141218
@@ -1263,7 +1267,9 @@ def workspace_groups_info() -> List[Dict[str, Any]]:
12631267 return {
12641268 "status" : "success" ,
12651269 "message" : f"Retrieved { len (groups )} workspace groups" ,
1266- "data" : {"workspace_groups" : groups },
1270+ "data" : {
1271+ "result" : groups ,
1272+ },
12671273 "metadata" : {
12681274 "execution_time_ms" : round (execution_time , 2 ),
12691275 "count" : len (groups ),
@@ -1273,7 +1279,7 @@ def workspace_groups_info() -> List[Dict[str, Any]]:
12731279 }
12741280
12751281
1276- def workspaces_info (workspace_group_id : str ) -> List [ Dict [str , Any ] ]:
1282+ def workspaces_info (workspace_group_id : str ) -> Dict [str , Any ]:
12771283 """
12781284 List all workspaces within a specified workspace group in SingleStore.
12791285
@@ -1342,7 +1348,7 @@ def workspaces_info(workspace_group_id: str) -> List[Dict[str, Any]]:
13421348 return {
13431349 "status" : "success" ,
13441350 "message" : f"Retrieved { len (workspaces )} workspaces from group { workspace_group_id } " ,
1345- "data" : {"workspaces " : workspaces },
1351+ "data" : {"result " : workspaces },
13461352 "metadata" : {
13471353 "execution_time_ms" : round (execution_time , 2 ),
13481354 "workspace_group_id" : workspace_group_id ,
@@ -1375,7 +1381,7 @@ def organization_info() -> Dict[str, Any]:
13751381 return {
13761382 "status" : "success" ,
13771383 "message" : f"Retrieved organization information for '{ org_data .get ('name' , 'Unknown' )} '" ,
1378- "data" : {"organization " : org_data },
1384+ "data" : {"result " : org_data },
13791385 "metadata" : {
13801386 "execution_time_ms" : round (execution_time , 2 ),
13811387 "org_id" : org_data .get ("orgID" ),
@@ -1384,7 +1390,7 @@ def organization_info() -> Dict[str, Any]:
13841390 }
13851391
13861392
1387- def list_of_regions () -> List [ Dict [str , Any ] ]:
1393+ def list_of_regions () -> Dict [str , Any ]:
13881394 """
13891395 List all available deployment regions where SingleStore workspaces can be deployed for the user.
13901396
@@ -1415,7 +1421,7 @@ def list_of_regions() -> List[Dict[str, Any]]:
14151421 return {
14161422 "status" : "success" ,
14171423 "message" : f"Retrieved { len (regions_data )} available deployment regions" ,
1418- "data" : {"regions " : regions_data },
1424+ "data" : {"result " : regions_data },
14191425 "metadata" : {
14201426 "execution_time_ms" : round (execution_time , 2 ),
14211427 "count" : len (regions_data ),
@@ -1425,7 +1431,7 @@ def list_of_regions() -> List[Dict[str, Any]]:
14251431 }
14261432
14271433
1428- def list_virtual_workspaces () -> List [ Dict [str , Any ] ]:
1434+ def list_virtual_workspaces () -> Dict [str , Any ]:
14291435 """
14301436 List all starter (virtual) workspaces available to the user in SingleStore.
14311437
@@ -1448,7 +1454,7 @@ def list_virtual_workspaces() -> List[Dict[str, Any]]:
14481454 return {
14491455 "status" : "success" ,
14501456 "message" : f"Retrieved { len (workspaces )} virtual workspaces" ,
1451- "data" : {"workspaces " : workspaces , "count" : len (workspaces )},
1457+ "data" : {"result " : workspaces , "count" : len (workspaces )},
14521458 "metadata" : {
14531459 "total_count" : len (workspaces ),
14541460 "active_count" : sum (1 for w in workspaces if w .get ("state" ) == "ACTIVE" ),
@@ -1492,7 +1498,9 @@ def organization_billing_usage(
14921498 return {
14931499 "status" : "success" ,
14941500 "message" : f"Retrieved billing usage from { start_time } to { end_time } (aggregated by { aggregate_type } )" ,
1495- "data" : usage_data ,
1501+ "data" : {
1502+ "result" : usage_data ,
1503+ },
14961504 "metadata" : {
14971505 "execution_time_ms" : round (execution_time , 2 ),
14981506 "time_range" : {"start" : start_time , "end" : end_time },
@@ -1542,7 +1550,7 @@ def list_notebook_samples() -> List[Dict[str, Any]]:
15421550 return {
15431551 "status" : "success" ,
15441552 "message" : f"Retrieved { len (notebooks_data )} sample notebooks" ,
1545- "data" : {"notebooks " : notebooks_data },
1553+ "data" : {"result " : notebooks_data },
15461554 "metadata" : {
15471555 "execution_time_ms" : round (execution_time , 2 ),
15481556 "count" : len (notebooks_data ),
@@ -1597,7 +1605,9 @@ def list_shared_files() -> Dict[str, Any]:
15971605 return {
15981606 "status" : "success" ,
15991607 "message" : f"Retrieved { len (files_data .get ('content' , []))} files from shared space" ,
1600- "data" : files_data ,
1608+ "data" : {
1609+ "result" : files_data ,
1610+ },
16011611 "metadata" : {
16021612 "execution_time_ms" : round (execution_time , 2 ),
16031613 "file_count" : len (files_data .get ("content" , [])),
@@ -1639,7 +1649,7 @@ def get_job_details(job_id: str) -> Dict[str, Any]:
16391649 return {
16401650 "status" : "success" ,
16411651 "message" : f"Retrieved details for job '{ job_data .get ('name' , job_id )} '" ,
1642- "data" : {"job " : job_data },
1652+ "data" : {"result " : job_data },
16431653 "metadata" : {
16441654 "execution_time_ms" : round (execution_time , 2 ),
16451655 "job_id" : job_id ,
@@ -1692,7 +1702,9 @@ def list_job_executions(job_id: str, start: int = 1, end: int = 10) -> Dict[str,
16921702 return {
16931703 "status" : "success" ,
16941704 "message" : f"Retrieved { len (executions )} executions for job { job_id } (range { start } -{ end } )" ,
1695- "data" : executions_data ,
1705+ "data" : {
1706+ "result" : executions_data ,
1707+ },
16961708 "metadata" : {
16971709 "execution_time_ms" : round (execution_time , 2 ),
16981710 "job_id" : job_id ,
@@ -1725,7 +1737,7 @@ def get_notebook_path(notebook_name: str, location: str = "personal") -> str:
17251737 return {
17261738 "status" : "success" ,
17271739 "message" : f"Found notebook path for '{ notebook_name } ' in { location } space" ,
1728- "data" : {"notebook_path " : notebook_path },
1740+ "data" : {"result " : notebook_path },
17291741 "metadata" : {
17301742 "execution_time_ms" : round (execution_time , 2 ),
17311743 "notebook_name" : notebook_name ,
@@ -1803,7 +1815,7 @@ def get_organizations(ctx: Context) -> dict:
18031815 "status" : "success" ,
18041816 "message" : message ,
18051817 "data" : {
1806- "organizations " : organizations ,
1818+ "result " : organizations ,
18071819 "count" : len (organizations ),
18081820 "instructions" : "Use set_organization tool to select an organization" ,
18091821 },
@@ -1893,7 +1905,7 @@ def set_organization(orgID: str, ctx: Context) -> dict:
18931905 "status" : "success" ,
18941906 "message" : f"Successfully selected organization: { selected_org ['name' ]} (ID: { selected_org ['orgID' ]} )" ,
18951907 "data" : {
1896- "organization " : {
1908+ "result " : {
18971909 "orgID" : selected_org ["orgID" ],
18981910 "name" : selected_org ["name" ],
18991911 },
@@ -1954,7 +1966,7 @@ def set_organization(orgID: str, ctx: Context) -> dict:
19541966 "status" : "success" ,
19551967 "message" : f"Successfully selected organization: { current_org_name } (ID: { current_org_id } )" ,
19561968 "data" : {
1957- "organization " : {
1969+ "result " : {
19581970 "orgID" : current_org_id ,
19591971 "name" : current_org_name ,
19601972 },
@@ -1983,7 +1995,7 @@ def set_organization(orgID: str, ctx: Context) -> dict:
19831995 "message" : f"Successfully set organization ID: { orgID } " ,
19841996 "warning_details" : "Could not validate organization, set directly" ,
19851997 "data" : {
1986- "organization " : {"orgID" : orgID , "name" : "Unknown" },
1998+ "result " : {"orgID" : orgID , "name" : "Unknown" },
19871999 "operation" : "organization_set_unvalidated" ,
19882000 },
19892001 "metadata" : {
@@ -2008,7 +2020,7 @@ def set_organization(orgID: str, ctx: Context) -> dict:
20082020 "message" : f"Successfully set organization ID: { orgID } " ,
20092021 "warning_details" : "All validation methods failed, set organization ID directly" ,
20102022 "data" : {
2011- "organization " : {"orgID" : orgID , "name" : "Unknown" },
2023+ "result " : {"orgID" : orgID , "name" : "Unknown" },
20122024 "operation" : "organization_force_set" ,
20132025 "errors" : {
20142026 "graphql_error" : str (graphql_error ),
@@ -2094,7 +2106,7 @@ def __init__(self, data):
20942106 return WorkspaceTarget (target , is_shared )
20952107
20962108
2097- def create_starter_workspace (
2109+ async def create_starter_workspace (
20982110 ctx : Context , name : str , database_name : str
20992111) -> Dict [str , Any ]:
21002112 """
@@ -2125,7 +2137,9 @@ def create_starter_workspace(
21252137 endpoint = result["endpoint"]
21262138 ```
21272139 """
2128- ctx .info (f"Creating starter workspace '{ name } ' with database '{ database_name } '" )
2140+ await ctx .info (
2141+ f"Creating starter workspace '{ name } ' with database '{ database_name } '"
2142+ )
21292143
21302144 settings = config .get_settings ()
21312145 user_id = config .get_user_id ()
@@ -2154,7 +2168,7 @@ def create_starter_workspace(
21542168 "POST" , "sharedtier/virtualWorkspaces" , data = payload
21552169 )
21562170
2157- ctx .info (
2171+ await ctx .info (
21582172 f"Starter workspace '{ name } ' created successfully with ID: { starter_workspace_data .get ('virtualWorkspaceID' )} "
21592173 )
21602174
@@ -2180,7 +2194,7 @@ def create_starter_workspace(
21802194 }
21812195
21822196
2183- def terminate_virtual_workspace (
2197+ async def terminate_virtual_workspace (
21842198 ctx : Context ,
21852199 workspace_id : str ,
21862200) -> Dict [str , Any ]:
@@ -2225,7 +2239,7 @@ def terminate_virtual_workspace(
22252239 # Validate workspace ID format
22262240 validated_workspace_id = validate_workspace_id (workspace_id )
22272241
2228- ctx .info (f"Terminating virtual workspace with ID: { validated_workspace_id } " )
2242+ await ctx .info (f"Terminating virtual workspace with ID: { validated_workspace_id } " )
22292243
22302244 settings = config .get_settings ()
22312245 user_id = config .get_user_id ()
@@ -2248,7 +2262,7 @@ def terminate_virtual_workspace(
22482262 "GET" , f"sharedtier/virtualWorkspaces/{ validated_workspace_id } "
22492263 )
22502264 workspace_name = starter_workspace_data .get ("name" )
2251- ctx .info (
2265+ await ctx .info (
22522266 f"Found virtual workspace '{ workspace_name } ' (ID: { validated_workspace_id } )"
22532267 )
22542268 except Exception as e :
@@ -2266,7 +2280,7 @@ def terminate_virtual_workspace(
22662280 termination_time = datetime .now ().isoformat ()
22672281
22682282 success_message = f"Virtual workspace '{ workspace_name or validated_workspace_id } ' terminated successfully"
2269- ctx .info (success_message )
2283+ await ctx .info (success_message )
22702284
22712285 return {
22722286 "status" : "success" ,
0 commit comments