integrate-sdk 0.9.58 → 0.9.62

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.
Files changed (43) hide show
  1. package/dist/adapters/index.js +1 -1
  2. package/dist/adapters/solid-start.js +1 -1
  3. package/dist/adapters/svelte-kit.js +1 -1
  4. package/dist/ai/index.js +77 -0
  5. package/dist/ai/tool-cache.d.ts +50 -0
  6. package/dist/ai/tool-cache.d.ts.map +1 -0
  7. package/dist/ai/utils.d.ts +5 -0
  8. package/dist/ai/utils.d.ts.map +1 -1
  9. package/dist/ai/vercel-ai.d.ts.map +1 -1
  10. package/dist/ai/vercel-ai.js +77 -0
  11. package/dist/index.js +77 -1
  12. package/dist/integrations.js +77 -1
  13. package/dist/react.d.ts +2 -2
  14. package/dist/react.d.ts.map +1 -1
  15. package/dist/react.js +86 -0
  16. package/dist/server.js +353 -29
  17. package/dist/src/ai/tool-cache.d.ts +50 -0
  18. package/dist/src/ai/tool-cache.d.ts.map +1 -0
  19. package/dist/src/ai/utils.d.ts +5 -0
  20. package/dist/src/ai/utils.d.ts.map +1 -1
  21. package/dist/src/ai/vercel-ai.d.ts.map +1 -1
  22. package/dist/src/client.d.ts +1 -3
  23. package/dist/src/client.d.ts.map +1 -1
  24. package/dist/src/config/types.d.ts +11 -0
  25. package/dist/src/config/types.d.ts.map +1 -1
  26. package/dist/src/index.d.ts +1 -0
  27. package/dist/src/index.d.ts.map +1 -1
  28. package/dist/src/integrations/bundle.d.ts +18 -0
  29. package/dist/src/integrations/bundle.d.ts.map +1 -0
  30. package/dist/src/integrations/granola.d.ts.map +1 -1
  31. package/dist/src/integrations/mercury.d.ts.map +1 -1
  32. package/dist/src/integrations/resend.d.ts.map +1 -1
  33. package/dist/src/integrations/tldraw.d.ts.map +1 -1
  34. package/dist/src/react/hooks.d.ts +16 -0
  35. package/dist/src/react/hooks.d.ts.map +1 -1
  36. package/dist/src/server.d.ts +12 -0
  37. package/dist/src/server.d.ts.map +1 -1
  38. package/dist/src/utils/normalize-tool-name.d.ts +14 -0
  39. package/dist/src/utils/normalize-tool-name.d.ts.map +1 -0
  40. package/dist/src/utils/parse-tool-result.d.ts +23 -0
  41. package/dist/src/utils/parse-tool-result.d.ts.map +1 -0
  42. package/package.json +1 -1
  43. package/react.ts +10 -2
package/dist/server.js CHANGED
@@ -5298,7 +5298,7 @@ class MCPClientBase {
5298
5298
  logger5.debug(`Discovered ${totalDiscovered} tools, ${enabledCount} enabled by integrations`);
5299
5299
  }
5300
5300
  async _callToolByName(name, args, options) {
5301
- return await this.callToolWithRetry(name, args, 0, options);
5301
+ return await this.callTool(name, args, options);
5302
5302
  }
