@better-auth/mcp 1.8.0-beta.8 → 1.8.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +7 -7
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ import { DpopReplayReservations, DpopReplayStore, VerifyAccessTokenRequestOption
|
|
|
3
3
|
import { Awaitable } from "@better-auth/core";
|
|
4
4
|
import { JWTPayload, JWTVerifyOptions } from "jose";
|
|
5
5
|
import { BetterAuthOptions } from "better-auth/types";
|
|
6
|
-
//#region src/handler.d.ts
|
|
7
6
|
interface McpProtectedRequestHandlerOptions {
|
|
8
7
|
/** Expected authorization-server issuer for the access token. */
|
|
9
8
|
issuer: string;
|
|
@@ -58,8 +57,6 @@ interface McpProtectedRequestHandlerOptions {
|
|
|
58
57
|
* @external
|
|
59
58
|
*/
|
|
60
59
|
export declare const createMcpProtectedRequestHandler: (options: McpProtectedRequestHandlerOptions, handler: (request: Request, accessTokenClaims: JWTPayload) => Awaitable<Response>) => (request: Request) => Promise<Response>;
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/plugin.d.ts
|
|
63
60
|
/**
|
|
64
61
|
* Options for the {@link mcp} plugin: the full OAuth provider configuration plus
|
|
65
62
|
* the MCP resource identifier.
|
|
@@ -134,8 +131,6 @@ interface McpOptions extends OAuthOptions<Scope[]> {
|
|
|
134
131
|
* ```
|
|
135
132
|
*/
|
|
136
133
|
export declare const mcp: (options: McpOptions) => ReturnType<typeof oauthProvider>;
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region src/require-mcp-auth.d.ts
|
|
139
134
|
interface RequireMcpAuthOptions {
|
|
140
135
|
/**
|
|
141
136
|
* The protected resource identifier the access token must be bound to.
|
|
@@ -224,5 +219,4 @@ export declare const requireMcpAuth: <Auth extends {
|
|
|
224
219
|
secret?: string;
|
|
225
220
|
}>;
|
|
226
221
|
}>(auth: Auth, handler: (request: Request, accessTokenClaims: JWTPayload) => Awaitable<Response>, opts?: RequireMcpAuthOptions) => (req: Request) => Promise<Response>;
|
|
227
|
-
//#endregion
|
|
228
222
|
export type { McpOptions, McpProtectedRequestHandlerOptions, RequireMcpAuthOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { isLoopbackHost } from "@better-auth/core/utils/host";
|
|
|
2
2
|
import { createResourceServerChallenge, getIssuer, metadataResponse, oauthProvider } from "@better-auth/oauth-provider";
|
|
3
3
|
import { withExposedHeaders } from "@better-auth/oauth-provider/internal";
|
|
4
4
|
import { DPOP_NONCE_HEADER, DPOP_SIGNING_ALGORITHMS, createDpopNonce, createDpopReplayStore, getDpopJktFromPayload, isInsufficientScopeError, requestToResourceInput, verifyAccessTokenRequest } from "better-auth/oauth2";
|
|
5
|
-
|
|
5
|
+
// src/handler.ts
|
|
6
6
|
/**
|
|
7
7
|
* Validates the canonical protected-resource identifier accepted by MCP.
|
|
8
8
|
*
|
|
@@ -87,7 +87,10 @@ const createMcpProtectedRequestHandler = (options, handler) => {
|
|
|
87
87
|
try {
|
|
88
88
|
accessTokenClaims = await verifyAccessTokenRequest(requestToResourceInput(request), accessTokenVerificationOptions);
|
|
89
89
|
} catch (error) {
|
|
90
|
-
return toChallengeResponse(error, resource,
|
|
90
|
+
return toChallengeResponse(error, resource, {
|
|
91
|
+
...resolvedChallengeOptions,
|
|
92
|
+
request
|
|
93
|
+
});
|
|
91
94
|
}
|
|
92
95
|
let response;
|
|
93
96
|
try {
|
|
@@ -100,8 +103,7 @@ const createMcpProtectedRequestHandler = (options, handler) => {
|
|
|
100
103
|
return nonce?.required && getDpopJktFromPayload(accessTokenClaims) ? withNextDpopNonce(response, nonce.secret) : response;
|
|
101
104
|
};
|
|
102
105
|
};
|
|
103
|
-
|
|
104
|
-
//#region src/plugin.ts
|
|
106
|
+
// src/plugin.ts
|
|
105
107
|
const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
|
|
106
108
|
const AUTHORIZATION_SERVER_ONLY_SCOPES = /* @__PURE__ */ new Set([
|
|
107
109
|
"openid",
|
|
@@ -220,8 +222,7 @@ const mcp = (options) => {
|
|
|
220
222
|
}
|
|
221
223
|
};
|
|
222
224
|
};
|
|
223
|
-
|
|
224
|
-
//#region src/require-mcp-auth.ts
|
|
225
|
+
// src/require-mcp-auth.ts
|
|
225
226
|
/** The OAuth provider's `dpop.nonce.expiresIn`, which `mcp()` passes through. */
|
|
226
227
|
function getProviderNonceExpiresIn(options) {
|
|
227
228
|
return (options.plugins?.find((plugin) => plugin.id === "oauth-provider"))?.options?.dpop?.nonce?.expiresIn;
|
|
@@ -276,5 +277,4 @@ const requireMcpAuth = (auth, handler, opts) => {
|
|
|
276
277
|
}, handler)(req);
|
|
277
278
|
};
|
|
278
279
|
};
|
|
279
|
-
//#endregion
|
|
280
280
|
export { createMcpProtectedRequestHandler, mcp, requireMcpAuth };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/mcp",
|
|
3
|
-
"version": "1.8.0-beta.
|
|
3
|
+
"version": "1.8.0-beta.9",
|
|
4
4
|
"description": "Model Context Protocol (MCP) plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,21 +46,21 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
49
|
+
"@better-auth/oauth-provider": "^1.8.0-beta.9",
|
|
50
|
+
"jose": "^6.1.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"@better-auth/core": "1.8.0-beta.9",
|
|
53
54
|
"@modelcontextprotocol/client": "2.3.1",
|
|
54
55
|
"@modelcontextprotocol/server": "2.3.1",
|
|
56
|
+
"better-auth": "1.8.0-beta.9",
|
|
55
57
|
"better-call": "1.4.5",
|
|
56
|
-
"tsdown": "0.23.1"
|
|
57
|
-
"@better-auth/core": "1.8.0-beta.8",
|
|
58
|
-
"better-auth": "1.8.0-beta.8"
|
|
58
|
+
"tsdown": "0.23.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"better-
|
|
62
|
-
"
|
|
63
|
-
"better-
|
|
61
|
+
"@better-auth/core": "^1.8.0-beta.9",
|
|
62
|
+
"better-auth": "^1.8.0-beta.9",
|
|
63
|
+
"better-call": "1.4.5"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsdown",
|