mcp-use 1.5.0-canary.1 → 1.5.0-canary.2
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-5XVM4A23.js → chunk-GPAOZN2F.js} +13 -3
- package/dist/{chunk-GRLCLVAK.js → chunk-UT7O4SIJ.js} +14 -4
- package/dist/index.cjs +26 -6
- package/dist/index.js +2 -2
- package/dist/src/browser.cjs +14 -4
- package/dist/src/browser.js +1 -1
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/connectors/base.d.ts +5 -0
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/connectors/http.d.ts.map +1 -1
- package/dist/src/react/index.cjs +26 -6
- package/dist/src/react/index.js +2 -2
- package/dist/src/react/types.d.ts +2 -0
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrowserMCPClient,
|
|
3
3
|
BrowserOAuthClientProvider
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UT7O4SIJ.js";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -42,8 +42,9 @@ function useMcp(options) {
|
|
|
42
42
|
onPopupWindow,
|
|
43
43
|
timeout = 3e4,
|
|
44
44
|
// 30 seconds default for connection timeout
|
|
45
|
-
sseReadTimeout = 3e5
|
|
45
|
+
sseReadTimeout = 3e5,
|
|
46
46
|
// 5 minutes default for SSE read timeout
|
|
47
|
+
wrapTransport
|
|
47
48
|
} = options;
|
|
48
49
|
const [state, setState] = useState("discovering");
|
|
49
50
|
const [tools, setTools] = useState([]);
|
|
@@ -194,8 +195,17 @@ function useMcp(options) {
|
|
|
194
195
|
}
|
|
195
196
|
clientRef.current.addServer(serverName, {
|
|
196
197
|
...serverConfig,
|
|
197
|
-
authProvider: authProviderRef.current
|
|
198
|
+
authProvider: authProviderRef.current,
|
|
198
199
|
// ← SDK handles OAuth automatically!
|
|
200
|
+
wrapTransport: wrapTransport ? (transport) => {
|
|
201
|
+
console.log(
|
|
202
|
+
"[useMcp] Applying transport wrapper for server:",
|
|
203
|
+
serverName,
|
|
204
|
+
"url:",
|
|
205
|
+
url
|
|
206
|
+
);
|
|
207
|
+
return wrapTransport(transport, url);
|
|
208
|
+
} : void 0
|
|
199
209
|
});
|
|
200
210
|
const session = await clientRef.current.createSession(serverName);
|
|
201
211
|
await session.initialize();
|
|
@@ -371,7 +371,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
371
371
|
maxRetries: 2
|
|
372
372
|
}
|
|
373
373
|
});
|
|
374
|
-
|
|
374
|
+
let transport = await this.connectionManager.start();
|
|
375
|
+
if (this.opts.wrapTransport) {
|
|
376
|
+
const serverId = this.baseUrl;
|
|
377
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
378
|
+
}
|
|
375
379
|
this.client = new Client(this.clientInfo, this.opts.clientOptions);
|
|
376
380
|
try {
|
|
377
381
|
await this.client.connect(transport);
|
|
@@ -405,7 +409,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
405
409
|
headers: this.headers
|
|
406
410
|
}
|
|
407
411
|
});
|
|
408
|
-
|
|
412
|
+
let transport = await this.connectionManager.start();
|
|
413
|
+
if (this.opts.wrapTransport) {
|
|
414
|
+
const serverId = this.baseUrl;
|
|
415
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
416
|
+
}
|
|
409
417
|
this.client = new Client(this.clientInfo, this.opts.clientOptions);
|
|
410
418
|
await this.client.connect(transport);
|
|
411
419
|
this.connected = true;
|
|
@@ -1140,15 +1148,17 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
1140
1148
|
* Supports HTTP and WebSocket connectors only
|
|
1141
1149
|
*/
|
|
1142
1150
|
createConnectorFromConfig(serverConfig) {
|
|
1143
|
-
const { url, transport, headers, authToken, authProvider } = serverConfig;
|
|
1151
|
+
const { url, transport, headers, authToken, authProvider, wrapTransport } = serverConfig;
|
|
1144
1152
|
if (!url) {
|
|
1145
1153
|
throw new Error("Server URL is required");
|
|
1146
1154
|
}
|
|
1147
1155
|
const connectorOptions = {
|
|
1148
1156
|
headers,
|
|
1149
1157
|
authToken,
|
|
1150
|
-
authProvider
|
|
1158
|
+
authProvider,
|
|
1151
1159
|
// ← Pass OAuth provider to connector
|
|
1160
|
+
wrapTransport
|
|
1161
|
+
// ← Pass transport wrapper if provided
|
|
1152
1162
|
};
|
|
1153
1163
|
if (transport === "websocket" || url.startsWith("ws://") || url.startsWith("wss://")) {
|
|
1154
1164
|
return new WebSocketConnector(url, connectorOptions);
|
package/dist/index.cjs
CHANGED
|
@@ -5443,7 +5443,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
5443
5443
|
maxRetries: 2
|
|
5444
5444
|
}
|
|
5445
5445
|
});
|
|
5446
|
-
|
|
5446
|
+
let transport = await this.connectionManager.start();
|
|
5447
|
+
if (this.opts.wrapTransport) {
|
|
5448
|
+
const serverId = this.baseUrl;
|
|
5449
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
5450
|
+
}
|
|
5447
5451
|
this.client = new import_client.Client(this.clientInfo, this.opts.clientOptions);
|
|
5448
5452
|
try {
|
|
5449
5453
|
await this.client.connect(transport);
|
|
@@ -5477,7 +5481,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
5477
5481
|
headers: this.headers
|
|
5478
5482
|
}
|
|
5479
5483
|
});
|
|
5480
|
-
|
|
5484
|
+
let transport = await this.connectionManager.start();
|
|
5485
|
+
if (this.opts.wrapTransport) {
|
|
5486
|
+
const serverId = this.baseUrl;
|
|
5487
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
5488
|
+
}
|
|
5481
5489
|
this.client = new import_client.Client(this.clientInfo, this.opts.clientOptions);
|
|
5482
5490
|
await this.client.connect(transport);
|
|
5483
5491
|
this.connected = true;
|
|
@@ -6900,15 +6908,17 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
6900
6908
|
* Supports HTTP and WebSocket connectors only
|
|
6901
6909
|
*/
|
|
6902
6910
|
createConnectorFromConfig(serverConfig) {
|
|
6903
|
-
const { url, transport, headers, authToken, authProvider } = serverConfig;
|
|
6911
|
+
const { url, transport, headers, authToken, authProvider, wrapTransport } = serverConfig;
|
|
6904
6912
|
if (!url) {
|
|
6905
6913
|
throw new Error("Server URL is required");
|
|
6906
6914
|
}
|
|
6907
6915
|
const connectorOptions = {
|
|
6908
6916
|
headers,
|
|
6909
6917
|
authToken,
|
|
6910
|
-
authProvider
|
|
6918
|
+
authProvider,
|
|
6911
6919
|
// ← Pass OAuth provider to connector
|
|
6920
|
+
wrapTransport
|
|
6921
|
+
// ← Pass transport wrapper if provided
|
|
6912
6922
|
};
|
|
6913
6923
|
if (transport === "websocket" || url.startsWith("ws://") || url.startsWith("wss://")) {
|
|
6914
6924
|
return new WebSocketConnector(url, connectorOptions);
|
|
@@ -6952,8 +6962,9 @@ function useMcp(options) {
|
|
|
6952
6962
|
onPopupWindow,
|
|
6953
6963
|
timeout = 3e4,
|
|
6954
6964
|
// 30 seconds default for connection timeout
|
|
6955
|
-
sseReadTimeout = 3e5
|
|
6965
|
+
sseReadTimeout = 3e5,
|
|
6956
6966
|
// 5 minutes default for SSE read timeout
|
|
6967
|
+
wrapTransport
|
|
6957
6968
|
} = options;
|
|
6958
6969
|
const [state, setState] = (0, import_react.useState)("discovering");
|
|
6959
6970
|
const [tools, setTools] = (0, import_react.useState)([]);
|
|
@@ -7104,8 +7115,17 @@ function useMcp(options) {
|
|
|
7104
7115
|
}
|
|
7105
7116
|
clientRef.current.addServer(serverName, {
|
|
7106
7117
|
...serverConfig,
|
|
7107
|
-
authProvider: authProviderRef.current
|
|
7118
|
+
authProvider: authProviderRef.current,
|
|
7108
7119
|
// ← SDK handles OAuth automatically!
|
|
7120
|
+
wrapTransport: wrapTransport ? (transport) => {
|
|
7121
|
+
console.log(
|
|
7122
|
+
"[useMcp] Applying transport wrapper for server:",
|
|
7123
|
+
serverName,
|
|
7124
|
+
"url:",
|
|
7125
|
+
url
|
|
7126
|
+
);
|
|
7127
|
+
return wrapTransport(transport, url);
|
|
7128
|
+
} : void 0
|
|
7109
7129
|
});
|
|
7110
7130
|
const session = await clientRef.current.createSession(serverName);
|
|
7111
7131
|
await session.initialize();
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
useWidgetProps,
|
|
35
35
|
useWidgetState,
|
|
36
36
|
useWidgetTheme
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-GPAOZN2F.js";
|
|
38
38
|
import {
|
|
39
39
|
BaseMCPClient,
|
|
40
40
|
BrowserOAuthClientProvider,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
MCPSession,
|
|
44
44
|
WebSocketConnector,
|
|
45
45
|
onMcpAuthorization
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-UT7O4SIJ.js";
|
|
47
47
|
import {
|
|
48
48
|
BaseConnector
|
|
49
49
|
} from "./chunk-DSBKVAWD.js";
|
package/dist/src/browser.cjs
CHANGED
|
@@ -1600,7 +1600,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1600
1600
|
maxRetries: 2
|
|
1601
1601
|
}
|
|
1602
1602
|
});
|
|
1603
|
-
|
|
1603
|
+
let transport = await this.connectionManager.start();
|
|
1604
|
+
if (this.opts.wrapTransport) {
|
|
1605
|
+
const serverId = this.baseUrl;
|
|
1606
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
1607
|
+
}
|
|
1604
1608
|
this.client = new import_client.Client(this.clientInfo, this.opts.clientOptions);
|
|
1605
1609
|
try {
|
|
1606
1610
|
await this.client.connect(transport);
|
|
@@ -1634,7 +1638,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1634
1638
|
headers: this.headers
|
|
1635
1639
|
}
|
|
1636
1640
|
});
|
|
1637
|
-
|
|
1641
|
+
let transport = await this.connectionManager.start();
|
|
1642
|
+
if (this.opts.wrapTransport) {
|
|
1643
|
+
const serverId = this.baseUrl;
|
|
1644
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
1645
|
+
}
|
|
1638
1646
|
this.client = new import_client.Client(this.clientInfo, this.opts.clientOptions);
|
|
1639
1647
|
await this.client.connect(transport);
|
|
1640
1648
|
this.connected = true;
|
|
@@ -2058,15 +2066,17 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
2058
2066
|
* Supports HTTP and WebSocket connectors only
|
|
2059
2067
|
*/
|
|
2060
2068
|
createConnectorFromConfig(serverConfig) {
|
|
2061
|
-
const { url, transport, headers, authToken, authProvider } = serverConfig;
|
|
2069
|
+
const { url, transport, headers, authToken, authProvider, wrapTransport } = serverConfig;
|
|
2062
2070
|
if (!url) {
|
|
2063
2071
|
throw new Error("Server URL is required");
|
|
2064
2072
|
}
|
|
2065
2073
|
const connectorOptions = {
|
|
2066
2074
|
headers,
|
|
2067
2075
|
authToken,
|
|
2068
|
-
authProvider
|
|
2076
|
+
authProvider,
|
|
2069
2077
|
// ← Pass OAuth provider to connector
|
|
2078
|
+
wrapTransport
|
|
2079
|
+
// ← Pass transport wrapper if provided
|
|
2070
2080
|
};
|
|
2071
2081
|
if (transport === "websocket" || url.startsWith("ws://") || url.startsWith("wss://")) {
|
|
2072
2082
|
return new WebSocketConnector(url, connectorOptions);
|
package/dist/src/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;gBACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAI1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;gBACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAI1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;CAkCjB"}
|
|
@@ -16,6 +16,11 @@ export interface ConnectorInitOptions {
|
|
|
16
16
|
* OAuth client provider for automatic authentication
|
|
17
17
|
*/
|
|
18
18
|
authProvider?: any;
|
|
19
|
+
/**
|
|
20
|
+
* Optional callback to wrap the transport before passing it to the Client.
|
|
21
|
+
* Useful for logging, monitoring, or other transport-level interceptors.
|
|
22
|
+
*/
|
|
23
|
+
wrapTransport?: (transport: any, serverId: string) => any;
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* Base class for MCP connectors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/connectors/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,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O,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,aAAa,CAA0C;gBAEnD,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,oBAAyB;IAkB5D,mFAAmF;IAC7E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YA6GhB,yBAAyB;YA6DzB,cAAc;IAkC5B,IAAI,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM7C;IAED;;OAEG;IACH,gBAAgB,IAAI,iBAAiB,GAAG,KAAK,GAAG,IAAI;CAGrD"}
|
package/dist/src/react/index.cjs
CHANGED
|
@@ -908,7 +908,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
908
908
|
maxRetries: 2
|
|
909
909
|
}
|
|
910
910
|
});
|
|
911
|
-
|
|
911
|
+
let transport = await this.connectionManager.start();
|
|
912
|
+
if (this.opts.wrapTransport) {
|
|
913
|
+
const serverId = this.baseUrl;
|
|
914
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
915
|
+
}
|
|
912
916
|
this.client = new import_client.Client(this.clientInfo, this.opts.clientOptions);
|
|
913
917
|
try {
|
|
914
918
|
await this.client.connect(transport);
|
|
@@ -942,7 +946,11 @@ var HttpConnector = class extends BaseConnector {
|
|
|
942
946
|
headers: this.headers
|
|
943
947
|
}
|
|
944
948
|
});
|
|
945
|
-
|
|
949
|
+
let transport = await this.connectionManager.start();
|
|
950
|
+
if (this.opts.wrapTransport) {
|
|
951
|
+
const serverId = this.baseUrl;
|
|
952
|
+
transport = this.opts.wrapTransport(transport, serverId);
|
|
953
|
+
}
|
|
946
954
|
this.client = new import_client.Client(this.clientInfo, this.opts.clientOptions);
|
|
947
955
|
await this.client.connect(transport);
|
|
948
956
|
this.connected = true;
|
|
@@ -1361,15 +1369,17 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
1361
1369
|
* Supports HTTP and WebSocket connectors only
|
|
1362
1370
|
*/
|
|
1363
1371
|
createConnectorFromConfig(serverConfig) {
|
|
1364
|
-
const { url, transport, headers, authToken, authProvider } = serverConfig;
|
|
1372
|
+
const { url, transport, headers, authToken, authProvider, wrapTransport } = serverConfig;
|
|
1365
1373
|
if (!url) {
|
|
1366
1374
|
throw new Error("Server URL is required");
|
|
1367
1375
|
}
|
|
1368
1376
|
const connectorOptions = {
|
|
1369
1377
|
headers,
|
|
1370
1378
|
authToken,
|
|
1371
|
-
authProvider
|
|
1379
|
+
authProvider,
|
|
1372
1380
|
// ← Pass OAuth provider to connector
|
|
1381
|
+
wrapTransport
|
|
1382
|
+
// ← Pass transport wrapper if provided
|
|
1373
1383
|
};
|
|
1374
1384
|
if (transport === "websocket" || url.startsWith("ws://") || url.startsWith("wss://")) {
|
|
1375
1385
|
return new WebSocketConnector(url, connectorOptions);
|
|
@@ -1628,8 +1638,9 @@ function useMcp(options) {
|
|
|
1628
1638
|
onPopupWindow,
|
|
1629
1639
|
timeout = 3e4,
|
|
1630
1640
|
// 30 seconds default for connection timeout
|
|
1631
|
-
sseReadTimeout = 3e5
|
|
1641
|
+
sseReadTimeout = 3e5,
|
|
1632
1642
|
// 5 minutes default for SSE read timeout
|
|
1643
|
+
wrapTransport
|
|
1633
1644
|
} = options;
|
|
1634
1645
|
const [state, setState] = (0, import_react.useState)("discovering");
|
|
1635
1646
|
const [tools, setTools] = (0, import_react.useState)([]);
|
|
@@ -1780,8 +1791,17 @@ function useMcp(options) {
|
|
|
1780
1791
|
}
|
|
1781
1792
|
clientRef.current.addServer(serverName, {
|
|
1782
1793
|
...serverConfig,
|
|
1783
|
-
authProvider: authProviderRef.current
|
|
1794
|
+
authProvider: authProviderRef.current,
|
|
1784
1795
|
// ← SDK handles OAuth automatically!
|
|
1796
|
+
wrapTransport: wrapTransport ? (transport) => {
|
|
1797
|
+
console.log(
|
|
1798
|
+
"[useMcp] Applying transport wrapper for server:",
|
|
1799
|
+
serverName,
|
|
1800
|
+
"url:",
|
|
1801
|
+
url
|
|
1802
|
+
);
|
|
1803
|
+
return wrapTransport(transport, url);
|
|
1804
|
+
} : void 0
|
|
1785
1805
|
});
|
|
1786
1806
|
const session = await clientRef.current.createSession(serverName);
|
|
1787
1807
|
await session.initialize();
|
package/dist/src/react/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
useWidgetProps,
|
|
10
10
|
useWidgetState,
|
|
11
11
|
useWidgetTheme
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-GPAOZN2F.js";
|
|
13
13
|
import {
|
|
14
14
|
onMcpAuthorization
|
|
15
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-UT7O4SIJ.js";
|
|
16
16
|
import "../../chunk-DSBKVAWD.js";
|
|
17
17
|
import "../../chunk-34R6SIER.js";
|
|
18
18
|
import "../../chunk-3GQAWCBQ.js";
|
|
@@ -42,6 +42,8 @@ export type UseMcpOptions = {
|
|
|
42
42
|
timeout?: number;
|
|
43
43
|
/** SSE read timeout in milliseconds to prevent idle connection drops (default: 300000 / 5 minutes) */
|
|
44
44
|
sseReadTimeout?: number;
|
|
45
|
+
/** Optional callback to wrap the transport before passing it to the Client. Useful for logging, monitoring, or other transport-level interceptors. */
|
|
46
|
+
wrapTransport?: (transport: any, serverId: string) => any;
|
|
45
47
|
};
|
|
46
48
|
export type UseMcpResult = {
|
|
47
49
|
/** List of tools available from the connected MCP server */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,IAAI,EACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG;IAC1B,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6HAA6H;IAC7H,OAAO,CAAC,EAAE,OAA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cp.d.ts","sourceRoot":"","sources":["../../../src/react/useMcp.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CA41B3D"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-use",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.0-canary.
|
|
4
|
+
"version": "1.5.0-canary.2",
|
|
5
5
|
"description": "Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents and Clients + MCP Servers with support for MCP-UI.",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
"ws": "^8.18.2",
|
|
116
116
|
"zod": "^3.25.48",
|
|
117
117
|
"zod-to-json-schema": "^3.24.6",
|
|
118
|
-
"@mcp-use/cli": "2.3.0-canary.
|
|
119
|
-
"@mcp-use/inspector": "0.7.0-canary.
|
|
118
|
+
"@mcp-use/cli": "2.3.0-canary.2",
|
|
119
|
+
"@mcp-use/inspector": "0.7.0-canary.2"
|
|
120
120
|
},
|
|
121
121
|
"optionalDependencies": {
|
|
122
122
|
"@tailwindcss/vite": "^4.1.15",
|