supermemory/apps/mcp/src/server
MaheshtheDev 6cae175852 fix(mcp): return 503 on auth-backend outages instead of invalid_token (#1591)
Cherry-picks #1587 from @Sravanjangam, plus the OAuth half on top.

When the auth backend is slow or returns a 5xx, the MCP server currently answers `invalid_token`. That is the protocol's signal to discard the credential and re-authenticate, so a brief upstream blip logs every connected client out, and `sm_` API key users have no automatic way back. These requests now return 503 with `Retry-After: 5` so clients retry instead.

His change covered the API key path only. This shares one `transientAuthErrorFor` helper between `validateApiKey` and `validateOAuthToken`, so a JWKS timeout or a 5xx also returns 503 on the OAuth path that Claude, Cursor and browser clients use.

Genuinely bad tokens are unaffected: bad signature, expired, and no-matching-key still resolve to 401. Verified across all seven cases.

Co-Authored-By: Sravanjangam <163002695+Sravanjangam@users.noreply.github.com>
2026-08-24 15:53:06 +00:00
..
auth fix(mcp): return 503 on auth-backend outages instead of invalid_token (#1591) 2026-08-24 15:53:06 +00:00
client fix(mcp): strip API extras from listMemories entries (#1539) 2026-08-19 14:05:52 -07:00
prompts MCP Revamp (#1120) (#1380) 2026-07-30 17:08:51 -07:00
resources fix mcp graph and file uploads (#1397) 2026-08-04 18:58:14 +00:00
tools fix(mcp): strip API extras from listMemories entries (#1539) 2026-08-19 14:05:52 -07:00
analytics.test.ts MCP Revamp (#1120) (#1380) 2026-07-30 17:08:51 -07:00
analytics.ts fix mcp graph and file uploads (#1397) 2026-08-04 18:58:14 +00:00
app-metadata.ts fix mcp app contracts (#1394) 2026-08-01 06:41:17 +00:00
container-tag.ts fix MCP app result contracts (#1385) 2026-07-31 18:23:29 +00:00
format.ts fix mcp app contracts (#1394) 2026-08-01 06:41:17 +00:00
html.d.ts MCP Revamp (#1120) (#1380) 2026-07-30 17:08:51 -07:00
index.ts fix(mcp): return 503 on auth-backend outages instead of invalid_token (#1591) 2026-08-24 15:53:06 +00:00
legacy-protocol-state.ts MCP Revamp (#1120) (#1380) 2026-07-30 17:08:51 -07:00
server.ts fix mcp graph and file uploads (#1397) 2026-08-04 18:58:14 +00:00
space-presentation.ts fix MCP app result contracts (#1385) 2026-07-31 18:23:29 +00:00
space-state.ts fix mcp graph and file uploads (#1397) 2026-08-04 18:58:14 +00:00
space.test.ts MCP Revamp (#1120) (#1380) 2026-07-30 17:08:51 -07:00
space.ts MCP Revamp (#1120) (#1380) 2026-07-30 17:08:51 -07:00
types.ts fix mcp graph and file uploads (#1397) 2026-08-04 18:58:14 +00:00
widget-manifest.d.ts fix mcp app contracts (#1394) 2026-08-01 06:41:17 +00:00
widget-resource-metadata.ts fix mcp graph and file uploads (#1397) 2026-08-04 18:58:14 +00:00