File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,9 +88,15 @@ async def get_tools(
8888 # OpenAPI Tool Servers
8989 server_access_grants = {}
9090 for server in await get_tool_servers (request ):
91- connection = request .app .state .config .TOOL_SERVER_CONNECTIONS [
92- server .get ("idx" , 0 )
93- ]
91+ server_idx = server .get ("idx" , 0 )
92+ connections = request .app .state .config .TOOL_SERVER_CONNECTIONS
93+ if server_idx >= len (connections ):
94+ log .warning (
95+ f"Tool server index { server_idx } out of range "
96+ f"(have { len (connections )} connections), skipping server { server .get ('id' )} "
97+ )
98+ continue
99+ connection = connections [server_idx ]
94100 server_config = connection .get ("config" , {})
95101
96102 server_id = f"server:{ server .get ('id' )} "
Original file line number Diff line number Diff line change @@ -275,11 +275,14 @@ async def get_tools(
275275 continue
276276
277277 tool_server_idx = tool_server_data .get ("idx" , 0 )
278- tool_server_connection = (
279- request .app .state .config .TOOL_SERVER_CONNECTIONS [
280- tool_server_idx
281- ]
282- )
278+ connections = request .app .state .config .TOOL_SERVER_CONNECTIONS
279+ if tool_server_idx >= len (connections ):
280+ log .warning (
281+ f"Tool server index { tool_server_idx } out of range "
282+ f"(have { len (connections )} connections), skipping server { server_id } "
283+ )
284+ continue
285+ tool_server_connection = connections [tool_server_idx ]
283286
284287 # Check access control for tool server
285288 if not has_connection_access (
You can’t perform that action at this time.
0 commit comments