@@ -1156,13 +1156,13 @@ async def update_gateway(
1156
1156
new_prompt_names = [prompt .name for prompt in prompts ]
1157
1157
1158
1158
# Update tools using helper method
1159
- tools_to_add = self ._update_or_create_tools (db , tools , gateway , "update" , append_to_gateway = True )
1159
+ tools_to_add = self ._update_or_create_tools (db , tools , gateway , "update" )
1160
1160
1161
1161
# Update resources using helper method
1162
- resources_to_add = self ._update_or_create_resources (db , resources , gateway , "update" , append_to_gateway = True )
1162
+ resources_to_add = self ._update_or_create_resources (db , resources , gateway , "update" )
1163
1163
1164
1164
# Update prompts using helper method
1165
- prompts_to_add = self ._update_or_create_prompts (db , prompts , gateway , "update" , append_to_gateway = True )
1165
+ prompts_to_add = self ._update_or_create_prompts (db , prompts , gateway , "update" )
1166
1166
1167
1167
# Log newly added items
1168
1168
items_added = len (tools_to_add ) + len (resources_to_add ) + len (prompts_to_add )
@@ -1375,9 +1375,9 @@ async def toggle_gateway_status(self, db: Session, gateway_id: str, activate: bo
1375
1375
new_prompt_names = [prompt .name for prompt in prompts ]
1376
1376
1377
1377
# Update tools, resources, and prompts using helper methods
1378
- tools_to_add = self ._update_or_create_tools (db , tools , gateway , "rediscovery" , append_to_gateway = True )
1379
- resources_to_add = self ._update_or_create_resources (db , resources , gateway , "rediscovery" , append_to_gateway = True )
1380
- prompts_to_add = self ._update_or_create_prompts (db , prompts , gateway , "rediscovery" , append_to_gateway = True )
1378
+ tools_to_add = self ._update_or_create_tools (db , tools , gateway , "rediscovery" )
1379
+ resources_to_add = self ._update_or_create_resources (db , resources , gateway , "rediscovery" )
1380
+ prompts_to_add = self ._update_or_create_prompts (db , prompts , gateway , "rediscovery" )
1381
1381
1382
1382
# Log newly added items
1383
1383
items_added = len (tools_to_add ) + len (resources_to_add ) + len (prompts_to_add )
@@ -2519,7 +2519,7 @@ def _create_db_tool(
2519
2519
visibility = "public" , # Federated tools should be public for discovery
2520
2520
)
2521
2521
2522
- def _update_or_create_tools (self , db : Session , tools : List [Any ], gateway : DbGateway , created_via : str , append_to_gateway : bool = False ) -> List [DbTool ]:
2522
+ def _update_or_create_tools (self , db : Session , tools : List [Any ], gateway : DbGateway , created_via : str ) -> List [DbTool ]:
2523
2523
"""Helper to handle update-or-create logic for tools from MCP server.
2524
2524
2525
2525
Args:
@@ -2583,16 +2583,14 @@ def _update_or_create_tools(self, db: Session, tools: List[Any], gateway: DbGate
2583
2583
# Attach relationship to avoid NoneType during flush
2584
2584
db_tool .gateway = gateway
2585
2585
tools_to_add .append (db_tool )
2586
- if append_to_gateway :
2587
- gateway .tools .append (db_tool )
2588
2586
logger .debug (f"Created new tool: { tool .name } " )
2589
2587
except Exception as e :
2590
2588
logger .warning (f"Failed to process tool { getattr (tool , 'name' , 'unknown' )} : { e } " )
2591
2589
continue
2592
2590
2593
2591
return tools_to_add
2594
2592
2595
- def _update_or_create_resources (self , db : Session , resources : List [Any ], gateway : DbGateway , created_via : str , append_to_gateway : bool = False ) -> List [DbResource ]:
2593
+ def _update_or_create_resources (self , db : Session , resources : List [Any ], gateway : DbGateway , created_via : str ) -> List [DbResource ]:
2596
2594
"""Helper to handle update-or-create logic for resources from MCP server.
2597
2595
2598
2596
Args:
@@ -2649,16 +2647,14 @@ def _update_or_create_resources(self, db: Session, resources: List[Any], gateway
2649
2647
visibility = gateway .visibility ,
2650
2648
)
2651
2649
resources_to_add .append (db_resource )
2652
- if append_to_gateway :
2653
- gateway .resources .append (db_resource )
2654
2650
logger .debug (f"Created new resource: { resource .uri } " )
2655
2651
except Exception as e :
2656
2652
logger .warning (f"Failed to process resource { getattr (resource , 'uri' , 'unknown' )} : { e } " )
2657
2653
continue
2658
2654
2659
2655
return resources_to_add
2660
2656
2661
- def _update_or_create_prompts (self , db : Session , prompts : List [Any ], gateway : DbGateway , created_via : str , append_to_gateway : bool = False ) -> List [DbPrompt ]:
2657
+ def _update_or_create_prompts (self , db : Session , prompts : List [Any ], gateway : DbGateway , created_via : str ) -> List [DbPrompt ]:
2662
2658
"""Helper to handle update-or-create logic for prompts from MCP server.
2663
2659
2664
2660
Args:
@@ -2710,8 +2706,6 @@ def _update_or_create_prompts(self, db: Session, prompts: List[Any], gateway: Db
2710
2706
visibility = gateway .visibility ,
2711
2707
)
2712
2708
prompts_to_add .append (db_prompt )
2713
- if append_to_gateway :
2714
- gateway .prompts .append (db_prompt )
2715
2709
logger .debug (f"Created new prompt: { prompt .name } " )
2716
2710
except Exception as e :
2717
2711
logger .warning (f"Failed to process prompt { getattr (prompt , 'name' , 'unknown' )} : { e } " )
0 commit comments