mirror of
https://github.com/better-auth/better-auth.git
synced 2026-08-03 08:49:26 -05:00
@better-auth/mcp
Model Context Protocol (MCP) plugin for Better Auth.
mcp() turns your Better Auth app into an OAuth 2.1 authorization server for MCP
clients, built on @better-auth/oauth-provider.
It serves the RFC 9728 protected resource metadata so MCP clients can discover it.
To protect an MCP route, wrap its handler with requireMcpAuth (or mcpHandler),
which verifies bearer tokens against the published JWKS.
import { betterAuth } from "better-auth";
import { jwt } from "better-auth/plugins";
import { mcp } from "@better-auth/mcp";
export const auth = betterAuth({
plugins: [jwt(), mcp({ loginPage: "/login", consentPage: "/consent" })],
});
See the MCP plugin documentation.