[PR #4419] [MERGED] feat(mcp): customize resource in protected resource metadata #13622

Closed
opened 2026-04-13 09:02:07 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4419
Author: @frectonz
Created: 9/4/2025
Status: Merged
Merged: 9/4/2025
Merged by: @himself65

Base: canaryHead: feat/mcp-customize-resource-in-protected-resource-metadata


📝 Commits (2)

  • 7c4b5c7 feat(mcp): allow customizing the resource in protected resource metadata
  • facfdd5 test(mcp): test proteected resource metdata endpoint

📊 Changes

3 files changed (+25 additions, -4 deletions)

View changed files

📝 docs/content/docs/plugins/mcp.mdx (+5 -0)
📝 packages/better-auth/src/plugins/mcp/index.ts (+5 -4)
📝 packages/better-auth/src/plugins/mcp/mcp.test.ts (+15 -0)

📄 Description

Optionally customizing the resource in protected resource metadata endpoints

It defaults to the baseURL.

export const auth = betterAuth({
    plugins: [
        mcp({
            loginPage: "/sign-in",
            resource: "http://localhost:3000/mcp"
        })
    ]
});

Updated docs

image image

Summary by cubic

Adds support to customize the resource returned by the MCP protected resource metadata endpoint. By default, it now uses the base URL origin instead of the full base URL.

  • New Features

    • New MCP plugin option: resource to override the protected resource metadata resource.
    • getMCPProtectedResourceMetadata now accepts MCPOptions; resource defaults to new URL(baseURL).origin.
    • jwks_uri and scopes_supported now read from oidcConfig.metadata.
    • Docs updated to include the resource option.
  • Migration

    • If you relied on resource being the full baseURL (including path), set resource to baseURL to keep old behavior.
    • If you call getMCPProtectedResourceMetadata directly, update usage to pass MCPOptions.

🔄 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/4419 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 9/4/2025 **Status:** ✅ Merged **Merged:** 9/4/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `feat/mcp-customize-resource-in-protected-resource-metadata` --- ### 📝 Commits (2) - [`7c4b5c7`](https://github.com/better-auth/better-auth/commit/7c4b5c7e82f29c7099a9abf5bfa895bd849316f4) feat(mcp): allow customizing the resource in protected resource metadata - [`facfdd5`](https://github.com/better-auth/better-auth/commit/facfdd54880e05fbab0c0a1465a97e5e84f5fceb) test(mcp): test proteected resource metdata endpoint ### 📊 Changes **3 files changed** (+25 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/mcp.mdx` (+5 -0) 📝 `packages/better-auth/src/plugins/mcp/index.ts` (+5 -4) 📝 `packages/better-auth/src/plugins/mcp/mcp.test.ts` (+15 -0) </details> ### 📄 Description ### Optionally customizing the resource in protected resource metadata endpoints It defaults to the `baseURL`. ```typescript export const auth = betterAuth({ plugins: [ mcp({ loginPage: "/sign-in", resource: "http://localhost:3000/mcp" }) ] }); ``` ### Updated docs <img width="918" height="346" alt="image" src="https://github.com/user-attachments/assets/56134354-e354-4b5e-b79c-847651fedce8" /> <img width="918" height="346" alt="image" src="https://github.com/user-attachments/assets/c410cb14-c3be-45a6-bb8c-e83969f29191" /> <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds support to customize the resource returned by the MCP protected resource metadata endpoint. By default, it now uses the base URL origin instead of the full base URL. - **New Features** - New MCP plugin option: resource to override the protected resource metadata resource. - getMCPProtectedResourceMetadata now accepts MCPOptions; resource defaults to new URL(baseURL).origin. - jwks_uri and scopes_supported now read from oidcConfig.metadata. - Docs updated to include the resource option. - **Migration** - If you relied on resource being the full baseURL (including path), set resource to baseURL to keep old behavior. - If you call getMCPProtectedResourceMetadata directly, update usage to pass MCPOptions. <!-- 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-13 09:02:07 -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#13622