Skip to content

Auth Providers

Choose the right auth middleware for your use case:

ScenarioMiddlewareTransport
Manual login toolguard()stdio + HTTP
Form-based credentialscredentials()stdio + HTTP
Pre-shared bearer tokenbearer()HTTP
JWT (e.g., from Auth0)jwt()HTTP
GitHub sign-ingithub()HTTP
Google sign-ingoogle()HTTP
Custom OAuth provideroauth()HTTP

stdio vs HTTP

stdio clients (Claude Desktop, Claude Code) communicate over stdin/stdout. They can display forms via elicitation but cannot open browser URLs. Use guard() or credentials().

HTTP clients send requests over the network. They support all auth strategies. Bearer tokens and JWTs are injected via the onRequest hook.

Quick Comparison

guard()credentials()bearer()jwt()github()google()
Peer depszodjose
User interactionManual login toolElicitation formNone (header)None (header)Browser redirectBrowser redirect
Session keyConfigurableConfigurable"user""user""user""user"
Hides toolsYesYesYesYesYesYes
persistentNoNoNoNoYesYes

oauth(), github(), and google() support persistent: true to store auth state in c.userStore so users don't need to re-authenticate on reconnection. See Store & Persistence.

What's Next