Narrow the scope of toolgroup exception catching

Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
Ben Browning 2025-07-10 11:34:33 -04:00 committed by Sébastien Han
parent 0c40eabf07
commit 9d06a8b147
No known key found for this signature in database

View file

@ -53,20 +53,20 @@ class ToolGroupsRoutingTable(CommonRoutingTableImpl, ToolGroups):
all_tools = [] all_tools = []
for toolgroup in toolgroups: for toolgroup in toolgroups:
try: if toolgroup.identifier not in self.toolgroups_to_tools:
if toolgroup.identifier not in self.toolgroups_to_tools: try:
await self._index_tools(toolgroup) await self._index_tools(toolgroup)
all_tools.extend(self.toolgroups_to_tools[toolgroup.identifier]) except AuthenticationRequiredError:
except AuthenticationRequiredError: # Send authentication errors back to the client so it knows
# Send authentication errors back to the client so it knows # that it needs to supply credentials for remote MCP servers.
# that it needs to supply credentials for remote MCP servers. raise
raise except Exception as e:
except Exception as e: # Other errors that the client cannot fix are logged and
# Other errors that the client cannot fix are logged and # those specific toolgroups are skipped.
# those specific toolgroups are skipped. logger.warning(f"Error listing tools for toolgroup {toolgroup.identifier}: {e}")
logger.warning(f"Error listing tools for toolgroup {toolgroup.identifier}: {e}") logger.debug(e, exc_info=True)
logger.debug(e, exc_info=True) continue
continue all_tools.extend(self.toolgroups_to_tools[toolgroup.identifier])
return ListToolsResponse(data=all_tools) return ListToolsResponse(data=all_tools)