integrate-sdk 0.9.27-dev.1 → 0.9.28-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.
Files changed (35) hide show
  1. package/README.md +82 -0
  2. package/dist/adapters/auto-routes.js +177 -8
  3. package/dist/adapters/base-handler.d.ts +4 -2
  4. package/dist/adapters/base-handler.d.ts.map +1 -1
  5. package/dist/adapters/base-handler.js +177 -8
  6. package/dist/adapters/index.js +245 -81
  7. package/dist/adapters/nextjs.js +177 -8
  8. package/dist/adapters/solid-start.js +245 -81
  9. package/dist/adapters/svelte-kit.js +245 -81
  10. package/dist/index.js +422 -109
  11. package/dist/oauth.js +177 -8
  12. package/dist/server.js +449 -138
  13. package/dist/src/adapters/base-handler.d.ts +4 -2
  14. package/dist/src/adapters/base-handler.d.ts.map +1 -1
  15. package/dist/src/client.d.ts +8 -0
  16. package/dist/src/client.d.ts.map +1 -1
  17. package/dist/src/index.d.ts +8 -0
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/integrations/dropbox.d.ts +22 -0
  20. package/dist/src/integrations/dropbox.d.ts.map +1 -0
  21. package/dist/src/integrations/granola.d.ts +14 -0
  22. package/dist/src/integrations/granola.d.ts.map +1 -0
  23. package/dist/src/integrations/integration-summary.d.ts +24 -0
  24. package/dist/src/integrations/integration-summary.d.ts.map +1 -0
  25. package/dist/src/integrations/library-metadata.d.ts +26 -0
  26. package/dist/src/integrations/library-metadata.d.ts.map +1 -0
  27. package/dist/src/integrations/mercury.d.ts +14 -0
  28. package/dist/src/integrations/mercury.d.ts.map +1 -0
  29. package/dist/src/integrations/server-client.d.ts +4 -0
  30. package/dist/src/integrations/server-client.d.ts.map +1 -1
  31. package/dist/src/integrations/types.d.ts +12 -0
  32. package/dist/src/integrations/types.d.ts.map +1 -1
  33. package/dist/src/server.d.ts +3 -0
  34. package/dist/src/server.d.ts.map +1 -1
  35. package/package.json +1 -1
@@ -284,6 +284,180 @@ function getContextCookieFromRequest(request) {
284
284
  }
285
285
  var CONTEXT_COOKIE_NAME = "__integrate_oauth_ctx", CONTEXT_COOKIE_MAX_AGE = 300;
286
286
 
