From 222742a737792319e95cf5d8892e24855bae6f97 Mon Sep 17 00:00:00 2001 From: Perseus Computing <51974392+tcconnally@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:53:22 -0500 Subject: [PATCH] fix: StatefulProxyClient.clear() no longer causes KeyError on session teardown (#4328) --- fastmcp_slim/fastmcp/server/providers/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastmcp_slim/fastmcp/server/providers/proxy.py b/fastmcp_slim/fastmcp/server/providers/proxy.py index 8dab75564..f5f160194 100644 --- a/fastmcp_slim/fastmcp/server/providers/proxy.py +++ b/fastmcp_slim/fastmcp/server/providers/proxy.py @@ -1230,7 +1230,7 @@ class StatefulProxyClient(ProxyClient[ClientTransportT]): self._caches[session] = proxy_client async def _on_session_exit(): - self._caches.pop(session) + self._caches.pop(session, None) logger.debug(f"{proxy_client} will be disconnect") # This callback runs while the server session's exit stack is # unwinding, which usually happens because the owning task is