Skip to content

Add Supabase OAuth authentication (passthrough mode) - #6

Merged
Adriansillo merged 2 commits into
mainfrom
Support-OAuth
Mar 19, 2026
Merged

Add Supabase OAuth authentication (passthrough mode)#6
Adriansillo merged 2 commits into
mainfrom
Support-OAuth

Conversation

@Adriansillo

@Adriansillo Adriansillo commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add OAuth support via Supabase using FastMCP's passthrough mode (enableTokenSwap: false), so MCP clients receive the raw Supabase JWT directly — no server-side token storage, meaning server restarts don't invalidate sessions
  • Hybrid authenticate handler supports three auth methods: plain API key header, ?token= query param, and Supabase JWT (decoded to resolve Browserless API key via PostgREST)
  • Fetch interceptor overrides Supabase's 60s token TTL to 1 hour to prevent constant refresh cycles
  • New account-resolver module with 5-min cache for JWT → API key resolution
  • tsconfig.json updated to Node16 module resolution to support fastmcp/auth package exports
  • All existing tests updated with new OAuth config fields; new tests for account-resolver

Test plan

  • npm run build — no type errors
  • npm test — all tests pass
  • Deploy to test environment with OAuth env vars, verify OAuth flow completes via VS Code
  • Verify plain API key auth still works: Authorization: Bearer <api-key>
  • Verify ?token= query param auth still works
  • Restart MCP server — verify OAuth clients reconnect without re-authenticating

🤖 Generated with Claude Code

Comment thread tsconfig.json
"baseUrl": ".",
"module": "es2022",
"moduleResolution": "node",
"module": "Node16",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Why 16 specifically?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fastmcp uses Node16 subpath exports (fastmcp/auth), and the old "moduleResolution": "node" can't resolve them. Without this change, import { OAuthProvider } from 'fastmcp/auth' fails to compile.

@Adriansillo
Adriansillo merged commit c80f802 into main Mar 19, 2026
1 check passed
andyMrtnzP pushed a commit that referenced this pull request May 20, 2026
Add Supabase OAuth authentication (passthrough mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants