# OAuth support added to MCP Adapter

**Published:** July 15, 2025 | **Authors:** Allen Zhou, Andrew Qu

---

Secure your MCP servers with OAuth using version `1.0.0` of the [MCP Adapter](https://github.com/vercel/mcp-adapter), which now includes official support for the [MCP Authorization spec](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization). 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:

**app/[transport]/route.ts**
```javascript
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 (!bearerToken) return undefined;

  const isValid = bearerToken === '123';
  if (!isValid) return undefined;
  return {
    token: bearerToken,
    scopes: ['read:stuff'],
    clientId: 'client123',
  };
};
const authHandler = withMcpAuth(handler, verifyToken, {
  required: true, 
});
export { authHandler as GET, authHandler as POST };
```

Additionally, use the `protectedResourceHandler` to expose resource server metadata for compliant clients. Learn more in the [MCP Auth documentation](https://vercel.com/docs/mcp#enabling-authorization).

### Start building secure MCP servers

Deploy an example MCP server by [cloning our Next.js MCP template](https://vercel.com/templates/ai/model-context-protocol-mcp-with-next-js), or explore starter integrations from our auth partners:

- [Better Auth](https://www.better-auth.com/docs/plugins/mcp)
- [Clerk](https://github.com/clerk/mcp-nextjs-example)
- [Descope](https://github.com/descope/ai/tree/main/examples/nextjs-vercel-mcp-server)
- [Stytch](https://github.com/stytchauth/vercel-mcp-example)
- [WorkOS](https://github.com/workos/vercel-mcp-example)

**MCP Server with Next.js**
Get started building your first MCP server on Vercel.
[Deploy now](https://vercel.com/templates/next.js/model-context-protocol-mcp-with-next-js)

---

📚 **More updates:** [View all changelog entries](/changelog/sitemap.md) | [Blog](/blog/sitemap.md)