[PR #8087] [MERGED] feat(mcp): add framework-agnostic remote MCP auth client #33337

Closed
opened 2026-04-17 23:58:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8087
Author: @Paola3stefania
Created: 2/21/2026
Status: Merged
Merged: 2/21/2026
Merged by: @Bekacru

Base: canaryHead: feat/mcp-remote-client


📝 Commits (5)

📊 Changes

6 files changed (+1167 additions, -0 deletions)

View changed files

📝 docs/content/docs/plugins/mcp.mdx (+211 -0)
📝 packages/better-auth/package.json (+16 -0)
packages/better-auth/src/plugins/mcp/client/adapters.ts (+221 -0)
packages/better-auth/src/plugins/mcp/client/index.ts (+286 -0)
packages/better-auth/src/plugins/mcp/client/mcp-client.test.ts (+431 -0)
📝 packages/better-auth/tsdown.config.ts (+2 -0)

📄 Description

Summary by cubic

Adds a remote, framework-agnostic MCP auth client that validates Bearer tokens against a Better Auth server over HTTP. Lets MCP servers in other processes or runtimes use Better Auth via small handlers, middleware, and adapters.

  • New Features
    • createMcpAuthClient with verifyToken, handler, discoveryHandler, protectedResourceHandler, and Node/Express-style middleware; sends proper CORS and WWW-Authenticate (resource_metadata).
    • Adapters for Hono (middleware + discovery routes), official MCP SDK, and mcp-use (direct mode + registration endpoint).
    • Proxies OAuth discovery metadata with a 1-minute cache and serves RFC 9470 protected resource metadata; handler responds to OPTIONS for CORS.
    • Options: authURL (required), resource, allowedOrigin, fetch. Added docs (Remote MCP Client guide), tests (auth flow, CORS, discovery, middleware, mcp-use), and updated package exports/types and build entries.

Written for commit 20bcbcefd5. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8087 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 2/21/2026 **Status:** ✅ Merged **Merged:** 2/21/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `feat/mcp-remote-client` --- ### 📝 Commits (5) - [`6a0a767`](https://github.com/better-auth/better-auth/commit/6a0a767ed31f8ab1aec41fcb6359ef57591f5a08) feat: build remote - [`612d774`](https://github.com/better-auth/better-auth/commit/612d774ad219cb42ad244eb6ad54bc21cb74cfc3) Merge branch 'canary' into feat/mcp-remote-client - [`8929402`](https://github.com/better-auth/better-auth/commit/8929402c37d80b42077de4103ce55d3b2861ea90) docu - [`195ff45`](https://github.com/better-auth/better-auth/commit/195ff451bacae9e7cafb624f2dd6fbb20792c329) Merge branch 'feat/mcp-remote-client' of https://github.com/better-auth/better-auth into feat/mcp-remote-client - [`20bcbce`](https://github.com/better-auth/better-auth/commit/20bcbcefd599499d5151ef889eda7702c1359a06) fix issues ### 📊 Changes **6 files changed** (+1167 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/mcp.mdx` (+211 -0) 📝 `packages/better-auth/package.json` (+16 -0) ➕ `packages/better-auth/src/plugins/mcp/client/adapters.ts` (+221 -0) ➕ `packages/better-auth/src/plugins/mcp/client/index.ts` (+286 -0) ➕ `packages/better-auth/src/plugins/mcp/client/mcp-client.test.ts` (+431 -0) 📝 `packages/better-auth/tsdown.config.ts` (+2 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds a remote, framework-agnostic MCP auth client that validates Bearer tokens against a Better Auth server over HTTP. Lets MCP servers in other processes or runtimes use Better Auth via small handlers, middleware, and adapters. - **New Features** - createMcpAuthClient with verifyToken, handler, discoveryHandler, protectedResourceHandler, and Node/Express-style middleware; sends proper CORS and WWW-Authenticate (resource_metadata). - Adapters for Hono (middleware + discovery routes), official MCP SDK, and mcp-use (direct mode + registration endpoint). - Proxies OAuth discovery metadata with a 1-minute cache and serves RFC 9470 protected resource metadata; handler responds to OPTIONS for CORS. - Options: authURL (required), resource, allowedOrigin, fetch. Added docs (Remote MCP Client guide), tests (auth flow, CORS, discovery, middleware, mcp-use), and updated package exports/types and build entries. <sup>Written for commit 20bcbcefd599499d5151ef889eda7702c1359a06. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:58:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#33337