@better-auth/mcp 1.7.21 → 1.7.22
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 } from "better-auth/oauth2";
|
|
|
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;
|
|
@@ -49,8 +48,6 @@ interface McpProtectedRequestHandlerOptions {
|
|
|
49
48
|
* @external
|
|
50
49
|
*/
|
|
51
50
|
export declare const createMcpProtectedRequestHandler: (options: McpProtectedRequestHandlerOptions, handler: (request: Request, accessTokenClaims: JWTPayload) => Awaitable<Response>) => (request: Request) => Promise<Response>;
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/plugin.d.ts
|
|
54
51
|
/**
|
|
55
52
|
* Options for the {@link mcp} plugin: the full OAuth provider configuration plus
|
|
56
53
|
* the MCP resource identifier.
|
|
@@ -125,8 +122,6 @@ interface McpOptions extends OAuthOptions<Scope[]> {
|
|
|
125
122
|
* ```
|
|
126
123
|
*/
|
|
127
124
|
export declare const mcp: (options: McpOptions) => ReturnType<typeof oauthProvider>;
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/require-mcp-auth.d.ts
|
|
130
125
|
interface RequireMcpAuthOptions {
|
|
131
126
|
/**
|
|
132
127
|
* The protected resource identifier the access token must be bound to.
|
|
@@ -194,5 +189,4 @@ export declare const requireMcpAuth: <Auth extends {
|
|
|
194
189
|
internalAdapter: DpopReplayReservations;
|
|
195
190
|
}>;
|
|
196
191
|
}>(auth: Auth, handler: (request: Request, accessTokenClaims: JWTPayload) => Awaitable<Response>, opts?: RequireMcpAuthOptions) => (req: Request) => Promise<Response>;
|
|
197
|
-
//#endregion
|
|
198
192
|
export type { McpOptions, McpProtectedRequestHandlerOptions, RequireMcpAuthOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isLoopbackHost } from "@better-auth/core/utils/host";
|
|
2
2
|
import { createResourceServerChallenge, getIssuer, metadataResponse, oauthProvider } from "@better-auth/oauth-provider";
|
|
3
3
|
import { DPOP_SIGNING_ALGORITHMS, createDpopReplayStore, isInsufficientScopeError, requestToResourceInput, verifyAccessTokenRequest } from "better-auth/oauth2";
|
|
4
|
-
|
|
4
|
+
// src/handler.ts
|
|
5
5
|
/**
|
|
6
6
|
* Validates the canonical protected-resource identifier accepted by MCP.
|
|
7
7
|
*
|
|
@@ -69,7 +69,10 @@ const createMcpProtectedRequestHandler = (options, handler) => {
|
|
|
69
69
|
try {
|
|
70
70
|
accessTokenClaims = await verifyAccessTokenRequest(requestToResourceInput(request), accessTokenVerificationOptions);
|
|
71
71
|
} catch (error) {
|
|
72
|
-
return toChallengeResponse(error, resource,
|
|
72
|
+
return toChallengeResponse(error, resource, {
|
|
73
|
+
...resolvedChallengeOptions,
|
|
74
|
+
request
|
|
75
|
+
});
|
|
73
76
|
}
|
|
74
77
|
try {
|
|
75
78
|
return await handler(request, accessTokenClaims);
|
|
@@ -79,8 +82,7 @@ const createMcpProtectedRequestHandler = (options, handler) => {
|
|
|
79
82
|
}
|
|
80
83
|
};
|
|
81
84
|
};
|
|
82
|
-
|
|
83
|
-
//#region src/plugin.ts
|
|
85
|
+
// src/plugin.ts
|
|
84
86
|
const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
|
|
85
87
|
const AUTHORIZATION_SERVER_ONLY_SCOPES = /* @__PURE__ */ new Set([
|
|
86
88
|
"openid",
|
|
@@ -199,8 +201,7 @@ const mcp = (options) => {
|
|
|
199
201
|
}
|
|
200
202
|
};
|
|
201
203
|
};
|
|
202
|
-
|
|
203
|
-
//#region src/require-mcp-auth.ts
|
|
204
|
+
// src/require-mcp-auth.ts
|
|
204
205
|
/**
|
|
205
206
|
* Protects an MCP server route handler. Verifies the bearer access token
|
|
206
207
|
* against the authorization server's JWKS (checking signature, issuer,
|
|
@@ -243,5 +244,4 @@ const requireMcpAuth = (auth, handler, opts) => {
|
|
|
243
244
|
}, handler)(req);
|
|
244
245
|
};
|
|
245
246
|
};
|
|
246
|
-
//#endregion
|
|
247
247
|
export { createMcpProtectedRequestHandler, mcp, requireMcpAuth };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/mcp",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.22",
|
|
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.7.22",
|
|
50
|
+
"jose": "^6.1.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"@better-auth/core": "1.7.22",
|
|
53
54
|
"@modelcontextprotocol/client": "2.3.1",
|
|
54
55
|
"@modelcontextprotocol/server": "2.3.1",
|
|
56
|
+
"better-auth": "1.7.22",
|
|
55
57
|
"better-call": "1.4.5",
|
|
56
|
-
"tsdown": "0.23.1"
|
|
57
|
-
"@better-auth/core": "1.7.21",
|
|
58
|
-
"better-auth": "1.7.21"
|
|
58
|
+
"tsdown": "0.23.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"better-
|
|
62
|
-
"
|
|
63
|
-
"better-
|
|
61
|
+
"@better-auth/core": "^1.7.22",
|
|
62
|
+
"better-auth": "^1.7.22",
|
|
63
|
+
"better-call": "1.4.5"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsdown",
|