mcp-use 1.34.4 → 1.34.5
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/.tsbuildinfo +1 -1
- package/dist/{chunk-AON7VXVM.js → chunk-35DRMA7E.js} +43 -0
- package/dist/{chunk-CI6MW6DM.js → chunk-3BUU264G.js} +4 -4
- package/dist/{chunk-YYUZ7XGB.js → chunk-6P7JMLV2.js} +45 -2
- package/dist/{chunk-GYSF6PR5.js → chunk-DAFFOVMW.js} +1 -1
- package/dist/{chunk-7DSZJBE2.js → chunk-JFYUK3XX.js} +1 -1
- package/dist/{chunk-WJ2EMDBB.js → chunk-LS73EEWA.js} +1 -1
- package/dist/{chunk-KO5XAWZ3.js → chunk-MD7U5C3K.js} +1 -1
- package/dist/{chunk-MKRTKKXV.js → chunk-NDIVAYZ3.js} +1 -1
- package/dist/{chunk-LEWR3GBF.js → chunk-V7Q4HEFC.js} +2 -2
- package/dist/{chunk-2J5OVVW6.js → chunk-VSSL5DL7.js} +1 -1
- package/dist/{chunk-WGK7GOZV.js → chunk-YH33JHUI.js} +2 -2
- package/dist/{chunk-XNWBPRVB.js → chunk-ZDC5CD3L.js} +1 -1
- package/dist/{client-A4Z5ZFV2.js → client-A5GK5WZD.js} +4 -4
- package/dist/index.cjs +51 -2
- package/dist/index.js +17 -8
- package/dist/src/agents/index.cjs +1 -1
- package/dist/src/agents/index.js +4 -4
- package/dist/src/auth/browser-provider.d.ts +10 -0
- package/dist/src/auth/browser-provider.d.ts.map +1 -1
- package/dist/src/auth/index.cjs +40 -0
- package/dist/src/auth/index.js +1 -1
- package/dist/src/browser-agent.cjs +1 -1
- package/dist/src/browser-agent.js +2 -2
- package/dist/src/browser.cjs +41 -1
- package/dist/src/browser.js +4 -4
- package/dist/src/client.cjs +1 -1
- package/dist/src/client.js +4 -4
- package/dist/src/react/index.cjs +51 -2
- package/dist/src/react/index.js +14 -5
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +1 -1
- package/dist/src/server/index.js +7 -7
- package/dist/src/version.d.ts +1 -1
- package/dist/{stdio-4SNFIKTV.js → stdio-I5TXQ4ET.js} +3 -3
- package/dist/{stdio-ZAOHF4EV.js → stdio-OFLQV3DJ.js} +2 -2
- package/dist/{tool-execution-helpers-ODJCEDUR.js → tool-execution-helpers-CEE337HP.js} +2 -2
- package/package.json +3 -3
|
@@ -6,6 +6,12 @@ import {
|
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-3GQAWCBQ.js";
|
|
8
8
|
|
|
9
|
+
// src/auth/browser-provider.ts
|
|
10
|
+
import {
|
|
11
|
+
checkResourceAllowed,
|
|
12
|
+
resourceUrlFromServerUrl
|
|
13
|
+
} from "@modelcontextprotocol/sdk/shared/auth-utils.js";
|
|
14
|
+
|
|
9
15
|
// src/auth/kv-store.ts
|
|
10
16
|
var LocalStorageKVStore = class {
|
|
11
17
|
static {
|
|
@@ -264,6 +270,43 @@ var BrowserOAuthClientProvider = class {
|
|
|
264
270
|
invalidateCredentials(scope) {
|
|
265
271
|
return this.session.invalidateCredentials(scope);
|
|
266
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Validate the protected resource discovered through the OAuth proxy.
|
|
275
|
+
*
|
|
276
|
+
* The proxy rewrites protected-resource metadata to the MCP connection URL
|
|
277
|
+
* so transport-anchored discovery remains valid. Manual authentication is
|
|
278
|
+
* anchored on the upstream MCP URL instead, so accept that rewrite and
|
|
279
|
+
* return the original upstream resource that the authorization server
|
|
280
|
+
* protects.
|
|
281
|
+
*/
|
|
282
|
+
async validateResourceURL(serverUrl, resource) {
|
|
283
|
+
if (!resource) return void 0;
|
|
284
|
+
const requestedResource = resourceUrlFromServerUrl(serverUrl);
|
|
285
|
+
if (checkResourceAllowed({
|
|
286
|
+
requestedResource,
|
|
287
|
+
configuredResource: resource
|
|
288
|
+
})) {
|
|
289
|
+
return new URL(resource);
|
|
290
|
+
}
|
|
291
|
+
const isConnectionResource = this.connectionUrl && checkResourceAllowed({
|
|
292
|
+
requestedResource: resourceUrlFromServerUrl(this.connectionUrl),
|
|
293
|
+
configuredResource: resource
|
|
294
|
+
});
|
|
295
|
+
if (isConnectionResource) {
|
|
296
|
+
const upstreamResource = resourceUrlFromServerUrl(
|
|
297
|
+
this._lastOriginalResource ?? this.serverUrl
|
|
298
|
+
);
|
|
299
|
+
if (checkResourceAllowed({
|
|
300
|
+
requestedResource,
|
|
301
|
+
configuredResource: upstreamResource
|
|
302
|
+
})) {
|
|
303
|
+
return upstreamResource;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
throw new Error(
|
|
307
|
+
`Protected resource ${resource} does not match expected ${requestedResource} (or origin)`
|
|
308
|
+
);
|
|
309
|
+
}
|
|
267
310
|
/**
|
|
268
311
|
* Resolve this server's OAuth token endpoint (via discovery, cached). Lets
|
|
269
312
|
* consumers persist the endpoint alongside the tokens for server-side
|
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./chunk-GKPKUKD6.js";
|
|
4
4
|
import {
|
|
5
5
|
CodeModeConnector
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LS73EEWA.js";
|
|
7
7
|
import {
|
|
8
8
|
BaseConnector
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JFYUK3XX.js";
|
|
10
10
|
import {
|
|
11
11
|
JSONSchemaToZod
|
|
12
12
|
} from "./chunk-LG5NSHEL.js";
|
|
13
13
|
import {
|
|
14
14
|
Tel,
|
|
15
15
|
getPackageVersion
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-NDIVAYZ3.js";
|
|
17
17
|
import {
|
|
18
18
|
logger
|
|
19
19
|
} from "./chunk-QWQYAQCK.js";
|
|
@@ -2356,7 +2356,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
2356
2356
|
clientInfo: serverConfig.clientInfo ?? this.config.clientInfo
|
|
2357
2357
|
};
|
|
2358
2358
|
if ("command" in merged && "args" in merged) {
|
|
2359
|
-
const { StdioConnector } = await import("./stdio-
|
|
2359
|
+
const { StdioConnector } = await import("./stdio-I5TXQ4ET.js");
|
|
2360
2360
|
const stdioConfig = merged;
|
|
2361
2361
|
return new StdioConnector({
|
|
2362
2362
|
command: stdioConfig.command,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
HttpConnector,
|
|
4
4
|
normalizeClientInfo,
|
|
5
5
|
resolveCallbacks
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-V7Q4HEFC.js";
|
|
7
7
|
import {
|
|
8
8
|
Tel,
|
|
9
9
|
getPackageVersion
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VSSL5DL7.js";
|
|
11
11
|
import {
|
|
12
12
|
logger
|
|
13
13
|
} from "./chunk-QWQYAQCK.js";
|
|
@@ -105,6 +105,12 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
+
// src/auth/browser-provider.ts
|
|
109
|
+
import {
|
|
110
|
+
checkResourceAllowed,
|
|
111
|
+
resourceUrlFromServerUrl
|
|
112
|
+
} from "@modelcontextprotocol/sdk/shared/auth-utils.js";
|
|
113
|
+
|
|
108
114
|
// src/utils/url-sanitize.ts
|
|
109
115
|
function sanitizeUrl(raw) {
|
|
110
116
|
const abort = /* @__PURE__ */ __name(() => {
|
|
@@ -726,6 +732,43 @@ var BrowserOAuthClientProvider = class {
|
|
|
726
732
|
invalidateCredentials(scope) {
|
|
727
733
|
return this.session.invalidateCredentials(scope);
|
|
728
734
|
}
|
|
735
|
+
/**
|
|
736
|
+
* Validate the protected resource discovered through the OAuth proxy.
|
|
737
|
+
*
|
|
738
|
+
* The proxy rewrites protected-resource metadata to the MCP connection URL
|
|
739
|
+
* so transport-anchored discovery remains valid. Manual authentication is
|
|
740
|
+
* anchored on the upstream MCP URL instead, so accept that rewrite and
|
|
741
|
+
* return the original upstream resource that the authorization server
|
|
742
|
+
* protects.
|
|
743
|
+
*/
|
|
744
|
+
async validateResourceURL(serverUrl, resource) {
|
|
745
|
+
if (!resource) return void 0;
|
|
746
|
+
const requestedResource = resourceUrlFromServerUrl(serverUrl);
|
|
747
|
+
if (checkResourceAllowed({
|
|
748
|
+
requestedResource,
|
|
749
|
+
configuredResource: resource
|
|
750
|
+
})) {
|
|
751
|
+
return new URL(resource);
|
|
752
|
+
}
|
|
753
|
+
const isConnectionResource = this.connectionUrl && checkResourceAllowed({
|
|
754
|
+
requestedResource: resourceUrlFromServerUrl(this.connectionUrl),
|
|
755
|
+
configuredResource: resource
|
|
756
|
+
});
|
|
757
|
+
if (isConnectionResource) {
|
|
758
|
+
const upstreamResource = resourceUrlFromServerUrl(
|
|
759
|
+
this._lastOriginalResource ?? this.serverUrl
|
|
760
|
+
);
|
|
761
|
+
if (checkResourceAllowed({
|
|
762
|
+
requestedResource,
|
|
763
|
+
configuredResource: upstreamResource
|
|
764
|
+
})) {
|
|
765
|
+
return upstreamResource;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
throw new Error(
|
|
769
|
+
`Protected resource ${resource} does not match expected ${requestedResource} (or origin)`
|
|
770
|
+
);
|
|
771
|
+
}
|
|
729
772
|
/**
|
|
730
773
|
* Resolve this server's OAuth token endpoint (via discovery, cached). Lets
|
|
731
774
|
* consumers persist the endpoint alongside the tokens for server-side
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseConnector,
|
|
3
3
|
ConnectionManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DAFFOVMW.js";
|
|
5
5
|
import {
|
|
6
6
|
Tel,
|
|
7
7
|
getPackageVersion
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VSSL5DL7.js";
|
|
9
9
|
import {
|
|
10
10
|
logger
|
|
11
11
|
} from "./chunk-QWQYAQCK.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CODE_MODE_AGENT_PROMPT
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LS73EEWA.js";
|
|
4
4
|
import {
|
|
5
5
|
LangChainAdapter
|
|
6
6
|
} from "./chunk-27JERD25.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Telemetry,
|
|
9
9
|
extractModelInfo,
|
|
10
10
|
getPackageVersion
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NDIVAYZ3.js";
|
|
12
12
|
import {
|
|
13
13
|
logger
|
|
14
14
|
} from "./chunk-QWQYAQCK.js";
|
|
@@ -7,15 +7,15 @@ import {
|
|
|
7
7
|
createConnectorFromConfig,
|
|
8
8
|
normalizeClientInfo,
|
|
9
9
|
resolveCallbacks
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-V7Q4HEFC.js";
|
|
11
11
|
import "./chunk-URE3PRDB.js";
|
|
12
12
|
import {
|
|
13
13
|
BaseConnector
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-DAFFOVMW.js";
|
|
15
15
|
import {
|
|
16
16
|
Tel,
|
|
17
17
|
getPackageVersion
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-VSSL5DL7.js";
|
|
19
19
|
import {
|
|
20
20
|
logger
|
|
21
21
|
} from "./chunk-QWQYAQCK.js";
|
|
@@ -1107,7 +1107,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
|
|
|
1107
1107
|
clientInfo: serverConfig.clientInfo ?? this.config.clientInfo
|
|
1108
1108
|
};
|
|
1109
1109
|
if ("command" in merged && "args" in merged) {
|
|
1110
|
-
const { StdioConnector } = await import("./stdio-
|
|
1110
|
+
const { StdioConnector } = await import("./stdio-OFLQV3DJ.js");
|
|
1111
1111
|
const stdioConfig = merged;
|
|
1112
1112
|
return new StdioConnector({
|
|
1113
1113
|
command: stdioConfig.command,
|
package/dist/index.cjs
CHANGED
|
@@ -1170,7 +1170,7 @@ var VERSION;
|
|
|
1170
1170
|
var init_version = __esm({
|
|
1171
1171
|
"src/version.ts"() {
|
|
1172
1172
|
"use strict";
|
|
1173
|
-
VERSION = "1.34.
|
|
1173
|
+
VERSION = "1.34.5";
|
|
1174
1174
|
__name(getPackageVersion, "getPackageVersion");
|
|
1175
1175
|
}
|
|
1176
1176
|
});
|
|
@@ -9688,6 +9688,9 @@ __name(streamEventsToAISDKWithTools, "streamEventsToAISDKWithTools");
|
|
|
9688
9688
|
init_telemetry();
|
|
9689
9689
|
init_version();
|
|
9690
9690
|
|
|
9691
|
+
// src/auth/browser-provider.ts
|
|
9692
|
+
var import_auth_utils = require("@modelcontextprotocol/sdk/shared/auth-utils.js");
|
|
9693
|
+
|
|
9691
9694
|
// src/utils/url-sanitize.ts
|
|
9692
9695
|
function sanitizeUrl(raw) {
|
|
9693
9696
|
const abort = /* @__PURE__ */ __name(() => {
|
|
@@ -10305,6 +10308,43 @@ var BrowserOAuthClientProvider = class {
|
|
|
10305
10308
|
invalidateCredentials(scope) {
|
|
10306
10309
|
return this.session.invalidateCredentials(scope);
|
|
10307
10310
|
}
|
|
10311
|
+
/**
|
|
10312
|
+
* Validate the protected resource discovered through the OAuth proxy.
|
|
10313
|
+
*
|
|
10314
|
+
* The proxy rewrites protected-resource metadata to the MCP connection URL
|
|
10315
|
+
* so transport-anchored discovery remains valid. Manual authentication is
|
|
10316
|
+
* anchored on the upstream MCP URL instead, so accept that rewrite and
|
|
10317
|
+
* return the original upstream resource that the authorization server
|
|
10318
|
+
* protects.
|
|
10319
|
+
*/
|
|
10320
|
+
async validateResourceURL(serverUrl, resource) {
|
|
10321
|
+
if (!resource) return void 0;
|
|
10322
|
+
const requestedResource = (0, import_auth_utils.resourceUrlFromServerUrl)(serverUrl);
|
|
10323
|
+
if ((0, import_auth_utils.checkResourceAllowed)({
|
|
10324
|
+
requestedResource,
|
|
10325
|
+
configuredResource: resource
|
|
10326
|
+
})) {
|
|
10327
|
+
return new URL(resource);
|
|
10328
|
+
}
|
|
10329
|
+
const isConnectionResource = this.connectionUrl && (0, import_auth_utils.checkResourceAllowed)({
|
|
10330
|
+
requestedResource: (0, import_auth_utils.resourceUrlFromServerUrl)(this.connectionUrl),
|
|
10331
|
+
configuredResource: resource
|
|
10332
|
+
});
|
|
10333
|
+
if (isConnectionResource) {
|
|
10334
|
+
const upstreamResource = (0, import_auth_utils.resourceUrlFromServerUrl)(
|
|
10335
|
+
this._lastOriginalResource ?? this.serverUrl
|
|
10336
|
+
);
|
|
10337
|
+
if ((0, import_auth_utils.checkResourceAllowed)({
|
|
10338
|
+
requestedResource,
|
|
10339
|
+
configuredResource: upstreamResource
|
|
10340
|
+
})) {
|
|
10341
|
+
return upstreamResource;
|
|
10342
|
+
}
|
|
10343
|
+
}
|
|
10344
|
+
throw new Error(
|
|
10345
|
+
`Protected resource ${resource} does not match expected ${requestedResource} (or origin)`
|
|
10346
|
+
);
|
|
10347
|
+
}
|
|
10308
10348
|
/**
|
|
10309
10349
|
* Resolve this server's OAuth token endpoint (via discovery, cached). Lets
|
|
10310
10350
|
* consumers persist the endpoint alongside the tokens for server-side
|
|
@@ -12945,6 +12985,7 @@ function useMcp(options) {
|
|
|
12945
12985
|
addLog("info", "Triggering fresh OAuth authorization...");
|
|
12946
12986
|
const parsedUrl = new URL(url);
|
|
12947
12987
|
const baseUrl = parsedUrl.origin + parsedUrl.pathname.replace(/\/+$/, "");
|
|
12988
|
+
let authFlowError = null;
|
|
12948
12989
|
try {
|
|
12949
12990
|
await (0, import_auth4.auth)(freshAuthProvider, {
|
|
12950
12991
|
serverUrl: baseUrl,
|
|
@@ -12952,13 +12993,21 @@ function useMcp(options) {
|
|
|
12952
12993
|
});
|
|
12953
12994
|
addLog("info", "OAuth flow completed (tokens obtained)");
|
|
12954
12995
|
} catch (err) {
|
|
12996
|
+
authFlowError = err instanceof Error ? err : new Error(String(err));
|
|
12955
12997
|
addLog(
|
|
12956
12998
|
"info",
|
|
12957
12999
|
"OAuth flow initiated (popup/redirect):",
|
|
12958
|
-
|
|
13000
|
+
authFlowError.message
|
|
12959
13001
|
);
|
|
12960
13002
|
}
|
|
12961
13003
|
const newAuthUrl = freshAuthProvider.getLastAttemptedAuthUrl?.();
|
|
13004
|
+
if (authFlowError && !capturedPopup && !newAuthUrl) {
|
|
13005
|
+
failConnection(
|
|
13006
|
+
`Authentication failed: ${authFlowError.message}`,
|
|
13007
|
+
authFlowError
|
|
13008
|
+
);
|
|
13009
|
+
return;
|
|
13010
|
+
}
|
|
12962
13011
|
if (newAuthUrl) {
|
|
12963
13012
|
setAuthUrl(newAuthUrl);
|
|
12964
13013
|
addLog("info", "Updated auth URL for fallback:", newAuthUrl);
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-OWF2HVMR.js";
|
|
6
6
|
import {
|
|
7
7
|
StdioConnector
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZDC5CD3L.js";
|
|
9
9
|
import {
|
|
10
10
|
clearRpcLogs,
|
|
11
11
|
getAllRpcLogs,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
reject,
|
|
33
33
|
resolveCallbacks,
|
|
34
34
|
validate
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-3BUU264G.js";
|
|
36
36
|
import "./chunk-GKPKUKD6.js";
|
|
37
37
|
import "./chunk-GXNAXUDI.js";
|
|
38
38
|
import {
|
|
@@ -50,12 +50,12 @@ import {
|
|
|
50
50
|
getSupportedProviders,
|
|
51
51
|
isValidLLMString,
|
|
52
52
|
parseLLMString
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-YH33JHUI.js";
|
|
54
54
|
import "./chunk-N27VLLMA.js";
|
|
55
|
-
import "./chunk-
|
|
55
|
+
import "./chunk-LS73EEWA.js";
|
|
56
56
|
import {
|
|
57
57
|
BaseConnector
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-JFYUK3XX.js";
|
|
59
59
|
import {
|
|
60
60
|
BaseAdapter
|
|
61
61
|
} from "./chunk-27JERD25.js";
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
onMcpAuthorization,
|
|
68
68
|
probeAuthParams,
|
|
69
69
|
runAuthPopup
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-35DRMA7E.js";
|
|
71
71
|
import {
|
|
72
72
|
sanitizeUrl
|
|
73
73
|
} from "./chunk-QZVO7T36.js";
|
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
createServerRunEventData,
|
|
99
99
|
getPackageVersion,
|
|
100
100
|
setTelemetrySource
|
|
101
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-NDIVAYZ3.js";
|
|
102
102
|
import {
|
|
103
103
|
telFetch
|
|
104
104
|
} from "./chunk-BXZHMYMM.js";
|
|
@@ -1884,6 +1884,7 @@ function useMcp(options) {
|
|
|
1884
1884
|
addLog("info", "Triggering fresh OAuth authorization...");
|
|
1885
1885
|
const parsedUrl = new URL(url);
|
|
1886
1886
|
const baseUrl = parsedUrl.origin + parsedUrl.pathname.replace(/\/+$/, "");
|
|
1887
|
+
let authFlowError = null;
|
|
1887
1888
|
try {
|
|
1888
1889
|
await auth(freshAuthProvider, {
|
|
1889
1890
|
serverUrl: baseUrl,
|
|
@@ -1891,13 +1892,21 @@ function useMcp(options) {
|
|
|
1891
1892
|
});
|
|
1892
1893
|
addLog("info", "OAuth flow completed (tokens obtained)");
|
|
1893
1894
|
} catch (err) {
|
|
1895
|
+
authFlowError = err instanceof Error ? err : new Error(String(err));
|
|
1894
1896
|
addLog(
|
|
1895
1897
|
"info",
|
|
1896
1898
|
"OAuth flow initiated (popup/redirect):",
|
|
1897
|
-
|
|
1899
|
+
authFlowError.message
|
|
1898
1900
|
);
|
|
1899
1901
|
}
|
|
1900
1902
|
const newAuthUrl = freshAuthProvider.getLastAttemptedAuthUrl?.();
|
|
1903
|
+
if (authFlowError && !capturedPopup && !newAuthUrl) {
|
|
1904
|
+
failConnection(
|
|
1905
|
+
`Authentication failed: ${authFlowError.message}`,
|
|
1906
|
+
authFlowError
|
|
1907
|
+
);
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1901
1910
|
if (newAuthUrl) {
|
|
1902
1911
|
setAuthUrl(newAuthUrl);
|
|
1903
1912
|
addLog("info", "Updated auth URL for fallback:", newAuthUrl);
|
package/dist/src/agents/index.js
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
MCPAgent,
|
|
4
4
|
PROMPTS,
|
|
5
5
|
RemoteAgent
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-YH33JHUI.js";
|
|
7
7
|
import "../../chunk-N27VLLMA.js";
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-LS73EEWA.js";
|
|
9
|
+
import "../../chunk-JFYUK3XX.js";
|
|
10
10
|
import "../../chunk-27JERD25.js";
|
|
11
11
|
import "../../chunk-LG5NSHEL.js";
|
|
12
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-NDIVAYZ3.js";
|
|
13
13
|
import "../../chunk-BXZHMYMM.js";
|
|
14
14
|
import "../../chunk-MTHLLDCX.js";
|
|
15
15
|
import "../../chunk-QWQYAQCK.js";
|
|
@@ -100,6 +100,16 @@ export declare class BrowserOAuthClientProvider implements OAuthClientProvider {
|
|
|
100
100
|
codeVerifier(): Promise<string>;
|
|
101
101
|
saveCodeVerifier(codeVerifier: string): Promise<void>;
|
|
102
102
|
invalidateCredentials(scope: "all" | "client" | "tokens" | "verifier"): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Validate the protected resource discovered through the OAuth proxy.
|
|
105
|
+
*
|
|
106
|
+
* The proxy rewrites protected-resource metadata to the MCP connection URL
|
|
107
|
+
* so transport-anchored discovery remains valid. Manual authentication is
|
|
108
|
+
* anchored on the upstream MCP URL instead, so accept that rewrite and
|
|
109
|
+
* return the original upstream resource that the authorization server
|
|
110
|
+
* protects.
|
|
111
|
+
*/
|
|
112
|
+
validateResourceURL(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
|
|
103
113
|
/**
|
|
104
114
|
* Resolve this server's OAuth token endpoint (via discovery, cached). Lets
|
|
105
115
|
* consumers persist the endpoint alongside the tokens for server-side
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-provider.d.ts","sourceRoot":"","sources":["../../../src/auth/browser-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-provider.d.ts","sourceRoot":"","sources":["../../../src/auth/browser-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAKpF,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACZ,MAAM,0CAA0C,CAAC;AAkBlD,UAAU,mBAAmB;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,CACd,GAAG,EAAE,MAAM,EAC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;CAqCvB"}
|
package/dist/src/auth/index.cjs
CHANGED
|
@@ -30,6 +30,9 @@ __export(auth_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(auth_exports);
|
|
32
32
|
|
|
33
|
+
// src/auth/browser-provider.ts
|
|
34
|
+
var import_auth_utils = require("@modelcontextprotocol/sdk/shared/auth-utils.js");
|
|
35
|
+
|
|
33
36
|
// src/utils/url-sanitize.ts
|
|
34
37
|
function sanitizeUrl(raw) {
|
|
35
38
|
const abort = /* @__PURE__ */ __name(() => {
|
|
@@ -647,6 +650,43 @@ var BrowserOAuthClientProvider = class {
|
|
|
647
650
|
invalidateCredentials(scope) {
|
|
648
651
|
return this.session.invalidateCredentials(scope);
|
|
649
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* Validate the protected resource discovered through the OAuth proxy.
|
|
655
|
+
*
|
|
656
|
+
* The proxy rewrites protected-resource metadata to the MCP connection URL
|
|
657
|
+
* so transport-anchored discovery remains valid. Manual authentication is
|
|
658
|
+
* anchored on the upstream MCP URL instead, so accept that rewrite and
|
|
659
|
+
* return the original upstream resource that the authorization server
|
|
660
|
+
* protects.
|
|
661
|
+
*/
|
|
662
|
+
async validateResourceURL(serverUrl, resource) {
|
|
663
|
+
if (!resource) return void 0;
|
|
664
|
+
const requestedResource = (0, import_auth_utils.resourceUrlFromServerUrl)(serverUrl);
|
|
665
|
+
if ((0, import_auth_utils.checkResourceAllowed)({
|
|
666
|
+
requestedResource,
|
|
667
|
+
configuredResource: resource
|
|
668
|
+
})) {
|
|
669
|
+
return new URL(resource);
|
|
670
|
+
}
|
|
671
|
+
const isConnectionResource = this.connectionUrl && (0, import_auth_utils.checkResourceAllowed)({
|
|
672
|
+
requestedResource: (0, import_auth_utils.resourceUrlFromServerUrl)(this.connectionUrl),
|
|
673
|
+
configuredResource: resource
|
|
674
|
+
});
|
|
675
|
+
if (isConnectionResource) {
|
|
676
|
+
const upstreamResource = (0, import_auth_utils.resourceUrlFromServerUrl)(
|
|
677
|
+
this._lastOriginalResource ?? this.serverUrl
|
|
678
|
+
);
|
|
679
|
+
if ((0, import_auth_utils.checkResourceAllowed)({
|
|
680
|
+
requestedResource,
|
|
681
|
+
configuredResource: upstreamResource
|
|
682
|
+
})) {
|
|
683
|
+
return upstreamResource;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
throw new Error(
|
|
687
|
+
`Protected resource ${resource} does not match expected ${requestedResource} (or origin)`
|
|
688
|
+
);
|
|
689
|
+
}
|
|
650
690
|
/**
|
|
651
691
|
* Resolve this server's OAuth token endpoint (via discovery, cached). Lets
|
|
652
692
|
* consumers persist the endpoint alongside the tokens for server-side
|
package/dist/src/auth/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Telemetry,
|
|
8
8
|
extractModelInfo,
|
|
9
9
|
getPackageVersion
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-VSSL5DL7.js";
|
|
11
11
|
import {
|
|
12
12
|
logger
|
|
13
13
|
} from "../chunk-QWQYAQCK.js";
|
|
@@ -1671,7 +1671,7 @@ var MCPAgent = class {
|
|
|
1671
1671
|
logger.debug(
|
|
1672
1672
|
`Creating MCPClient with ${Object.keys(this.mcpServersConfig).length} server(s)...`
|
|
1673
1673
|
);
|
|
1674
|
-
const { MCPClient } = await import("../client-
|
|
1674
|
+
const { MCPClient } = await import("../client-A5GK5WZD.js");
|
|
1675
1675
|
this.client = new MCPClient({ mcpServers: this.mcpServersConfig });
|
|
1676
1676
|
logger.debug("\u2705 MCPClient created successfully");
|
|
1677
1677
|
}
|