mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 06:17:23 +00:00
Stop a removed MCP connection from saving its server as a custom tool
After removing a Linear connection, connecting again could skip signing in and save Linear as an unconnected custom tool: a client cached before the removal still held the old tokens, and a late token write re-created a connection for them. A token write for a named connection no longer creates one, removing or disconnecting a connection drops its cached clients, and a sign-in server is never saved without its connection.
This commit is contained in:
1 parent
159ac03904
commit
56ababae71
5 files changed
+124
-6
No files matched your search
@@ -37,6 +37,20 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
_mcp_clients_cache = {}
|
||||
|
||||
|
||||
def forget_cached_clients(*identities: str) -> None:
|
||||
"""Drop cached OAuth clients signed in as any of ``identities``.
|
||||
|
||||
OAuth cache keys name the connection or user whose tokens the client
|
||||
holds (see ``MCPTool._generate_cache_key``).
|
||||
|
||||
Args:
|
||||
identities: Connection ids and user ids.
|
||||
"""
|
||||
markers = tuple(f"#oauth:{identity}:" for identity in identities if identity)
|
||||
for key in [k for k in list(_mcp_clients_cache) if any(marker in k for marker in markers)]:
|
||||
_mcp_clients_cache.pop(key, None)
|
||||
|
||||
# A token expiry long past: a stored token of unknown age is renewed before use.
|
||||
_EXPIRED = 1.0
|
||||
|
||||
|
||||
Reference in new issue
Block a user