mcp-use 1.2.5-dev.5 → 1.3.0-canary.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/.tsbuildinfo +1 -1
- package/dist/{chunk-37MPZ3D6.js → chunk-TIUSJAAE.js} +12 -0
- package/dist/{chunk-X2HJQBDI.js → chunk-VNEGDXZO.js} +26 -1
- package/dist/index.cjs +37 -0
- package/dist/index.js +2 -2
- package/dist/src/browser.cjs +12 -0
- package/dist/src/browser.js +1 -1
- package/dist/src/connectors/base.d.ts +11 -0
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/react/index.cjs +37 -0
- package/dist/src/react/index.js +2 -2
- package/dist/src/react/types.d.ts +7 -0
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +74 -45
- package/dist/src/server/index.js +74 -45
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/package.json +41 -44
|
@@ -42,6 +42,7 @@ var BaseConnector = class {
|
|
|
42
42
|
connectionManager = null;
|
|
43
43
|
toolsCache = null;
|
|
44
44
|
capabilitiesCache = null;
|
|
45
|
+
serverInfoCache = null;
|
|
45
46
|
connected = false;
|
|
46
47
|
opts;
|
|
47
48
|
constructor(opts = {}) {
|
|
@@ -76,6 +77,8 @@ var BaseConnector = class {
|
|
|
76
77
|
logger.debug("Caching server capabilities & tools");
|
|
77
78
|
const capabilities = this.client.getServerCapabilities();
|
|
78
79
|
this.capabilitiesCache = capabilities;
|
|
80
|
+
const serverInfo = this.client.getServerVersion();
|
|
81
|
+
this.serverInfoCache = serverInfo || null;
|
|
79
82
|
const listToolsRes = await this.client.listTools(
|
|
80
83
|
void 0,
|
|
81
84
|
defaultRequestOptions
|
|
@@ -83,6 +86,7 @@ var BaseConnector = class {
|
|
|
83
86
|
this.toolsCache = listToolsRes.tools ?? [];
|
|
84
87
|
logger.debug(`Fetched ${this.toolsCache.length} tools from server`);
|
|
85
88
|
logger.debug("Server capabilities:", capabilities);
|
|
89
|
+
logger.debug("Server info:", serverInfo);
|
|
86
90
|
return capabilities;
|
|
87
91
|
}
|
|
88
92
|
/** Lazily expose the cached tools list. */
|
|
@@ -92,6 +96,14 @@ var BaseConnector = class {
|
|
|
92
96
|
}
|
|
93
97
|
return this.toolsCache;
|
|
94
98
|
}
|
|
99
|
+
/** Expose cached server capabilities. */
|
|
100
|
+
get serverCapabilities() {
|
|
101
|
+
return this.capabilitiesCache;
|
|
102
|
+
}
|
|
103
|
+
/** Expose cached server info. */
|
|
104
|
+
get serverInfo() {
|
|
105
|
+
return this.serverInfoCache;
|
|
106
|
+
}
|
|
95
107
|
/** Call a tool on the server. */
|
|
96
108
|
async callTool(name, args, options) {
|
|
97
109
|
if (!this.client) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrowserMCPClient,
|
|
3
3
|
BrowserOAuthClientProvider
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TIUSJAAE.js";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -50,6 +50,8 @@ function useMcp(options) {
|
|
|
50
50
|
const [resources, setResources] = useState([]);
|
|
51
51
|
const [resourceTemplates, setResourceTemplates] = useState([]);
|
|
52
52
|
const [prompts, setPrompts] = useState([]);
|
|
53
|
+
const [serverInfo, setServerInfo] = useState();
|
|
54
|
+
const [capabilities, setCapabilities] = useState();
|
|
53
55
|
const [error, setError] = useState(void 0);
|
|
54
56
|
const [log, setLog] = useState([]);
|
|
55
57
|
const [authUrl, setAuthUrl] = useState(void 0);
|
|
@@ -198,6 +200,17 @@ function useMcp(options) {
|
|
|
198
200
|
const session = await clientRef.current.createSession(serverName);
|
|
199
201
|
await session.initialize();
|
|
200
202
|
addLog("info", "\u2705 Successfully connected to MCP server");
|
|
203
|
+
addLog("info", "Server info:", session.connector.serverInfo);
|
|
204
|
+
addLog(
|
|
205
|
+
"info",
|
|
206
|
+
"Server capabilities:",
|
|
207
|
+
session.connector.serverCapabilities
|
|
208
|
+
);
|
|
209
|
+
console.log("[useMcp] Server info:", session.connector.serverInfo);
|
|
210
|
+
console.log(
|
|
211
|
+
"[useMcp] Server capabilities:",
|
|
212
|
+
session.connector.serverCapabilities
|
|
213
|
+
);
|
|
201
214
|
setState("ready");
|
|
202
215
|
successfulTransportRef.current = transportTypeParam;
|
|
203
216
|
setTools(session.connector.tools || []);
|
|
@@ -205,6 +218,16 @@ function useMcp(options) {
|
|
|
205
218
|
setResources(resourcesResult.resources || []);
|
|
206
219
|
const promptsResult = await session.connector.listPrompts();
|
|
207
220
|
setPrompts(promptsResult.prompts || []);
|
|
221
|
+
const serverInfo2 = session.connector.serverInfo;
|
|
222
|
+
const capabilities2 = session.connector.serverCapabilities;
|
|
223
|
+
if (serverInfo2) {
|
|
224
|
+
console.log("[useMcp] Server info:", serverInfo2);
|
|
225
|
+
setServerInfo(serverInfo2);
|
|
226
|
+
}
|
|
227
|
+
if (capabilities2) {
|
|
228
|
+
console.log("[useMcp] Server capabilities:", capabilities2);
|
|
229
|
+
setCapabilities(capabilities2);
|
|
230
|
+
}
|
|
208
231
|
return "success";
|
|
209
232
|
} catch (err) {
|
|
210
233
|
const errorMessage = err?.message || String(err);
|
|
@@ -567,6 +590,8 @@ function useMcp(options) {
|
|
|
567
590
|
resources,
|
|
568
591
|
resourceTemplates,
|
|
569
592
|
prompts,
|
|
593
|
+
serverInfo,
|
|
594
|
+
capabilities,
|
|
570
595
|
error,
|
|
571
596
|
log,
|
|
572
597
|
authUrl,
|
package/dist/index.cjs
CHANGED
|
@@ -3593,6 +3593,7 @@ var BaseConnector = class {
|
|
|
3593
3593
|
connectionManager = null;
|
|
3594
3594
|
toolsCache = null;
|
|
3595
3595
|
capabilitiesCache = null;
|
|
3596
|
+
serverInfoCache = null;
|
|
3596
3597
|
connected = false;
|
|
3597
3598
|
opts;
|
|
3598
3599
|
constructor(opts = {}) {
|
|
@@ -3627,6 +3628,8 @@ var BaseConnector = class {
|
|
|
3627
3628
|
logger.debug("Caching server capabilities & tools");
|
|
3628
3629
|
const capabilities = this.client.getServerCapabilities();
|
|
3629
3630
|
this.capabilitiesCache = capabilities;
|
|
3631
|
+
const serverInfo = this.client.getServerVersion();
|
|
3632
|
+
this.serverInfoCache = serverInfo || null;
|
|
3630
3633
|
const listToolsRes = await this.client.listTools(
|
|
3631
3634
|
void 0,
|
|
3632
3635
|
defaultRequestOptions
|
|
@@ -3634,6 +3637,7 @@ var BaseConnector = class {
|
|
|
3634
3637
|
this.toolsCache = listToolsRes.tools ?? [];
|
|
3635
3638
|
logger.debug(`Fetched ${this.toolsCache.length} tools from server`);
|
|
3636
3639
|
logger.debug("Server capabilities:", capabilities);
|
|
3640
|
+
logger.debug("Server info:", serverInfo);
|
|
3637
3641
|
return capabilities;
|
|
3638
3642
|
}
|
|
3639
3643
|
/** Lazily expose the cached tools list. */
|
|
@@ -3643,6 +3647,14 @@ var BaseConnector = class {
|
|
|
3643
3647
|
}
|
|
3644
3648
|
return this.toolsCache;
|
|
3645
3649
|
}
|
|
3650
|
+
/** Expose cached server capabilities. */
|
|
3651
|
+
get serverCapabilities() {
|
|
3652
|
+
return this.capabilitiesCache;
|
|
3653
|
+
}
|
|
3654
|
+
/** Expose cached server info. */
|
|
3655
|
+
get serverInfo() {
|
|
3656
|
+
return this.serverInfoCache;
|
|
3657
|
+
}
|
|
3646
3658
|
/** Call a tool on the server. */
|
|
3647
3659
|
async callTool(name, args, options) {
|
|
3648
3660
|
if (!this.client) {
|
|
@@ -5330,6 +5342,8 @@ function useMcp(options) {
|
|
|
5330
5342
|
const [resources, setResources] = (0, import_react.useState)([]);
|
|
5331
5343
|
const [resourceTemplates, setResourceTemplates] = (0, import_react.useState)([]);
|
|
5332
5344
|
const [prompts, setPrompts] = (0, import_react.useState)([]);
|
|
5345
|
+
const [serverInfo, setServerInfo] = (0, import_react.useState)();
|
|
5346
|
+
const [capabilities, setCapabilities] = (0, import_react.useState)();
|
|
5333
5347
|
const [error, setError] = (0, import_react.useState)(void 0);
|
|
5334
5348
|
const [log, setLog] = (0, import_react.useState)([]);
|
|
5335
5349
|
const [authUrl, setAuthUrl] = (0, import_react.useState)(void 0);
|
|
@@ -5478,6 +5492,17 @@ function useMcp(options) {
|
|
|
5478
5492
|
const session = await clientRef.current.createSession(serverName);
|
|
5479
5493
|
await session.initialize();
|
|
5480
5494
|
addLog("info", "\u2705 Successfully connected to MCP server");
|
|
5495
|
+
addLog("info", "Server info:", session.connector.serverInfo);
|
|
5496
|
+
addLog(
|
|
5497
|
+
"info",
|
|
5498
|
+
"Server capabilities:",
|
|
5499
|
+
session.connector.serverCapabilities
|
|
5500
|
+
);
|
|
5501
|
+
console.log("[useMcp] Server info:", session.connector.serverInfo);
|
|
5502
|
+
console.log(
|
|
5503
|
+
"[useMcp] Server capabilities:",
|
|
5504
|
+
session.connector.serverCapabilities
|
|
5505
|
+
);
|
|
5481
5506
|
setState("ready");
|
|
5482
5507
|
successfulTransportRef.current = transportTypeParam;
|
|
5483
5508
|
setTools(session.connector.tools || []);
|
|
@@ -5485,6 +5510,16 @@ function useMcp(options) {
|
|
|
5485
5510
|
setResources(resourcesResult.resources || []);
|
|
5486
5511
|
const promptsResult = await session.connector.listPrompts();
|
|
5487
5512
|
setPrompts(promptsResult.prompts || []);
|
|
5513
|
+
const serverInfo2 = session.connector.serverInfo;
|
|
5514
|
+
const capabilities2 = session.connector.serverCapabilities;
|
|
5515
|
+
if (serverInfo2) {
|
|
5516
|
+
console.log("[useMcp] Server info:", serverInfo2);
|
|
5517
|
+
setServerInfo(serverInfo2);
|
|
5518
|
+
}
|
|
5519
|
+
if (capabilities2) {
|
|
5520
|
+
console.log("[useMcp] Server capabilities:", capabilities2);
|
|
5521
|
+
setCapabilities(capabilities2);
|
|
5522
|
+
}
|
|
5488
5523
|
return "success";
|
|
5489
5524
|
} catch (err) {
|
|
5490
5525
|
const errorMessage = err?.message || String(err);
|
|
@@ -5847,6 +5882,8 @@ function useMcp(options) {
|
|
|
5847
5882
|
resources,
|
|
5848
5883
|
resourceTemplates,
|
|
5849
5884
|
prompts,
|
|
5885
|
+
serverInfo,
|
|
5886
|
+
capabilities,
|
|
5850
5887
|
error,
|
|
5851
5888
|
log,
|
|
5852
5889
|
authUrl,
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
useWidgetProps,
|
|
25
25
|
useWidgetState,
|
|
26
26
|
useWidgetTheme
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-VNEGDXZO.js";
|
|
28
28
|
import {
|
|
29
29
|
BaseConnector,
|
|
30
30
|
BaseMCPClient,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
MCPSession,
|
|
35
35
|
WebSocketConnector,
|
|
36
36
|
onMcpAuthorization
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-TIUSJAAE.js";
|
|
38
38
|
import "./chunk-YURRUCIM.js";
|
|
39
39
|
import {
|
|
40
40
|
Logger,
|
package/dist/src/browser.cjs
CHANGED
|
@@ -814,6 +814,7 @@ var BaseConnector = class {
|
|
|
814
814
|
connectionManager = null;
|
|
815
815
|
toolsCache = null;
|
|
816
816
|
capabilitiesCache = null;
|
|
817
|
+
serverInfoCache = null;
|
|
817
818
|
connected = false;
|
|
818
819
|
opts;
|
|
819
820
|
constructor(opts = {}) {
|
|
@@ -848,6 +849,8 @@ var BaseConnector = class {
|
|
|
848
849
|
logger.debug("Caching server capabilities & tools");
|
|
849
850
|
const capabilities = this.client.getServerCapabilities();
|
|
850
851
|
this.capabilitiesCache = capabilities;
|
|
852
|
+
const serverInfo = this.client.getServerVersion();
|
|
853
|
+
this.serverInfoCache = serverInfo || null;
|
|
851
854
|
const listToolsRes = await this.client.listTools(
|
|
852
855
|
void 0,
|
|
853
856
|
defaultRequestOptions
|
|
@@ -855,6 +858,7 @@ var BaseConnector = class {
|
|
|
855
858
|
this.toolsCache = listToolsRes.tools ?? [];
|
|
856
859
|
logger.debug(`Fetched ${this.toolsCache.length} tools from server`);
|
|
857
860
|
logger.debug("Server capabilities:", capabilities);
|
|
861
|
+
logger.debug("Server info:", serverInfo);
|
|
858
862
|
return capabilities;
|
|
859
863
|
}
|
|
860
864
|
/** Lazily expose the cached tools list. */
|
|
@@ -864,6 +868,14 @@ var BaseConnector = class {
|
|
|
864
868
|
}
|
|
865
869
|
return this.toolsCache;
|
|
866
870
|
}
|
|
871
|
+
/** Expose cached server capabilities. */
|
|
872
|
+
get serverCapabilities() {
|
|
873
|
+
return this.capabilitiesCache;
|
|
874
|
+
}
|
|
875
|
+
/** Expose cached server info. */
|
|
876
|
+
get serverInfo() {
|
|
877
|
+
return this.serverInfoCache;
|
|
878
|
+
}
|
|
867
879
|
/** Call a tool on the server. */
|
|
868
880
|
async callTool(name, args, options) {
|
|
869
881
|
if (!this.client) {
|
package/dist/src/browser.js
CHANGED
|
@@ -25,6 +25,10 @@ export declare abstract class BaseConnector {
|
|
|
25
25
|
protected connectionManager: ConnectionManager<any> | null;
|
|
26
26
|
protected toolsCache: Tool[] | null;
|
|
27
27
|
protected capabilitiesCache: any;
|
|
28
|
+
protected serverInfoCache: {
|
|
29
|
+
name: string;
|
|
30
|
+
version?: string;
|
|
31
|
+
} | null;
|
|
28
32
|
protected connected: boolean;
|
|
29
33
|
protected readonly opts: ConnectorInitOptions;
|
|
30
34
|
constructor(opts?: ConnectorInitOptions);
|
|
@@ -46,6 +50,13 @@ export declare abstract class BaseConnector {
|
|
|
46
50
|
initialize(defaultRequestOptions?: RequestOptions): Promise<ReturnType<Client["getServerCapabilities"]>>;
|
|
47
51
|
/** Lazily expose the cached tools list. */
|
|
48
52
|
get tools(): Tool[];
|
|
53
|
+
/** Expose cached server capabilities. */
|
|
54
|
+
get serverCapabilities(): any;
|
|
55
|
+
/** Expose cached server info. */
|
|
56
|
+
get serverInfo(): {
|
|
57
|
+
name: string;
|
|
58
|
+
version?: string;
|
|
59
|
+
} | null;
|
|
49
60
|
/** Call a tool on the server. */
|
|
50
61
|
callTool(name: string, args: Record<string, any>, options?: RequestOptions): Promise<CallToolResult>;
|
|
51
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/connectors/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACd,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,cAAc,CAAC;IACvC;;OAEG;IACH,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,8BAAsB,aAAa;IACjC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IACvC,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAClE,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,IAAI,CAAQ;IAC3C,SAAS,CAAC,iBAAiB,EAAE,GAAG,CAAQ;IACxC,SAAS,CAAC,SAAS,UAAS;IAC5B,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;gBAElC,IAAI,GAAE,oBAAyB;IAI3C,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAEjC,4CAA4C;IAC5C,QAAQ,KAAK,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASvD,6CAA6C;IACvC,OAAO,CACX,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAW,EACzC,OAAO,CAAC,EAAE,cAAc;IAc1B;;OAEG;cACa,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAkClD"}
|
package/dist/src/react/index.cjs
CHANGED
|
@@ -542,6 +542,7 @@ var BaseConnector = class {
|
|
|
542
542
|
connectionManager = null;
|
|
543
543
|
toolsCache = null;
|
|
544
544
|
capabilitiesCache = null;
|
|
545
|
+
serverInfoCache = null;
|
|
545
546
|
connected = false;
|
|
546
547
|
opts;
|
|
547
548
|
constructor(opts = {}) {
|
|
@@ -576,6 +577,8 @@ var BaseConnector = class {
|
|
|
576
577
|
logger.debug("Caching server capabilities & tools");
|
|
577
578
|
const capabilities = this.client.getServerCapabilities();
|
|
578
579
|
this.capabilitiesCache = capabilities;
|
|
580
|
+
const serverInfo = this.client.getServerVersion();
|
|
581
|
+
this.serverInfoCache = serverInfo || null;
|
|
579
582
|
const listToolsRes = await this.client.listTools(
|
|
580
583
|
void 0,
|
|
581
584
|
defaultRequestOptions
|
|
@@ -583,6 +586,7 @@ var BaseConnector = class {
|
|
|
583
586
|
this.toolsCache = listToolsRes.tools ?? [];
|
|
584
587
|
logger.debug(`Fetched ${this.toolsCache.length} tools from server`);
|
|
585
588
|
logger.debug("Server capabilities:", capabilities);
|
|
589
|
+
logger.debug("Server info:", serverInfo);
|
|
586
590
|
return capabilities;
|
|
587
591
|
}
|
|
588
592
|
/** Lazily expose the cached tools list. */
|
|
@@ -592,6 +596,14 @@ var BaseConnector = class {
|
|
|
592
596
|
}
|
|
593
597
|
return this.toolsCache;
|
|
594
598
|
}
|
|
599
|
+
/** Expose cached server capabilities. */
|
|
600
|
+
get serverCapabilities() {
|
|
601
|
+
return this.capabilitiesCache;
|
|
602
|
+
}
|
|
603
|
+
/** Expose cached server info. */
|
|
604
|
+
get serverInfo() {
|
|
605
|
+
return this.serverInfoCache;
|
|
606
|
+
}
|
|
595
607
|
/** Call a tool on the server. */
|
|
596
608
|
async callTool(name, args, options) {
|
|
597
609
|
if (!this.client) {
|
|
@@ -1619,6 +1631,8 @@ function useMcp(options) {
|
|
|
1619
1631
|
const [resources, setResources] = (0, import_react.useState)([]);
|
|
1620
1632
|
const [resourceTemplates, setResourceTemplates] = (0, import_react.useState)([]);
|
|
1621
1633
|
const [prompts, setPrompts] = (0, import_react.useState)([]);
|
|
1634
|
+
const [serverInfo, setServerInfo] = (0, import_react.useState)();
|
|
1635
|
+
const [capabilities, setCapabilities] = (0, import_react.useState)();
|
|
1622
1636
|
const [error, setError] = (0, import_react.useState)(void 0);
|
|
1623
1637
|
const [log, setLog] = (0, import_react.useState)([]);
|
|
1624
1638
|
const [authUrl, setAuthUrl] = (0, import_react.useState)(void 0);
|
|
@@ -1767,6 +1781,17 @@ function useMcp(options) {
|
|
|
1767
1781
|
const session = await clientRef.current.createSession(serverName);
|
|
1768
1782
|
await session.initialize();
|
|
1769
1783
|
addLog("info", "\u2705 Successfully connected to MCP server");
|
|
1784
|
+
addLog("info", "Server info:", session.connector.serverInfo);
|
|
1785
|
+
addLog(
|
|
1786
|
+
"info",
|
|
1787
|
+
"Server capabilities:",
|
|
1788
|
+
session.connector.serverCapabilities
|
|
1789
|
+
);
|
|
1790
|
+
console.log("[useMcp] Server info:", session.connector.serverInfo);
|
|
1791
|
+
console.log(
|
|
1792
|
+
"[useMcp] Server capabilities:",
|
|
1793
|
+
session.connector.serverCapabilities
|
|
1794
|
+
);
|
|
1770
1795
|
setState("ready");
|
|
1771
1796
|
successfulTransportRef.current = transportTypeParam;
|
|
1772
1797
|
setTools(session.connector.tools || []);
|
|
@@ -1774,6 +1799,16 @@ function useMcp(options) {
|
|
|
1774
1799
|
setResources(resourcesResult.resources || []);
|
|
1775
1800
|
const promptsResult = await session.connector.listPrompts();
|
|
1776
1801
|
setPrompts(promptsResult.prompts || []);
|
|
1802
|
+
const serverInfo2 = session.connector.serverInfo;
|
|
1803
|
+
const capabilities2 = session.connector.serverCapabilities;
|
|
1804
|
+
if (serverInfo2) {
|
|
1805
|
+
console.log("[useMcp] Server info:", serverInfo2);
|
|
1806
|
+
setServerInfo(serverInfo2);
|
|
1807
|
+
}
|
|
1808
|
+
if (capabilities2) {
|
|
1809
|
+
console.log("[useMcp] Server capabilities:", capabilities2);
|
|
1810
|
+
setCapabilities(capabilities2);
|
|
1811
|
+
}
|
|
1777
1812
|
return "success";
|
|
1778
1813
|
} catch (err) {
|
|
1779
1814
|
const errorMessage = err?.message || String(err);
|
|
@@ -2136,6 +2171,8 @@ function useMcp(options) {
|
|
|
2136
2171
|
resources,
|
|
2137
2172
|
resourceTemplates,
|
|
2138
2173
|
prompts,
|
|
2174
|
+
serverInfo,
|
|
2175
|
+
capabilities,
|
|
2139
2176
|
error,
|
|
2140
2177
|
log,
|
|
2141
2178
|
authUrl,
|
package/dist/src/react/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
useWidgetProps,
|
|
5
5
|
useWidgetState,
|
|
6
6
|
useWidgetTheme
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-VNEGDXZO.js";
|
|
8
8
|
import {
|
|
9
9
|
onMcpAuthorization
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-TIUSJAAE.js";
|
|
11
11
|
import "../../chunk-34R6SIER.js";
|
|
12
12
|
import "../../chunk-3GQAWCBQ.js";
|
|
13
13
|
export {
|
|
@@ -52,6 +52,13 @@ export type UseMcpResult = {
|
|
|
52
52
|
resourceTemplates: ResourceTemplate[];
|
|
53
53
|
/** List of prompts available from the connected MCP server */
|
|
54
54
|
prompts: Prompt[];
|
|
55
|
+
/** Server information from the initialize response */
|
|
56
|
+
serverInfo?: {
|
|
57
|
+
name: string;
|
|
58
|
+
version?: string;
|
|
59
|
+
};
|
|
60
|
+
/** Server capabilities from the initialize response */
|
|
61
|
+
capabilities?: Record<string, any>;
|
|
55
62
|
/**
|
|
56
63
|
* The current state of the MCP connection:
|
|
57
64
|
* - 'discovering': Checking server existence and capabilities (including auth requirements).
|
|
@@ -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,OAAO,CAAC;IAClB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iGAAiG;IACjG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,YAAY,CAAC,EAAE;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,+EAA+E;IAC/E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,2FAA2F;IAC3F,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,4FAA4F;IAC5F,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;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,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC,CAAC;KACJ,CAAC,CAAC;IACH;;;;OAIG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC;;;;;;OAMG;IACH,SAAS,EAAE,CACT,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC1B,OAAO,CAAC;QACX,QAAQ,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;YAC3B,OAAO,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;aAAE,CAAC;SAC9D,CAAC,CAAC;KACJ,CAAC,CAAC;IACH,+DAA+D;IAC/D,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kDAAkD;IAClD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,+GAA+G;IAC/G,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMcp.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,CA+
|
|
1
|
+
{"version":3,"file":"useMcp.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,CA+0B3D"}
|
|
@@ -465,7 +465,7 @@ var McpServer = class {
|
|
|
465
465
|
return new Proxy(this, {
|
|
466
466
|
get(target, prop) {
|
|
467
467
|
if (prop === "use") {
|
|
468
|
-
return (...args) => {
|
|
468
|
+
return async (...args) => {
|
|
469
469
|
const hasPath = typeof args[0] === "string";
|
|
470
470
|
const path = hasPath ? args[0] : "*";
|
|
471
471
|
const handlers = hasPath ? args.slice(1) : args;
|
|
@@ -479,7 +479,7 @@ var McpServer = class {
|
|
|
479
479
|
(h) => h.__isExpressMiddleware
|
|
480
480
|
);
|
|
481
481
|
if (hasExpressMiddleware) {
|
|
482
|
-
Promise.all(
|
|
482
|
+
await Promise.all(
|
|
483
483
|
adaptedHandlers.map(async (h) => {
|
|
484
484
|
if (h.__isExpressMiddleware) {
|
|
485
485
|
const adapted = await adaptConnectMiddleware(
|
|
@@ -499,12 +499,7 @@ var McpServer = class {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
})
|
|
502
|
-
)
|
|
503
|
-
console.error(
|
|
504
|
-
"[MIDDLEWARE] Failed to adapt Express middleware:",
|
|
505
|
-
err
|
|
506
|
-
);
|
|
507
|
-
});
|
|
502
|
+
);
|
|
508
503
|
return target;
|
|
509
504
|
}
|
|
510
505
|
return target.app.use(...args);
|
|
@@ -1054,9 +1049,9 @@ var McpServer = class {
|
|
|
1054
1049
|
async readBuildManifest() {
|
|
1055
1050
|
try {
|
|
1056
1051
|
const manifestPath = pathHelpers.join(
|
|
1057
|
-
getCwd(),
|
|
1052
|
+
isDeno ? "." : getCwd(),
|
|
1058
1053
|
"dist",
|
|
1059
|
-
"
|
|
1054
|
+
"mcp-use.json"
|
|
1060
1055
|
);
|
|
1061
1056
|
const content = await fsHelpers.readFileSync(manifestPath, "utf8");
|
|
1062
1057
|
return JSON.parse(content);
|
|
@@ -1288,7 +1283,6 @@ if (container && Component) {
|
|
|
1288
1283
|
error
|
|
1289
1284
|
);
|
|
1290
1285
|
}
|
|
1291
|
-
console.log("[WIDGET dev] Metadata:", metadata);
|
|
1292
1286
|
let html = "";
|
|
1293
1287
|
try {
|
|
1294
1288
|
html = await fsHelpers.readFileSync(
|
|
@@ -1396,23 +1390,35 @@ if (container && Component) {
|
|
|
1396
1390
|
async mountWidgetsProduction(options) {
|
|
1397
1391
|
const baseRoute = options?.baseRoute || "/mcp-use/widgets";
|
|
1398
1392
|
const widgetsDir = pathHelpers.join(
|
|
1399
|
-
getCwd(),
|
|
1393
|
+
isDeno ? "." : getCwd(),
|
|
1400
1394
|
"dist",
|
|
1401
1395
|
"resources",
|
|
1402
1396
|
"widgets"
|
|
1403
1397
|
);
|
|
1404
1398
|
console.log("widgetsDir", widgetsDir);
|
|
1405
1399
|
this.setupWidgetRoutes();
|
|
1406
|
-
const manifestPath =
|
|
1400
|
+
const manifestPath = "./dist/mcp-use.json";
|
|
1407
1401
|
let widgets = [];
|
|
1402
|
+
let widgetsMetadata = {};
|
|
1408
1403
|
try {
|
|
1409
|
-
const manifestContent = await fsHelpers.readFileSync(
|
|
1404
|
+
const manifestContent = await fsHelpers.readFileSync(
|
|
1405
|
+
manifestPath,
|
|
1406
|
+
"utf8"
|
|
1407
|
+
);
|
|
1410
1408
|
const manifest = JSON.parse(manifestContent);
|
|
1411
|
-
if (manifest.widgets && Array.isArray(manifest.widgets)) {
|
|
1409
|
+
if (manifest.widgets && typeof manifest.widgets === "object" && !Array.isArray(manifest.widgets)) {
|
|
1410
|
+
widgets = Object.keys(manifest.widgets);
|
|
1411
|
+
widgetsMetadata = manifest.widgets;
|
|
1412
|
+
console.log(
|
|
1413
|
+
`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest`
|
|
1414
|
+
);
|
|
1415
|
+
} else if (manifest.widgets && Array.isArray(manifest.widgets)) {
|
|
1412
1416
|
widgets = manifest.widgets;
|
|
1413
|
-
console.log(
|
|
1417
|
+
console.log(
|
|
1418
|
+
`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest (legacy format)`
|
|
1419
|
+
);
|
|
1414
1420
|
} else {
|
|
1415
|
-
console.log("[WIDGETS] No widgets
|
|
1421
|
+
console.log("[WIDGETS] No widgets found in manifest");
|
|
1416
1422
|
}
|
|
1417
1423
|
} catch (error) {
|
|
1418
1424
|
console.log(
|
|
@@ -1433,9 +1439,7 @@ if (container && Component) {
|
|
|
1433
1439
|
}
|
|
1434
1440
|
}
|
|
1435
1441
|
if (widgets.length === 0) {
|
|
1436
|
-
console.log(
|
|
1437
|
-
"[WIDGETS] No built widgets found"
|
|
1438
|
-
);
|
|
1442
|
+
console.log("[WIDGETS] No built widgets found");
|
|
1439
1443
|
return;
|
|
1440
1444
|
}
|
|
1441
1445
|
console.log(
|
|
@@ -1444,7 +1448,6 @@ if (container && Component) {
|
|
|
1444
1448
|
for (const widgetName of widgets) {
|
|
1445
1449
|
const widgetPath = pathHelpers.join(widgetsDir, widgetName);
|
|
1446
1450
|
const indexPath = pathHelpers.join(widgetPath, "index.html");
|
|
1447
|
-
const metadataPath = pathHelpers.join(widgetPath, "metadata.json");
|
|
1448
1451
|
let html = "";
|
|
1449
1452
|
try {
|
|
1450
1453
|
html = await fsHelpers.readFileSync(indexPath, "utf8");
|
|
@@ -1491,25 +1494,14 @@ if (container && Component) {
|
|
|
1491
1494
|
);
|
|
1492
1495
|
continue;
|
|
1493
1496
|
}
|
|
1494
|
-
|
|
1497
|
+
const metadata = widgetsMetadata[widgetName] || {};
|
|
1495
1498
|
let props = {};
|
|
1496
1499
|
let description = `Widget: ${widgetName}`;
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
metadata = JSON.parse(metadataContent);
|
|
1503
|
-
if (metadata.description) {
|
|
1504
|
-
description = metadata.description;
|
|
1505
|
-
}
|
|
1506
|
-
if (metadata.inputs) {
|
|
1507
|
-
props = metadata.inputs;
|
|
1508
|
-
}
|
|
1509
|
-
} catch (error) {
|
|
1510
|
-
console.log(
|
|
1511
|
-
`[WIDGET] No metadata found for ${widgetName}, using defaults`
|
|
1512
|
-
);
|
|
1500
|
+
if (metadata.description) {
|
|
1501
|
+
description = metadata.description;
|
|
1502
|
+
}
|
|
1503
|
+
if (metadata.inputs) {
|
|
1504
|
+
props = metadata.inputs;
|
|
1513
1505
|
}
|
|
1514
1506
|
this.uiResource({
|
|
1515
1507
|
name: widgetName,
|
|
@@ -1787,16 +1779,53 @@ if (container && Component) {
|
|
|
1787
1779
|
await this.mountMcp();
|
|
1788
1780
|
await this.mountInspector();
|
|
1789
1781
|
if (isDeno) {
|
|
1782
|
+
const corsHeaders = {
|
|
1783
|
+
"Access-Control-Allow-Origin": "*",
|
|
1784
|
+
"Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type"
|
|
1785
|
+
};
|
|
1790
1786
|
globalThis.Deno.serve(
|
|
1791
1787
|
{ port: this.serverPort, hostname: this.serverHost },
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1788
|
+
async (req) => {
|
|
1789
|
+
if (req.method === "OPTIONS") {
|
|
1790
|
+
return new Response("ok", { headers: corsHeaders });
|
|
1791
|
+
}
|
|
1792
|
+
const url = new URL(req.url);
|
|
1793
|
+
const pathname = url.pathname;
|
|
1794
|
+
let newPathname = pathname;
|
|
1795
|
+
const functionsMatch = pathname.match(
|
|
1796
|
+
/^\/functions\/v1\/[^/]+(\/.*)?$/
|
|
1797
|
+
);
|
|
1798
|
+
if (functionsMatch) {
|
|
1799
|
+
newPathname = functionsMatch[1] || "/";
|
|
1800
|
+
} else {
|
|
1801
|
+
const functionNameMatch = pathname.match(/^\/([^/]+)(\/.*)?$/);
|
|
1802
|
+
if (functionNameMatch && functionNameMatch[2]) {
|
|
1803
|
+
newPathname = functionNameMatch[2] || "/";
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
let finalReq = req;
|
|
1807
|
+
if (newPathname !== pathname) {
|
|
1808
|
+
const newUrl = new URL(newPathname + url.search, url.origin);
|
|
1809
|
+
finalReq = new Request(newUrl, {
|
|
1810
|
+
method: req.method,
|
|
1811
|
+
headers: req.headers,
|
|
1812
|
+
body: req.body,
|
|
1813
|
+
redirect: req.redirect
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
const response = await this.app.fetch(finalReq);
|
|
1817
|
+
const newHeaders = new Headers(response.headers);
|
|
1818
|
+
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
1819
|
+
newHeaders.set(key, value);
|
|
1820
|
+
});
|
|
1821
|
+
return new Response(response.body, {
|
|
1822
|
+
status: response.status,
|
|
1823
|
+
statusText: response.statusText,
|
|
1824
|
+
headers: newHeaders
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1799
1827
|
);
|
|
1828
|
+
console.log(`[SERVER] Listening`);
|
|
1800
1829
|
} else {
|
|
1801
1830
|
const { serve } = await import("@hono/node-server");
|
|
1802
1831
|
serve(
|