integrate-sdk 0.8.54-dev.0 → 0.8.55-dev.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/adapters/auto-routes.js +67 -13
- package/dist/adapters/index.js +67 -13
- package/dist/adapters/nextjs.js +67 -13
- package/dist/adapters/node.js +67 -13
- package/dist/adapters/svelte-kit.js +67 -13
- package/dist/adapters/tanstack-start.js +67 -13
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +1 -2
- package/dist/ai/google.d.ts.map +1 -1
- package/dist/ai/google.js +1 -2
- package/dist/ai/index.js +4 -8
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +1 -2
- package/dist/ai/trigger-tools.d.ts +4 -4
- package/dist/ai/vercel-ai.d.ts.map +1 -1
- package/dist/ai/vercel-ai.js +1 -2
- package/dist/index.js +67 -13
- package/dist/oauth.js +67 -13
- package/dist/server.js +67 -13
- package/dist/src/ai/anthropic.d.ts.map +1 -1
- package/dist/src/ai/google.d.ts.map +1 -1
- package/dist/src/ai/openai.d.ts.map +1 -1
- package/dist/src/ai/trigger-tools.d.ts +4 -4
- package/dist/src/ai/vercel-ai.d.ts.map +1 -1
- package/dist/src/client.d.ts +25 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/integrations/server-client.d.ts +10 -2
- package/dist/src/integrations/server-client.d.ts.map +1 -1
- package/dist/src/protocol/messages.d.ts +18 -6
- package/dist/src/protocol/messages.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2205,6 +2205,69 @@ class MCPClientBase {
|
|
|
2205
2205
|
getEnabledTools() {
|
|
2206
2206
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2207
2207
|
}
|
|
2208
|
+
async getEnabledToolsAsync() {
|
|
2209
|
+
if (this.isConnected() && this.availableTools.size > 0) {
|
|
2210
|
+
return this.getEnabledTools();
|
|
2211
|
+
}
|
|
2212
|
+
if (this.availableTools.size > 0) {
|
|
2213
|
+
return this.getEnabledTools();
|
|
2214
|
+
}
|
|
2215
|
+
const tools = [];
|
|
2216
|
+
const integrationIds = new Set;
|
|
2217
|
+
for (const integration of this.integrations) {
|
|
2218
|
+
integrationIds.add(integration.id);
|
|
2219
|
+
}
|
|
2220
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
2221
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(integrationIds), async (integrationId) => {
|
|
2222
|
+
try {
|
|
2223
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
2224
|
+
integration: integrationId
|
|
2225
|
+
});
|
|
2226
|
+
const integrationTools = [];
|
|
2227
|
+
if (response.content && Array.isArray(response.content)) {
|
|
2228
|
+
for (const item of response.content) {
|
|
2229
|
+
if (item.type === "text" && item.text) {
|
|
2230
|
+
try {
|
|
2231
|
+
const parsed = JSON.parse(item.text);
|
|
2232
|
+
if (Array.isArray(parsed)) {
|
|
2233
|
+
for (const tool of parsed) {
|
|
2234
|
+
if (tool.name && tool.inputSchema) {
|
|
2235
|
+
integrationTools.push({
|
|
2236
|
+
name: tool.name,
|
|
2237
|
+
description: tool.description,
|
|
2238
|
+
inputSchema: tool.inputSchema
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
2243
|
+
for (const tool of parsed.tools) {
|
|
2244
|
+
if (tool.name && tool.inputSchema) {
|
|
2245
|
+
integrationTools.push({
|
|
2246
|
+
name: tool.name,
|
|
2247
|
+
description: tool.description,
|
|
2248
|
+
inputSchema: tool.inputSchema
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
} catch {}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
return integrationTools;
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
logger5.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
2260
|
+
return [];
|
|
2261
|
+
}
|
|
2262
|
+
}, 3);
|
|
2263
|
+
for (const integrationTools of integrationToolsResults) {
|
|
2264
|
+
tools.push(...integrationTools);
|
|
2265
|
+
}
|
|
2266
|
+
for (const tool of tools) {
|
|
2267
|
+
this.availableTools.set(tool.name, tool);
|
|
2268
|
+
}
|
|
2269
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2270
|
+
}
|
|
2208
2271
|
getOAuthConfig(integrationId) {
|
|
2209
2272
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
|
2210
2273
|
return integration?.oauth;
|
|
@@ -7727,11 +7790,6 @@ async function executeToolWithToken(client, toolName, args, options) {
|
|
|
7727
7790
|
const result = await client._callToolByName(toolName, args);
|
|
7728
7791
|
return result;
|
|
7729
7792
|
}
|
|
7730
|
-
async function ensureClientConnected(client) {
|
|
7731
|
-
if (!client.isConnected()) {
|
|
7732
|
-
await client.connect();
|
|
7733
|
-
}
|
|
7734
|
-
}
|
|
7735
7793
|
var init_utils = __esm(() => {
|
|
7736
7794
|
init_zod();
|
|
7737
7795
|
});
|
|
@@ -7974,7 +8032,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8032
|
};
|
|
7975
8033
|
}
|
|
7976
8034
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8035
|
let providerTokens = options?.providerTokens;
|
|
7979
8036
|
if (!providerTokens) {
|
|
7980
8037
|
try {
|
|
@@ -7982,7 +8039,7 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8039
|
} catch {}
|
|
7983
8040
|
}
|
|
7984
8041
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
const mcpTools = client.
|
|
8042
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8043
|
const vercelTools = {};
|
|
7987
8044
|
for (const mcpTool of mcpTools) {
|
|
7988
8045
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9472,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9472
|
};
|
|
9416
9473
|
}
|
|
9417
9474
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9475
|
let providerTokens = options?.providerTokens;
|
|
9420
9476
|
if (!providerTokens) {
|
|
9421
9477
|
try {
|
|
@@ -9423,7 +9479,7 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9479
|
} catch {}
|
|
9424
9480
|
}
|
|
9425
9481
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
const mcpTools = client.
|
|
9482
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9483
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9484
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9485
|
if (triggerConfig) {
|
|
@@ -9547,7 +9603,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9603
|
return toolResults;
|
|
9548
9604
|
}
|
|
9549
9605
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9606
|
let providerTokens = options?.providerTokens;
|
|
9552
9607
|
if (!providerTokens) {
|
|
9553
9608
|
try {
|
|
@@ -9555,7 +9610,7 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9610
|
} catch {}
|
|
9556
9611
|
}
|
|
9557
9612
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
const mcpTools = client.
|
|
9613
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9614
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9615
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9616
|
if (triggerConfig) {
|
|
@@ -9702,7 +9757,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9757
|
return results;
|
|
9703
9758
|
}
|
|
9704
9759
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9760
|
let providerTokens = options?.providerTokens;
|
|
9707
9761
|
if (!providerTokens) {
|
|
9708
9762
|
try {
|
|
@@ -9710,7 +9764,7 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9764
|
} catch {}
|
|
9711
9765
|
}
|
|
9712
9766
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
const mcpTools = client.
|
|
9767
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9768
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9769
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9770
|
if (triggerConfig) {
|
package/dist/adapters/index.js
CHANGED
|
@@ -2205,6 +2205,69 @@ class MCPClientBase {
|
|
|
2205
2205
|
getEnabledTools() {
|
|
2206
2206
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2207
2207
|
}
|
|
2208
|
+
async getEnabledToolsAsync() {
|
|
2209
|
+
if (this.isConnected() && this.availableTools.size > 0) {
|
|
2210
|
+
return this.getEnabledTools();
|
|
2211
|
+
}
|
|
2212
|
+
if (this.availableTools.size > 0) {
|
|
2213
|
+
return this.getEnabledTools();
|
|
2214
|
+
}
|
|
2215
|
+
const tools = [];
|
|
2216
|
+
const integrationIds = new Set;
|
|
2217
|
+
for (const integration of this.integrations) {
|
|
2218
|
+
integrationIds.add(integration.id);
|
|
2219
|
+
}
|
|
2220
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
2221
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(integrationIds), async (integrationId) => {
|
|
2222
|
+
try {
|
|
2223
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
2224
|
+
integration: integrationId
|
|
2225
|
+
});
|
|
2226
|
+
const integrationTools = [];
|
|
2227
|
+
if (response.content && Array.isArray(response.content)) {
|
|
2228
|
+
for (const item of response.content) {
|
|
2229
|
+
if (item.type === "text" && item.text) {
|
|
2230
|
+
try {
|
|
2231
|
+
const parsed = JSON.parse(item.text);
|
|
2232
|
+
if (Array.isArray(parsed)) {
|
|
2233
|
+
for (const tool of parsed) {
|
|
2234
|
+
if (tool.name && tool.inputSchema) {
|
|
2235
|
+
integrationTools.push({
|
|
2236
|
+
name: tool.name,
|
|
2237
|
+
description: tool.description,
|
|
2238
|
+
inputSchema: tool.inputSchema
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
2243
|
+
for (const tool of parsed.tools) {
|
|
2244
|
+
if (tool.name && tool.inputSchema) {
|
|
2245
|
+
integrationTools.push({
|
|
2246
|
+
name: tool.name,
|
|
2247
|
+
description: tool.description,
|
|
2248
|
+
inputSchema: tool.inputSchema
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
} catch {}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
return integrationTools;
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
logger5.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
2260
|
+
return [];
|
|
2261
|
+
}
|
|
2262
|
+
}, 3);
|
|
2263
|
+
for (const integrationTools of integrationToolsResults) {
|
|
2264
|
+
tools.push(...integrationTools);
|
|
2265
|
+
}
|
|
2266
|
+
for (const tool of tools) {
|
|
2267
|
+
this.availableTools.set(tool.name, tool);
|
|
2268
|
+
}
|
|
2269
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2270
|
+
}
|
|
2208
2271
|
getOAuthConfig(integrationId) {
|
|
2209
2272
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
|
2210
2273
|
return integration?.oauth;
|
|
@@ -7727,11 +7790,6 @@ async function executeToolWithToken(client, toolName, args, options) {
|
|
|
7727
7790
|
const result = await client._callToolByName(toolName, args);
|
|
7728
7791
|
return result;
|
|
7729
7792
|
}
|
|
7730
|
-
async function ensureClientConnected(client) {
|
|
7731
|
-
if (!client.isConnected()) {
|
|
7732
|
-
await client.connect();
|
|
7733
|
-
}
|
|
7734
|
-
}
|
|
7735
7793
|
var init_utils = __esm(() => {
|
|
7736
7794
|
init_zod();
|
|
7737
7795
|
});
|
|
@@ -7974,7 +8032,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8032
|
};
|
|
7975
8033
|
}
|
|
7976
8034
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8035
|
let providerTokens = options?.providerTokens;
|
|
7979
8036
|
if (!providerTokens) {
|
|
7980
8037
|
try {
|
|
@@ -7982,7 +8039,7 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8039
|
} catch {}
|
|
7983
8040
|
}
|
|
7984
8041
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
const mcpTools = client.
|
|
8042
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8043
|
const vercelTools = {};
|
|
7987
8044
|
for (const mcpTool of mcpTools) {
|
|
7988
8045
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9472,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9472
|
};
|
|
9416
9473
|
}
|
|
9417
9474
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9475
|
let providerTokens = options?.providerTokens;
|
|
9420
9476
|
if (!providerTokens) {
|
|
9421
9477
|
try {
|
|
@@ -9423,7 +9479,7 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9479
|
} catch {}
|
|
9424
9480
|
}
|
|
9425
9481
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
const mcpTools = client.
|
|
9482
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9483
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9484
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9485
|
if (triggerConfig) {
|
|
@@ -9547,7 +9603,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9603
|
return toolResults;
|
|
9548
9604
|
}
|
|
9549
9605
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9606
|
let providerTokens = options?.providerTokens;
|
|
9552
9607
|
if (!providerTokens) {
|
|
9553
9608
|
try {
|
|
@@ -9555,7 +9610,7 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9610
|
} catch {}
|
|
9556
9611
|
}
|
|
9557
9612
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
const mcpTools = client.
|
|
9613
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9614
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9615
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9616
|
if (triggerConfig) {
|
|
@@ -9702,7 +9757,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9757
|
return results;
|
|
9703
9758
|
}
|
|
9704
9759
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9760
|
let providerTokens = options?.providerTokens;
|
|
9707
9761
|
if (!providerTokens) {
|
|
9708
9762
|
try {
|
|
@@ -9710,7 +9764,7 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9764
|
} catch {}
|
|
9711
9765
|
}
|
|
9712
9766
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
const mcpTools = client.
|
|
9767
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9768
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9769
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9770
|
if (triggerConfig) {
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -2205,6 +2205,69 @@ class MCPClientBase {
|
|
|
2205
2205
|
getEnabledTools() {
|
|
2206
2206
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2207
2207
|
}
|
|
2208
|
+
async getEnabledToolsAsync() {
|
|
2209
|
+
if (this.isConnected() && this.availableTools.size > 0) {
|
|
2210
|
+
return this.getEnabledTools();
|
|
2211
|
+
}
|
|
2212
|
+
if (this.availableTools.size > 0) {
|
|
2213
|
+
return this.getEnabledTools();
|
|
2214
|
+
}
|
|
2215
|
+
const tools = [];
|
|
2216
|
+
const integrationIds = new Set;
|
|
2217
|
+
for (const integration of this.integrations) {
|
|
2218
|
+
integrationIds.add(integration.id);
|
|
2219
|
+
}
|
|
2220
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
2221
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(integrationIds), async (integrationId) => {
|
|
2222
|
+
try {
|
|
2223
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
2224
|
+
integration: integrationId
|
|
2225
|
+
});
|
|
2226
|
+
const integrationTools = [];
|
|
2227
|
+
if (response.content && Array.isArray(response.content)) {
|
|
2228
|
+
for (const item of response.content) {
|
|
2229
|
+
if (item.type === "text" && item.text) {
|
|
2230
|
+
try {
|
|
2231
|
+
const parsed = JSON.parse(item.text);
|
|
2232
|
+
if (Array.isArray(parsed)) {
|
|
2233
|
+
for (const tool of parsed) {
|
|
2234
|
+
if (tool.name && tool.inputSchema) {
|
|
2235
|
+
integrationTools.push({
|
|
2236
|
+
name: tool.name,
|
|
2237
|
+
description: tool.description,
|
|
2238
|
+
inputSchema: tool.inputSchema
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
2243
|
+
for (const tool of parsed.tools) {
|
|
2244
|
+
if (tool.name && tool.inputSchema) {
|
|
2245
|
+
integrationTools.push({
|
|
2246
|
+
name: tool.name,
|
|
2247
|
+
description: tool.description,
|
|
2248
|
+
inputSchema: tool.inputSchema
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
} catch {}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
return integrationTools;
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
logger5.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
2260
|
+
return [];
|
|
2261
|
+
}
|
|
2262
|
+
}, 3);
|
|
2263
|
+
for (const integrationTools of integrationToolsResults) {
|
|
2264
|
+
tools.push(...integrationTools);
|
|
2265
|
+
}
|
|
2266
|
+
for (const tool of tools) {
|
|
2267
|
+
this.availableTools.set(tool.name, tool);
|
|
2268
|
+
}
|
|
2269
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2270
|
+
}
|
|
2208
2271
|
getOAuthConfig(integrationId) {
|
|
2209
2272
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
|
2210
2273
|
return integration?.oauth;
|
|
@@ -7727,11 +7790,6 @@ async function executeToolWithToken(client, toolName, args, options) {
|
|
|
7727
7790
|
const result = await client._callToolByName(toolName, args);
|
|
7728
7791
|
return result;
|
|
7729
7792
|
}
|
|
7730
|
-
async function ensureClientConnected(client) {
|
|
7731
|
-
if (!client.isConnected()) {
|
|
7732
|
-
await client.connect();
|
|
7733
|
-
}
|
|
7734
|
-
}
|
|
7735
7793
|
var init_utils = __esm(() => {
|
|
7736
7794
|
init_zod();
|
|
7737
7795
|
});
|
|
@@ -7974,7 +8032,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8032
|
};
|
|
7975
8033
|
}
|
|
7976
8034
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8035
|
let providerTokens = options?.providerTokens;
|
|
7979
8036
|
if (!providerTokens) {
|
|
7980
8037
|
try {
|
|
@@ -7982,7 +8039,7 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8039
|
} catch {}
|
|
7983
8040
|
}
|
|
7984
8041
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
const mcpTools = client.
|
|
8042
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8043
|
const vercelTools = {};
|
|
7987
8044
|
for (const mcpTool of mcpTools) {
|
|
7988
8045
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9472,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9472
|
};
|
|
9416
9473
|
}
|
|
9417
9474
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9475
|
let providerTokens = options?.providerTokens;
|
|
9420
9476
|
if (!providerTokens) {
|
|
9421
9477
|
try {
|
|
@@ -9423,7 +9479,7 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9479
|
} catch {}
|
|
9424
9480
|
}
|
|
9425
9481
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
const mcpTools = client.
|
|
9482
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9483
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9484
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9485
|
if (triggerConfig) {
|
|
@@ -9547,7 +9603,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9603
|
return toolResults;
|
|
9548
9604
|
}
|
|
9549
9605
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9606
|
let providerTokens = options?.providerTokens;
|
|
9552
9607
|
if (!providerTokens) {
|
|
9553
9608
|
try {
|
|
@@ -9555,7 +9610,7 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9610
|
} catch {}
|
|
9556
9611
|
}
|
|
9557
9612
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
const mcpTools = client.
|
|
9613
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9614
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9615
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9616
|
if (triggerConfig) {
|
|
@@ -9702,7 +9757,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9757
|
return results;
|
|
9703
9758
|
}
|
|
9704
9759
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9760
|
let providerTokens = options?.providerTokens;
|
|
9707
9761
|
if (!providerTokens) {
|
|
9708
9762
|
try {
|
|
@@ -9710,7 +9764,7 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9764
|
} catch {}
|
|
9711
9765
|
}
|
|
9712
9766
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
const mcpTools = client.
|
|
9767
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9768
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9769
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9770
|
if (triggerConfig) {
|
package/dist/adapters/node.js
CHANGED
|
@@ -2205,6 +2205,69 @@ class MCPClientBase {
|
|
|
2205
2205
|
getEnabledTools() {
|
|
2206
2206
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2207
2207
|
}
|
|
2208
|
+
async getEnabledToolsAsync() {
|
|
2209
|
+
if (this.isConnected() && this.availableTools.size > 0) {
|
|
2210
|
+
return this.getEnabledTools();
|
|
2211
|
+
}
|
|
2212
|
+
if (this.availableTools.size > 0) {
|
|
2213
|
+
return this.getEnabledTools();
|
|
2214
|
+
}
|
|
2215
|
+
const tools = [];
|
|
2216
|
+
const integrationIds = new Set;
|
|
2217
|
+
for (const integration of this.integrations) {
|
|
2218
|
+
integrationIds.add(integration.id);
|
|
2219
|
+
}
|
|
2220
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
2221
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(integrationIds), async (integrationId) => {
|
|
2222
|
+
try {
|
|
2223
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
2224
|
+
integration: integrationId
|
|
2225
|
+
});
|
|
2226
|
+
const integrationTools = [];
|
|
2227
|
+
if (response.content && Array.isArray(response.content)) {
|
|
2228
|
+
for (const item of response.content) {
|
|
2229
|
+
if (item.type === "text" && item.text) {
|
|
2230
|
+
try {
|
|
2231
|
+
const parsed = JSON.parse(item.text);
|
|
2232
|
+
if (Array.isArray(parsed)) {
|
|
2233
|
+
for (const tool of parsed) {
|
|
2234
|
+
if (tool.name && tool.inputSchema) {
|
|
2235
|
+
integrationTools.push({
|
|
2236
|
+
name: tool.name,
|
|
2237
|
+
description: tool.description,
|
|
2238
|
+
inputSchema: tool.inputSchema
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
2243
|
+
for (const tool of parsed.tools) {
|
|
2244
|
+
if (tool.name && tool.inputSchema) {
|
|
2245
|
+
integrationTools.push({
|
|
2246
|
+
name: tool.name,
|
|
2247
|
+
description: tool.description,
|
|
2248
|
+
inputSchema: tool.inputSchema
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
} catch {}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
return integrationTools;
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
logger5.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
2260
|
+
return [];
|
|
2261
|
+
}
|
|
2262
|
+
}, 3);
|
|
2263
|
+
for (const integrationTools of integrationToolsResults) {
|
|
2264
|
+
tools.push(...integrationTools);
|
|
2265
|
+
}
|
|
2266
|
+
for (const tool of tools) {
|
|
2267
|
+
this.availableTools.set(tool.name, tool);
|
|
2268
|
+
}
|
|
2269
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
2270
|
+
}
|
|
2208
2271
|
getOAuthConfig(integrationId) {
|
|
2209
2272
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
|
2210
2273
|
return integration?.oauth;
|
|
@@ -7727,11 +7790,6 @@ async function executeToolWithToken(client, toolName, args, options) {
|
|
|
7727
7790
|
const result = await client._callToolByName(toolName, args);
|
|
7728
7791
|
return result;
|
|
7729
7792
|
}
|
|
7730
|
-
async function ensureClientConnected(client) {
|
|
7731
|
-
if (!client.isConnected()) {
|
|
7732
|
-
await client.connect();
|
|
7733
|
-
}
|
|
7734
|
-
}
|
|
7735
7793
|
var init_utils = __esm(() => {
|
|
7736
7794
|
init_zod();
|
|
7737
7795
|
});
|
|
@@ -7974,7 +8032,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8032
|
};
|
|
7975
8033
|
}
|
|
7976
8034
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8035
|
let providerTokens = options?.providerTokens;
|
|
7979
8036
|
if (!providerTokens) {
|
|
7980
8037
|
try {
|
|
@@ -7982,7 +8039,7 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8039
|
} catch {}
|
|
7983
8040
|
}
|
|
7984
8041
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
const mcpTools = client.
|
|
8042
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8043
|
const vercelTools = {};
|
|
7987
8044
|
for (const mcpTool of mcpTools) {
|
|
7988
8045
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9472,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9472
|
};
|
|
9416
9473
|
}
|
|
9417
9474
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9475
|
let providerTokens = options?.providerTokens;
|
|
9420
9476
|
if (!providerTokens) {
|
|
9421
9477
|
try {
|
|
@@ -9423,7 +9479,7 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9479
|
} catch {}
|
|
9424
9480
|
}
|
|
9425
9481
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
const mcpTools = client.
|
|
9482
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9483
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9484
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9485
|
if (triggerConfig) {
|
|
@@ -9547,7 +9603,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9603
|
return toolResults;
|
|
9548
9604
|
}
|
|
9549
9605
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9606
|
let providerTokens = options?.providerTokens;
|
|
9552
9607
|
if (!providerTokens) {
|
|
9553
9608
|
try {
|
|
@@ -9555,7 +9610,7 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9610
|
} catch {}
|
|
9556
9611
|
}
|
|
9557
9612
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
const mcpTools = client.
|
|
9613
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9614
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9615
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9616
|
if (triggerConfig) {
|
|
@@ -9702,7 +9757,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9757
|
return results;
|
|
9703
9758
|
}
|
|
9704
9759
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9760
|
let providerTokens = options?.providerTokens;
|
|
9707
9761
|
if (!providerTokens) {
|
|
9708
9762
|
try {
|
|
@@ -9710,7 +9764,7 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9764
|
} catch {}
|
|
9711
9765
|
}
|
|
9712
9766
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
const mcpTools = client.
|
|
9767
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9768
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9769
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9770
|
if (triggerConfig) {
|