287
+ // ../integrations/library-metadata.ts
288
+ function integrationLibraryPresentationFields(integration) {
289
+ const id = typeof integration["id"] === "string" ? integration["id"] : String(integration["id"] ?? "");
290
+ const fromCatalog = id ? INTEGRATION_LIBRARY_METADATA[id] : undefined;
291
+ const explicitDescription = integration["description"];
292
+ const explicitCategory = integration["category"];
293
+ const description = typeof explicitDescription === "string" && explicitDescription.trim().length > 0 ? explicitDescription.trim() : fromCatalog?.description;
294
+ const category = typeof explicitCategory === "string" && explicitCategory.trim().length > 0 ? explicitCategory.trim() : fromCatalog?.category;
295
+ const out = {};
296
+ if (description)
297
+ out.description = description;
298
+ if (category)
299
+ out.category = category;
300
+ return out;
301
+ }
302
+ var INTEGRATION_LIBRARY_METADATA;
303
+ var init_library_metadata = __esm(() => {
304
+ INTEGRATION_LIBRARY_METADATA = {
305
+ airtable: {
306
+ description: "Manage Airtable bases, tables, and records",
307
+ category: "Business"
308
+ },
309
+ calcom: {
310
+ description: "Manage Cal.com bookings and schedules",
311
+ category: "Productivity"
312
+ },
313
+ cursor: {
314
+ description: "Manage Cursor Cloud Agents and background tasks",
315
+ category: "Engineering"
316
+ },
317
+ figma: {
318
+ description: "Access Figma files, comments, and components",
319
+ category: "Engineering"
320
+ },
321
+ github: {
322
+ description: "Manage GitHub repos, issues, and pull requests",
323
+ category: "Engineering"
324
+ },
325
+ gmail: {
326
+ description: "Send, read, and search Gmail messages",
327
+ category: "Communication"
328
+ },
329
+ gcal: {
330
+ description: "Manage Google Calendar events and schedules",
331
+ category: "Productivity"
332
+ },
333
+ hubspot: {
334
+ description: "Manage HubSpot contacts, deals, and tickets",
335
+ category: "Business"
336
+ },
337
+ intercom: {
338
+ description: "Manage Intercom contacts and conversations",
339
+ category: "Business"
340
+ },
341
+ linear: {
342
+ description: "Manage Linear issues, projects, and cycles",
343
+ category: "Engineering"
344
+ },
345
+ notion: {
346
+ description: "Manage Notion pages and databases",
347
+ category: "Productivity"
348
+ },
349
+ onedrive: {
350
+ description: "Manage OneDrive files, folders, and sharing",
351
+ category: "Storage"
352
+ },
353
+ outlook: {
354
+ description: "Manage Outlook mail, calendars, and contacts",
355
+ category: "Communication"
356
+ },
357
+ polar: {
358
+ description: "Manage Polar products, orders, and subscriptions",
359
+ category: "Business"
360
+ },
361
+ ramp: {
362
+ description: "Manage Ramp corporate cards, bills, and spend",
363
+ category: "Business"
364
+ },
365
+ slack: {
366
+ description: "Send and manage Slack messages and channels",
367
+ category: "Communication"
368
+ },
369
+ stripe: {
370
+ description: "Manage Stripe customers, payments, and subscriptions",
371
+ category: "Business"
372
+ },
373
+ todoist: {
374
+ description: "Manage Todoist tasks, projects, and labels",
375
+ category: "Productivity"
376
+ },
377
+ gslides: {
378
+ description: "Create and update Google Slides presentations",
379
+ category: "Productivity"
380
+ },
381
+ gsheets: {
382
+ description: "Read and update Google Sheets spreadsheets",
383
+ category: "Productivity"
384
+ },
385
+ gdocs: {
386
+ description: "Create and edit Google Docs documents",
387
+ category: "Productivity"
388
+ },
389
+ gdrive: {
390
+ description: "Manage Google Drive files, folders, and sharing",
391
+ category: "Storage"
392
+ },
393
+ vercel: {
394
+ description: "Manage Vercel projects, deployments, and domains",
395
+ category: "Engineering"
396
+ },
397
+ whatsapp: {
398
+ description: "Send WhatsApp messages and templates",
399
+ category: "Communication"
400
+ },
401
+ youtube: {
402
+ description: "Search and access YouTube videos and channels",
403
+ category: "Communication"
404
+ },
405
+ powerpoint: {
406
+ description: "Manage PowerPoint presentations and sharing",
407
+ category: "Productivity"
408
+ },
409
+ excel: {
410
+ description: "Manage Excel workbooks, worksheets, and tables",
411
+ category: "Productivity"
412
+ },
413
+ word: {
414
+ description: "Manage Word documents and sharing",
415
+ category: "Productivity"
416
+ },
417
+ dropbox: {
418
+ description: "Manage Dropbox files, folders, and sharing",
419
+ category: "Storage"
420
+ },
421
+ granola: {
422
+ description: "List and read Granola meeting notes and folders",
423
+ category: "Productivity"
424
+ },
425
+ mercury: {
426
+ description: "Manage Mercury bank accounts, cards, and transactions",
427
+ category: "Business"
428
+ },
429
+ zendesk: {
430
+ description: "Manage Zendesk tickets, users, and help center content",
431
+ category: "Business"
432
+ }
433
+ };
434
+ });
435
+
436
+ // ../integrations/integration-summary.ts
437
+ function toConfiguredIntegrationSummary(integration) {
438
+ const row = integration;
439
+ const pres = integrationLibraryPresentationFields(row);
440
+ return {
441
+ id: integration.id,
442
+ name: row.name || integration.id,
443
+ logoUrl: row.logoUrl,
444
+ tools: integration.tools,
445
+ hasOAuth: !!integration.oauth,
446
+ scopes: integration.oauth?.scopes,
447
+ provider: integration.oauth?.provider,
448
+ ...pres
449
+ };
450
+ }
451
+ function toConfiguredIntegrationWithToolMetadata(integration, toolMetadata) {
452
+ return {
453
+ ...toConfiguredIntegrationSummary(integration),
454
+ toolMetadata
455
+ };
456
+ }
457
+ var init_integration_summary = __esm(() => {
458
+ init_library_metadata();
459
+ });
460
+
287
461
  // ../utils/logger.ts
288
462
  function shouldLog(level, context) {
289
463
  return logLevelHierarchy[level] <= logLevelHierarchy[contextLogLevels[context]];
@@ -447,14 +621,8 @@ class OAuthHandler {
447
621
  const integrations = this.config.integrations || [];
448
622
  return {
449
623
  integrations: integrations.map((integration) => ({
450
- id: integration.id,
451
- name: integration.name || integration.id,
452
- logoUrl: integration.logoUrl,
453
- tools: integration.tools,
454
- hasOAuth: !!integration.oauth,
455
- scopes: integration.oauth?.scopes,
456
- optionalScopes: integration.oauth?.optionalScopes,
457
- provider: integration.oauth?.provider
624
+ ...toConfiguredIntegrationSummary(integration),
625
+ optionalScopes: integration.oauth?.optionalScopes
458
626
  }))
459
627
  };
460
628
  }
@@ -841,6 +1009,7 @@ class OAuthHandler {
841
1009
  }
842
1010
  var SERVER_LOG_CONTEXT = "server", logger2, MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
843
1011
  var init_base_handler = __esm(() => {
1012
+ init_integration_summary();
844
1013
  init_email_fetcher();
845
1014
  init_logger();
846
1015
  logger2 = createLogger("OAuthHandler", SERVER_LOG_CONTEXT);
@@ -1696,6 +1865,8 @@ class HttpSessionTransport {
1696
1865
  }
1697
1866
 
1698
1867
  // ../client.ts
1868
+ init_integration_summary();
1869
+ init_library_metadata();
1699
1870
  init_errors();
1700
1871
  init_logger();
1701
1872
 
@@ -3011,31 +3182,14 @@ class MCPClientBase {
3011
3182
  const serverConfig = this.__oauthConfig;
3012
3183
  const localIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
3013
3184
  const formatLocalIntegrations = (integrations) => ({
3014
- integrations: integrations.map((integration) => ({
3015
- id: integration.id,
3016
- name: integration.name || integration.id,
3017
- logoUrl: integration.logoUrl,
3018
- tools: integration.tools,
3019
- hasOAuth: !!integration.oauth,
3020
- scopes: integration.oauth?.scopes,
3021
- provider: integration.oauth?.provider
3022
- }))
3185
+ integrations: integrations.map((integration) => toConfiguredIntegrationSummary(integration))
3023
3186
  });
3024
3187
  if (hasApiKey || !this.__useServerConfig) {
3025
3188
  if (options?.includeToolMetadata && hasApiKey) {
3026
3189
  await this.ensureConnected();
3027
3190
  const integrationsWithMetadata = localIntegrations.map((integration) => {
3028
3191
  const toolMetadata = integration.tools.map((toolName) => this.availableTools.get(toolName)).filter((tool) => !!tool);
3029
- return {
3030
- id: integration.id,
3031
- name: integration.name || integration.id,
3032
- logoUrl: integration.logoUrl,
3033
- tools: integration.tools,
3034
- hasOAuth: !!integration.oauth,
3035
- scopes: integration.oauth?.scopes,
3036
- provider: integration.oauth?.provider,
3037
- toolMetadata
3038
- };
3192
+ return toConfiguredIntegrationWithToolMetadata(integration, toolMetadata);
3039
3193
  });
3040
3194
  return { integrations: integrationsWithMetadata };
3041
3195
  }
@@ -3061,28 +3215,10 @@ class MCPClientBase {
3061
3215
  }
3062
3216
  }
3063
3217
  }
3064
- return {
3065
- id: integration.id,
3066
- name: integration.name || integration.id,
3067
- logoUrl: integration.logoUrl,
3068
- tools: integration.tools,
3069
- hasOAuth: !!integration.oauth,
3070
- scopes: integration.oauth?.scopes,
3071
- provider: integration.oauth?.provider,
3072
- toolMetadata
3073
- };
3218
+ return toConfiguredIntegrationWithToolMetadata(integration, toolMetadata);
3074
3219
  } catch (error) {
3075
3220
  logger7.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
3076
- return {
3077
- id: integration.id,
3078
- name: integration.name || integration.id,
3079
- logoUrl: integration.logoUrl,
3080
- tools: integration.tools,
3081
- hasOAuth: !!integration.oauth,
3082
- scopes: integration.oauth?.scopes,
3083
- provider: integration.oauth?.provider,
3084
- toolMetadata: []
3085
- };
3221
+ return toConfiguredIntegrationWithToolMetadata(integration, []);
3086
3222
  }
3087
3223
  }, 3);
3088
3224
  return { integrations: integrationsWithMetadata };
@@ -3102,6 +3238,12 @@ class MCPClientBase {
3102
3238
  return formatLocalIntegrations(localIntegrations);
3103
3239
  }
3104
3240
  const result = await response.json();
3241
+ if (result.integrations && Array.isArray(result.integrations)) {
3242
+ result.integrations = result.integrations.map((row) => ({
3243
+ ...row,
3244
+ ...integrationLibraryPresentationFields(row)
3245
+ }));
3246
+ }
3105
3247
  if (options?.includeToolMetadata && result.integrations) {
3106
3248
  const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
3107
3249
  const integrationsWithMetadata = await parallelWithLimit2(result.integrations, async (integration) => {
@@ -3126,12 +3268,14 @@ class MCPClientBase {
3126
3268
  }
3127
3269
  return {
3128
3270
  ...integration,
3271
+ ...integrationLibraryPresentationFields(integration),
3129
3272
  toolMetadata
3130
3273
  };
3131
3274
  } catch (error) {
3132
3275
  logger7.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
3133
3276
  return {
3134
3277
  ...integration,
3278
+ ...integrationLibraryPresentationFields(integration),
3135
3279
  toolMetadata: []
3136
3280
  };
3137
3281
  }
@@ -3224,6 +3368,9 @@ class MCPClientBase {
3224
3368
  async _callToolByName(name, args, options) {
3225
3369
  return await this.callToolWithRetry(name, args, 0, options);
3226
3370
  }
3371
+ async callTool(name, args, options) {
3372
+ return await this.callToolWithRetry(name, args, 0, options);
3373
+ }
3227
3374
  async callServerTool(name, args) {
3228
3375
  try {
3229
3376
  const response = await this.callToolThroughHandler(name, args);
@@ -3234,35 +3381,38 @@ class MCPClientBase {
3234
3381
  }
3235
3382
  }
3236
3383
  async callToolThroughHandler(name, args, provider, options) {
3384
+ const integrationHeaders = this.getHeadersForTool(name);
3237
3385
  const transportHeaders = this.transport.headers || {};
3238
3386
  const hasApiKey = !!transportHeaders["X-API-KEY"];
3239
3387
  if (hasApiKey) {
3240
3388
  await this.ensureConnected();
3389
+ const temporaryHeaders = { ...integrationHeaders };
3241
3390
  if (provider) {
3242
3391
  const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
3243
- if (tokenData && this.transport.setHeader) {
3244
- const previousAuthHeader = transportHeaders["Authorization"];
3245
- try {
3246
- this.transport.setHeader("Authorization", `Bearer ${tokenData.accessToken}`);
3247
- const result3 = await this.transport.sendRequest("tools/call", {
3248
- name,
3249
- arguments: args || {}
3250
- });
3251
- return result3;
3252
- } finally {
3253
- if (previousAuthHeader && this.transport.setHeader) {
3254
- this.transport.setHeader("Authorization", previousAuthHeader);
3255
- } else if (this.transport.removeHeader) {
3256
- this.transport.removeHeader("Authorization");
3257
- }
3392
+ if (tokenData) {
3393
+ temporaryHeaders["Authorization"] = `Bearer ${tokenData.accessToken}`;
3394
+ }
3395
+ }
3396
+ const previousHeaders = new Map;
3397
+ for (const [key, value] of Object.entries(temporaryHeaders)) {
3398
+ previousHeaders.set(key, transportHeaders[key]);
3399
+ this.transport.setHeader(key, value);
3400
+ }
3401
+ try {
3402
+ const result2 = await this.transport.sendRequest("tools/call", {
3403
+ name,
3404
+ arguments: args || {}
3405
+ });
3406
+ return result2;
3407
+ } finally {
3408
+ for (const [key, previousValue] of previousHeaders.entries()) {
3409
+ if (previousValue !== undefined) {
3410
+ this.transport.setHeader(key, previousValue);
3411
+ } else {
3412
+ this.transport.removeHeader(key);
3258
3413
  }
3259
3414
  }
3260
3415
  }
3261
- const result2 = await this.transport.sendRequest("tools/call", {
3262
- name,
3263
- arguments: args || {}
3264
- });
3265
- return result2;
3266
3416
  }
3267
3417
  const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
3268
3418
  const headers = {
@@ -3272,6 +3422,7 @@ class MCPClientBase {
3272
3422
  if (integrationsHeader) {
3273
3423
  headers["X-Integrations"] = integrationsHeader;
3274
3424
  }
3425
+ Object.assign(headers, integrationHeaders);
3275
3426
  if (provider) {
3276
3427
  const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
3277
3428
  if (tokenData) {
@@ -3361,6 +3512,14 @@ class MCPClientBase {
3361
3512
  }
3362
3513
  return;
3363
3514
  }
3515
+ getHeadersForTool(toolName) {
3516
+ for (const integration of this.integrations) {
3517
+ if (integration.tools.includes(toolName) && integration.getHeaders) {
3518
+ return integration.getHeaders();
3519
+ }
3520
+ }
3521
+ return {};
3522
+ }
3364
3523
  getTool(name) {
3365
3524
  return this.availableTools.get(name);
3366
3525
  }
@@ -3690,7 +3849,9 @@ class MCPClientBase {
3690
3849
  return success;
3691
3850
  }
3692
3851
  }
3852
+
3693
3853
  // ../server.ts
3854
+ init_integration_summary();
3694
3855
  init_logger();
3695
3856
 
3696
3857
  // ../integrations/github.ts
@@ -3741,45 +3902,48 @@ var logger22 = createLogger("Ramp");
3741
3902
  // ../integrations/onedrive.ts
3742
3903
  init_logger();
3743
3904
  var logger23 = createLogger("OneDrive");
3905
+ // ../integrations/dropbox.ts
3906
+ init_logger();
3907
+ var logger24 = createLogger("Dropbox");
3744
3908
  // ../integrations/word.ts
3745
3909
  init_logger();
3746
- var logger24 = createLogger("Word");
3910
+ var logger25 = createLogger("Word");
3747
3911
  // ../integrations/excel.ts
3748
3912
  init_logger();
3749
- var logger25 = createLogger("Excel");
3913
+ var logger26 = createLogger("Excel");
3750
3914
  // ../integrations/powerpoint.ts
3751
3915
  init_logger();
3752
- var logger26 = createLogger("PowerPoint");
3916
+ var logger27 = createLogger("PowerPoint");
3753
3917
  // ../integrations/gdocs.ts
3754
3918
  init_logger();
3755
- var logger27 = createLogger("Google Docs");
3919
+ var logger28 = createLogger("Google Docs");
3756
3920
  // ../integrations/gdrive.ts
3757
3921
  init_logger();
3758
- var logger28 = createLogger("Google Drive");
3922
+ var logger29 = createLogger("Google Drive");
3759
3923
  // ../integrations/gsheets.ts
3760
3924
  init_logger();
3761
- var logger29 = createLogger("Google Sheets");
3925
+ var logger30 = createLogger("Google Sheets");
3762
3926
  // ../integrations/gslides.ts
3763
3927
  init_logger();
3764
- var logger30 = createLogger("Google Slides");
3928
+ var logger31 = createLogger("Google Slides");
3765
3929
  // ../integrations/polar.ts
3766
3930
  init_logger();
3767
- var logger31 = createLogger("Polar");
3931
+ var logger32 = createLogger("Polar");
3768
3932
  // ../integrations/figma.ts
3769
3933
  init_logger();
3770
- var logger32 = createLogger("Figma");
3934
+ var logger33 = createLogger("Figma");
3771
3935
  // ../integrations/intercom.ts
3772
3936
  init_logger();
3773
- var logger33 = createLogger("Intercom");
3937
+ var logger34 = createLogger("Intercom");
3774
3938
  // ../integrations/hubspot.ts
3775
3939
  init_logger();
3776
- var logger34 = createLogger("HubSpot");
3940
+ var logger35 = createLogger("HubSpot");
3777
3941
  // ../integrations/youtube.ts
3778
3942
  init_logger();
3779
- var logger35 = createLogger("YouTube");
3943
+ var logger36 = createLogger("YouTube");
3780
3944
  // ../integrations/cursor.ts
3781
3945
  init_logger();
3782
- var logger36 = createLogger("Cursor");
3946
+ var logger37 = createLogger("Cursor");
3783
3947
  // ../ai/trigger-tools.ts
3784
3948
  init_utils();
3785
3949
 
@@ -3798,7 +3962,7 @@ init_tool_builder();
3798
3962
  init_tool_builder();
3799
3963
  // ../server.ts
3800
3964
  var SERVER_LOG_CONTEXT3 = "server";
3801
- var logger37 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);
3965
+ var logger38 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);
3802
3966
  var codeVerifierStorage = new Map;
3803
3967
  var unauthenticatedCodeModeWarnings = new Set;
3804
3968
  function toSolidStartHandler(clientOrHandlerOrOptions, _redirectOptions) {