integrate-sdk 0.9.61 → 0.9.64
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 +2 -2
- package/dist/adapters/index.js +93 -50
- package/dist/adapters/solid-start.js +93 -50
- package/dist/adapters/svelte-kit.js +93 -50
- package/dist/index.js +103 -50
- package/dist/integrations.js +103 -50
- package/dist/server.js +105 -50
- package/dist/src/client.d.ts +1 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/integrations/granola.d.ts.map +1 -1
- package/dist/src/integrations/list-tools-by-integration.d.ts +11 -0
- package/dist/src/integrations/list-tools-by-integration.d.ts.map +1 -0
- package/dist/src/integrations/mercury.d.ts.map +1 -1
- package/dist/src/integrations/resend.d.ts.map +1 -1
- package/dist/src/integrations/tldraw.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -344,7 +344,7 @@ For complete OAuth setup including:
|
|
|
344
344
|
- Multiple providers
|
|
345
345
|
- Callback page setup
|
|
346
346
|
|
|
347
|
-
See the [`/examples`](/examples) directory or [OAuth documentation](https://integrate.dev/docs/
|
|
347
|
+
See the [`/examples`](/examples) directory or [OAuth documentation](https://integrate.dev/docs/getting-started/basic-usage).
|
|
348
348
|
|
|
349
349
|
## Scheduled Triggers
|
|
350
350
|
|
|
@@ -488,7 +488,7 @@ const result = await generateText({
|
|
|
488
488
|
For detailed guides, API reference, and examples, visit the [complete documentation](https://integrate.dev):
|
|
489
489
|
|
|
490
490
|
- **[Getting Started](https://integrate.dev/docs/getting-started/installation)** - Installation and quick start
|
|
491
|
-
- **[OAuth Flow](https://integrate.dev/docs/
|
|
491
|
+
- **[OAuth Flow](https://integrate.dev/docs/getting-started/basic-usage)** - OAuth 2.0 authorization guide
|
|
492
492
|
- **[Integrations](https://integrate.dev/docs/integrations)** - Built-in integrations and configuration
|
|
493
493
|
- **[Vercel AI SDK](https://integrate.dev/docs/artificial-intelligence/vercel-ai-sdk)** - AI model integration
|
|
494
494
|
- **[Advanced Usage](https://integrate.dev/docs/guides/advanced-usage)** - Error handling, retries, and more
|
package/dist/adapters/index.js
CHANGED
|
@@ -2728,6 +2728,79 @@ class HttpSessionTransport {
|
|
|
2728
2728
|
|
|
2729
2729
|
// ../client.ts
|
|
2730
2730
|
init_integration_summary();
|
|
2731
|
+
|
|
2732
|
+
// ../integrations/list-tools-by-integration.ts
|
|
2733
|
+
function extractToolEntries(payload) {
|
|
2734
|
+
if (Array.isArray(payload)) {
|
|
2735
|
+
return payload;
|
|
2736
|
+
}
|
|
2737
|
+
if (payload && typeof payload === "object" && "tools" in payload) {
|
|
2738
|
+
const tools = payload.tools;
|
|
2739
|
+
if (Array.isArray(tools)) {
|
|
2740
|
+
return tools;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
return [];
|
|
2744
|
+
}
|
|
2745
|
+
function toMetadataTool(entry, availableTools) {
|
|
2746
|
+
if (entry.inputSchema) {
|
|
2747
|
+
return {
|
|
2748
|
+
name: entry.name,
|
|
2749
|
+
description: entry.description,
|
|
2750
|
+
inputSchema: entry.inputSchema
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
const cached = availableTools.get(entry.name);
|
|
2754
|
+
if (cached) {
|
|
2755
|
+
return cached;
|
|
2756
|
+
}
|
|
2757
|
+
return {
|
|
2758
|
+
name: entry.name,
|
|
2759
|
+
description: entry.description,
|
|
2760
|
+
inputSchema: {
|
|
2761
|
+
type: "object",
|
|
2762
|
+
properties: {}
|
|
2763
|
+
}
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
function parseToolsFromListByIntegrationPayload(payload, availableTools) {
|
|
2767
|
+
const tools = [];
|
|
2768
|
+
for (const entry of extractToolEntries(payload)) {
|
|
2769
|
+
if (typeof entry === "string") {
|
|
2770
|
+
const cached = availableTools.get(entry);
|
|
2771
|
+
tools.push(cached ?? {
|
|
2772
|
+
name: entry,
|
|
2773
|
+
inputSchema: { type: "object", properties: {} }
|
|
2774
|
+
});
|
|
2775
|
+
continue;
|
|
2776
|
+
}
|
|
2777
|
+
if (!entry || typeof entry !== "object" || !("name" in entry)) {
|
|
2778
|
+
continue;
|
|
2779
|
+
}
|
|
2780
|
+
const candidate = entry;
|
|
2781
|
+
if (!candidate.name) {
|
|
2782
|
+
continue;
|
|
2783
|
+
}
|
|
2784
|
+
const normalized = toMetadataTool({
|
|
2785
|
+
name: candidate.name,
|
|
2786
|
+
description: candidate.description,
|
|
2787
|
+
inputSchema: candidate.inputSchema
|
|
2788
|
+
}, availableTools);
|
|
2789
|
+
if (normalized) {
|
|
2790
|
+
tools.push(normalized);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
return tools;
|
|
2794
|
+
}
|
|
2795
|
+
function parseToolsFromListByIntegrationText(text, availableTools) {
|
|
2796
|
+
try {
|
|
2797
|
+
return parseToolsFromListByIntegrationPayload(JSON.parse(text), availableTools);
|
|
2798
|
+
} catch {
|
|
2799
|
+
return [];
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
// ../client.ts
|
|
2731
2804
|
init_library_metadata();
|
|
2732
2805
|
|
|
2733
2806
|
// ../database/token-store.ts
|
|
@@ -4270,21 +4343,7 @@ class MCPClientBase {
|
|
|
4270
4343
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4271
4344
|
integration: integration.id
|
|
4272
4345
|
});
|
|
4273
|
-
|
|
4274
|
-
if (response.content && Array.isArray(response.content)) {
|
|
4275
|
-
for (const item of response.content) {
|
|
4276
|
-
if (item.type === "text" && item.text) {
|
|
4277
|
-
try {
|
|
4278
|
-
const parsed = JSON.parse(item.text);
|
|
4279
|
-
if (Array.isArray(parsed)) {
|
|
4280
|
-
toolMetadata = parsed;
|
|
4281
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4282
|
-
toolMetadata = parsed.tools;
|
|
4283
|
-
}
|
|
4284
|
-
} catch {}
|
|
4285
|
-
}
|
|
4286
|
-
}
|
|
4287
|
-
}
|
|
4346
|
+
const toolMetadata = this.parseListToolsByIntegrationContent(response.content);
|
|
4288
4347
|
return toConfiguredIntegrationWithToolMetadata(integration, toolMetadata);
|
|
4289
4348
|
} catch (error) {
|
|
4290
4349
|
logger7.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
@@ -4321,21 +4380,7 @@ class MCPClientBase {
|
|
|
4321
4380
|
const metadataResponse = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4322
4381
|
integration: integration.id
|
|
4323
4382
|
});
|
|
4324
|
-
|
|
4325
|
-
if (metadataResponse.content && Array.isArray(metadataResponse.content)) {
|
|
4326
|
-
for (const item of metadataResponse.content) {
|
|
4327
|
-
if (item.type === "text" && item.text) {
|
|
4328
|
-
try {
|
|
4329
|
-
const parsed = JSON.parse(item.text);
|
|
4330
|
-
if (Array.isArray(parsed)) {
|
|
4331
|
-
toolMetadata = parsed;
|
|
4332
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4333
|
-
toolMetadata = parsed.tools;
|
|
4334
|
-
}
|
|
4335
|
-
} catch {}
|
|
4336
|
-
}
|
|
4337
|
-
}
|
|
4338
|
-
}
|
|
4383
|
+
const toolMetadata = this.parseListToolsByIntegrationContent(metadataResponse.content);
|
|
4339
4384
|
return {
|
|
4340
4385
|
...integration,
|
|
4341
4386
|
...integrationLibraryPresentationFields(integration),
|
|
@@ -4593,6 +4638,18 @@ class MCPClientBase {
|
|
|
4593
4638
|
}
|
|
4594
4639
|
return {};
|
|
4595
4640
|
}
|
|
4641
|
+
parseListToolsByIntegrationContent(content) {
|
|
4642
|
+
const tools = [];
|
|
4643
|
+
if (!content || !Array.isArray(content)) {
|
|
4644
|
+
return tools;
|
|
4645
|
+
}
|
|
4646
|
+
for (const item of content) {
|
|
4647
|
+
if (item.type === "text" && item.text) {
|
|
4648
|
+
tools.push(...parseToolsFromListByIntegrationText(item.text, this.availableTools));
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
return tools;
|
|
4652
|
+
}
|
|
4596
4653
|
getTool(name) {
|
|
4597
4654
|
return this.availableTools.get(name);
|
|
4598
4655
|
}
|
|
@@ -4637,6 +4694,11 @@ class MCPClientBase {
|
|
|
4637
4694
|
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
4638
4695
|
return filterToTargets(this.getEnabledTools());
|
|
4639
4696
|
}
|
|
4697
|
+
const transportHeaders = this.transport.headers || {};
|
|
4698
|
+
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
4699
|
+
if (hasApiKey) {
|
|
4700
|
+
await this.ensureConnected();
|
|
4701
|
+
}
|
|
4640
4702
|
const tools = [];
|
|
4641
4703
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
4642
4704
|
const concurrency = options?.fetchConcurrency ?? 8;
|
|
@@ -4645,26 +4707,7 @@ class MCPClientBase {
|
|
|
4645
4707
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4646
4708
|
integration: integrationId
|
|
4647
4709
|
});
|
|
4648
|
-
const integrationTools =
|
|
4649
|
-
if (response.content && Array.isArray(response.content)) {
|
|
4650
|
-
for (const item of response.content) {
|
|
4651
|
-
if (item.type === "text" && item.text) {
|
|
4652
|
-
try {
|
|
4653
|
-
const parsed = JSON.parse(item.text);
|
|
4654
|
-
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
4655
|
-
for (const tool of parsedTools) {
|
|
4656
|
-
if (tool.name && tool.inputSchema) {
|
|
4657
|
-
integrationTools.push({
|
|
4658
|
-
name: tool.name,
|
|
4659
|
-
description: tool.description,
|
|
4660
|
-
inputSchema: tool.inputSchema
|
|
4661
|
-
});
|
|
4662
|
-
}
|
|
4663
|
-
}
|
|
4664
|
-
} catch {}
|
|
4665
|
-
}
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4710
|
+
const integrationTools = this.parseListToolsByIntegrationContent(response.content).filter((tool) => tool.inputSchema);
|
|
4668
4711
|
return integrationTools;
|
|
4669
4712
|
} catch (error) {
|
|
4670
4713
|
logger7.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
@@ -2728,6 +2728,79 @@ class HttpSessionTransport {
|
|
|
2728
2728
|
|
|
2729
2729
|
// ../client.ts
|
|
2730
2730
|
init_integration_summary();
|
|
2731
|
+
|
|
2732
|
+
// ../integrations/list-tools-by-integration.ts
|
|
2733
|
+
function extractToolEntries(payload) {
|
|
2734
|
+
if (Array.isArray(payload)) {
|
|
2735
|
+
return payload;
|
|
2736
|
+
}
|
|
2737
|
+
if (payload && typeof payload === "object" && "tools" in payload) {
|
|
2738
|
+
const tools = payload.tools;
|
|
2739
|
+
if (Array.isArray(tools)) {
|
|
2740
|
+
return tools;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
return [];
|
|
2744
|
+
}
|
|
2745
|
+
function toMetadataTool(entry, availableTools) {
|
|
2746
|
+
if (entry.inputSchema) {
|
|
2747
|
+
return {
|
|
2748
|
+
name: entry.name,
|
|
2749
|
+
description: entry.description,
|
|
2750
|
+
inputSchema: entry.inputSchema
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
const cached = availableTools.get(entry.name);
|
|
2754
|
+
if (cached) {
|
|
2755
|
+
return cached;
|
|
2756
|
+
}
|
|
2757
|
+
return {
|
|
2758
|
+
name: entry.name,
|
|
2759
|
+
description: entry.description,
|
|
2760
|
+
inputSchema: {
|
|
2761
|
+
type: "object",
|
|
2762
|
+
properties: {}
|
|
2763
|
+
}
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
function parseToolsFromListByIntegrationPayload(payload, availableTools) {
|
|
2767
|
+
const tools = [];
|
|
2768
|
+
for (const entry of extractToolEntries(payload)) {
|
|
2769
|
+
if (typeof entry === "string") {
|
|
2770
|
+
const cached = availableTools.get(entry);
|
|
2771
|
+
tools.push(cached ?? {
|
|
2772
|
+
name: entry,
|
|
2773
|
+
inputSchema: { type: "object", properties: {} }
|
|
2774
|
+
});
|
|
2775
|
+
continue;
|
|
2776
|
+
}
|
|
2777
|
+
if (!entry || typeof entry !== "object" || !("name" in entry)) {
|
|
2778
|
+
continue;
|
|
2779
|
+
}
|
|
2780
|
+
const candidate = entry;
|
|
2781
|
+
if (!candidate.name) {
|
|
2782
|
+
continue;
|
|
2783
|
+
}
|
|
2784
|
+
const normalized = toMetadataTool({
|
|
2785
|
+
name: candidate.name,
|
|
2786
|
+
description: candidate.description,
|
|
2787
|
+
inputSchema: candidate.inputSchema
|
|
2788
|
+
}, availableTools);
|
|
2789
|
+
if (normalized) {
|
|
2790
|
+
tools.push(normalized);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
return tools;
|
|
2794
|
+
}
|
|
2795
|
+
function parseToolsFromListByIntegrationText(text, availableTools) {
|
|
2796
|
+
try {
|
|
2797
|
+
return parseToolsFromListByIntegrationPayload(JSON.parse(text), availableTools);
|
|
2798
|
+
} catch {
|
|
2799
|
+
return [];
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
// ../client.ts
|
|
2731
2804
|
init_library_metadata();
|
|
2732
2805
|
|
|
2733
2806
|
// ../database/token-store.ts
|
|
@@ -4270,21 +4343,7 @@ class MCPClientBase {
|
|
|
4270
4343
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4271
4344
|
integration: integration.id
|
|
4272
4345
|
});
|
|
4273
|
-
|
|
4274
|
-
if (response.content && Array.isArray(response.content)) {
|
|
4275
|
-
for (const item of response.content) {
|
|
4276
|
-
if (item.type === "text" && item.text) {
|
|
4277
|
-
try {
|
|
4278
|
-
const parsed = JSON.parse(item.text);
|
|
4279
|
-
if (Array.isArray(parsed)) {
|
|
4280
|
-
toolMetadata = parsed;
|
|
4281
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4282
|
-
toolMetadata = parsed.tools;
|
|
4283
|
-
}
|
|
4284
|
-
} catch {}
|
|
4285
|
-
}
|
|
4286
|
-
}
|
|
4287
|
-
}
|
|
4346
|
+
const toolMetadata = this.parseListToolsByIntegrationContent(response.content);
|
|
4288
4347
|
return toConfiguredIntegrationWithToolMetadata(integration, toolMetadata);
|
|
4289
4348
|
} catch (error) {
|
|
4290
4349
|
logger7.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
@@ -4321,21 +4380,7 @@ class MCPClientBase {
|
|
|
4321
4380
|
const metadataResponse = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4322
4381
|
integration: integration.id
|
|
4323
4382
|
});
|
|
4324
|
-
|
|
4325
|
-
if (metadataResponse.content && Array.isArray(metadataResponse.content)) {
|
|
4326
|
-
for (const item of metadataResponse.content) {
|
|
4327
|
-
if (item.type === "text" && item.text) {
|
|
4328
|
-
try {
|
|
4329
|
-
const parsed = JSON.parse(item.text);
|
|
4330
|
-
if (Array.isArray(parsed)) {
|
|
4331
|
-
toolMetadata = parsed;
|
|
4332
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4333
|
-
toolMetadata = parsed.tools;
|
|
4334
|
-
}
|
|
4335
|
-
} catch {}
|
|
4336
|
-
}
|
|
4337
|
-
}
|
|
4338
|
-
}
|
|
4383
|
+
const toolMetadata = this.parseListToolsByIntegrationContent(metadataResponse.content);
|
|
4339
4384
|
return {
|
|
4340
4385
|
...integration,
|
|
4341
4386
|
...integrationLibraryPresentationFields(integration),
|
|
@@ -4593,6 +4638,18 @@ class MCPClientBase {
|
|
|
4593
4638
|
}
|
|
4594
4639
|
return {};
|
|
4595
4640
|
}
|
|
4641
|
+
parseListToolsByIntegrationContent(content) {
|
|
4642
|
+
const tools = [];
|
|
4643
|
+
if (!content || !Array.isArray(content)) {
|
|
4644
|
+
return tools;
|
|
4645
|
+
}
|
|
4646
|
+
for (const item of content) {
|
|
4647
|
+
if (item.type === "text" && item.text) {
|
|
4648
|
+
tools.push(...parseToolsFromListByIntegrationText(item.text, this.availableTools));
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
return tools;
|
|
4652
|
+
}
|
|
4596
4653
|
getTool(name) {
|
|
4597
4654
|
return this.availableTools.get(name);
|
|
4598
4655
|
}
|
|
@@ -4637,6 +4694,11 @@ class MCPClientBase {
|
|
|
4637
4694
|
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
4638
4695
|
return filterToTargets(this.getEnabledTools());
|
|
4639
4696
|
}
|
|
4697
|
+
const transportHeaders = this.transport.headers || {};
|
|
4698
|
+
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
4699
|
+
if (hasApiKey) {
|
|
4700
|
+
await this.ensureConnected();
|
|
4701
|
+
}
|
|
4640
4702
|
const tools = [];
|
|
4641
4703
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
4642
4704
|
const concurrency = options?.fetchConcurrency ?? 8;
|
|
@@ -4645,26 +4707,7 @@ class MCPClientBase {
|
|
|
4645
4707
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4646
4708
|
integration: integrationId
|
|
4647
4709
|
});
|
|
4648
|
-
const integrationTools =
|
|
4649
|
-
if (response.content && Array.isArray(response.content)) {
|
|
4650
|
-
for (const item of response.content) {
|
|
4651
|
-
if (item.type === "text" && item.text) {
|
|
4652
|
-
try {
|
|
4653
|
-
const parsed = JSON.parse(item.text);
|
|
4654
|
-
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
4655
|
-
for (const tool of parsedTools) {
|
|
4656
|
-
if (tool.name && tool.inputSchema) {
|
|
4657
|
-
integrationTools.push({
|
|
4658
|
-
name: tool.name,
|
|
4659
|
-
description: tool.description,
|
|
4660
|
-
inputSchema: tool.inputSchema
|
|
4661
|
-
});
|
|
4662
|
-
}
|
|
4663
|
-
}
|
|
4664
|
-
} catch {}
|
|
4665
|
-
}
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4710
|
+
const integrationTools = this.parseListToolsByIntegrationContent(response.content).filter((tool) => tool.inputSchema);
|
|
4668
4711
|
return integrationTools;
|
|
4669
4712
|
} catch (error) {
|
|
4670
4713
|
logger7.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
@@ -2728,6 +2728,79 @@ class HttpSessionTransport {
|
|
|
2728
2728
|
|
|
2729
2729
|
// ../client.ts
|
|
2730
2730
|
init_integration_summary();
|
|
2731
|
+
|
|
2732
|
+
// ../integrations/list-tools-by-integration.ts
|
|
2733
|
+
function extractToolEntries(payload) {
|
|
2734
|
+
if (Array.isArray(payload)) {
|
|
2735
|
+
return payload;
|
|
2736
|
+
}
|
|
2737
|
+
if (payload && typeof payload === "object" && "tools" in payload) {
|
|
2738
|
+
const tools = payload.tools;
|
|
2739
|
+
if (Array.isArray(tools)) {
|
|
2740
|
+
return tools;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
return [];
|
|
2744
|
+
}
|
|
2745
|
+
function toMetadataTool(entry, availableTools) {
|
|
2746
|
+
if (entry.inputSchema) {
|
|
2747
|
+
return {
|
|
2748
|
+
name: entry.name,
|
|
2749
|
+
description: entry.description,
|
|
2750
|
+
inputSchema: entry.inputSchema
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
const cached = availableTools.get(entry.name);
|
|
2754
|
+
if (cached) {
|
|
2755
|
+
return cached;
|
|
2756
|
+
}
|
|
2757
|
+
return {
|
|
2758
|
+
name: entry.name,
|
|
2759
|
+
description: entry.description,
|
|
2760
|
+
inputSchema: {
|
|
2761
|
+
type: "object",
|
|
2762
|
+
properties: {}
|
|
2763
|
+
}
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
function parseToolsFromListByIntegrationPayload(payload, availableTools) {
|
|
2767
|
+
const tools = [];
|
|
2768
|
+
for (const entry of extractToolEntries(payload)) {
|
|
2769
|
+
if (typeof entry === "string") {
|
|
2770
|
+
const cached = availableTools.get(entry);
|
|
2771
|
+
tools.push(cached ?? {
|
|
2772
|
+
name: entry,
|
|
2773
|
+
inputSchema: { type: "object", properties: {} }
|
|
2774
|
+
});
|
|
2775
|
+
continue;
|
|
2776
|
+
}
|
|
2777
|
+
if (!entry || typeof entry !== "object" || !("name" in entry)) {
|
|
2778
|
+
continue;
|
|
2779
|
+
}
|
|
2780
|
+
const candidate = entry;
|
|
2781
|
+
if (!candidate.name) {
|
|
2782
|
+
continue;
|
|
2783
|
+
}
|
|
2784
|
+
const normalized = toMetadataTool({
|
|
2785
|
+
name: candidate.name,
|
|
2786
|
+
description: candidate.description,
|
|
2787
|
+
inputSchema: candidate.inputSchema
|
|
2788
|
+
}, availableTools);
|
|
2789
|
+
if (normalized) {
|
|
2790
|
+
tools.push(normalized);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
return tools;
|
|
2794
|
+
}
|
|
2795
|
+
function parseToolsFromListByIntegrationText(text, availableTools) {
|
|
2796
|
+
try {
|
|
2797
|
+
return parseToolsFromListByIntegrationPayload(JSON.parse(text), availableTools);
|
|
2798
|
+
} catch {
|
|
2799
|
+
return [];
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
// ../client.ts
|
|
2731
2804
|
init_library_metadata();
|
|
2732
2805
|
|
|
2733
2806
|
// ../database/token-store.ts
|
|
@@ -4270,21 +4343,7 @@ class MCPClientBase {
|
|
|
4270
4343
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4271
4344
|
integration: integration.id
|
|
4272
4345
|
});
|
|
4273
|
-
|
|
4274
|
-
if (response.content && Array.isArray(response.content)) {
|
|
4275
|
-
for (const item of response.content) {
|
|
4276
|
-
if (item.type === "text" && item.text) {
|
|
4277
|
-
try {
|
|
4278
|
-
const parsed = JSON.parse(item.text);
|
|
4279
|
-
if (Array.isArray(parsed)) {
|
|
4280
|
-
toolMetadata = parsed;
|
|
4281
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4282
|
-
toolMetadata = parsed.tools;
|
|
4283
|
-
}
|
|
4284
|
-
} catch {}
|
|
4285
|
-
}
|
|
4286
|
-
}
|
|
4287
|
-
}
|
|
4346
|
+
const toolMetadata = this.parseListToolsByIntegrationContent(response.content);
|
|
4288
4347
|
return toConfiguredIntegrationWithToolMetadata(integration, toolMetadata);
|
|
4289
4348
|
} catch (error) {
|
|
4290
4349
|
logger7.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
@@ -4321,21 +4380,7 @@ class MCPClientBase {
|
|
|
4321
4380
|
const metadataResponse = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4322
4381
|
integration: integration.id
|
|
4323
4382
|
});
|
|
4324
|
-
|
|
4325
|
-
if (metadataResponse.content && Array.isArray(metadataResponse.content)) {
|
|
4326
|
-
for (const item of metadataResponse.content) {
|
|
4327
|
-
if (item.type === "text" && item.text) {
|
|
4328
|
-
try {
|
|
4329
|
-
const parsed = JSON.parse(item.text);
|
|
4330
|
-
if (Array.isArray(parsed)) {
|
|
4331
|
-
toolMetadata = parsed;
|
|
4332
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4333
|
-
toolMetadata = parsed.tools;
|
|
4334
|
-
}
|
|
4335
|
-
} catch {}
|
|
4336
|
-
}
|
|
4337
|
-
}
|
|
4338
|
-
}
|
|
4383
|
+
const toolMetadata = this.parseListToolsByIntegrationContent(metadataResponse.content);
|
|
4339
4384
|
return {
|
|
4340
4385
|
...integration,
|
|
4341
4386
|
...integrationLibraryPresentationFields(integration),
|
|
@@ -4593,6 +4638,18 @@ class MCPClientBase {
|
|
|
4593
4638
|
}
|
|
4594
4639
|
return {};
|
|
4595
4640
|
}
|
|
4641
|
+
parseListToolsByIntegrationContent(content) {
|
|
4642
|
+
const tools = [];
|
|
4643
|
+
if (!content || !Array.isArray(content)) {
|
|
4644
|
+
return tools;
|
|
4645
|
+
}
|
|
4646
|
+
for (const item of content) {
|
|
4647
|
+
if (item.type === "text" && item.text) {
|
|
4648
|
+
tools.push(...parseToolsFromListByIntegrationText(item.text, this.availableTools));
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
return tools;
|
|
4652
|
+
}
|
|
4596
4653
|
getTool(name) {
|
|
4597
4654
|
return this.availableTools.get(name);
|
|
4598
4655
|
}
|
|
@@ -4637,6 +4694,11 @@ class MCPClientBase {
|
|
|
4637
4694
|
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
4638
4695
|
return filterToTargets(this.getEnabledTools());
|
|
4639
4696
|
}
|
|
4697
|
+
const transportHeaders = this.transport.headers || {};
|
|
4698
|
+
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
4699
|
+
if (hasApiKey) {
|
|
4700
|
+
await this.ensureConnected();
|
|
4701
|
+
}
|
|
4640
4702
|
const tools = [];
|
|
4641
4703
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
4642
4704
|
const concurrency = options?.fetchConcurrency ?? 8;
|
|
@@ -4645,26 +4707,7 @@ class MCPClientBase {
|
|
|
4645
4707
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4646
4708
|
integration: integrationId
|
|
4647
4709
|
});
|
|
4648
|
-
const integrationTools =
|
|
4649
|
-
if (response.content && Array.isArray(response.content)) {
|
|
4650
|
-
for (const item of response.content) {
|
|
4651
|
-
if (item.type === "text" && item.text) {
|
|
4652
|
-
try {
|
|
4653
|
-
const parsed = JSON.parse(item.text);
|
|
4654
|
-
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
4655
|
-
for (const tool of parsedTools) {
|
|
4656
|
-
if (tool.name && tool.inputSchema) {
|
|
4657
|
-
integrationTools.push({
|
|
4658
|
-
name: tool.name,
|
|
4659
|
-
description: tool.description,
|
|
4660
|
-
inputSchema: tool.inputSchema
|
|
4661
|
-
});
|
|
4662
|
-
}
|
|
4663
|
-
}
|
|
4664
|
-
} catch {}
|
|
4665
|
-
}
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4710
|
+
const integrationTools = this.parseListToolsByIntegrationContent(response.content).filter((tool) => tool.inputSchema);
|
|
4668
4711
|
return integrationTools;
|
|
4669
4712
|
} catch (error) {
|
|
4670
4713
|
logger7.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|