mcp-use 0.2.0 → 0.3.0
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/chunk-2HFIPY7C.js +429 -0
- package/dist/chunk-4DEFXVWT.js +680 -0
- package/dist/chunk-JXLQRAW2.js +532 -0
- package/dist/chunk-SHUYVCID.js +6 -0
- package/dist/chunk-YUSC6R6V.js +299 -0
- package/dist/index.cjs +5762 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3767 -22
- package/dist/langfuse-YA2S23SM.js +13 -0
- package/dist/src/agents/remote.d.ts.map +1 -1
- package/dist/src/agents/utils/ai_sdk.d.ts.map +1 -1
- package/dist/src/auth/browser-provider.d.ts +52 -0
- package/dist/src/auth/browser-provider.d.ts.map +1 -0
- package/dist/src/auth/callback.d.ts +6 -0
- package/dist/src/auth/callback.d.ts.map +1 -0
- package/dist/src/auth/index.d.ts +7 -0
- package/dist/src/auth/index.d.ts.map +1 -0
- package/dist/src/auth/types.d.ts +18 -0
- package/dist/src/auth/types.d.ts.map +1 -0
- package/dist/src/browser.cjs +323 -0
- package/dist/src/browser.d.ts +5 -46
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +9 -75
- package/dist/src/oauth-helper.d.ts +2 -12
- package/dist/src/oauth-helper.d.ts.map +1 -1
- package/dist/src/react/index.cjs +986 -0
- package/dist/src/react/index.d.ts +9 -0
- package/dist/src/react/index.d.ts.map +1 -0
- package/dist/src/react/index.js +11 -0
- package/dist/src/react/types.d.ts +139 -0
- package/dist/src/react/types.d.ts.map +1 -0
- package/dist/src/react/useMcp.d.ts +3 -0
- package/dist/src/react/useMcp.d.ts.map +1 -0
- package/dist/src/server/index.cjs +566 -0
- package/dist/src/server/index.d.ts +3 -0
- package/dist/src/server/index.d.ts.map +1 -0
- package/dist/src/server/index.js +9 -0
- package/dist/src/server/logging.d.ts +16 -0
- package/dist/src/server/logging.d.ts.map +1 -0
- package/dist/src/server/mcp-server.d.ts +282 -0
- package/dist/src/server/mcp-server.d.ts.map +1 -0
- package/dist/src/server/types.d.ts +47 -0
- package/dist/src/server/types.d.ts.map +1 -0
- package/dist/src/utils/assert.d.ts +8 -0
- package/dist/src/utils/assert.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +67 -40
- package/dist/src/adapters/base.js +0 -124
- package/dist/src/adapters/index.js +0 -2
- package/dist/src/adapters/langchain_adapter.js +0 -49
- package/dist/src/agents/base.js +0 -9
- package/dist/src/agents/index.js +0 -3
- package/dist/src/agents/mcp_agent.js +0 -1002
- package/dist/src/agents/prompts/system_prompt_builder.js +0 -40
- package/dist/src/agents/prompts/templates.js +0 -39
- package/dist/src/agents/remote.js +0 -264
- package/dist/src/agents/utils/ai_sdk.js +0 -62
- package/dist/src/agents/utils/index.js +0 -1
- package/dist/src/client/base.js +0 -119
- package/dist/src/client.js +0 -50
- package/dist/src/config.js +0 -34
- package/dist/src/connectors/base.js +0 -143
- package/dist/src/connectors/http.js +0 -150
- package/dist/src/connectors/index.js +0 -4
- package/dist/src/connectors/stdio.js +0 -68
- package/dist/src/connectors/websocket.js +0 -157
- package/dist/src/logging.js +0 -232
- package/dist/src/managers/index.js +0 -2
- package/dist/src/managers/server_manager.js +0 -106
- package/dist/src/managers/tools/acquire_active_mcp_server.js +0 -17
- package/dist/src/managers/tools/add_server_from_config.js +0 -40
- package/dist/src/managers/tools/base.js +0 -17
- package/dist/src/managers/tools/connect_mcp_server.js +0 -46
- package/dist/src/managers/tools/index.js +0 -5
- package/dist/src/managers/tools/list_mcp_servers.js +0 -33
- package/dist/src/managers/tools/release_mcp_server_connection.js +0 -19
- package/dist/src/oauth-helper.js +0 -427
- package/dist/src/observability/index.js +0 -12
- package/dist/src/observability/langfuse.js +0 -211
- package/dist/src/observability/manager.js +0 -199
- package/dist/src/observability/types.js +0 -4
- package/dist/src/session.js +0 -23
- package/dist/src/task_managers/base.js +0 -127
- package/dist/src/task_managers/index.js +0 -5
- package/dist/src/task_managers/sse.js +0 -43
- package/dist/src/task_managers/stdio.js +0 -51
- package/dist/src/task_managers/streamable_http.js +0 -50
- package/dist/src/task_managers/websocket.js +0 -67
- package/dist/src/telemetry/events.js +0 -44
- package/dist/src/telemetry/index.js +0 -8
- package/dist/src/telemetry/telemetry.js +0 -324
- package/dist/src/telemetry/utils.js +0 -39
- package/dist/tests/ai_sdk_compatibility.test.js +0 -214
- package/dist/tests/stream_events.test.js +0 -307
- package/dist/tests/stream_events_simple.test.js +0 -179
- package/dist/vitest.config.js +0 -21
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../src/agents/remote.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAQpC,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,MAAM,CAAsB;gBAExB,OAAO,EAAE;QACnB,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;IAgBD,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,uBAAuB;YAoDjB,iBAAiB;IAmDlB,GAAG,CAAC,CAAC,GAAG,MAAM,EACzB,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,OAAO,EACzB,eAAe,CAAC,EAAE,WAAW,EAAE,EAC/B,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../../src/agents/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ErE;;;GAGG;AACH,wBAAuB,mBAAmB,CACxC,YAAY,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GACpD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CASpC;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAC5C,cAAc,CAAC,MAAM,CAAC,CAcxB;AAED;;;GAGG;AACH,wBAAuB,4BAA4B,CACjD,YAAY,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GACpD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,
|
1
|
+
{"version":3,"file":"ai_sdk.d.ts","sourceRoot":"","sources":["../../../../src/agents/utils/ai_sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAErE;;;GAGG;AACH,wBAAuB,mBAAmB,CACxC,YAAY,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GACpD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CASpC;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAC5C,cAAc,CAAC,MAAM,CAAC,CAcxB;AAED;;;GAGG;AACH,wBAAuB,4BAA4B,CACjD,YAAY,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GACpD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAwBpC"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import type { OAuthClientInformation, OAuthTokens, OAuthClientMetadata } from '@modelcontextprotocol/sdk/shared/auth.js';
|
2
|
+
import type { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
|
3
|
+
/**
|
4
|
+
* Browser-compatible OAuth client provider for MCP using localStorage.
|
5
|
+
*/
|
6
|
+
export declare class BrowserOAuthClientProvider implements OAuthClientProvider {
|
7
|
+
readonly serverUrl: string;
|
8
|
+
readonly storageKeyPrefix: string;
|
9
|
+
readonly serverUrlHash: string;
|
10
|
+
readonly clientName: string;
|
11
|
+
readonly clientUri: string;
|
12
|
+
readonly callbackUrl: string;
|
13
|
+
private preventAutoAuth?;
|
14
|
+
readonly onPopupWindow: ((url: string, features: string, window: globalThis.Window | null) => void) | undefined;
|
15
|
+
constructor(serverUrl: string, options?: {
|
16
|
+
storageKeyPrefix?: string;
|
17
|
+
clientName?: string;
|
18
|
+
clientUri?: string;
|
19
|
+
callbackUrl?: string;
|
20
|
+
preventAutoAuth?: boolean;
|
21
|
+
onPopupWindow?: (url: string, features: string, window: globalThis.Window | null) => void;
|
22
|
+
});
|
23
|
+
get redirectUrl(): string;
|
24
|
+
get clientMetadata(): OAuthClientMetadata;
|
25
|
+
clientInformation(): Promise<OAuthClientInformation | undefined>;
|
26
|
+
saveClientInformation(clientInformation: OAuthClientInformation): Promise<void>;
|
27
|
+
tokens(): Promise<OAuthTokens | undefined>;
|
28
|
+
saveTokens(tokens: OAuthTokens): Promise<void>;
|
29
|
+
saveCodeVerifier(codeVerifier: string): Promise<void>;
|
30
|
+
codeVerifier(): Promise<string>;
|
31
|
+
/**
|
32
|
+
* Generates and stores the authorization URL with state, without opening a popup.
|
33
|
+
* Used when preventAutoAuth is enabled to provide the URL for manual navigation.
|
34
|
+
* @param authorizationUrl The fully constructed authorization URL from the SDK.
|
35
|
+
* @returns The full authorization URL with state parameter.
|
36
|
+
*/
|
37
|
+
prepareAuthorizationUrl(authorizationUrl: URL): Promise<string>;
|
38
|
+
/**
|
39
|
+
* Redirects the user agent to the authorization URL, storing necessary state.
|
40
|
+
* This now adheres to the SDK's void return type expectation for the interface.
|
41
|
+
* @param authorizationUrl The fully constructed authorization URL from the SDK.
|
42
|
+
*/
|
43
|
+
redirectToAuthorization(authorizationUrl: URL): Promise<void>;
|
44
|
+
/**
|
45
|
+
* Retrieves the last URL passed to `redirectToAuthorization`. Useful for manual fallback.
|
46
|
+
*/
|
47
|
+
getLastAttemptedAuthUrl(): string | null;
|
48
|
+
clearStorage(): number;
|
49
|
+
private hashString;
|
50
|
+
getKey(keySuffix: string): string;
|
51
|
+
}
|
52
|
+
//# sourceMappingURL=browser-provider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"browser-provider.d.ts","sourceRoot":"","sources":["../../../src/auth/browser-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAA;AACxH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAA;AAKnF;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;gBAG7G,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;QACP,gBAAgB,CAAC,EAAE,MAAM,CAAA;QACzB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,OAAO,CAAA;QACzB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;KACrF;IAiBR,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,cAAc,IAAI,mBAAmB,CAUxC;IAEK,iBAAiB,IAAI,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAgBhE,qBAAqB,CAAC,iBAAiB,EAAE,sBAAsB,GAAsC,OAAO,CAAC,IAAI,CAAC;IAMlH,MAAM,IAAI,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAc1C,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9C,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrD,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAarC;;;;;OAKG;IACG,uBAAuB,CAAC,gBAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAiCrE;;;;OAIG;IACG,uBAAuB,CAAC,gBAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCnE;;OAEG;IACH,uBAAuB,IAAI,MAAM,GAAG,IAAI;IAKxC,YAAY,IAAI,MAAM;IAuCtB,OAAO,CAAC,UAAU;IAUlB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAGlC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../src/auth/callback.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAsB,kBAAkB,kBA4HvC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Authentication utilities for browser-based MCP OAuth
|
3
|
+
*/
|
4
|
+
export { BrowserOAuthClientProvider } from './browser-provider.js';
|
5
|
+
export { onMcpAuthorization } from './callback.js';
|
6
|
+
export type { StoredState } from './types.js';
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { OAuthMetadata } from '@modelcontextprotocol/sdk/shared/auth.js';
|
2
|
+
/**
|
3
|
+
* Internal type for storing OAuth state in localStorage during the popup flow.
|
4
|
+
* @internal
|
5
|
+
*/
|
6
|
+
export interface StoredState {
|
7
|
+
expiry: number;
|
8
|
+
metadata?: OAuthMetadata;
|
9
|
+
serverUrlHash: string;
|
10
|
+
providerOptions: {
|
11
|
+
serverUrl: string;
|
12
|
+
storageKeyPrefix: string;
|
13
|
+
clientName: string;
|
14
|
+
clientUri: string;
|
15
|
+
callbackUrl: string;
|
16
|
+
};
|
17
|
+
}
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAA;AAE7E;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;IAErB,eAAe,EAAE;QACf,SAAS,EAAE,MAAM,CAAA;QACjB,gBAAgB,EAAE,MAAM,CAAA;QACxB,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;CACF"}
|
@@ -0,0 +1,323 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20
|
+
|
21
|
+
// src/browser.ts
|
22
|
+
var browser_exports = {};
|
23
|
+
__export(browser_exports, {
|
24
|
+
BrowserOAuthClientProvider: () => BrowserOAuthClientProvider,
|
25
|
+
onMcpAuthorization: () => onMcpAuthorization
|
26
|
+
});
|
27
|
+
module.exports = __toCommonJS(browser_exports);
|
28
|
+
|
29
|
+
// src/auth/browser-provider.ts
|
30
|
+
var import_strict_url_sanitise = require("strict-url-sanitise");
|
31
|
+
var BrowserOAuthClientProvider = class {
|
32
|
+
static {
|
33
|
+
__name(this, "BrowserOAuthClientProvider");
|
34
|
+
}
|
35
|
+
serverUrl;
|
36
|
+
storageKeyPrefix;
|
37
|
+
serverUrlHash;
|
38
|
+
clientName;
|
39
|
+
clientUri;
|
40
|
+
callbackUrl;
|
41
|
+
preventAutoAuth;
|
42
|
+
onPopupWindow;
|
43
|
+
constructor(serverUrl, options = {}) {
|
44
|
+
this.serverUrl = serverUrl;
|
45
|
+
this.storageKeyPrefix = options.storageKeyPrefix || "mcp:auth";
|
46
|
+
this.serverUrlHash = this.hashString(serverUrl);
|
47
|
+
this.clientName = options.clientName || "MCP Browser Client";
|
48
|
+
this.clientUri = options.clientUri || (typeof window !== "undefined" ? window.location.origin : "");
|
49
|
+
this.callbackUrl = (0, import_strict_url_sanitise.sanitizeUrl)(
|
50
|
+
options.callbackUrl || (typeof window !== "undefined" ? new URL("/oauth/callback", window.location.origin).toString() : "/oauth/callback")
|
51
|
+
);
|
52
|
+
this.preventAutoAuth = options.preventAutoAuth;
|
53
|
+
this.onPopupWindow = options.onPopupWindow;
|
54
|
+
}
|
55
|
+
// --- SDK Interface Methods ---
|
56
|
+
get redirectUrl() {
|
57
|
+
return (0, import_strict_url_sanitise.sanitizeUrl)(this.callbackUrl);
|
58
|
+
}
|
59
|
+
get clientMetadata() {
|
60
|
+
return {
|
61
|
+
redirect_uris: [this.redirectUrl],
|
62
|
+
token_endpoint_auth_method: "none",
|
63
|
+
// Public client
|
64
|
+
grant_types: ["authorization_code", "refresh_token"],
|
65
|
+
response_types: ["code"],
|
66
|
+
client_name: this.clientName,
|
67
|
+
client_uri: this.clientUri
|
68
|
+
// scope: 'openid profile email mcp', // Example scopes, adjust as needed
|
69
|
+
};
|
70
|
+
}
|
71
|
+
async clientInformation() {
|
72
|
+
const key = this.getKey("client_info");
|
73
|
+
const data = localStorage.getItem(key);
|
74
|
+
if (!data) return void 0;
|
75
|
+
try {
|
76
|
+
return JSON.parse(data);
|
77
|
+
} catch (e) {
|
78
|
+
console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`, e);
|
79
|
+
localStorage.removeItem(key);
|
80
|
+
return void 0;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
// NOTE: The SDK's auth() function uses this if dynamic registration is needed.
|
84
|
+
// Ensure your OAuthClientInformationFull matches the expected structure if DCR is used.
|
85
|
+
async saveClientInformation(clientInformation) {
|
86
|
+
const key = this.getKey("client_info");
|
87
|
+
localStorage.setItem(key, JSON.stringify(clientInformation));
|
88
|
+
}
|
89
|
+
async tokens() {
|
90
|
+
const key = this.getKey("tokens");
|
91
|
+
const data = localStorage.getItem(key);
|
92
|
+
if (!data) return void 0;
|
93
|
+
try {
|
94
|
+
return JSON.parse(data);
|
95
|
+
} catch (e) {
|
96
|
+
console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`, e);
|
97
|
+
localStorage.removeItem(key);
|
98
|
+
return void 0;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
async saveTokens(tokens) {
|
102
|
+
const key = this.getKey("tokens");
|
103
|
+
localStorage.setItem(key, JSON.stringify(tokens));
|
104
|
+
localStorage.removeItem(this.getKey("code_verifier"));
|
105
|
+
localStorage.removeItem(this.getKey("last_auth_url"));
|
106
|
+
}
|
107
|
+
async saveCodeVerifier(codeVerifier) {
|
108
|
+
const key = this.getKey("code_verifier");
|
109
|
+
localStorage.setItem(key, codeVerifier);
|
110
|
+
}
|
111
|
+
async codeVerifier() {
|
112
|
+
const key = this.getKey("code_verifier");
|
113
|
+
const verifier = localStorage.getItem(key);
|
114
|
+
if (!verifier) {
|
115
|
+
throw new Error(
|
116
|
+
`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${key}. Auth flow likely corrupted or timed out.`
|
117
|
+
);
|
118
|
+
}
|
119
|
+
return verifier;
|
120
|
+
}
|
121
|
+
/**
|
122
|
+
* Generates and stores the authorization URL with state, without opening a popup.
|
123
|
+
* Used when preventAutoAuth is enabled to provide the URL for manual navigation.
|
124
|
+
* @param authorizationUrl The fully constructed authorization URL from the SDK.
|
125
|
+
* @returns The full authorization URL with state parameter.
|
126
|
+
*/
|
127
|
+
async prepareAuthorizationUrl(authorizationUrl) {
|
128
|
+
const state = globalThis.crypto.randomUUID();
|
129
|
+
const stateKey = `${this.storageKeyPrefix}:state_${state}`;
|
130
|
+
const stateData = {
|
131
|
+
serverUrlHash: this.serverUrlHash,
|
132
|
+
expiry: Date.now() + 1e3 * 60 * 10,
|
133
|
+
// State expires in 10 minutes
|
134
|
+
// Store provider options needed to reconstruct on callback
|
135
|
+
providerOptions: {
|
136
|
+
serverUrl: this.serverUrl,
|
137
|
+
storageKeyPrefix: this.storageKeyPrefix,
|
138
|
+
clientName: this.clientName,
|
139
|
+
clientUri: this.clientUri,
|
140
|
+
callbackUrl: this.callbackUrl
|
141
|
+
}
|
142
|
+
};
|
143
|
+
localStorage.setItem(stateKey, JSON.stringify(stateData));
|
144
|
+
authorizationUrl.searchParams.set("state", state);
|
145
|
+
const authUrlString = authorizationUrl.toString();
|
146
|
+
const sanitizedAuthUrl = (0, import_strict_url_sanitise.sanitizeUrl)(authUrlString);
|
147
|
+
localStorage.setItem(this.getKey("last_auth_url"), sanitizedAuthUrl);
|
148
|
+
return sanitizedAuthUrl;
|
149
|
+
}
|
150
|
+
/**
|
151
|
+
* Redirects the user agent to the authorization URL, storing necessary state.
|
152
|
+
* This now adheres to the SDK's void return type expectation for the interface.
|
153
|
+
* @param authorizationUrl The fully constructed authorization URL from the SDK.
|
154
|
+
*/
|
155
|
+
async redirectToAuthorization(authorizationUrl) {
|
156
|
+
if (this.preventAutoAuth) return;
|
157
|
+
const sanitizedAuthUrl = await this.prepareAuthorizationUrl(authorizationUrl);
|
158
|
+
const popupFeatures = "width=600,height=700,resizable=yes,scrollbars=yes,status=yes";
|
159
|
+
try {
|
160
|
+
const popup = window.open(sanitizedAuthUrl, `mcp_auth_${this.serverUrlHash}`, popupFeatures);
|
161
|
+
if (this.onPopupWindow) {
|
162
|
+
this.onPopupWindow(sanitizedAuthUrl, popupFeatures, popup);
|
163
|
+
}
|
164
|
+
if (!popup || popup.closed || typeof popup.closed === "undefined") {
|
165
|
+
console.warn(
|
166
|
+
`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`
|
167
|
+
);
|
168
|
+
} else {
|
169
|
+
popup.focus();
|
170
|
+
console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`);
|
171
|
+
}
|
172
|
+
} catch (e) {
|
173
|
+
console.error(`[${this.storageKeyPrefix}] Error opening popup window:`, e);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
// --- Helper Methods ---
|
177
|
+
/**
|
178
|
+
* Retrieves the last URL passed to `redirectToAuthorization`. Useful for manual fallback.
|
179
|
+
*/
|
180
|
+
getLastAttemptedAuthUrl() {
|
181
|
+
const storedUrl = localStorage.getItem(this.getKey("last_auth_url"));
|
182
|
+
return storedUrl ? (0, import_strict_url_sanitise.sanitizeUrl)(storedUrl) : null;
|
183
|
+
}
|
184
|
+
clearStorage() {
|
185
|
+
const prefixPattern = `${this.storageKeyPrefix}_${this.serverUrlHash}_`;
|
186
|
+
const statePattern = `${this.storageKeyPrefix}:state_`;
|
187
|
+
const keysToRemove = [];
|
188
|
+
let count = 0;
|
189
|
+
for (let i = 0; i < localStorage.length; i++) {
|
190
|
+
const key = localStorage.key(i);
|
191
|
+
if (!key) continue;
|
192
|
+
if (key.startsWith(prefixPattern)) {
|
193
|
+
keysToRemove.push(key);
|
194
|
+
} else if (key.startsWith(statePattern)) {
|
195
|
+
try {
|
196
|
+
const item = localStorage.getItem(key);
|
197
|
+
if (item) {
|
198
|
+
const state = JSON.parse(item);
|
199
|
+
if (state.serverUrlHash === this.serverUrlHash) {
|
200
|
+
keysToRemove.push(key);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
} catch (e) {
|
204
|
+
console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${key} during clearStorage:`, e);
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
const uniqueKeysToRemove = [...new Set(keysToRemove)];
|
209
|
+
uniqueKeysToRemove.forEach((key) => {
|
210
|
+
localStorage.removeItem(key);
|
211
|
+
count++;
|
212
|
+
});
|
213
|
+
return count;
|
214
|
+
}
|
215
|
+
hashString(str) {
|
216
|
+
let hash = 0;
|
217
|
+
for (let i = 0; i < str.length; i++) {
|
218
|
+
const char = str.charCodeAt(i);
|
219
|
+
hash = (hash << 5) - hash + char;
|
220
|
+
hash = hash & hash;
|
221
|
+
}
|
222
|
+
return Math.abs(hash).toString(16);
|
223
|
+
}
|
224
|
+
getKey(keySuffix) {
|
225
|
+
return `${this.storageKeyPrefix}_${this.serverUrlHash}_${keySuffix}`;
|
226
|
+
}
|
227
|
+
};
|
228
|
+
|
229
|
+
// src/auth/callback.ts
|
230
|
+
var import_auth = require("@modelcontextprotocol/sdk/client/auth.js");
|
231
|
+
async function onMcpAuthorization() {
|
232
|
+
const queryParams = new URLSearchParams(window.location.search);
|
233
|
+
const code = queryParams.get("code");
|
234
|
+
const state = queryParams.get("state");
|
235
|
+
const error = queryParams.get("error");
|
236
|
+
const errorDescription = queryParams.get("error_description");
|
237
|
+
const logPrefix = "[mcp-callback]";
|
238
|
+
console.log(`${logPrefix} Handling callback...`, { code, state, error, errorDescription });
|
239
|
+
let provider = null;
|
240
|
+
let storedStateData = null;
|
241
|
+
const stateKey = state ? `mcp:auth:state_${state}` : null;
|
242
|
+
try {
|
243
|
+
if (error) {
|
244
|
+
throw new Error(`OAuth error: ${error} - ${errorDescription || "No description provided."}`);
|
245
|
+
}
|
246
|
+
if (!code) {
|
247
|
+
throw new Error("Authorization code not found in callback query parameters.");
|
248
|
+
}
|
249
|
+
if (!state || !stateKey) {
|
250
|
+
throw new Error("State parameter not found or invalid in callback query parameters.");
|
251
|
+
}
|
252
|
+
const storedStateJSON = localStorage.getItem(stateKey);
|
253
|
+
if (!storedStateJSON) {
|
254
|
+
throw new Error(`Invalid or expired state parameter "${state}". No matching state found in storage.`);
|
255
|
+
}
|
256
|
+
try {
|
257
|
+
storedStateData = JSON.parse(storedStateJSON);
|
258
|
+
} catch (e) {
|
259
|
+
throw new Error("Failed to parse stored OAuth state.");
|
260
|
+
}
|
261
|
+
if (!storedStateData.expiry || storedStateData.expiry < Date.now()) {
|
262
|
+
localStorage.removeItem(stateKey);
|
263
|
+
throw new Error("OAuth state has expired. Please try initiating authentication again.");
|
264
|
+
}
|
265
|
+
if (!storedStateData.providerOptions) {
|
266
|
+
throw new Error("Stored state is missing required provider options.");
|
267
|
+
}
|
268
|
+
const { serverUrl, ...providerOptions } = storedStateData.providerOptions;
|
269
|
+
console.log(`${logPrefix} Re-instantiating provider for server: ${serverUrl}`);
|
270
|
+
provider = new BrowserOAuthClientProvider(serverUrl, providerOptions);
|
271
|
+
console.log(`${logPrefix} Calling SDK auth() to exchange code...`);
|
272
|
+
const authResult = await (0, import_auth.auth)(provider, { serverUrl, authorizationCode: code });
|
273
|
+
if (authResult === "AUTHORIZED") {
|
274
|
+
console.log(`${logPrefix} Authorization successful via SDK auth(). Notifying opener...`);
|
275
|
+
if (window.opener && !window.opener.closed) {
|
276
|
+
window.opener.postMessage({ type: "mcp_auth_callback", success: true }, window.location.origin);
|
277
|
+
window.close();
|
278
|
+
} else {
|
279
|
+
console.warn(`${logPrefix} No opener window detected. Redirecting to root.`);
|
280
|
+
const pathParts = window.location.pathname.split("/").filter(Boolean);
|
281
|
+
const basePath = pathParts.length > 0 && pathParts[pathParts.length - 1] === "callback" ? "/" + pathParts.slice(0, -2).join("/") : "/";
|
282
|
+
window.location.href = basePath || "/";
|
283
|
+
}
|
284
|
+
localStorage.removeItem(stateKey);
|
285
|
+
} else {
|
286
|
+
console.warn(`${logPrefix} SDK auth() returned unexpected status: ${authResult}`);
|
287
|
+
throw new Error(`Unexpected result from authentication library: ${authResult}`);
|
288
|
+
}
|
289
|
+
} catch (err) {
|
290
|
+
console.error(`${logPrefix} Error during OAuth callback handling:`, err);
|
291
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
292
|
+
if (window.opener && !window.opener.closed) {
|
293
|
+
window.opener.postMessage({ type: "mcp_auth_callback", success: false, error: errorMessage }, window.location.origin);
|
294
|
+
}
|
295
|
+
try {
|
296
|
+
document.body.innerHTML = `
|
297
|
+
<div style="font-family: sans-serif; padding: 20px;">
|
298
|
+
<h1>Authentication Error</h1>
|
299
|
+
<p style="color: red; background-color: #ffebeb; border: 1px solid red; padding: 10px; border-radius: 4px;">
|
300
|
+
${errorMessage}
|
301
|
+
</p>
|
302
|
+
<p>You can close this window or <a href="#" onclick="window.close(); return false;">click here to close</a>.</p>
|
303
|
+
<pre style="font-size: 0.8em; color: #555; margin-top: 20px; white-space: pre-wrap;">${err instanceof Error ? err.stack : ""}</pre>
|
304
|
+
</div>
|
305
|
+
`;
|
306
|
+
} catch (displayError) {
|
307
|
+
console.error(`${logPrefix} Could not display error in callback window:`, displayError);
|
308
|
+
}
|
309
|
+
if (stateKey) {
|
310
|
+
localStorage.removeItem(stateKey);
|
311
|
+
}
|
312
|
+
if (provider) {
|
313
|
+
localStorage.removeItem(provider.getKey("code_verifier"));
|
314
|
+
localStorage.removeItem(provider.getKey("last_auth_url"));
|
315
|
+
}
|
316
|
+
}
|
317
|
+
}
|
318
|
+
__name(onMcpAuthorization, "onMcpAuthorization");
|
319
|
+
// Annotate the CommonJS export names for ESM import in node:
|
320
|
+
0 && (module.exports = {
|
321
|
+
BrowserOAuthClientProvider,
|
322
|
+
onMcpAuthorization
|
323
|
+
});
|
package/dist/src/browser.d.ts
CHANGED
@@ -1,49 +1,8 @@
|
|
1
1
|
/**
|
2
|
-
* Browser-
|
3
|
-
*
|
4
|
-
* This module provides browser-safe versions of mcp-use components
|
5
|
-
* that avoid Node.js-specific dependencies (like fs, path for file operations).
|
6
|
-
*
|
7
|
-
* The actual MCP protocol connectors (WebSocket, HTTP/SSE) work fine in browsers.
|
2
|
+
* Browser entry point - exports OAuth utilities for browser-based MCP usage
|
8
3
|
*/
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
import { logger } from './logging.js';
|
14
|
-
import { MCPSession } from './session.js';
|
15
|
-
/**
|
16
|
-
* Browser-compatible MCP Client
|
17
|
-
*
|
18
|
-
* Unlike the Node.js version, this doesn't support:
|
19
|
-
* - Loading config from files (loadConfigFile)
|
20
|
-
* - Saving config to files (saveConfig)
|
21
|
-
* - StdioConnector (requires child_process)
|
22
|
-
*
|
23
|
-
* Supported connectors:
|
24
|
-
* - WebSocketConnector: Connect to MCP servers via WebSocket
|
25
|
-
* - HttpConnector: Connect to MCP servers via HTTP/SSE
|
26
|
-
*/
|
27
|
-
export declare class MCPClient extends BaseMCPClient {
|
28
|
-
constructor(config?: Record<string, any>);
|
29
|
-
static fromDict(cfg: Record<string, any>): MCPClient;
|
30
|
-
/**
|
31
|
-
* Create a connector from server configuration (browser-safe version)
|
32
|
-
*
|
33
|
-
* Supports:
|
34
|
-
* - WebSocket connections: { ws_url: "ws://..." }
|
35
|
-
* - HTTP connections: { url: "http://..." }
|
36
|
-
*
|
37
|
-
* Does NOT support:
|
38
|
-
* - Stdio connections: { command: "...", args: [...] }
|
39
|
-
*/
|
40
|
-
protected createConnectorFromConfig(serverConfig: Record<string, any>): BaseConnector;
|
41
|
-
}
|
42
|
-
export { HttpConnector, WebSocketConnector };
|
43
|
-
export { MCPSession };
|
44
|
-
export { logger };
|
45
|
-
export { createOAuthMCPConfig, LINEAR_OAUTH_CONFIG, OAuthHelper } from './oauth-helper.js';
|
46
|
-
export type { ClientRegistration, OAuthConfig, OAuthDiscovery, OAuthResult, OAuthState } from './oauth-helper.js';
|
47
|
-
export type { AIMessage, BaseMessage, HumanMessage, SystemMessage, ToolMessage } from '@langchain/core/messages';
|
48
|
-
export type { StreamEvent } from '@langchain/core/tracers/log_stream';
|
4
|
+
export { BrowserOAuthClientProvider } from './auth/browser-provider.js';
|
5
|
+
export { onMcpAuthorization } from './auth/callback.js';
|
6
|
+
export type { StoredState } from './auth/types.js';
|
7
|
+
export type { OAuthClientInformation, OAuthMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
49
8
|
//# sourceMappingURL=browser.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA"}
|
package/dist/src/browser.js
CHANGED
@@ -1,75 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
import { HttpConnector } from './connectors/http.js';
|
11
|
-
import { WebSocketConnector } from './connectors/websocket.js';
|
12
|
-
import { logger } from './logging.js';
|
13
|
-
import { MCPSession } from './session.js';
|
14
|
-
/**
|
15
|
-
* Browser-compatible MCP Client
|
16
|
-
*
|
17
|
-
* Unlike the Node.js version, this doesn't support:
|
18
|
-
* - Loading config from files (loadConfigFile)
|
19
|
-
* - Saving config to files (saveConfig)
|
20
|
-
* - StdioConnector (requires child_process)
|
21
|
-
*
|
22
|
-
* Supported connectors:
|
23
|
-
* - WebSocketConnector: Connect to MCP servers via WebSocket
|
24
|
-
* - HttpConnector: Connect to MCP servers via HTTP/SSE
|
25
|
-
*/
|
26
|
-
export class MCPClient extends BaseMCPClient {
|
27
|
-
constructor(config) {
|
28
|
-
super(config);
|
29
|
-
}
|
30
|
-
static fromDict(cfg) {
|
31
|
-
return new MCPClient(cfg);
|
32
|
-
}
|
33
|
-
/**
|
34
|
-
* Create a connector from server configuration (browser-safe version)
|
35
|
-
*
|
36
|
-
* Supports:
|
37
|
-
* - WebSocket connections: { ws_url: "ws://..." }
|
38
|
-
* - HTTP connections: { url: "http://..." }
|
39
|
-
*
|
40
|
-
* Does NOT support:
|
41
|
-
* - Stdio connections: { command: "...", args: [...] }
|
42
|
-
*/
|
43
|
-
createConnectorFromConfig(serverConfig) {
|
44
|
-
// WebSocket connector
|
45
|
-
if ('ws_url' in serverConfig) {
|
46
|
-
return new WebSocketConnector(serverConfig.ws_url, {
|
47
|
-
headers: serverConfig.headers,
|
48
|
-
authToken: serverConfig.auth_token || serverConfig.authToken,
|
49
|
-
});
|
50
|
-
}
|
51
|
-
// HTTP/SSE connector
|
52
|
-
if ('url' in serverConfig) {
|
53
|
-
const transport = serverConfig.transport || 'http';
|
54
|
-
return new HttpConnector(serverConfig.url, {
|
55
|
-
headers: serverConfig.headers,
|
56
|
-
authToken: serverConfig.auth_token || serverConfig.authToken,
|
57
|
-
preferSse: serverConfig.preferSse || transport === 'sse',
|
58
|
-
});
|
59
|
-
}
|
60
|
-
// Stdio is not supported in browser
|
61
|
-
if ('command' in serverConfig && 'args' in serverConfig) {
|
62
|
-
throw new Error('StdioConnector is not supported in browser environments. '
|
63
|
-
+ 'Use WebSocket (ws_url) or HTTP (url) connectors instead.');
|
64
|
-
}
|
65
|
-
throw new Error('Cannot determine connector type from config. Use "url" for HTTP or "ws_url" for WebSocket.');
|
66
|
-
}
|
67
|
-
}
|
68
|
-
// Re-export browser-safe connectors
|
69
|
-
export { HttpConnector, WebSocketConnector };
|
70
|
-
// Re-export session
|
71
|
-
export { MCPSession };
|
72
|
-
// Re-export logger (already browser-safe)
|
73
|
-
export { logger };
|
74
|
-
// Re-export OAuth helper for browser authentication
|
75
|
-
export { createOAuthMCPConfig, LINEAR_OAUTH_CONFIG, OAuthHelper } from './oauth-helper.js';
|
1
|
+
import {
|
2
|
+
BrowserOAuthClientProvider,
|
3
|
+
onMcpAuthorization
|
4
|
+
} from "../chunk-YUSC6R6V.js";
|
5
|
+
import "../chunk-SHUYVCID.js";
|
6
|
+
export {
|
7
|
+
BrowserOAuthClientProvider,
|
8
|
+
onMcpAuthorization
|
9
|
+
};
|
@@ -49,21 +49,11 @@ export declare class OAuthHelper {
|
|
49
49
|
private discovery?;
|
50
50
|
private state;
|
51
51
|
private clientRegistration?;
|
52
|
-
private serverUrl?;
|
53
|
-
private storageKey;
|
54
52
|
constructor(config: OAuthConfig);
|
55
53
|
/**
|
56
54
|
* Get current OAuth state
|
57
55
|
*/
|
58
56
|
getState(): OAuthState;
|
59
|
-
/**
|
60
|
-
* Load client registration from localStorage
|
61
|
-
*/
|
62
|
-
private loadClientRegistration;
|
63
|
-
/**
|
64
|
-
* Save client registration to localStorage
|
65
|
-
*/
|
66
|
-
private saveClientRegistration;
|
67
57
|
/**
|
68
58
|
* Check if a server requires authentication by pinging the URL
|
69
59
|
*/
|
@@ -75,11 +65,11 @@ export declare class OAuthHelper {
|
|
75
65
|
/**
|
76
66
|
* Discover OAuth configuration from a server
|
77
67
|
*/
|
78
|
-
discoverOAuthConfig(serverUrl: string): Promise<OAuthDiscovery>;
|
68
|
+
discoverOAuthConfig(serverUrl: string): Promise<OAuthDiscovery | undefined>;
|
79
69
|
/**
|
80
70
|
* Register a new OAuth client dynamically
|
81
71
|
*/
|
82
|
-
registerClient(
|
72
|
+
registerClient(_serverUrl: string): Promise<ClientRegistration>;
|
83
73
|
/**
|
84
74
|
* Generate authorization URL for OAuth flow
|
85
75
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oauth-helper.d.ts","sourceRoot":"","sources":["../../src/oauth-helper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,sBAAsB,EAAE,MAAM,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA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