integrate-sdk 0.8.54-dev.0 → 0.8.57-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 +72 -8
- package/dist/adapters/index.js +72 -8
- package/dist/adapters/nextjs.js +72 -8
- package/dist/adapters/node.js +72 -8
- package/dist/adapters/svelte-kit.js +72 -8
- package/dist/adapters/tanstack-start.js +72 -8
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +3 -2
- package/dist/ai/google.d.ts.map +1 -1
- package/dist/ai/google.js +3 -2
- package/dist/ai/index.js +9 -8
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +3 -2
- package/dist/ai/trigger-tools.d.ts +4 -4
- package/dist/ai/utils.d.ts.map +1 -1
- package/dist/ai/utils.js +1 -0
- package/dist/ai/vercel-ai.d.ts.map +1 -1
- package/dist/ai/vercel-ai.js +3 -2
- package/dist/index.js +72 -8
- package/dist/oauth.js +72 -8
- package/dist/server.js +72 -8
- 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/utils.d.ts.map +1 -1
- 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;
|
|
@@ -7701,6 +7764,7 @@ function jsonSchemaToZod(schema) {
|
|
|
7701
7764
|
return exports_external.object({});
|
|
7702
7765
|
}
|
|
7703
7766
|
async function executeToolWithToken(client, toolName, args, options) {
|
|
7767
|
+
await ensureClientConnected(client);
|
|
7704
7768
|
if (options?.providerTokens) {
|
|
7705
7769
|
const provider = getProviderForTool(client, toolName);
|
|
7706
7770
|
if (provider && options.providerTokens[provider]) {
|
|
@@ -7974,7 +8038,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8038
|
};
|
|
7975
8039
|
}
|
|
7976
8040
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8041
|
let providerTokens = options?.providerTokens;
|
|
7979
8042
|
if (!providerTokens) {
|
|
7980
8043
|
try {
|
|
@@ -7982,7 +8045,8 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8045
|
} catch {}
|
|
7983
8046
|
}
|
|
7984
8047
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
|
|
8048
|
+
await ensureClientConnected(client);
|
|
8049
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8050
|
const vercelTools = {};
|
|
7987
8051
|
for (const mcpTool of mcpTools) {
|
|
7988
8052
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9479,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9479
|
};
|
|
9416
9480
|
}
|
|
9417
9481
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9482
|
let providerTokens = options?.providerTokens;
|
|
9420
9483
|
if (!providerTokens) {
|
|
9421
9484
|
try {
|
|
@@ -9423,7 +9486,8 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9486
|
} catch {}
|
|
9424
9487
|
}
|
|
9425
9488
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
|
|
9489
|
+
await ensureClientConnected(client);
|
|
9490
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9491
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9492
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9493
|
if (triggerConfig) {
|
|
@@ -9547,7 +9611,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9611
|
return toolResults;
|
|
9548
9612
|
}
|
|
9549
9613
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9614
|
let providerTokens = options?.providerTokens;
|
|
9552
9615
|
if (!providerTokens) {
|
|
9553
9616
|
try {
|
|
@@ -9555,7 +9618,8 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9618
|
} catch {}
|
|
9556
9619
|
}
|
|
9557
9620
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
|
|
9621
|
+
await ensureClientConnected(client);
|
|
9622
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9623
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9624
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9625
|
if (triggerConfig) {
|
|
@@ -9702,7 +9766,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9766
|
return results;
|
|
9703
9767
|
}
|
|
9704
9768
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9769
|
let providerTokens = options?.providerTokens;
|
|
9707
9770
|
if (!providerTokens) {
|
|
9708
9771
|
try {
|
|
@@ -9710,7 +9773,8 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9773
|
} catch {}
|
|
9711
9774
|
}
|
|
9712
9775
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
|
|
9776
|
+
await ensureClientConnected(client);
|
|
9777
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9778
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9779
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9780
|
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;
|
|
@@ -7701,6 +7764,7 @@ function jsonSchemaToZod(schema) {
|
|
|
7701
7764
|
return exports_external.object({});
|
|
7702
7765
|
}
|
|
7703
7766
|
async function executeToolWithToken(client, toolName, args, options) {
|
|
7767
|
+
await ensureClientConnected(client);
|
|
7704
7768
|
if (options?.providerTokens) {
|
|
7705
7769
|
const provider = getProviderForTool(client, toolName);
|
|
7706
7770
|
if (provider && options.providerTokens[provider]) {
|
|
@@ -7974,7 +8038,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8038
|
};
|
|
7975
8039
|
}
|
|
7976
8040
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8041
|
let providerTokens = options?.providerTokens;
|
|
7979
8042
|
if (!providerTokens) {
|
|
7980
8043
|
try {
|
|
@@ -7982,7 +8045,8 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8045
|
} catch {}
|
|
7983
8046
|
}
|
|
7984
8047
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
|
|
8048
|
+
await ensureClientConnected(client);
|
|
8049
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8050
|
const vercelTools = {};
|
|
7987
8051
|
for (const mcpTool of mcpTools) {
|
|
7988
8052
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9479,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9479
|
};
|
|
9416
9480
|
}
|
|
9417
9481
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9482
|
let providerTokens = options?.providerTokens;
|
|
9420
9483
|
if (!providerTokens) {
|
|
9421
9484
|
try {
|
|
@@ -9423,7 +9486,8 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9486
|
} catch {}
|
|
9424
9487
|
}
|
|
9425
9488
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
|
|
9489
|
+
await ensureClientConnected(client);
|
|
9490
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9491
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9492
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9493
|
if (triggerConfig) {
|
|
@@ -9547,7 +9611,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9611
|
return toolResults;
|
|
9548
9612
|
}
|
|
9549
9613
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9614
|
let providerTokens = options?.providerTokens;
|
|
9552
9615
|
if (!providerTokens) {
|
|
9553
9616
|
try {
|
|
@@ -9555,7 +9618,8 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9618
|
} catch {}
|
|
9556
9619
|
}
|
|
9557
9620
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
|
|
9621
|
+
await ensureClientConnected(client);
|
|
9622
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9623
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9624
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9625
|
if (triggerConfig) {
|
|
@@ -9702,7 +9766,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9766
|
return results;
|
|
9703
9767
|
}
|
|
9704
9768
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9769
|
let providerTokens = options?.providerTokens;
|
|
9707
9770
|
if (!providerTokens) {
|
|
9708
9771
|
try {
|
|
@@ -9710,7 +9773,8 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9773
|
} catch {}
|
|
9711
9774
|
}
|
|
9712
9775
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
|
|
9776
|
+
await ensureClientConnected(client);
|
|
9777
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9778
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9779
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9780
|
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;
|
|
@@ -7701,6 +7764,7 @@ function jsonSchemaToZod(schema) {
|
|
|
7701
7764
|
return exports_external.object({});
|
|
7702
7765
|
}
|
|
7703
7766
|
async function executeToolWithToken(client, toolName, args, options) {
|
|
7767
|
+
await ensureClientConnected(client);
|
|
7704
7768
|
if (options?.providerTokens) {
|
|
7705
7769
|
const provider = getProviderForTool(client, toolName);
|
|
7706
7770
|
if (provider && options.providerTokens[provider]) {
|
|
@@ -7974,7 +8038,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8038
|
};
|
|
7975
8039
|
}
|
|
7976
8040
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8041
|
let providerTokens = options?.providerTokens;
|
|
7979
8042
|
if (!providerTokens) {
|
|
7980
8043
|
try {
|
|
@@ -7982,7 +8045,8 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8045
|
} catch {}
|
|
7983
8046
|
}
|
|
7984
8047
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
|
|
8048
|
+
await ensureClientConnected(client);
|
|
8049
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8050
|
const vercelTools = {};
|
|
7987
8051
|
for (const mcpTool of mcpTools) {
|
|
7988
8052
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9479,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9479
|
};
|
|
9416
9480
|
}
|
|
9417
9481
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9482
|
let providerTokens = options?.providerTokens;
|
|
9420
9483
|
if (!providerTokens) {
|
|
9421
9484
|
try {
|
|
@@ -9423,7 +9486,8 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9486
|
} catch {}
|
|
9424
9487
|
}
|
|
9425
9488
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
|
|
9489
|
+
await ensureClientConnected(client);
|
|
9490
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9491
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9492
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9493
|
if (triggerConfig) {
|
|
@@ -9547,7 +9611,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9611
|
return toolResults;
|
|
9548
9612
|
}
|
|
9549
9613
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9614
|
let providerTokens = options?.providerTokens;
|
|
9552
9615
|
if (!providerTokens) {
|
|
9553
9616
|
try {
|
|
@@ -9555,7 +9618,8 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9618
|
} catch {}
|
|
9556
9619
|
}
|
|
9557
9620
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
|
|
9621
|
+
await ensureClientConnected(client);
|
|
9622
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9623
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9624
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9625
|
if (triggerConfig) {
|
|
@@ -9702,7 +9766,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9766
|
return results;
|
|
9703
9767
|
}
|
|
9704
9768
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9769
|
let providerTokens = options?.providerTokens;
|
|
9707
9770
|
if (!providerTokens) {
|
|
9708
9771
|
try {
|
|
@@ -9710,7 +9773,8 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9773
|
} catch {}
|
|
9711
9774
|
}
|
|
9712
9775
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
|
|
9776
|
+
await ensureClientConnected(client);
|
|
9777
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9778
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9779
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9780
|
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;
|
|
@@ -7701,6 +7764,7 @@ function jsonSchemaToZod(schema) {
|
|
|
7701
7764
|
return exports_external.object({});
|
|
7702
7765
|
}
|
|
7703
7766
|
async function executeToolWithToken(client, toolName, args, options) {
|
|
7767
|
+
await ensureClientConnected(client);
|
|
7704
7768
|
if (options?.providerTokens) {
|
|
7705
7769
|
const provider = getProviderForTool(client, toolName);
|
|
7706
7770
|
if (provider && options.providerTokens[provider]) {
|
|
@@ -7974,7 +8038,6 @@ function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
|
7974
8038
|
};
|
|
7975
8039
|
}
|
|
7976
8040
|
async function getVercelAITools(client, options) {
|
|
7977
|
-
await ensureClientConnected(client);
|
|
7978
8041
|
let providerTokens = options?.providerTokens;
|
|
7979
8042
|
if (!providerTokens) {
|
|
7980
8043
|
try {
|
|
@@ -7982,7 +8045,8 @@ async function getVercelAITools(client, options) {
|
|
|
7982
8045
|
} catch {}
|
|
7983
8046
|
}
|
|
7984
8047
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
7985
|
-
|
|
8048
|
+
await ensureClientConnected(client);
|
|
8049
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
7986
8050
|
const vercelTools = {};
|
|
7987
8051
|
for (const mcpTool of mcpTools) {
|
|
7988
8052
|
vercelTools[mcpTool.name] = convertMCPToolToVercelAI(mcpTool, client, finalOptions);
|
|
@@ -9415,7 +9479,6 @@ function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
|
9415
9479
|
};
|
|
9416
9480
|
}
|
|
9417
9481
|
async function getOpenAITools(client, options) {
|
|
9418
|
-
await ensureClientConnected(client);
|
|
9419
9482
|
let providerTokens = options?.providerTokens;
|
|
9420
9483
|
if (!providerTokens) {
|
|
9421
9484
|
try {
|
|
@@ -9423,7 +9486,8 @@ async function getOpenAITools(client, options) {
|
|
|
9423
9486
|
} catch {}
|
|
9424
9487
|
}
|
|
9425
9488
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9426
|
-
|
|
9489
|
+
await ensureClientConnected(client);
|
|
9490
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9427
9491
|
const openaiTools = mcpTools.map((mcpTool) => convertMCPToolToOpenAI(mcpTool, client, finalOptions));
|
|
9428
9492
|
const triggerConfig = client.__triggerConfig;
|
|
9429
9493
|
if (triggerConfig) {
|
|
@@ -9547,7 +9611,6 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
9547
9611
|
return toolResults;
|
|
9548
9612
|
}
|
|
9549
9613
|
async function getAnthropicTools(client, options) {
|
|
9550
|
-
await ensureClientConnected(client);
|
|
9551
9614
|
let providerTokens = options?.providerTokens;
|
|
9552
9615
|
if (!providerTokens) {
|
|
9553
9616
|
try {
|
|
@@ -9555,7 +9618,8 @@ async function getAnthropicTools(client, options) {
|
|
|
9555
9618
|
} catch {}
|
|
9556
9619
|
}
|
|
9557
9620
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9558
|
-
|
|
9621
|
+
await ensureClientConnected(client);
|
|
9622
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9559
9623
|
const anthropicTools = mcpTools.map((mcpTool) => convertMCPToolToAnthropic(mcpTool, client, finalOptions));
|
|
9560
9624
|
const triggerConfig = client.__triggerConfig;
|
|
9561
9625
|
if (triggerConfig) {
|
|
@@ -9702,7 +9766,6 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
9702
9766
|
return results;
|
|
9703
9767
|
}
|
|
9704
9768
|
async function getGoogleTools(client, options) {
|
|
9705
|
-
await ensureClientConnected(client);
|
|
9706
9769
|
let providerTokens = options?.providerTokens;
|
|
9707
9770
|
if (!providerTokens) {
|
|
9708
9771
|
try {
|
|
@@ -9710,7 +9773,8 @@ async function getGoogleTools(client, options) {
|
|
|
9710
9773
|
} catch {}
|
|
9711
9774
|
}
|
|
9712
9775
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
9713
|
-
|
|
9776
|
+
await ensureClientConnected(client);
|
|
9777
|
+
const mcpTools = await client.getEnabledToolsAsync();
|
|
9714
9778
|
const googleTools = await Promise.all(mcpTools.map((mcpTool) => convertMCPToolToGoogle(mcpTool, client, finalOptions)));
|
|
9715
9779
|
const triggerConfig = client.__triggerConfig;
|
|
9716
9780
|
if (triggerConfig) {
|