Skip to content

Commit 9e4d45e

Browse files
committed
Fix MCP OAuth credentials cache not invalidating when the server URL changes
1 parent 8077b6e commit 9e4d45e

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix MCP OAuth credentials cache not invalidating when the server URL changes.
6+
57
## 0.112.0
68

79
- Add `plugins` config for loading external configuration from git repos or local paths. #349

src/eca/features/tools/mcp.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@
259259
:on-success (fn [{:keys [code]}]
260260
(let [{:keys [access-token refresh-token expires-at]} (oauth/authorize-token! oauth-info code)]
261261
(swap! db* assoc-in [:mcp-auth server-name] {:type :auth/oauth
262+
:url (:url server-config)
262263
:refresh-token refresh-token
263264
:access-token access-token
264265
:expires-at expires-at}))
@@ -321,6 +322,8 @@
321322
;; Skip OAuth entirely if Authorization header is configured
322323
has-static-auth? (some-> server-config :headers :Authorization some?)
323324
mcp-auth (get-in @db* [:mcp-auth name])
325+
;; Invalidate cached credentials when URL changed
326+
mcp-auth (when (= url (:url mcp-auth)) mcp-auth)
324327
has-token? (some? (:access-token mcp-auth))
325328
token-expired? (token-expired? (:expires-at mcp-auth))
326329
;; Try to refresh if token exists but is expired

0 commit comments

Comments
 (0)