Skip to content

Commit 1e6c619

Browse files
gabe-l-hartkevalmahajan
authored andcommitted
fix: Invalidate resource cache when gateway with resources is deleted
Branch: ClientCLI Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
1 parent 59fb824 commit 1e6c619

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mcpgateway/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,7 +3628,17 @@ async def delete_gateway(gateway_id: str, db: Session = Depends(get_db), user=De
36283628
logger.debug(f"User '{user}' requested deletion of gateway {gateway_id}")
36293629
try:
36303630
user_email = user.get("email") if isinstance(user, dict) else str(user)
3631+
current = await gateway_service.get_gateway(db, gateway_id)
3632+
has_resources = bool(current.capabilities.get("resources"))
36313633
await gateway_service.delete_gateway(db, gateway_id, user_email=user_email)
3634+
3635+
# If the gateway had resources and was successfully deleted, invalidate
3636+
# the whole resource cache. This is needed since the cache holds both
3637+
# individual resources and the full listing which will also need to be
3638+
# invalidated.
3639+
if has_resources:
3640+
await invalidate_resource_cache()
3641+
36323642
return {"status": "success", "message": f"Gateway {gateway_id} deleted"}
36333643
except PermissionError as e:
36343644
raise HTTPException(status_code=403, detail=str(e))

0 commit comments

Comments
 (0)