Secure your MCP servers with OAuth using version 1.0.0 of the MCP Adapter , which now includes official support for the MCP Authorization spec . This release introduces:
Helper functions for OAuth-compliant authorization flows
A new withMcpAuth wrapper for securing routes
One-click deployable examples with popular auth providers like Better Auth, Clerk, Descope, Stytch, and WorkOS
Here’s an example of how to integrate auth in your MCP server:
import { createMcpHandler , withMcpAuth } from 'mcp-handler' ;
const handler = createMcpHandler ( ( server ) => {
server . tool (
'roll_dice' ,
'Rolls an N-sided die' ,
{ sides : z . number ( ) . int ( ) . min ( 2 ) } ,
async ( { sides } ) => {
const value = 1 + Math . floor ( Math . random ( ) * sides ) ;
return { content : [ { type : 'text' , text : ` 🎲 You rolled a ${ value } ! ` } ] } ;
}
) ;
} )
const verifyToken = async (
req : Request ,
bearerToken ? : string ,
) => {
if ( !…