Skip to content

The agent that grows with you

fix(mcp-oauth): keep the refresh-fence sidecar when removing token state

kshitijk4poor2e89c5da48de
diff --git a/tools/mcp_oauth.py b/tools/mcp_oauth.py
index c824478e641..6e17a8e821d 100644
--- a/tools/mcp_oauth.py
+++ b/tools/mcp_oauth.py
@@ -566,7 +566,9 @@ class HermesTokenStorage:
def remove(self) -> None:
"""Delete all stored OAuth state for this server."""
- for p in (*self._state_paths(), self._cimd_rejected_path(), _refresh_lock_path(self._tokens_path())):
+ # The ``.refresh.lock`` sidecar is deliberately kept: flock is inode-bound, so unlinking it
+ # while a peer holds the fence would let the next acquirer lock a fresh inode (two holders).
+ for p in (*self._state_paths(), self._cimd_rejected_path()):
p.unlink(missing_ok=True)
def snapshot(self) -> dict[str, bytes]: