integrate-sdk 0.9.27-dev.1 → 0.9.27-dev.2

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/index.js CHANGED
@@ -2451,6 +2451,9 @@ class MCPClientBase {
2451
2451
  async _callToolByName(name, args, options) {
2452
2452
  return await this.callToolWithRetry(name, args, 0, options);
2453
2453
  }
2454
+ async callTool(name, args, options) {
2455
+ return await this.callToolWithRetry(name, args, 0, options);
2456
+ }
2454
2457
  async callServerTool(name, args) {
2455
2458
  try {
2456
2459
  const response = await this.callToolThroughHandler(name, args);
@@ -2461,35 +2464,38 @@ class MCPClientBase {
2461
2464
  }
2462
2465
  }
2463
2466
  async callToolThroughHandler(name, args, provider, options) {
2467
+ const integrationHeaders = this.getHeadersForTool(name);
2464
2468
  const transportHeaders = this.transport.headers || {};
2465
2469
  const hasApiKey = !!transportHeaders["X-API-KEY"];
2466
2470
  if (hasApiKey) {
2467
2471
  await this.ensureConnected();
2472
+ const temporaryHeaders = { ...integrationHeaders };
2468
2473
  if (provider) {
2469
2474
  const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
2470
- if (tokenData && this.transport.setHeader) {
2471
- const previousAuthHeader = transportHeaders["Authorization"];
2472
- try {
2473
- this.transport.setHeader("Authorization", `Bearer ${tokenData.accessToken}`);
2474
- const result3 = await this.transport.sendRequest("tools/call", {
2475
- name,
2476
- arguments: args || {}
2477
- });
2478
- return result3;
2479
- } finally {
2480
- if (previousAuthHeader && this.transport.setHeader) {
2481
- this.transport.setHeader("Authorization", previousAuthHeader);
2482
- } else if (this.transport.removeHeader) {
2483
- this.transport.removeHeader("Authorization");
2484
- }
2475
+ if (tokenData) {
2476
+ temporaryHeaders["Authorization"] = `Bearer ${tokenData.accessToken}`;
2477
+ }
2478
+ }
2479
+ const previousHeaders = new Map;
2480
+ for (const [key, value] of Object.entries(temporaryHeaders)) {
2481
+ previousHeaders.set(key, transportHeaders[key]);
2482
+ this.transport.setHeader(key, value);
2483
+ }
2484
+ try {
2485
+ const result2 = await this.transport.sendRequest("tools/call", {
2486
+ name,
2487
+ arguments: args || {}
2488
+ });
2489
+ return result2;
2490
+ } finally {
2491
+ for (const [key, previousValue] of previousHeaders.entries()) {
2492
+ if (previousValue !== undefined) {
2493
+ this.transport.setHeader(key, previousValue);
2494
+ } else {
2495
+ this.transport.removeHeader(key);
2485
2496
  }
2486
2497
  }
2487
2498
  }
2488
- const result2 = await this.transport.sendRequest("tools/call", {
2489
- name,
2490
- arguments: args || {}
2491
- });
2492
- return result2;
2493
2499
  }
2494
2500
  const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
2495
2501
  const headers = {
@@ -2499,6 +2505,7 @@ class MCPClientBase {
2499
2505
  if (integrationsHeader) {
2500
2506
  headers["X-Integrations"] = integrationsHeader;
2501
2507
  }
2508
+ Object.assign(headers, integrationHeaders);
2502
2509
  if (provider) {
2503
2510
  const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
2504
2511
  if (tokenData) {
@@ -2588,6 +2595,14 @@ class MCPClientBase {
2588
2595
  }
2589
2596
  return;
2590
2597
  }
2598
+ getHeadersForTool(toolName) {
2599
+ for (const integration of this.integrations) {
2600
+ if (integration.tools.includes(toolName) && integration.getHeaders) {
2601
+ return integration.getHeaders();
2602
+ }
2603
+ }
2604
+ return {};
2605
+ }
2591
2606
  getTool(name) {
2592
2607
  return this.availableTools.get(name);
2593
2608
  }
@@ -4757,8 +4772,55 @@ function onedriveIntegration(config = {}) {
4757
4772
  }
4758
4773
  };
4759
4774
  }
4775
+ // src/integrations/dropbox.ts
4776
+ var logger25 = createLogger("Dropbox");
4777
+ var DROPBOX_TOOLS = [
4778
+ "dropbox_get_current_account",
4779
+ "dropbox_get_space_usage",
4780
+ "dropbox_list_folder",
4781
+ "dropbox_list_folder_continue",
4782
+ "dropbox_get_metadata",
4783
+ "dropbox_search_files",
4784
+ "dropbox_create_folder",
4785
+ "dropbox_delete_path",
4786
+ "dropbox_move_path",
4787
+ "dropbox_copy_path",
4788
+ "dropbox_upload_text_file",
4789
+ "dropbox_download_file",
4790
+ "dropbox_get_temporary_link",
4791
+ "dropbox_create_shared_link",
4792
+ "dropbox_list_shared_links",
4793
+ "dropbox_revoke_shared_link"
4794
+ ];
4795
+ function dropboxIntegration(options = {}) {
4796
+ if (options.scopes !== undefined && (!Array.isArray(options.scopes) || options.scopes.some((scope) => typeof scope !== "string"))) {
4797
+ throw new Error("dropboxIntegration scopes must be an array of strings");
4798
+ }
4799
+ const oauth = {
4800
+ provider: "dropbox",
4801
+ clientId: options.clientId ?? getEnv("DROPBOX_CLIENT_ID"),
4802
+ clientSecret: options.clientSecret ?? getEnv("DROPBOX_CLIENT_SECRET"),
4803
+ scopes: options.scopes,
4804
+ optionalScopes: options.optionalScopes,
4805
+ redirectUri: options.redirectUri,
4806
+ config: options
4807
+ };
4808
+ return {
4809
+ id: "dropbox",
4810
+ name: "Dropbox",
4811
+ tools: [...DROPBOX_TOOLS],
4812
+ authType: "oauth",
4813
+ oauth,
4814
+ async onInit(_client) {
4815
+ logger25.debug("Dropbox integration initialized");
4816
+ },
4817
+ async onAfterConnect(_client) {
4818
+ logger25.debug("Dropbox integration connected");
4819
+ }
4820
+ };
4821
+ }
4760
4822
  // src/integrations/gdocs.ts
4761
- var logger25 = createLogger("Google Docs");
4823
+ var logger26 = createLogger("Google Docs");
4762
4824
  var GDOCS_TOOLS = [
4763
4825
  "gdocs_list",
4764
4826
  "gdocs_get",
@@ -4783,15 +4845,15 @@ function gdocsIntegration(config = {}) {
4783
4845
  tools: [...GDOCS_TOOLS],
4784
4846
  oauth,
4785
4847
  async onInit(_client) {
4786
- logger25.debug("Google Docs integration initialized");
4848
+ logger26.debug("Google Docs integration initialized");
4787
4849
  },
4788
4850
  async onAfterConnect(_client) {
4789
- logger25.debug("Google Docs integration connected");
4851
+ logger26.debug("Google Docs integration connected");
4790
4852
  }
4791
4853
  };
4792
4854
  }
4793
4855
  // src/integrations/gsheets.ts
4794
- var logger26 = createLogger("Google Sheets");
4856
+ var logger27 = createLogger("Google Sheets");
4795
4857
  var GSHEETS_TOOLS = [
4796
4858
  "gsheets_list",
4797
4859
  "gsheets_get",
@@ -4819,15 +4881,15 @@ function gsheetsIntegration(config = {}) {
4819
4881
  tools: [...GSHEETS_TOOLS],
4820
4882
  oauth,
4821
4883
  async onInit(_client) {
4822
- logger26.debug("Google Sheets integration initialized");
4884
+ logger27.debug("Google Sheets integration initialized");
4823
4885
  },
4824
4886
  async onAfterConnect(_client) {
4825
- logger26.debug("Google Sheets integration connected");
4887
+ logger27.debug("Google Sheets integration connected");
4826
4888
  }
4827
4889
  };
4828
4890
  }
4829
4891
  // src/integrations/gslides.ts
4830
- var logger27 = createLogger("Google Slides");
4892
+ var logger28 = createLogger("Google Slides");
4831
4893
  var GSLIDES_TOOLS = [
4832
4894
  "gslides_list",
4833
4895
  "gslides_get",
@@ -4854,15 +4916,15 @@ function gslidesIntegration(config = {}) {
4854
4916
  tools: [...GSLIDES_TOOLS],
4855
4917
  oauth,
4856
4918
  async onInit(_client) {
4857
- logger27.debug("Google Slides integration initialized");
4919
+ logger28.debug("Google Slides integration initialized");
4858
4920
  },
4859
4921
  async onAfterConnect(_client) {
4860
- logger27.debug("Google Slides integration connected");
4922
+ logger28.debug("Google Slides integration connected");
4861
4923
  }
4862
4924
  };
4863
4925
  }
4864
4926
  // src/integrations/polar.ts
4865
- var logger28 = createLogger("Polar");
4927
+ var logger29 = createLogger("Polar");
4866
4928
  var POLAR_TOOLS = [
4867
4929
  "polar_list_products",
4868
4930
  "polar_get_product",
@@ -4919,15 +4981,15 @@ function polarIntegration(config = {}) {
4919
4981
  tools: [...POLAR_TOOLS],
4920
4982
  oauth,
4921
4983
  async onInit(_client) {
4922
- logger28.debug("Polar integration initialized");
4984
+ logger29.debug("Polar integration initialized");
4923
4985
  },
4924
4986
  async onAfterConnect(_client) {
4925
- logger28.debug("Polar integration connected");
4987
+ logger29.debug("Polar integration connected");
4926
4988
  }
4927
4989
  };
4928
4990
  }
4929
4991
  // src/integrations/figma.ts
4930
- var logger29 = createLogger("Figma");
4992
+ var logger30 = createLogger("Figma");
4931
4993
  var FIGMA_TOOLS = [
4932
4994
  "figma_get_file",
4933
4995
  "figma_get_file_nodes",
@@ -4993,15 +5055,15 @@ function figmaIntegration(config = {}) {
4993
5055
  tools: [...FIGMA_TOOLS],
4994
5056
  oauth,
4995
5057
  async onInit(_client) {
4996
- logger29.debug("Figma integration initialized");
5058
+ logger30.debug("Figma integration initialized");
4997
5059
  },
4998
5060
  async onAfterConnect(_client) {
4999
- logger29.debug("Figma integration connected");
5061
+ logger30.debug("Figma integration connected");
5000
5062
  }
5001
5063
  };
5002
5064
  }
5003
5065
  // src/integrations/intercom.ts
5004
- var logger30 = createLogger("Intercom");
5066
+ var logger31 = createLogger("Intercom");
5005
5067
  var INTERCOM_TOOLS = [
5006
5068
  "intercom_list_contacts",
5007
5069
  "intercom_get_contact",
@@ -5032,15 +5094,15 @@ function intercomIntegration(config = {}) {
5032
5094
  tools: [...INTERCOM_TOOLS],
5033
5095
  oauth,
5034
5096
  async onInit(_client) {
5035
- logger30.debug("Intercom integration initialized");
5097
+ logger31.debug("Intercom integration initialized");
5036
5098
  },
5037
5099
  async onAfterConnect(_client) {
5038
- logger30.debug("Intercom integration connected");
5100
+ logger31.debug("Intercom integration connected");
5039
5101
  }
5040
5102
  };
5041
5103
  }
5042
5104
  // src/integrations/hubspot.ts
5043
- var logger31 = createLogger("HubSpot");
5105
+ var logger32 = createLogger("HubSpot");
5044
5106
  var HUBSPOT_TOOLS = [
5045
5107
  "hubspot_list_contacts",
5046
5108
  "hubspot_get_contact",
@@ -5090,15 +5152,15 @@ function hubspotIntegration(config = {}) {
5090
5152
  tools: [...HUBSPOT_TOOLS],
5091
5153
  oauth,
5092
5154
  async onInit(_client) {
5093
- logger31.debug("HubSpot integration initialized");
5155
+ logger32.debug("HubSpot integration initialized");
5094
5156
  },
5095
5157
  async onAfterConnect(_client) {
5096
- logger31.debug("HubSpot integration connected");
5158
+ logger32.debug("HubSpot integration connected");
5097
5159
  }
5098
5160
  };
5099
5161
  }
5100
5162
  // src/integrations/youtube.ts
5101
- var logger32 = createLogger("YouTube");
5163
+ var logger33 = createLogger("YouTube");
5102
5164
  var YOUTUBE_TOOLS = [
5103
5165
  "youtube_search",
5104
5166
  "youtube_get_video",
@@ -5144,15 +5206,15 @@ function youtubeIntegration(config = {}) {
5144
5206
  tools: [...YOUTUBE_TOOLS],
5145
5207
  oauth,
5146
5208
  async onInit(_client) {
5147
- logger32.debug("YouTube integration initialized");
5209
+ logger33.debug("YouTube integration initialized");
5148
5210
  },
5149
5211
  async onAfterConnect(_client) {
5150
- logger32.debug("YouTube integration connected");
5212
+ logger33.debug("YouTube integration connected");
5151
5213
  }
5152
5214
  };
5153
5215
  }
5154
5216
  // src/integrations/cursor.ts
5155
- var logger33 = createLogger("Cursor");
5217
+ var logger34 = createLogger("Cursor");
5156
5218
  var CURSOR_TOOLS = [
5157
5219
  "cursor_list_agents",
5158
5220
  "cursor_get_agent",
@@ -5172,10 +5234,114 @@ function cursorIntegration(_config = {}) {
5172
5234
  logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/cursor.jpeg",
5173
5235
  tools: [...CURSOR_TOOLS],
5174
5236
  async onInit(_client) {
5175
- logger33.debug("Cursor integration initialized");
5237
+ logger34.debug("Cursor integration initialized");
5176
5238
  },
5177
5239
  async onAfterConnect(_client) {
5178
- logger33.debug("Cursor integration connected");
5240
+ logger34.debug("Cursor integration connected");
5241
+ }
5242
+ };
5243
+ }
5244
+ // src/integrations/granola.ts
5245
+ var GRANOLA_TOOLS = [
5246
+ "granola_list_notes",
5247
+ "granola_get_note",
5248
+ "granola_list_folders"
5249
+ ];
5250
+ function granolaIntegration(options) {
5251
+ if (!options.apiKey) {
5252
+ throw new Error("granolaIntegration requires an apiKey");
5253
+ }
5254
+ return {
5255
+ id: "granola",
5256
+ name: "Granola",
5257
+ tools: [...GRANOLA_TOOLS],
5258
+ authType: "apiKey",
5259
+ getHeaders() {
5260
+ return {
5261
+ Authorization: `Bearer ${options.apiKey}`
5262
+ };
5263
+ }
5264
+ };
5265
+ }
5266
+ // src/integrations/mercury.ts
5267
+ var MERCURY_TOOLS = [
5268
+ "mercury_get_organization",
5269
+ "mercury_list_accounts",
5270
+ "mercury_get_account",
5271
+ "mercury_get_account_cards",
5272
+ "mercury_list_account_transactions",
5273
+ "mercury_get_account_transaction",
5274
+ "mercury_list_account_statements",
5275
+ "mercury_download_statement_pdf",
5276
+ "mercury_list_transactions",
5277
+ "mercury_get_transaction",
5278
+ "mercury_update_transaction",
5279
+ "mercury_upload_transaction_attachment",
5280
+ "mercury_list_cards",
5281
+ "mercury_get_card",
5282
+ "mercury_create_card",
5283
+ "mercury_update_card",
5284
+ "mercury_freeze_card",
5285
+ "mercury_unfreeze_card",
5286
+ "mercury_cancel_card",
5287
+ "mercury_list_categories",
5288
+ "mercury_create_category",
5289
+ "mercury_update_category",
5290
+ "mercury_list_credit_accounts",
5291
+ "mercury_list_users",
5292
+ "mercury_get_user",
5293
+ "mercury_list_recipients",
5294
+ "mercury_get_recipient",
5295
+ "mercury_create_recipient",
5296
+ "mercury_update_recipient",
5297
+ "mercury_list_recipient_attachments",
5298
+ "mercury_upload_recipient_attachment",
5299
+ "mercury_list_customers",
5300
+ "mercury_get_customer",
5301
+ "mercury_create_customer",
5302
+ "mercury_update_customer",
5303
+ "mercury_delete_customer",
5304
+ "mercury_list_invoices",
5305
+ "mercury_get_invoice",
5306
+ "mercury_create_invoice",
5307
+ "mercury_update_invoice",
5308
+ "mercury_cancel_invoice",
5309
+ "mercury_list_invoice_attachments",
5310
+ "mercury_get_attachment",
5311
+ "mercury_download_invoice_pdf",
5312
+ "mercury_list_treasury_accounts",
5313
+ "mercury_list_treasury_transactions",
5314
+ "mercury_list_treasury_statements",
5315
+ "mercury_list_events",
5316
+ "mercury_get_event",
5317
+ "mercury_list_send_money_requests",
5318
+ "mercury_get_send_money_request",
5319
+ "mercury_list_safe_requests",
5320
+ "mercury_get_safe_request",
5321
+ "mercury_download_safe_request_document",
5322
+ "mercury_list_webhooks",
5323
+ "mercury_get_webhook",
5324
+ "mercury_create_webhook",
5325
+ "mercury_update_webhook",
5326
+ "mercury_delete_webhook",
5327
+ "mercury_verify_webhook",
5328
+ "mercury_create_internal_transfer",
5329
+ "mercury_send_money",
5330
+ "mercury_request_send_money"
5331
+ ];
5332
+ function mercuryIntegration(options) {
5333
+ if (!options.apiKey) {
5334
+ throw new Error("mercuryIntegration requires an apiKey");
5335
+ }
5336
+ return {
5337
+ id: "mercury",
5338
+ name: "Mercury",
5339
+ tools: [...MERCURY_TOOLS],
5340
+ authType: "apiKey",
5341
+ getHeaders() {
5342
+ return {
5343
+ Authorization: `Bearer ${options.apiKey}`
5344
+ };
5179
5345
  }
5180
5346
  };
5181
5347
  }
@@ -5193,7 +5359,7 @@ function validateStepLimit(stepIndex, maxSteps) {
5193
5359
  return { valid: true };
5194
5360
  }
5195
5361
  // src/triggers/webhooks.ts
5196
- var logger34 = createLogger("Webhooks", "server");
5362
+ var logger35 = createLogger("Webhooks", "server");
5197
5363
  async function signPayload(payload, secret) {
5198
5364
  const encoder = new TextEncoder;
5199
5365
  const data = encoder.encode(JSON.stringify(payload));
@@ -5219,7 +5385,7 @@ async function deliverWebhook(webhook, payload, timeoutMs) {
5219
5385
  signal: controller.signal
5220
5386
  });
5221
5387
  if (!response.ok) {
5222
- logger34.warn(`Webhook delivery to ${webhook.url} returned ${response.status}`);
5388
+ logger35.warn(`Webhook delivery to ${webhook.url} returned ${response.status}`);
5223
5389
  }
5224
5390
  } finally {
5225
5391
  clearTimeout(timeout);
@@ -5232,7 +5398,7 @@ async function deliverWebhooks(webhooks, payload, timeoutMs) {
5232
5398
  for (let i = 0;i < results.length; i++) {
5233
5399
  const result = results[i];
5234
5400
  if (result.status === "rejected") {
5235
- logger34.warn(`Webhook delivery to ${webhooks[i].url} failed:`, result.reason);
5401
+ logger35.warn(`Webhook delivery to ${webhooks[i].url} failed:`, result.reason);
5236
5402
  }
5237
5403
  }
5238
5404
  }
@@ -5269,7 +5435,7 @@ function createSimpleIntegration(config) {
5269
5435
  };
5270
5436
  }
5271
5437
  // src/integrations/word.ts
5272
- var logger35 = createLogger("Word");
5438
+ var logger36 = createLogger("Word");
5273
5439
  var WORD_TOOLS = [
5274
5440
  "word_list",
5275
5441
  "word_get",
@@ -5295,16 +5461,16 @@ function wordIntegration(config = {}) {
5295
5461
  tools: [...WORD_TOOLS],
5296
5462
  oauth,
5297
5463
  async onInit(_client) {
5298
- logger35.debug("Word integration initialized");
5464
+ logger36.debug("Word integration initialized");
5299
5465
  },
5300
5466
  async onAfterConnect(_client) {
5301
- logger35.debug("Word integration connected");
5467
+ logger36.debug("Word integration connected");
5302
5468
  }
5303
5469
  };
5304
5470
  }
5305
5471
 
5306
5472
  // src/integrations/excel.ts
5307
- var logger36 = createLogger("Excel");
5473
+ var logger37 = createLogger("Excel");
5308
5474
  var EXCEL_TOOLS = [
5309
5475
  "excel_list",
5310
5476
  "excel_get",
@@ -5340,16 +5506,16 @@ function excelIntegration(config = {}) {
5340
5506
  tools: [...EXCEL_TOOLS],
5341
5507
  oauth,
5342
5508
  async onInit(_client) {
5343
- logger36.debug("Excel integration initialized");
5509
+ logger37.debug("Excel integration initialized");
5344
5510
  },
5345
5511
  async onAfterConnect(_client) {
5346
- logger36.debug("Excel integration connected");
5512
+ logger37.debug("Excel integration connected");
5347
5513
  }
5348
5514
  };
5349
5515
  }
5350
5516
 
5351
5517
  // src/integrations/powerpoint.ts
5352
- var logger37 = createLogger("PowerPoint");
5518
+ var logger38 = createLogger("PowerPoint");
5353
5519
  var POWERPOINT_TOOLS = [
5354
5520
  "powerpoint_list",
5355
5521
  "powerpoint_get",
@@ -5375,16 +5541,16 @@ function powerpointIntegration(config = {}) {
5375
5541
  tools: [...POWERPOINT_TOOLS],
5376
5542
  oauth,
5377
5543
  async onInit(_client) {
5378
- logger37.debug("PowerPoint integration initialized");
5544
+ logger38.debug("PowerPoint integration initialized");
5379
5545
  },
5380
5546
  async onAfterConnect(_client) {
5381
- logger37.debug("PowerPoint integration connected");
5547
+ logger38.debug("PowerPoint integration connected");
5382
5548
  }
5383
5549
  };
5384
5550
  }
5385
5551
 
5386
5552
  // src/integrations/gdrive.ts
5387
- var logger38 = createLogger("Google Drive");
5553
+ var logger39 = createLogger("Google Drive");
5388
5554
  var GDRIVE_TOOLS = [
5389
5555
  "gdrive_list_files",
5390
5556
  "gdrive_get_file",
@@ -5418,10 +5584,10 @@ function gdriveIntegration(config = {}) {
5418
5584
  tools: [...GDRIVE_TOOLS],
5419
5585
  oauth,
5420
5586
  async onInit(_client) {
5421
- logger38.debug("Google Drive integration initialized");
5587
+ logger39.debug("Google Drive integration initialized");
5422
5588
  },
5423
5589
  async onAfterConnect(_client) {
5424
- logger38.debug("Google Drive integration connected");
5590
+ logger39.debug("Google Drive integration connected");
5425
5591
  }
5426
5592
  };
5427
5593
  }
@@ -5480,6 +5646,7 @@ export {
5480
5646
  outlookIntegration,
5481
5647
  onedriveIntegration,
5482
5648
  notionIntegration,
5649
+ mercuryIntegration,
5483
5650
  linearIntegration,
5484
5651
  isTokenExpiredError,
5485
5652
  isAuthorizationError,
@@ -5488,6 +5655,7 @@ export {
5488
5655
  hubspotIntegration,
5489
5656
  gslidesIntegration,
5490
5657
  gsheetsIntegration,
5658
+ granolaIntegration,
5491
5659
  gmailIntegration,
5492
5660
  githubIntegration,
5493
5661
  genericOAuthIntegration,
@@ -5499,6 +5667,7 @@ export {
5499
5667
  gcalIntegration,
5500
5668
  fromNodeHeaders,
5501
5669
  figmaIntegration,
5670
+ dropboxIntegration,
5502
5671
  deliverWebhooks,
5503
5672
  cursorIntegration,
5504
5673
  createTanStackOAuthHandler,