5303
5303
  async callTool(name, args, options) {
5304
5304
  return await this.callToolWithRetry(name, args, 0, options);
@@ -6148,6 +6148,51 @@ async function sendWebResponse(webRes, nodeRes) {
6148
6148
  // src/server.ts
6149
6149
  init_logger();
6150
6150
 
6151
+ // src/utils/normalize-tool-name.ts
6152
+ var TOOL_ALIASES = {
6153
+ github_list_repo_contents: "github_get_file_contents",
6154
+ gdrive_list: "gdrive_list_files",
6155
+ gdrive_get: "gdrive_get_file",
6156
+ gdrive_delete: "gdrive_delete_file",
6157
+ gdrive_trash: "gdrive_trash_file",
6158
+ gdrive_upload: "gdrive_upload_text_file",
6159
+ gdrive_download: "gdrive_download_file",
6160
+ slack_send: "slack_send_message",
6161
+ gmail_send: "gmail_send_email",
6162
+ notion_create_page: "notion_create_page"
6163
+ };
6164
+ function normalizeToolName(toolName, integrationCandidates = []) {
6165
+ if (TOOL_ALIASES[toolName]) {
6166
+ return TOOL_ALIASES[toolName];
6167
+ }
6168
+ const tripleIdx = toolName.indexOf("___");
6169
+ if (tripleIdx > 0) {
6170
+ const prefix = toolName.slice(0, tripleIdx);
6171
+ const suffix = toolName.slice(tripleIdx + 3);
6172
+ if (integrationCandidates.some((c) => c === prefix)) {
6173
+ if (suffix.startsWith("_")) {
6174
+ return `___${suffix.slice(1)}`;
6175
+ }
6176
+ return `${prefix}_${suffix}`;
6177
+ }
6178
+ }
6179
+ for (const candidate of integrationCandidates) {
6180
+ const doublePrefix = `${candidate}_${candidate}_`;
6181
+ if (toolName.startsWith(doublePrefix)) {
6182
+ return `${candidate}_${toolName.slice(doublePrefix.length)}`;
6183
+ }
6184
+ }
6185
+ const firstUnderscore = toolName.indexOf("_");
6186
+ if (firstUnderscore > 0) {
6187
+ const prefix = toolName.slice(0, firstUnderscore);
6188
+ const rest = toolName.slice(firstUnderscore + 1);
6189
+ if (integrationCandidates.includes(prefix) && rest.startsWith(`${prefix}_`)) {
6190
+ return `${prefix}_${rest.slice(prefix.length + 1)}`;
6191
+ }
6192
+ }
6193
+ return toolName;
6194
+ }
6195
+
6151
6196
  // src/integrations/github.ts
6152
6197
  init_logger();
6153
6198
  var logger8 = createLogger("GitHub");
@@ -13679,6 +13724,9 @@ function granolaIntegration(options) {
13679
13724
  return {
13680
13725
  id: "granola",
13681
13726
  name: "Granola",
13727
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/granola.png",
13728
+ description: "List and read Granola meeting notes and folders",
13729
+ category: "Productivity",
13682
13730
  tools: [...GRANOLA_TOOLS],
13683
13731
  authType: "apiKey",
13684
13732
  getHeaders() {
@@ -13761,6 +13809,9 @@ function mercuryIntegration(options) {
13761
13809
  return {
13762
13810
  id: "mercury",
13763
13811
  name: "Mercury",
13812
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/mercury.png",
13813
+ description: "Manage Mercury bank accounts, cards, and transactions",
13814
+ category: "Finance",
13764
13815
  tools: [...MERCURY_TOOLS],
13765
13816
  authType: "apiKey",
13766
13817
  getHeaders() {
@@ -14372,6 +14423,9 @@ function resendIntegration(options = {}) {
14372
14423
  return {
14373
14424
  id: "resend",
14374
14425
  name: "Resend",
14426
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/resend.png",
14427
+ description: "Send email and manage domains with the Resend API",
14428
+ category: "Communication",
14375
14429
  tools: [...RESEND_TOOLS],
14376
14430
  authType: "apiKey",
14377
14431
  getHeaders() {
@@ -14398,6 +14452,9 @@ function tldrawIntegration(options = {}) {
14398
14452
  return {
14399
14453
  id: "tldraw",
14400
14454
  name: "tldraw",
14455
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/tldraw.png",
14456
+ description: "Create and manage tldraw collaborative whiteboards",
14457
+ category: "Productivity",
14401
14458
  tools: [...TLDRAW_TOOLS],
14402
14459
  authType: apiKey ? "apiKey" : undefined,
14403
14460
  getHeaders: apiKey ? () => ({ Authorization: `Bearer ${apiKey}` }) : undefined
@@ -18834,6 +18891,82 @@ function createTriggerTools(config, context) {
18834
18891
 
18835
18892
  // src/ai/vercel-ai.ts
18836
18893
  init_tool_builder();
18894
+
18895
+ // src/ai/tool-cache.ts
18896
+ function buildToolDiscoveryCacheKey(userId, connectedIntegrationIds) {
18897
+ const sorted = [...connectedIntegrationIds].sort().join(",");
18898
+ return `${userId}:${sorted}`;
18899
+ }
18900
+ function createMemoryToolDiscoveryCache() {
18901
+ const store = new Map;
18902
+ return {
18903
+ async get(key) {
18904
+ const entry = store.get(key);
18905
+ if (!entry)
18906
+ return null;
18907
+ if (entry.expiresAt <= Date.now()) {
18908
+ store.delete(key);
18909
+ return null;
18910
+ }
18911
+ return entry.stubs;
18912
+ },
18913
+ async set(key, stubs, ttlMs = 5 * 60 * 1000) {
18914
+ store.set(key, { stubs, expiresAt: Date.now() + ttlMs });
18915
+ },
18916
+ async invalidate(userIdOrKey) {
18917
+ for (const key of [...store.keys()]) {
18918
+ if (key === userIdOrKey || key.startsWith(`${userIdOrKey}:`)) {
18919
+ store.delete(key);
18920
+ }
18921
+ }
18922
+ }
18923
+ };
18924
+ }
18925
+ function createToolDiscoveryCacheInvalidator(cache) {
18926
+ return ({ userId }) => {
18927
+ cache.invalidate(userId);
18928
+ };
18929
+ }
18930
+ async function resolveToolDiscoveryCacheKey(client, context, options) {
18931
+ const userId = context.userId;
18932
+ if (!userId)
18933
+ return;
18934
+ const configuredIds = (client.integrations ?? []).map((i) => i.id);
18935
+ let targetIds;
18936
+ if (options?.integrationIds?.length) {
18937
+ targetIds = options.integrationIds;
18938
+ } else if (options?.connectedOnly) {
18939
+ targetIds = await listConnectedProviders(configuredIds, (provider, email, ctx) => client.getProviderToken(provider, email, ctx), context);
18940
+ } else {
18941
+ targetIds = configuredIds;
18942
+ }
18943
+ return buildToolDiscoveryCacheKey(userId, targetIds);
18944
+ }
18945
+ function stubsFromTools(tools) {
18946
+ return tools.map((t) => ({
18947
+ name: t.name,
18948
+ description: t.description,
18949
+ inputSchema: t.inputSchema
18950
+ }));
18951
+ }
18952
+ function applyToolDiscoveryCache(client, stubs) {
18953
+ client.hydrateToolCache(stubs);
18954
+ }
18955
+ async function persistToolDiscoveryCache(client, cache, cacheKey, ttlMs) {
18956
+ const tools = client.getAvailableTools();
18957
+ if (tools.length === 0)
18958
+ return;
18959
+ await cache.set(cacheKey, stubsFromTools(tools), ttlMs);
18960
+ }
18961
+ async function warmToolDiscoveryFromCache(client, cache, cacheKey) {
18962
+ const stubs = await cache.get(cacheKey);
18963
+ if (!stubs || stubs.length === 0)
18964
+ return false;
18965
+ applyToolDiscoveryCache(client, stubs);
18966
+ return true;
18967
+ }
18968
+
18969
+ // src/ai/vercel-ai.ts
18837
18970
  function convertMCPToolToVercelAI(mcpTool, client, options) {
18838
18971
  return {
18839
18972
  description: mcpTool.description || `Execute ${mcpTool.name}`,
@@ -18855,7 +18988,21 @@ async function getVercelAITools(client, options) {
18855
18988
  }
18856
18989
  const finalOptions = providerTokens ? { ...options, providerTokens } : options;
18857
18990
  await ensureClientConnected(client);
18991
+ const cacheConfig = options?.cache;
18992
+ let cacheKey;
18993
+ if (cacheConfig?.cache && options?.context) {
18994
+ cacheKey = await resolveToolDiscoveryCacheKey(client, options.context, {
18995
+ integrationIds: options.integrationIds,
18996
+ connectedOnly: options.connectedOnly
18997
+ });
18998
+ if (cacheKey) {
18999
+ await warmToolDiscoveryFromCache(client, cacheConfig.cache, cacheKey);
19000
+ }
19001
+ }
18858
19002
  const mcpTools = await client.getEnabledToolsAsync(toEnabledToolsAsyncOptions(options));
19003
+ if (cacheConfig?.cache && cacheKey) {
19004
+ await persistToolDiscoveryCache(client, cacheConfig.cache, cacheKey, cacheConfig.ttlMs);
19005
+ }
18859
19006
  const vercelTools = {};
18860
19007
  let effectiveMode;
18861
19008
  if (options?.mode !== undefined) {
@@ -21432,6 +21579,126 @@ function zohoSprintsIntegration(config = {}) {
21432
21579
  }
21433
21580
  };
21434
21581
  }
21582
+ // src/integrations/bundle.ts
21583
+ function allIntegrations() {
21584
+ return [
21585
+ githubIntegration(),
21586
+ gmailIntegration(),
21587
+ notionIntegration(),
21588
+ slackIntegration(),
21589
+ discordIntegration(),
21590
+ boxIntegration(),
21591
+ paypalIntegration(),
21592
+ squareIntegration(),
21593
+ spotifyIntegration(),
21594
+ stravaIntegration(),
21595
+ asanaIntegration(),
21596
+ confluenceIntegration(),
21597
+ oktaIntegration(),
21598
+ quickbooksIntegration(),
21599
+ bitbucketIntegration(),
21600
+ smartthingsIntegration(),
21601
+ googleAdsIntegration(),
21602
+ pinterestIntegration(),
21603
+ twitchIntegration(),
21604
+ xIntegration(),
21605
+ ebayIntegration(),
21606
+ miroIntegration(),
21607
+ smartsheetIntegration(),
21608
+ docusignIntegration(),
21609
+ pipedriveIntegration(),
21610
+ freshserviceIntegration(),
21611
+ zohoCrmIntegration(),
21612
+ zohoMailIntegration(),
21613
+ zohoDeskIntegration(),
21614
+ zohoBooksIntegration(),
21615
+ zohoProjectsIntegration(),
21616
+ zohoCampaignsIntegration(),
21617
+ zohoAnalyticsIntegration(),
21618
+ zohoInvoiceIntegration(),
21619
+ linearIntegration(),
21620
+ vercelIntegration(),
21621
+ zendeskIntegration(),
21622
+ stripeIntegration(),
21623
+ gcalIntegration(),
21624
+ gmeetIntegration(),
21625
+ gtasksIntegration(),
21626
+ gkeepIntegration(),
21627
+ gcontactsIntegration(),
21628
+ outlookIntegration(),
21629
+ teamsIntegration(),
21630
+ airtableIntegration(),
21631
+ attioIntegration(),
21632
+ todoistIntegration(),
21633
+ whatsappIntegration(),
21634
+ calcomIntegration(),
21635
+ canvaIntegration(),
21636
+ cloudflareIntegration(),
21637
+ rampIntegration(),
21638
+ onedriveIntegration(),
21639
+ plannerIntegration(),
21640
+ sharepointIntegration(),
21641
+ wordIntegration(),
21642
+ excelIntegration(),
21643
+ powerpointIntegration(),
21644
+ gdocsIntegration(),
21645
+ gdriveIntegration(),
21646
+ gsheetsIntegration(),
21647
+ gslidesIntegration(),
21648
+ polarIntegration(),
21649
+ facebookIntegration(),
21650
+ figmaIntegration(),
21651
+ intercomIntegration(),
21652
+ hubspotIntegration(),
21653
+ instagramIntegration(),
21654
+ linkedinIntegration(),
21655
+ threadsIntegration(),
21656
+ tiktokIntegration(),
21657
+ typeformIntegration(),
21658
+ xeroIntegration(),
21659
+ gchatIntegration(),
21660
+ shopifyIntegration(),
21661
+ youtubeIntegration(),
21662
+ zoomIntegration(),
21663
+ redditIntegration(),
21664
+ cursorIntegration(),
21665
+ posthogIntegration(),
21666
+ sentryIntegration(),
21667
+ datadogIntegration(),
21668
+ netlifyIntegration(),
21669
+ mondayIntegration(),
21670
+ webflowIntegration(),
21671
+ jiraIntegration(),
21672
+ salesforceIntegration(),
21673
+ workdayIntegration(),
21674
+ calendlyIntegration(),
21675
+ klaviyoIntegration(),
21676
+ googleFormsIntegration(),
21677
+ firebaseIntegration(),
21678
+ microsoftToDoIntegration(),
21679
+ onenoteIntegration(),
21680
+ microsoftBookingsIntegration(),
21681
+ azureDevopsIntegration(),
21682
+ googlePlayConsoleIntegration(),
21683
+ squarespaceIntegration(),
21684
+ zohoPeopleIntegration(),
21685
+ zohoRecruitIntegration(),
21686
+ zohoSignIntegration(),
21687
+ zohoWorkdriveIntegration(),
21688
+ zohoCreatorIntegration(),
21689
+ zohoInventoryIntegration(),
21690
+ zohoBillingIntegration(),
21691
+ zohoWriterIntegration(),
21692
+ zohoSprintsIntegration()
21693
+ ];
21694
+ }
21695
+ function createIntegrationBundle(options) {
21696
+ const all = allIntegrations();
21697
+ if (!options?.include?.length)
21698
+ return all;
21699
+ const allowed = new Set(options.include);
21700
+ return all.filter((i) => allowed.has(i.id));
21701
+ }
21435
21702
  // src/database/trigger-store.ts
21436
21703
  function toIsoString(value) {
21437
21704
  if (!value)
@@ -24768,6 +25035,69 @@ var integrateTrigger = pgTable("trigger", {
24768
25035
  index("trigger_status_idx").on(table.status),
24769
25036
  index("trigger_next_run_at_idx").on(table.nextRunAt)
24770
25037
  ]);
25038
+ // src/utils/parse-tool-result.ts
25039
+ function isRecord(value) {
25040
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25041
+ }
25042
+ function getBooleanProperty(value, key) {
25043
+ const property = value[key];
25044
+ return typeof property === "boolean" ? property : undefined;
25045
+ }
25046
+ function getStringProperty(value, key) {
25047
+ const property = value[key];
25048
+ if (typeof property !== "string") {
25049
+ return;
25050
+ }
25051
+ const trimmed = property.trim();
25052
+ return trimmed.length > 0 ? trimmed : undefined;
25053
+ }
25054
+ function getStructuredContent(result) {
25055
+ const structuredContent = result.structuredContent;
25056
+ return isRecord(structuredContent) ? structuredContent : undefined;
25057
+ }
25058
+ function getContentText(result) {
25059
+ const content = result.content;
25060
+ if (!Array.isArray(content)) {
25061
+ return;
25062
+ }
25063
+ for (const item of content) {
25064
+ if (!isRecord(item)) {
25065
+ continue;
25066
+ }
25067
+ const text2 = getStringProperty(item, "text");
25068
+ if (text2) {
25069
+ return text2;
25070
+ }
25071
+ }
25072
+ return;
25073
+ }
25074
+ function isMCPToolError(result) {
25075
+ return parseMCPToolResult(result).ok === false;
25076
+ }
25077
+ function parseMCPToolResult(result) {
25078
+ if (!isRecord(result)) {
25079
+ return {
25080
+ ok: true,
25081
+ data: result,
25082
+ raw: result
25083
+ };
25084
+ }
25085
+ const structuredContent = getStructuredContent(result);
25086
+ const failed = getBooleanProperty(result, "isError") === true || getBooleanProperty(result, "success") === false || getBooleanProperty(structuredContent ?? {}, "isError") === true || getBooleanProperty(structuredContent ?? {}, "success") === false;
25087
+ if (!failed) {
25088
+ return {
25089
+ ok: true,
25090
+ data: structuredContent ?? result,
25091
+ raw: result
25092
+ };
25093
+ }
25094
+ return {
25095
+ ok: false,
25096
+ error: getStringProperty(result, "error") ?? getStringProperty(structuredContent ?? {}, "error") ?? getContentText(result) ?? "Tool returned an error result",
25097
+ raw: result
25098
+ };
25099
+ }
25100
+
24771
25101
  // src/server.ts
24772
25102
  var SERVER_LOG_CONTEXT3 = "server";
24773
25103
  var logger203 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);
@@ -24841,33 +25171,6 @@ function resolveProviderFromToolName(toolName, candidates) {
24841
25171
  }
24842
25172
  return best;
24843
25173
  }
24844
- var TOOL_ALIASES = {
24845
- github_list_repo_contents: "github_get_file_contents",
24846
- gdrive_list: "gdrive_list_files",
24847
- gdrive_get: "gdrive_get_file",
24848
- gdrive_delete: "gdrive_delete_file",
24849
- gdrive_trash: "gdrive_trash_file",
24850
- gdrive_upload: "gdrive_upload_text_file",
24851
- gdrive_download: "gdrive_download_file"
24852
- };
24853
- function normalizeToolName(toolName, candidates) {
24854
- if (TOOL_ALIASES[toolName])
24855
- return TOOL_ALIASES[toolName];
24856
- const tripleIdx = toolName.indexOf("___");
24857
- if (tripleIdx > 0) {
24858
- const prefix = toolName.slice(0, tripleIdx);
24859
- if (candidates.some((c) => c === prefix)) {
24860
- return toolName.slice(tripleIdx);
24861
- }
24862
- }
24863
- for (const candidate of candidates) {
24864
- const doublePrefix = `${candidate}_${candidate}_`;
24865
- if (toolName.startsWith(doublePrefix)) {
24866
- return `${candidate}_${toolName.slice(doublePrefix.length)}`;
24867
- }
24868
- }
24869
- return toolName;
24870
- }
24871
25174
  var unauthenticatedCodeModeWarnings = new Set;
24872
25175
  function warnUnauthenticatedCodeModeCallback(details) {
24873
25176
  if (unauthenticatedCodeModeWarnings.has(details.toolName))
@@ -24922,7 +25225,14 @@ function getDefaultRedirectUri() {
24922
25225
  return "http://localhost:3000/api/integrate/oauth/callback";
24923
25226
  }
24924
25227
  function createMCPServer(inputConfig) {
24925
- const config = mergeDatabaseConfig(inputConfig);
25228
+ let config = mergeDatabaseConfig(inputConfig);
25229
+ if (config.enabledProviders?.length) {
25230
+ const allowed = new Set(config.enabledProviders);
25231
+ config = {
25232
+ ...config,
25233
+ integrations: config.integrations.filter((i) => allowed.has(i.id))
25234
+ };
25235
+ }
24926
25236
  setLogLevel(config.debug ? "debug" : "error", SERVER_LOG_CONTEXT3);
24927
25237
  if (typeof window !== "undefined") {
24928
25238
  throw new Error("createMCPServer() should only be called on the server-side. " + "Use createMCPClient() for client-side code.");
@@ -25859,6 +26169,7 @@ export {
25859
26169
  whoopIntegration,
25860
26170
  whatsappIntegration,
25861
26171
  webflowIntegration,
26172
+ warmToolDiscoveryFromCache,
25862
26173
  vercelIntegration,
25863
26174
  upstashIntegration,
25864
26175
  upsIntegration,
@@ -25891,6 +26202,7 @@ export {
25891
26202
  tableauIntegration,
25892
26203
  svelteKitHandler,
25893
26204
  supabaseIntegration,
26205
+ stubsFromTools,
25894
26206
  stripeIntegration,
25895
26207
  stravaIntegration,
25896
26208
  storeCodeVerifier,
@@ -25910,6 +26222,7 @@ export {
25910
26222
  salesforceIntegration,
25911
26223
  sageIntegration,
25912
26224
  ringIntegration,
26225
+ resolveToolDiscoveryCacheKey,
25913
26226
  resendIntegration,
25914
26227
  redisIntegration,
25915
26228
  redditIntegration,
@@ -25930,8 +26243,10 @@ export {
25930
26243
  pinterestIntegration,
25931
26244
  philipsHueIntegration,
25932
26245
  phantomIntegration,
26246
+ persistToolDiscoveryCache,
25933
26247
  paypalIntegration,
25934
26248
  parseScopes,
26249
+ parseMCPToolResult,
25935
26250
  paperIntegration,
25936
26251
  pandadocIntegration,
25937
26252
  outlookIntegration,
@@ -25941,6 +26256,7 @@ export {
25941
26256
  onedriveIntegration,
25942
26257
  oktaIntegration,
25943
26258
  notionIntegration,
26259
+ normalizeToolName,
25944
26260
  normalizeProviderTokenType,
25945
26261
  normalizeAccountIdentifier,
25946
26262
  normalizeAccountIdHint,
@@ -25974,6 +26290,7 @@ export {
25974
26290
  klaviyoIntegration,
25975
26291
  kickIntegration,
25976
26292
  jiraIntegration,
26293
+ isMCPToolError,
25977
26294
  isLikelyUsableToken,
25978
26295
  intercomIntegration,
25979
26296
  integrateTrigger,
@@ -26048,10 +26365,13 @@ export {
26048
26365
  databricksIntegration,
26049
26366
  cursorIntegration,
26050
26367
  createTriggerTools,
26368
+ createToolDiscoveryCacheInvalidator,
26051
26369
  createTanStackOAuthHandler,
26052
26370
  createSimpleIntegration,
26053
26371
  createNextOAuthHandler,
26372
+ createMemoryToolDiscoveryCache,
26054
26373
  createMCPServer,
26374
+ createIntegrationBundle,
26055
26375
  createDatabaseAdapterFactory,
26056
26376
  createDatabaseAdapterCallbacks,
26057
26377
  convexIntegration,
@@ -26064,6 +26384,7 @@ export {
26064
26384
  canvaIntegration,
26065
26385
  calendlyIntegration,
26066
26386
  calcomIntegration,
26387
+ buildToolDiscoveryCacheKey,
26067
26388
  buildPhantomBrowseDeeplink,
26068
26389
  buildCodeModeTool,
26069
26390
  boxIntegration,
@@ -26079,13 +26400,16 @@ export {
26079
26400
  attioIntegration,
26080
26401
  astronomerIntegration,
26081
26402
  asanaIntegration,
26403
+ applyToolDiscoveryCache,
26082
26404
  amazonIntegration,
26083
26405
  amazonAdsIntegration,
26084
26406
  amadeusIntegration,
26085
26407
  alpacaIntegration,
26408
+ allIntegrations,
26086
26409
  airtableIntegration,
26087
26410
  adobeAcrobatSignIntegration,
26088
26411
  __resetUnauthenticatedCodeModeWarnings,
26412
+ TOOL_ALIASES,
26089
26413
  RUNTIME_STUB_SOURCE,
26090
26414
  POST,
26091
26415
  OAuthHandler,
@@ -0,0 +1,50 @@
1
+ import type { MCPClient } from "../client.js";
2
+ import type { MCPTool } from "../protocol/messages.js";
3
+ import type { MCPContext } from "../config/types.js";
4
+ /** Serializable MCP tool metadata for cross-request / Redis caching. */
5
+ export type ToolMetadataStub = Pick<MCPTool, "name" | "description" | "inputSchema">;
6
+ export interface ToolDiscoveryCacheAdapter {
7
+ get(key: string): Promise<ToolMetadataStub[] | null>;
8
+ set(key: string, stubs: ToolMetadataStub[], ttlMs?: number): Promise<void>;
9
+ /** Invalidate all keys for a user (prefix match) or a single key when exact. */
10
+ invalidate(userIdOrKey: string): Promise<void>;
11
+ }
12
+ export interface ToolDiscoveryCacheOptions {
13
+ cache: ToolDiscoveryCacheAdapter;
14
+ /** @default 5 minutes */
15
+ ttlMs?: number;
16
+ }
17
+ /**
18
+ * Build a cache key from user id and connected integration ids.
19
+ * Include connected providers so reconnecting OAuth invalidates stale tool lists.
20
+ */
21
+ export declare function buildToolDiscoveryCacheKey(userId: string, connectedIntegrationIds: readonly string[]): string;
22
+ /**
23
+ * In-memory tool discovery cache (single process). Use Redis in production serverless.
24
+ */
25
+ export declare function createMemoryToolDiscoveryCache(): ToolDiscoveryCacheAdapter;
26
+ /**
27
+ * Hook for database adapter `onTokenChange` — invalidates cached tool metadata for the user.
28
+ */
29
+ export declare function createToolDiscoveryCacheInvalidator(cache: ToolDiscoveryCacheAdapter): (event: {
30
+ userId: string;
31
+ }) => void;
32
+ export declare function resolveToolDiscoveryCacheKey(client: MCPClient<any>, context: MCPContext, options?: {
33
+ integrationIds?: string[];
34
+ connectedOnly?: boolean;
35
+ }): Promise<string | undefined>;
36
+ export declare function stubsFromTools(tools: readonly MCPTool[]): ToolMetadataStub[];
37
+ /**
38
+ * Hydrate the client tool cache from persisted stubs (serverless cold start).
39
+ */
40
+ export declare function applyToolDiscoveryCache(client: MCPClient<any>, stubs: readonly ToolMetadataStub[]): void;
41
+ /**
42
+ * Persist current client tool metadata to a cache adapter.
43
+ */
44
+ export declare function persistToolDiscoveryCache(client: MCPClient<any>, cache: ToolDiscoveryCacheAdapter, cacheKey: string, ttlMs?: number): Promise<void>;
45
+ /**
46
+ * Load stubs from cache into the client before tool discovery.
47
+ * @returns true when cache was hydrated
48
+ */
49
+ export declare function warmToolDiscoveryFromCache(client: MCPClient<any>, cache: ToolDiscoveryCacheAdapter, cacheKey: string): Promise<boolean>;
50
+ //# sourceMappingURL=tool-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-cache.d.ts","sourceRoot":"","sources":["../../../src/ai/tool-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC,CAAC;AAErF,MAAM,WAAW,yBAAyB;IACxC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,CAAC;IACrD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,gFAAgF;IAChF,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,yBAAyB,CAAC;IACjC,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,SAAS,MAAM,EAAE,GACzC,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,yBAAyB,CAwB1E;AAED;;GAEG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,yBAAyB,GAC/B,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAIrC;AAED,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAuB7B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,gBAAgB,EAAE,CAM5E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,KAAK,EAAE,SAAS,gBAAgB,EAAE,GACjC,IAAI,CAEN;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,KAAK,EAAE,yBAAyB,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,KAAK,EAAE,yBAAyB,EAChC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAKlB"}
@@ -57,6 +57,11 @@ export interface AIToolsOptions {
57
57
  * @default 8
58
58
  */
59
59
  fetchConcurrency?: number;
60
+ /**
61
+ * Optional cache for tool metadata (serverless cold-start optimization).
62
+ * Pair with {@link createToolDiscoveryCacheInvalidator} on `onTokenChange`.
63
+ */
64
+ cache?: import("./tool-cache.js").ToolDiscoveryCacheOptions;
60
65
  }
61
66
  /** Map AI helper options to client tool-discovery options */
62
67
  export declare function toEnabledToolsAsyncOptions(options?: Pick<AIToolsOptions, "integrationIds" | "connectedOnly" | "context" | "fetchConcurrency">): EnabledToolsAsyncOptions | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ai/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,6DAA6D;AAC7D,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,IAAI,CACZ,cAAc,EACd,gBAAgB,GAAG,eAAe,GAAG,SAAS,GAAG,kBAAkB,CACpE,GACA,wBAAwB,GAAG,SAAS,CAYtC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG/F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAqFvE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CA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Ac;IAC1D,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,gCA+F/B"}
@@ -524,9 +524,7 @@ export declare class MCPClientBase<TIntegrations extends readonly MCPIntegration
524
524
  */
525
525
  private discoverTools;
526
526
  /**
527
- * Internal method for integrations to call tools by name
528
- * Used by integrations like Vercel AI that need to map from tool names
529
- * @internal
527
+ * @deprecated Use {@link MCPClientBase.callTool} instead. Alias retained for compatibility.
530
528
  */
531
529
  _callToolByName(name: string, args?: Record<string, unknown>, options?: ToolCallOptions): Promise<MCPToolCallResponse>;
532
530
  /**