mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-27 01:16:55 -05:00
* chore: consistent package names
* chore: init changesets
* chore: update contribution doc to include generating a changeset
* chore: configure all better auth packages to always have the same version number
* chore: update nextjs demo package name
* chore(changesets): ignore all private packages
* chore(changesets): check for changesets in CI
* chore(changesets): install chagesets cli
* chore(changesets): use orgin as main
* chore(changesets): fix typo
* chore(changesets): check for changes since main in ci
* chore(changesets): check for changes since main in ci with the correct command
* chore(changesets): check against `origin/main`
* chore(changesets): checking for changesets should be the last action
* chore(changesets): run changelog check after stoping the docker containers
* chore(changesets): run changelog check after building
* chore(changesets): run changelog check after starting docker compose
* chore(changesets): run changelog check after linting
* chore(changesets): run changelog check after testing
* Revert "chore(changesets): run changelog check after testing"
This reverts commit 6dc000f78d.
* chore: export siwe in better-auth/plugins (#3596)
The docs were using this import path, yet `siwe` wasn't exported there. This PR fixes this.
* chore: fix cookies test
* docs: make client-side vs. server-side explicit (#3603)
* docs: fix broken link to ERC-4361 in siwe docs (#3604)
* fix(jwt): ensure alg is added to the jwks when generating via /token endpoint (#3601)
* fix: Ensure alg is added to the jwks when generating via /token endpoint
* chore: resolve linting issues
* chore(example): fix SvelteKit example (#1742)
* refactor: upgrade Svelte, Vite and related packages
* refactor: replace no longer supported `body.callbackURL` with `onSuccess`
* fix: add missing `svelte-kit sync` on `prepare`
* fix: add missing `import`s
* chore(svelte-kit-example): show message & redirect to index after sign up
* chore: add npm script to migrate database
* doc: add more commands to set up
* chore: explicitly disable verification email on sign up
The example does not work if you set `sendOnSignUp: true` without setting up the email server.
* refactor(svelte-kit-example): add type for hooks
* chore(svelte-kit-example): redirect to sign in page if users open dashboard without log in
* chore: diable some rules for svelte-kit-example due to Biome's limited Svelte support
* style: fix format
* chore: update pnpm-lock.yaml
* chore: fix lock file
---------
Co-authored-by: Bereket Engida <Bekacru@gmail.com>
* fix: make sveltekit plugin ALS-agnostic (#3533)
* svelte cookie
* udpate
* update
* update
* update
* chore(cli): update zod to v4 (#3618)
* fix: correct typo in freeTrial variable name in Stripe integration
* chore: fix lock file
* chore: add changeset for typo fix in freeTrial
---------
Co-authored-by: Maxwell <145994855+ping-maxwell@users.noreply.github.com>
Co-authored-by: Bereket Engida <Bekacru@gmail.com>
Co-authored-by: Justin <127172022+jl33-ai@users.noreply.github.com>
Co-authored-by: Elliott Minns <elliott.minns@pm.me>
Co-authored-by: Jumpei Ogawa <git@phanective.org>
Co-authored-by: KinfeMichael Tariku <65047246+Kinfe123@users.noreply.github.com>
Better Auth - MCP Demo
This is an example repo on how to setup Better Auth for MCP Auth using Nextjs and Vercel MCP adapter.
Usage
First, add the plugin to your auth instance
// auth.ts
import { betterAuth } from "better-auth";
import { mcp } from "better-auth/plugins";
export const auth = betterAuth({
plugins: [
mcp({
loginPage: "/sign-in" // path to a page where users login
})
]
})
Make sure to generate or migrate required schema using the cli:
npx @better-auth/cli generate ## or (migrate)
Add a route to expose oauth metadata
// .well-known/oauth-authroization-server/route.ts
import { oAuthDiscoveryMetadata } from "better-auth/plugins";
import { auth } from "../../../lib/auth";
export const GET = oAuthDiscoveryMetadata(auth);
Mount the handlers if you haven't
// api/auth/[...all]/route.ts
import { auth } from "@/lib/auth";
import { toNextJsHandler } from "better-auth/next-js";
export const { GET, POST } = toNextJsHandler(auth);
You can use the helper function withMcpAuth to get the session and handle unauthenticated calls automatically.
import { auth } from "@/lib/auth";
import { createMcpHandler } from "@vercel/mcp-adapter";
import { withMcpAuth } from "better-auth/plugins";
import { z } from "zod";
const handler = withMcpAuth(auth, (req, session) => {
//session => This isn’t a typical Better Auth session - instead, it returns the access token record along with the scopes and user ID.
return createMcpHandler(
(server) => {
server.tool(
"echo",
"Echo a message",
{ message: z.string() },
async ({ message }) => {
return {
content: [{ type: "text", text: `Tool echo: ${message}` }],
};
},
);
},
{
capabilities: {
tools: {
echo: {
description: "Echo a message",
},
},
},
},
{
redisUrl: process.env.REDIS_URL,
basePath: "/api",
verboseLogs: true,
maxDuration: 60,
},
)(req);
});
export { handler as GET, handler as POST, handler as DELETE };
And that's it!!