Skip to content

Commit 607b74f

Browse files
committed
Fix nested tool calls
1 parent 588d4ab commit 607b74f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/mcp_server_uyuni/server.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ async def get_list_of_active_systems(ctx: Context) -> List[Dict[str, Any]]:
214214
return await _get_list_of_active_systems(ctx.get_state('token'))
215215

216216
async def _get_list_of_active_systems(token: str) -> List[Dict[str, Union[str, int]]]:
217-
218217
async with httpx.AsyncClient(verify=UYUNI_MCP_SSL_VERIFY) as client:
219218
systems_data_result = await _call_uyuni_api(
220219
client=client,
@@ -452,6 +451,9 @@ async def check_system_updates(system_identifier: Union[str, int], ctx: Context)
452451
log_string = f"Checking pending updates for system {system_identifier}"
453452
logger.info(log_string)
454453
await ctx.info(log_string)
454+
return await _check_system_updates(system_identifier, ctx)
455+
456+
async def _check_system_updates(system_identifier: Union[str, int], ctx: Context) -> Dict[str, Any]:
455457
token = ctx.get_state('token')
456458
system_id = await _resolve_system_id(system_identifier, token)
457459
default_error_response = {
@@ -492,7 +494,7 @@ async def check_system_updates(system_identifier: Union[str, int], ctx: Context)
492494
unscheduled_errata_call
493495
)
494496
relevant_updates_list, unscheduled_updates_list = results
495-
497+
496498
if not isinstance(relevant_updates_list, list) or not isinstance(unscheduled_updates_list, list):
497499
logger.error(
498500
f"API calls for system {system_id} did not return lists as expected. "
@@ -521,7 +523,7 @@ async def check_system_updates(system_identifier: Union[str, int], ctx: Context)
521523
update_details['application_status'] = 'Pending'
522524
else:
523525
update_details['application_status'] = 'Queued'
524-
526+
525527
# Initialize and fetch CVEs
526528
update_details['cves'] = []
527529
if advisory_name:
@@ -575,7 +577,7 @@ async def check_all_systems_for_updates(ctx: Context) -> List[Dict[str, Any]]:
575577
await ctx.info(log_string)
576578

577579
systems_with_updates = []
578-
active_systems = await get_list_of_active_systems(ctx) # Get the list of all systems
580+
active_systems = await _get_list_of_active_systems(ctx.get_state('token')) # Get the list of all systems
579581

580582
if not active_systems:
581583
print("Warning: No active systems found or failed to retrieve system list.")
@@ -593,7 +595,7 @@ async def check_all_systems_for_updates(ctx: Context) -> List[Dict[str, Any]]:
593595

594596
print(f"Checking updates for system: {system_name} (ID: {system_id})")
595597
# Use the existing check_system_updates tool
596-
update_check_result = await check_system_updates(system_id, ctx)
598+
update_check_result = await _check_system_updates(system_id, ctx)
597599

598600
if update_check_result.get('has_pending_updates', False):
599601
# If the system has updates, add its info and update details to the result list
@@ -637,7 +639,7 @@ async def schedule_apply_pending_updates_to_system(system_identifier: Union[str,
637639
token = ctx.get_state('token')
638640

639641
# 1. Use check_system_updates to get relevant errata
640-
update_info = await check_system_updates(system_identifier, ctx)
642+
update_info = await _check_system_updates(system_identifier, ctx)
641643

642644
if not update_info or not update_info.get('has_pending_updates'):
643645
print(f"No pending updates found for system {system_identifier}, or an error occurred while fetching update information.")

0 commit comments

Comments
 (0)