mcp-use 1.10.1-canary.2 → 1.11.0-canary.3
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/README.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-CFX74U7W.js → chunk-BONN23WU.js} +2 -2
- package/dist/{chunk-OTZ32HGI.js → chunk-DKLRVWPJ.js} +1 -1
- package/dist/{chunk-KFTQ3UL5.js → chunk-FDWI2WVM.js} +21 -287
- package/dist/{chunk-34R6SIER.js → chunk-FRUZDWXH.js} +1 -1
- package/dist/{chunk-CPG2WZUL.js → chunk-JRGQRPTN.js} +1 -1
- package/dist/{chunk-FAELBZOW.js → chunk-KZL3RCT6.js} +4 -4
- package/dist/{chunk-VTNHO2TS.js → chunk-TZ7SHSRY.js} +2 -2
- package/dist/{chunk-QNZMNQCY.js → chunk-WFPXUU4A.js} +1 -1
- package/dist/{chunk-4NC7PPVE.js → chunk-YIZWQ5PM.js} +16 -2
- package/dist/index.cjs +34 -296
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -18
- package/dist/{langfuse-N5Y5BSXK.js → langfuse-74RGPTAH.js} +2 -2
- package/dist/src/agents/index.cjs +2 -2
- package/dist/src/agents/index.js +6 -6
- package/dist/src/browser.cjs +34 -289
- package/dist/src/browser.d.ts +0 -1
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +7 -9
- package/dist/src/client/browser.d.ts +2 -2
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client/prompts.cjs +1 -1
- package/dist/src/client/prompts.js +4 -4
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/connectors/base.d.ts +8 -0
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/connectors/index.d.ts +0 -1
- package/dist/src/connectors/index.d.ts.map +1 -1
- package/dist/src/react/index.cjs +34 -284
- package/dist/src/react/index.js +5 -5
- package/dist/src/react/types.d.ts +1 -3
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/server/index.cjs +2 -2
- package/dist/src/server/index.js +6 -6
- package/dist/src/session.d.ts +14 -0
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/task_managers/index.d.ts +0 -1
- package/dist/src/task_managers/index.d.ts.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/{tool-execution-helpers-PQGEPYY3.js → tool-execution-helpers-HNASWGXY.js} +3 -3
- package/package.json +17 -10
- package/dist/src/connectors/websocket.d.ts +0 -38
- package/dist/src/connectors/websocket.d.ts.map +0 -1
- package/dist/src/task_managers/websocket.d.ts +0 -18
- package/dist/src/task_managers/websocket.d.ts.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrowserMCPClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FDWI2WVM.js";
|
|
4
4
|
import {
|
|
5
5
|
BrowserOAuthClientProvider,
|
|
6
6
|
sanitizeUrl
|
|
7
7
|
} from "./chunk-J75I2C26.js";
|
|
8
8
|
import {
|
|
9
9
|
Tel
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TZ7SHSRY.js";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseConnector
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YIZWQ5PM.js";
|
|
4
4
|
import {
|
|
5
5
|
Tel,
|
|
6
|
-
generateUUID,
|
|
7
6
|
getPackageVersion
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TZ7SHSRY.js";
|
|
9
8
|
import {
|
|
10
9
|
logger
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FRUZDWXH.js";
|
|
12
11
|
import {
|
|
13
12
|
__name
|
|
14
13
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -98,6 +97,22 @@ var MCPSession = class {
|
|
|
98
97
|
get tools() {
|
|
99
98
|
return this.connector.tools;
|
|
100
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* List all available tools from the MCP server.
|
|
102
|
+
* This method fetches fresh tools from the server, unlike the `tools` getter which returns cached tools.
|
|
103
|
+
*
|
|
104
|
+
* @param options - Optional request options
|
|
105
|
+
* @returns Array of available tools
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const tools = await session.listTools();
|
|
110
|
+
* console.log(`Available tools: ${tools.map(t => t.name).join(", ")}`);
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
async listTools(options) {
|
|
114
|
+
return this.connector.listTools(options);
|
|
115
|
+
}
|
|
101
116
|
/**
|
|
102
117
|
* Get the server capabilities advertised during initialization.
|
|
103
118
|
*
|
|
@@ -713,279 +728,6 @@ var HttpConnector = class extends BaseConnector {
|
|
|
713
728
|
}
|
|
714
729
|
};
|
|
715
730
|
|
|
716
|
-
// src/task_managers/websocket.ts
|
|
717
|
-
import WS from "ws";
|
|
718
|
-
var WebSocketConnectionManager = class extends ConnectionManager {
|
|
719
|
-
static {
|
|
720
|
-
__name(this, "WebSocketConnectionManager");
|
|
721
|
-
}
|
|
722
|
-
url;
|
|
723
|
-
headers;
|
|
724
|
-
_ws = null;
|
|
725
|
-
/**
|
|
726
|
-
* @param url The WebSocket URL to connect to.
|
|
727
|
-
* @param headers Optional headers to include in the connection handshake.
|
|
728
|
-
*/
|
|
729
|
-
constructor(url, headers = {}) {
|
|
730
|
-
super();
|
|
731
|
-
this.url = url;
|
|
732
|
-
this.headers = headers;
|
|
733
|
-
}
|
|
734
|
-
/** Establish a WebSocket connection and wait until it is open. */
|
|
735
|
-
async establishConnection() {
|
|
736
|
-
logger.debug(`Connecting to WebSocket: ${this.url}`);
|
|
737
|
-
return new Promise((resolve, reject) => {
|
|
738
|
-
const ws = new WS(this.url, {
|
|
739
|
-
headers: this.headers
|
|
740
|
-
});
|
|
741
|
-
this._ws = ws;
|
|
742
|
-
const onOpen = /* @__PURE__ */ __name(() => {
|
|
743
|
-
cleanup();
|
|
744
|
-
logger.debug("WebSocket connected successfully");
|
|
745
|
-
resolve(ws);
|
|
746
|
-
}, "onOpen");
|
|
747
|
-
const onError = /* @__PURE__ */ __name((err) => {
|
|
748
|
-
cleanup();
|
|
749
|
-
logger.error(`Failed to connect to WebSocket: ${err}`);
|
|
750
|
-
reject(err);
|
|
751
|
-
}, "onError");
|
|
752
|
-
const cleanup = /* @__PURE__ */ __name(() => {
|
|
753
|
-
ws.off("open", onOpen);
|
|
754
|
-
ws.off("error", onError);
|
|
755
|
-
}, "cleanup");
|
|
756
|
-
ws.on("open", onOpen);
|
|
757
|
-
ws.on("error", onError);
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
/** Cleanly close the WebSocket connection. */
|
|
761
|
-
async closeConnection(connection) {
|
|
762
|
-
logger.debug("Closing WebSocket connection");
|
|
763
|
-
return new Promise((resolve) => {
|
|
764
|
-
const onClose = /* @__PURE__ */ __name(() => {
|
|
765
|
-
connection.off("close", onClose);
|
|
766
|
-
this._ws = null;
|
|
767
|
-
resolve();
|
|
768
|
-
}, "onClose");
|
|
769
|
-
if (connection.readyState === WS.CLOSED) {
|
|
770
|
-
onClose();
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
connection.on("close", onClose);
|
|
774
|
-
try {
|
|
775
|
-
connection.close();
|
|
776
|
-
} catch (e) {
|
|
777
|
-
logger.warn(`Error closing WebSocket connection: ${e}`);
|
|
778
|
-
onClose();
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
// src/connectors/websocket.ts
|
|
785
|
-
var WebSocketConnector = class extends BaseConnector {
|
|
786
|
-
static {
|
|
787
|
-
__name(this, "WebSocketConnector");
|
|
788
|
-
}
|
|
789
|
-
url;
|
|
790
|
-
headers;
|
|
791
|
-
connectionManager = null;
|
|
792
|
-
ws = null;
|
|
793
|
-
receiverTask = null;
|
|
794
|
-
pending = /* @__PURE__ */ new Map();
|
|
795
|
-
toolsCache = null;
|
|
796
|
-
constructor(url, opts = {}) {
|
|
797
|
-
super();
|
|
798
|
-
this.url = url;
|
|
799
|
-
this.headers = { ...opts.headers ?? {} };
|
|
800
|
-
if (opts.authToken) this.headers.Authorization = `Bearer ${opts.authToken}`;
|
|
801
|
-
}
|
|
802
|
-
async connect() {
|
|
803
|
-
if (this.connected) {
|
|
804
|
-
logger.debug("Already connected to MCP implementation");
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
logger.debug(`Connecting via WebSocket: ${this.url}`);
|
|
808
|
-
try {
|
|
809
|
-
this.connectionManager = new WebSocketConnectionManager(
|
|
810
|
-
this.url,
|
|
811
|
-
this.headers
|
|
812
|
-
);
|
|
813
|
-
this.ws = await this.connectionManager.start();
|
|
814
|
-
this.receiverTask = this.receiveLoop();
|
|
815
|
-
this.connected = true;
|
|
816
|
-
logger.debug("WebSocket connected successfully");
|
|
817
|
-
} catch (e) {
|
|
818
|
-
logger.error(`Failed to connect: ${e}`);
|
|
819
|
-
await this.cleanupResources();
|
|
820
|
-
throw e;
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
async disconnect() {
|
|
824
|
-
if (!this.connected) {
|
|
825
|
-
logger.debug("Not connected to MCP implementation");
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
logger.debug("Disconnecting \u2026");
|
|
829
|
-
await this.cleanupResources();
|
|
830
|
-
this.connected = false;
|
|
831
|
-
}
|
|
832
|
-
sendRequest(method, params = null) {
|
|
833
|
-
if (!this.ws) throw new Error("WebSocket is not connected");
|
|
834
|
-
const id = generateUUID();
|
|
835
|
-
const payload = JSON.stringify({ id, method, params: params ?? {} });
|
|
836
|
-
return new Promise((resolve, reject) => {
|
|
837
|
-
this.pending.set(id, { resolve, reject });
|
|
838
|
-
this.ws.send(payload, (err) => {
|
|
839
|
-
if (err) {
|
|
840
|
-
this.pending.delete(id);
|
|
841
|
-
reject(err);
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
async receiveLoop() {
|
|
847
|
-
if (!this.ws) return;
|
|
848
|
-
const socket = this.ws;
|
|
849
|
-
const onMessage = /* @__PURE__ */ __name((msg) => {
|
|
850
|
-
let data;
|
|
851
|
-
try {
|
|
852
|
-
data = JSON.parse(msg.data ?? msg);
|
|
853
|
-
} catch (e) {
|
|
854
|
-
logger.warn("Received non\u2011JSON frame", e);
|
|
855
|
-
return;
|
|
856
|
-
}
|
|
857
|
-
const id = data.id;
|
|
858
|
-
if (id && this.pending.has(id)) {
|
|
859
|
-
const { resolve, reject } = this.pending.get(id);
|
|
860
|
-
this.pending.delete(id);
|
|
861
|
-
if ("result" in data) resolve(data.result);
|
|
862
|
-
else if ("error" in data) reject(data.error);
|
|
863
|
-
} else if (data.method && !data.id) {
|
|
864
|
-
logger.debug("Received notification", data.method, data.params);
|
|
865
|
-
this.handleNotification(data);
|
|
866
|
-
} else {
|
|
867
|
-
logger.debug("Received unsolicited message", data);
|
|
868
|
-
}
|
|
869
|
-
}, "onMessage");
|
|
870
|
-
if (socket.addEventListener) {
|
|
871
|
-
socket.addEventListener("message", onMessage);
|
|
872
|
-
} else {
|
|
873
|
-
socket.on("message", onMessage);
|
|
874
|
-
}
|
|
875
|
-
return new Promise((resolve) => {
|
|
876
|
-
const onClose = /* @__PURE__ */ __name(() => {
|
|
877
|
-
if (socket.removeEventListener) {
|
|
878
|
-
socket.removeEventListener("message", onMessage);
|
|
879
|
-
} else {
|
|
880
|
-
socket.off("message", onMessage);
|
|
881
|
-
}
|
|
882
|
-
this.rejectAll(new Error("WebSocket closed"));
|
|
883
|
-
resolve();
|
|
884
|
-
}, "onClose");
|
|
885
|
-
if (socket.addEventListener) {
|
|
886
|
-
socket.addEventListener("close", onClose);
|
|
887
|
-
} else {
|
|
888
|
-
socket.on("close", onClose);
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
rejectAll(err) {
|
|
893
|
-
for (const { reject } of this.pending.values()) reject(err);
|
|
894
|
-
this.pending.clear();
|
|
895
|
-
}
|
|
896
|
-
async handleNotification(data) {
|
|
897
|
-
switch (data.method) {
|
|
898
|
-
case "notifications/tools/list_changed":
|
|
899
|
-
await this.refreshToolsCache();
|
|
900
|
-
break;
|
|
901
|
-
case "notifications/resources/list_changed":
|
|
902
|
-
await this.onResourcesListChanged();
|
|
903
|
-
break;
|
|
904
|
-
case "notifications/prompts/list_changed":
|
|
905
|
-
await this.onPromptsListChanged();
|
|
906
|
-
break;
|
|
907
|
-
default:
|
|
908
|
-
break;
|
|
909
|
-
}
|
|
910
|
-
for (const handler of this.notificationHandlers) {
|
|
911
|
-
try {
|
|
912
|
-
await handler({
|
|
913
|
-
method: data.method,
|
|
914
|
-
params: data.params
|
|
915
|
-
});
|
|
916
|
-
} catch (err) {
|
|
917
|
-
logger.error("Error in notification handler:", err);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
/**
|
|
922
|
-
* Auto-refresh tools cache when server sends tools/list_changed notification
|
|
923
|
-
* Override to use WebSocket-specific listTools method
|
|
924
|
-
*/
|
|
925
|
-
async refreshToolsCache() {
|
|
926
|
-
try {
|
|
927
|
-
logger.debug(
|
|
928
|
-
"[Auto] Refreshing tools cache due to list_changed notification"
|
|
929
|
-
);
|
|
930
|
-
const tools = await this.listTools();
|
|
931
|
-
this.toolsCache = tools.map((t) => t);
|
|
932
|
-
logger.debug(
|
|
933
|
-
`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`
|
|
934
|
-
);
|
|
935
|
-
} catch (err) {
|
|
936
|
-
logger.warn("[Auto] Failed to refresh tools cache:", err);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
async initialize() {
|
|
940
|
-
logger.debug("Initializing MCP session over WebSocket");
|
|
941
|
-
const result = await this.sendRequest("initialize");
|
|
942
|
-
const toolsList = await this.listTools();
|
|
943
|
-
this.toolsCache = toolsList.map((t) => t);
|
|
944
|
-
logger.debug(`Initialized with ${this.toolsCache.length} tools`);
|
|
945
|
-
return result;
|
|
946
|
-
}
|
|
947
|
-
async listTools() {
|
|
948
|
-
const res = await this.sendRequest("tools/list");
|
|
949
|
-
return res.tools ?? [];
|
|
950
|
-
}
|
|
951
|
-
async callTool(name, args) {
|
|
952
|
-
return await this.sendRequest("tools/call", { name, arguments: args });
|
|
953
|
-
}
|
|
954
|
-
async listResources() {
|
|
955
|
-
const resources = await this.sendRequest("resources/list");
|
|
956
|
-
return { resources: Array.isArray(resources) ? resources : [] };
|
|
957
|
-
}
|
|
958
|
-
async readResource(uri) {
|
|
959
|
-
const res = await this.sendRequest("resources/read", { uri });
|
|
960
|
-
return res;
|
|
961
|
-
}
|
|
962
|
-
async request(method, params = null) {
|
|
963
|
-
return await this.sendRequest(method, params);
|
|
964
|
-
}
|
|
965
|
-
get tools() {
|
|
966
|
-
if (!this.toolsCache) throw new Error("MCP client is not initialized");
|
|
967
|
-
return this.toolsCache;
|
|
968
|
-
}
|
|
969
|
-
async cleanupResources() {
|
|
970
|
-
if (this.receiverTask) await this.receiverTask.catch(() => {
|
|
971
|
-
});
|
|
972
|
-
this.receiverTask = null;
|
|
973
|
-
this.rejectAll(new Error("WebSocket disconnected"));
|
|
974
|
-
if (this.connectionManager) {
|
|
975
|
-
await this.connectionManager.stop();
|
|
976
|
-
this.connectionManager = null;
|
|
977
|
-
this.ws = null;
|
|
978
|
-
}
|
|
979
|
-
this.toolsCache = null;
|
|
980
|
-
}
|
|
981
|
-
get publicIdentifier() {
|
|
982
|
-
return {
|
|
983
|
-
type: "websocket",
|
|
984
|
-
url: this.url
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
};
|
|
988
|
-
|
|
989
731
|
// src/client/base.ts
|
|
990
732
|
var BaseMCPClient = class {
|
|
991
733
|
static {
|
|
@@ -1144,12 +886,11 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
1144
886
|
}
|
|
1145
887
|
/**
|
|
1146
888
|
* Create a connector from server configuration (Browser version)
|
|
1147
|
-
* Supports HTTP
|
|
889
|
+
* Supports HTTP connector only
|
|
1148
890
|
*/
|
|
1149
891
|
createConnectorFromConfig(serverConfig) {
|
|
1150
892
|
const {
|
|
1151
893
|
url,
|
|
1152
|
-
transport,
|
|
1153
894
|
headers,
|
|
1154
895
|
authToken,
|
|
1155
896
|
authProvider,
|
|
@@ -1185,13 +926,7 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
1185
926
|
"[BrowserMCPClient] No clientOptions provided to connector!"
|
|
1186
927
|
);
|
|
1187
928
|
}
|
|
1188
|
-
|
|
1189
|
-
return new WebSocketConnector(url, connectorOptions);
|
|
1190
|
-
} else if (transport === "http" || url.startsWith("http://") || url.startsWith("https://")) {
|
|
1191
|
-
return new HttpConnector(url, connectorOptions);
|
|
1192
|
-
} else {
|
|
1193
|
-
return new HttpConnector(url, connectorOptions);
|
|
1194
|
-
}
|
|
929
|
+
return new HttpConnector(url, connectorOptions);
|
|
1195
930
|
}
|
|
1196
931
|
};
|
|
1197
932
|
|
|
@@ -1200,6 +935,5 @@ export {
|
|
|
1200
935
|
BaseMCPClient,
|
|
1201
936
|
ConnectionManager,
|
|
1202
937
|
HttpConnector,
|
|
1203
|
-
WebSocketConnector,
|
|
1204
938
|
BrowserMCPClient
|
|
1205
939
|
};
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
Telemetry,
|
|
3
3
|
extractModelInfo,
|
|
4
4
|
getPackageVersion
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TZ7SHSRY.js";
|
|
6
6
|
import {
|
|
7
7
|
logger
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FRUZDWXH.js";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -1444,9 +1444,9 @@ var ObservabilityManager = class {
|
|
|
1444
1444
|
return;
|
|
1445
1445
|
}
|
|
1446
1446
|
try {
|
|
1447
|
-
const { langfuseHandler: langfuseHandler2, langfuseInitPromise: langfuseInitPromise2 } = await import("./langfuse-
|
|
1447
|
+
const { langfuseHandler: langfuseHandler2, langfuseInitPromise: langfuseInitPromise2 } = await import("./langfuse-74RGPTAH.js");
|
|
1448
1448
|
if (this.agentId || this.metadata || this.metadataProvider || this.tagsProvider) {
|
|
1449
|
-
const { initializeLangfuse } = await import("./langfuse-
|
|
1449
|
+
const { initializeLangfuse } = await import("./langfuse-74RGPTAH.js");
|
|
1450
1450
|
await initializeLangfuse(
|
|
1451
1451
|
this.agentId,
|
|
1452
1452
|
this.metadata,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
logger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FRUZDWXH.js";
|
|
4
4
|
import {
|
|
5
5
|
__name,
|
|
6
6
|
__require
|
|
@@ -92,7 +92,7 @@ function generateUUID() {
|
|
|
92
92
|
__name(generateUUID, "generateUUID");
|
|
93
93
|
|
|
94
94
|
// src/version.ts
|
|
95
|
-
var VERSION = "1.
|
|
95
|
+
var VERSION = "1.11.0-canary.3";
|
|
96
96
|
function getPackageVersion() {
|
|
97
97
|
return VERSION;
|
|
98
98
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Telemetry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TZ7SHSRY.js";
|
|
4
4
|
import {
|
|
5
5
|
logger
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FRUZDWXH.js";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -302,6 +302,20 @@ var BaseConnector = class {
|
|
|
302
302
|
logger.debug(`Tool '${name}' returned`, res);
|
|
303
303
|
return res;
|
|
304
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* List all available tools from the MCP server.
|
|
307
|
+
* This method fetches fresh tools from the server, unlike the `tools` getter which returns cached tools.
|
|
308
|
+
*
|
|
309
|
+
* @param options - Optional request options
|
|
310
|
+
* @returns Array of available tools
|
|
311
|
+
*/
|
|
312
|
+
async listTools(options) {
|
|
313
|
+
if (!this.client) {
|
|
314
|
+
throw new Error("MCP client is not connected");
|
|
315
|
+
}
|
|
316
|
+
const result = await this.client.listTools(void 0, options);
|
|
317
|
+
return result.tools ?? [];
|
|
318
|
+
}
|
|
305
319
|
/**
|
|
306
320
|
* List resources from the server with optional pagination
|
|
307
321
|
*
|