Skip to content

Commit 8894960

Browse files
committed
gateway: stamp last_seen for API-key clients on every request
update_client_last_seen() was only called from the /oauth/token grant handlers, which API-key clients (static mcpk_ bearer, no OAuth dance — e.g. the global Cursor bridge) never hit. Their Connections-page status dot stayed permanently gray ('never seen') no matter how active the connection was. Stamp it from the identity oauth_middleware already resolves on every request instead. Signed-off-by: crimsonsunset <jsangio1@gmail.com>
1 parent a55081e commit 8894960

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

crates/mcpmux-gateway/src/mcp/oauth_middleware.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,29 @@ pub async fn mcp_oauth_middleware(
137137
.get_client(&cid)
138138
.await
139139
{
140-
Ok(Some(_)) => Some(cid),
140+
Ok(Some(_)) => {
141+
// `last_seen` otherwise only gets stamped by the /oauth/token
142+
// grant handlers, which API-key clients (static `mcpk_`
143+
// bearer, no OAuth dance) never hit — leaving their
144+
// Connections-page status dot permanently "never seen"
145+
// regardless of how active they are. Stamp it here instead,
146+
// from the identity every request already resolves.
147+
//
148+
// ponytail: writes unconditionally on every request (no
149+
// throttling) — fine for local single-user SQLite; if this
150+
// ever shows up in profiling, bucket it to e.g. 10s windows
151+
// using the just-fetched `client.last_seen` instead of
152+
// writing every time.
153+
if let Err(e) = services
154+
.dependencies
155+
.inbound_client_repo
156+
.update_client_last_seen(&cid)
157+
.await
158+
{
159+
warn!(trace_id = %trace_id, client_id = %cid, "Failed to update last_seen: {}", e);
160+
}
161+
Some(cid)
162+
}
141163
Ok(None) => {
142164
warn!(trace_id = %trace_id, client_id = %cid, "Client no longer registered (revoked) — rejecting");
143165
None

0 commit comments

Comments
 (0)