# @better-auth/mcp

> Model Context Protocol (MCP) plugin for Better Auth

Latest version **1.7.27** (published 2026-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @better-auth/mcp
pnpm add @better-auth/mcp
yarn add @better-auth/mcp
bun add @better-auth/mcp
```

## Health

**Score 80/100 (A)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.7.27 |
| Published | 2026-11-20 |
| First published | 2026-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 24.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 30228 |
| Maintainers | bekacru, better-gustavo |
| Keywords | mcp, model context protocol, auth, oauth, oidc, rfc9728, rfc8707, typescript, better-auth |

## Links

- npm: https://www.npmjs.com/package/@better-auth/mcp
- Repository: https://github.com/better-auth/better-auth
- Homepage: https://www.better-auth.com/docs/plugins/mcp
- npm.io page: https://npm.io/package/@better-auth/mcp

## Dependencies (2)

- [jose](https://npm.io/package/jose.md) ^6.1.3
- [@better-auth/oauth-provider](https://npm.io/package/@better-auth/oauth-provider.md) ^1.7.27

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.7.27 (latest) — 2026-11-20
- 1.8.0-beta.10 (beta) — 2026-11-15
- 1.7.0-rc.6 (rc) — 2026-08-14
- 1.7.26 — 2026-11-18
- 1.7.25 — 2026-11-14
- 1.7.24 — 2026-11-14
- 1.7.23 — 2026-11-13
- 1.8.0-beta.9 — 2026-11-12
- 1.7.22 — 2026-11-12
- 1.8.0-beta.8 — 2026-11-11
- 1.7.21 — 2026-11-11
- 1.7.20 — 2026-11-10
- 1.8.0-beta.7 — 2026-11-10
- 1.7.19 — 2026-11-10
- 1.8.0-beta.6 — 2026-11-05
- … 41 more at https://npm.io/package/@better-auth/mcp/versions

## README

# @better-auth/mcp

Model Context Protocol (MCP) plugin for [Better Auth](https://www.better-auth.com).

`mcp()` turns your Better Auth app into an OAuth 2.1 authorization server and
protected resource for MCP clients, built on
[`@better-auth/oauth-provider`](https://www.better-auth.com/docs/plugins/oauth-provider).
It serves RFC 9728 protected resource metadata and binds issued tokens to the
configured resource. Compose it with `cimd()` for the MCP 2026-07-28 Client ID
Metadata Document flow, which pins CIMD draft-00 through an explicit metadata
profile. Dynamic Client Registration is disabled unless explicitly enabled.

`@better-auth/mcp` owns authorization, not MCP protocol transport. Serve MCP
2026-07-28 requests with version 2 of the official
[`@modelcontextprotocol/server`](https://www.npmjs.com/package/@modelcontextprotocol/server)
package, configure `createMcpHandler` with `legacy: "reject"`, mount it behind
`requireMcpAuth`, and expose only the HTTP `POST` route. The modern protocol
handles each request independently and does not need a Redis-backed MCP
session store. Multi-instance `subscriptions/listen` deployments can supply a
shared SDK event bus without introducing protocol-level sessions.

```ts
import { betterAuth } from "better-auth";
import { jwt } from "better-auth/plugins";
import { cimd } from "@better-auth/cimd";
import { fetchClientMetadataResource } from "@better-auth/cimd/node";
import { mcp } from "@better-auth/mcp";

export const auth = betterAuth({
  plugins: [
    jwt(),
    mcp({
      loginPage: "/login",
      consentPage: "/consent",
      resource: "https://api.example.com/mcp",
    }),
    cimd({
      fetchClientMetadataResource,
      metadataProfile: "mcp-2026-07-28",
    }),
  ],
});
```

See the [MCP plugin documentation](https://www.better-auth.com/docs/plugins/mcp).

---
_Source: https://npm.io/package/@better-auth/mcp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
