@mcp-use/client 2.1.1-canary.0 → 2.1.1-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/code-mode/connector.d.ts.map +1 -1
- package/dist/code-mode/executor.d.ts +16 -1
- package/dist/code-mode/executor.d.ts.map +1 -1
- package/dist/core/node.d.ts +0 -1
- package/dist/core/node.d.ts.map +1 -1
- package/dist/core/session.d.ts +2 -0
- package/dist/core/session.d.ts.map +1 -1
- package/dist/index-browser.js +22 -5
- package/dist/index-browser.js.map +1 -1
- package/dist/index.js +37 -14
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +78 -47
- package/dist/react/index.js.map +1 -1
- package/dist/react/useMcp.d.ts.map +1 -1
- package/dist/transport/base.d.ts +5 -0
- package/dist/transport/base.d.ts.map +1 -1
- package/dist/transport/http.d.ts +4 -1
- package/dist/transport/http.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -918,6 +918,13 @@ var BaseConnector = class {
|
|
|
918
918
|
get authorization() {
|
|
919
919
|
return this.authorizationCache;
|
|
920
920
|
}
|
|
921
|
+
/**
|
|
922
|
+
* Discover optional authorization metadata without delaying connection
|
|
923
|
+
* readiness. HTTP connectors override this with RFC 9728 discovery.
|
|
924
|
+
*/
|
|
925
|
+
async discoverAuthorization() {
|
|
926
|
+
return this.authorization;
|
|
927
|
+
}
|
|
921
928
|
/** Start optional OAuth for a connected mixed-auth server. */
|
|
922
929
|
async authenticate() {
|
|
923
930
|
throw new Error("This connector does not support interactive OAuth");
|
|
@@ -1397,6 +1404,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1397
1404
|
streamableTransport = null;
|
|
1398
1405
|
hadAccessTokenAtConnect = false;
|
|
1399
1406
|
pendingOAuthCompletion = null;
|
|
1407
|
+
authorizationDiscovery = null;
|
|
1400
1408
|
/**
|
|
1401
1409
|
* Creates an HTTP connector.
|
|
1402
1410
|
*
|
|
@@ -1479,11 +1487,15 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1479
1487
|
}
|
|
1480
1488
|
await this.completeInteractiveAuthorization();
|
|
1481
1489
|
}
|
|
1482
|
-
async
|
|
1483
|
-
const capabilities = await super.initialize(defaultRequestOptions);
|
|
1490
|
+
async discoverAuthorization() {
|
|
1484
1491
|
if (!this.detectMixedAuth || !this.oauthProvider || this.hadAccessTokenAtConnect) {
|
|
1485
|
-
return
|
|
1492
|
+
return this.authorizationCache;
|
|
1486
1493
|
}
|
|
1494
|
+
if (this.authorizationDiscovery) return this.authorizationDiscovery;
|
|
1495
|
+
this.authorizationDiscovery = this.discoverMixedAuthorization();
|
|
1496
|
+
return this.authorizationDiscovery;
|
|
1497
|
+
}
|
|
1498
|
+
async discoverMixedAuthorization() {
|
|
1487
1499
|
const controller = new AbortController();
|
|
1488
1500
|
let timeout;
|
|
1489
1501
|
const discoveryTimeout = new Promise((_, reject) => {
|
|
@@ -1519,7 +1531,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1519
1531
|
} finally {
|
|
1520
1532
|
if (timeout) clearTimeout(timeout);
|
|
1521
1533
|
}
|
|
1522
|
-
return
|
|
1534
|
+
return this.authorizationCache;
|
|
1523
1535
|
}
|
|
1524
1536
|
buildClientOptions() {
|
|
1525
1537
|
return {
|
|
@@ -1906,11 +1918,12 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1906
1918
|
}
|
|
1907
1919
|
}
|
|
1908
1920
|
await super.cleanupResources();
|
|
1921
|
+
this.authorizationDiscovery = null;
|
|
1909
1922
|
}
|
|
1910
1923
|
};
|
|
1911
1924
|
|
|
1912
1925
|
// src/utils/version.ts
|
|
1913
|
-
var VERSION = "2.1.1-canary.
|
|
1926
|
+
var VERSION = "2.1.1-canary.2";
|
|
1914
1927
|
function getPackageVersion() {
|
|
1915
1928
|
return VERSION;
|
|
1916
1929
|
}
|
|
@@ -3695,6 +3708,10 @@ var MCPConnection = class {
|
|
|
3695
3708
|
get authorization() {
|
|
3696
3709
|
return this.connector.authorization;
|
|
3697
3710
|
}
|
|
3711
|
+
/** Discover optional OAuth metadata without delaying MCP readiness. */
|
|
3712
|
+
async discoverAuthorization() {
|
|
3713
|
+
return this.connector.discoverAuthorization();
|
|
3714
|
+
}
|
|
3698
3715
|
/** Authenticate an already-connected mixed-auth server. */
|
|
3699
3716
|
async authenticate() {
|
|
3700
3717
|
await this.connector.authenticate();
|
|
@@ -5727,6 +5744,62 @@ function useMcp(options) {
|
|
|
5727
5744
|
}).catch(() => {
|
|
5728
5745
|
});
|
|
5729
5746
|
setTools(connection.tools || []);
|
|
5747
|
+
const {
|
|
5748
|
+
server: serverInfo2,
|
|
5749
|
+
capabilities: capabilities2,
|
|
5750
|
+
protocolEra: protocolEra2,
|
|
5751
|
+
protocolVersion: protocolVersion2,
|
|
5752
|
+
instructions: instructions2,
|
|
5753
|
+
extensions: extensions2,
|
|
5754
|
+
authorization: connectionAuthorization
|
|
5755
|
+
} = connection.info;
|
|
5756
|
+
if (connectionAuthorization) {
|
|
5757
|
+
setAuthorization(connectionAuthorization);
|
|
5758
|
+
authorizationRef.current = connectionAuthorization;
|
|
5759
|
+
}
|
|
5760
|
+
setProtocolEra(protocolEra2);
|
|
5761
|
+
setProtocolVersion(protocolVersion2);
|
|
5762
|
+
setInstructions(instructions2);
|
|
5763
|
+
setExtensions(extensions2);
|
|
5764
|
+
if (serverInfo2) {
|
|
5765
|
+
addLog("debug", "Server info:", serverInfo2);
|
|
5766
|
+
setServerInfo(serverInfo2);
|
|
5767
|
+
iconLoadingPromiseRef.current = loadServerIcon({
|
|
5768
|
+
serverInfo: serverInfo2,
|
|
5769
|
+
url,
|
|
5770
|
+
isMounted: () => isMountedRef.current,
|
|
5771
|
+
setServerInfo,
|
|
5772
|
+
addLog
|
|
5773
|
+
});
|
|
5774
|
+
}
|
|
5775
|
+
if (capabilities2) {
|
|
5776
|
+
addLog("debug", "Server capabilities:", capabilities2);
|
|
5777
|
+
setCapabilities(capabilities2);
|
|
5778
|
+
}
|
|
5779
|
+
successfulTransportRef.current = transportTypeParam;
|
|
5780
|
+
setState("ready");
|
|
5781
|
+
const discoverAuthorizationAfterReady = () => {
|
|
5782
|
+
if (!isMountedRef.current || connectionRef.current !== connection) {
|
|
5783
|
+
return;
|
|
5784
|
+
}
|
|
5785
|
+
const authorizationDiscovery = connection.discoverAuthorization?.();
|
|
5786
|
+
if (authorizationDiscovery) {
|
|
5787
|
+
void authorizationDiscovery.then((discovered) => {
|
|
5788
|
+
if (!discovered || !isMountedRef.current || connectionRef.current !== connection) {
|
|
5789
|
+
return;
|
|
5790
|
+
}
|
|
5791
|
+
authorizationRef.current = discovered;
|
|
5792
|
+
setAuthorization(discovered);
|
|
5793
|
+
});
|
|
5794
|
+
}
|
|
5795
|
+
};
|
|
5796
|
+
if (typeof globalThis.requestAnimationFrame === "function") {
|
|
5797
|
+
globalThis.requestAnimationFrame(() => {
|
|
5798
|
+
setTimeout(discoverAuthorizationAfterReady, 0);
|
|
5799
|
+
});
|
|
5800
|
+
} else {
|
|
5801
|
+
setTimeout(discoverAuthorizationAfterReady, 0);
|
|
5802
|
+
}
|
|
5730
5803
|
const [resourcesResult, promptsResult, templatesResult] = await Promise.all([
|
|
5731
5804
|
connection.listAllResources().catch((error2) => {
|
|
5732
5805
|
addLog("warn", "Failed to load initial resources:", error2);
|
|
@@ -5755,24 +5828,7 @@ function useMcp(options) {
|
|
|
5755
5828
|
setResources(resourcesResult.resources || []);
|
|
5756
5829
|
setPrompts(promptsResult.prompts || []);
|
|
5757
5830
|
setResourceTemplates(templatesResult.resourceTemplates || []);
|
|
5758
|
-
const {
|
|
5759
|
-
server: serverInfo2,
|
|
5760
|
-
capabilities: capabilities2,
|
|
5761
|
-
protocolEra: protocolEra2,
|
|
5762
|
-
protocolVersion: protocolVersion2,
|
|
5763
|
-
instructions: instructions2,
|
|
5764
|
-
extensions: extensions2,
|
|
5765
|
-
authorization: connectionAuthorization
|
|
5766
|
-
} = connection.info;
|
|
5767
|
-
if (connectionAuthorization) {
|
|
5768
|
-
setAuthorization(connectionAuthorization);
|
|
5769
|
-
authorizationRef.current = connectionAuthorization;
|
|
5770
|
-
}
|
|
5771
5831
|
if (isMountedRef.current) {
|
|
5772
|
-
setProtocolEra(protocolEra2);
|
|
5773
|
-
setProtocolVersion(protocolVersion2);
|
|
5774
|
-
setInstructions(instructions2);
|
|
5775
|
-
setExtensions(extensions2);
|
|
5776
5832
|
if (extensions2["io.modelcontextprotocol/skills"] !== void 0) {
|
|
5777
5833
|
try {
|
|
5778
5834
|
const result = await connection.listAllSkills();
|
|
@@ -5785,29 +5841,6 @@ function useMcp(options) {
|
|
|
5785
5841
|
setSkills([]);
|
|
5786
5842
|
}
|
|
5787
5843
|
}
|
|
5788
|
-
if (serverInfo2) {
|
|
5789
|
-
addLog("debug", "Server info:", serverInfo2);
|
|
5790
|
-
if (!isMountedRef.current) {
|
|
5791
|
-
addLog("debug", "Skipping state update - component unmounted");
|
|
5792
|
-
return "failed";
|
|
5793
|
-
}
|
|
5794
|
-
setServerInfo(serverInfo2);
|
|
5795
|
-
iconLoadingPromiseRef.current = loadServerIcon({
|
|
5796
|
-
serverInfo: serverInfo2,
|
|
5797
|
-
url,
|
|
5798
|
-
isMounted: () => isMountedRef.current,
|
|
5799
|
-
setServerInfo,
|
|
5800
|
-
addLog
|
|
5801
|
-
});
|
|
5802
|
-
}
|
|
5803
|
-
if (capabilities2) {
|
|
5804
|
-
addLog("debug", "Server capabilities:", capabilities2);
|
|
5805
|
-
if (!isMountedRef.current) {
|
|
5806
|
-
addLog("debug", "Skipping state update - component unmounted");
|
|
5807
|
-
return "failed";
|
|
5808
|
-
}
|
|
5809
|
-
setCapabilities(capabilities2);
|
|
5810
|
-
}
|
|
5811
5844
|
if (authProviderRef.current) {
|
|
5812
5845
|
const tokens = await authProviderRef.current.tokens?.();
|
|
5813
5846
|
if (!isMountedRef.current) {
|
|
@@ -5862,8 +5895,6 @@ function useMcp(options) {
|
|
|
5862
5895
|
});
|
|
5863
5896
|
}
|
|
5864
5897
|
}
|
|
5865
|
-
successfulTransportRef.current = transportTypeParam;
|
|
5866
|
-
setState("ready");
|
|
5867
5898
|
return "success";
|
|
5868
5899
|
} catch (err) {
|
|
5869
5900
|
const error2 = err;
|