File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -202,15 +202,17 @@ async def cleanup_expired_mappings(self) -> int:
202202 if self ._refresh_token_mapping .pop (code , None ):
203203 cleaned_count += 1
204204
205- # Also check for orphaned mappings (mappings without corresponding auth codes)
205+ # Also check for orphaned mappings
206+ # Token mappings: valid keys are either active auth codes (temporary) or active MCP tokens
206207 orphaned_token_keys = []
207208 for mapping_key in self ._token_mapping :
208- if mapping_key . startswith ( "mcp_" ) and mapping_key not in self ._auth_codes :
209+ if mapping_key not in self . _auth_codes and mapping_key not in self ._tokens :
209210 orphaned_token_keys .append (mapping_key )
210211
212+ # Refresh token mappings are only keyed by authorization codes; anything not in _auth_codes is orphaned
211213 orphaned_refresh_keys = []
212214 for mapping_key in self ._refresh_token_mapping :
213- if mapping_key . startswith ( "mcp_" ) and mapping_key not in self ._auth_codes :
215+ if mapping_key not in self ._auth_codes :
214216 orphaned_refresh_keys .append (mapping_key )
215217
216218 # Clean up orphaned mappings
You can’t perform that action at this time.
0 commit comments