integrate-sdk 0.9.27-dev.2 → 0.9.28-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/auto-routes.js +178 -8
- package/dist/adapters/base-handler.d.ts +5 -2
- package/dist/adapters/base-handler.d.ts.map +1 -1
- package/dist/adapters/base-handler.js +178 -8
- package/dist/adapters/index.js +243 -54
- package/dist/adapters/nextjs.d.ts.map +1 -1
- package/dist/adapters/nextjs.js +179 -9
- package/dist/adapters/solid-start.js +243 -54
- package/dist/adapters/svelte-kit.js +243 -54
- package/dist/index.js +241 -54
- package/dist/oauth.js +178 -8
- package/dist/server.js +248 -63
- package/dist/src/adapters/base-handler.d.ts +5 -2
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- package/dist/src/adapters/nextjs.d.ts.map +1 -1
- package/dist/src/client.d.ts +4 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/integrations/integration-summary.d.ts +24 -0
- package/dist/src/integrations/integration-summary.d.ts.map +1 -0
- package/dist/src/integrations/library-metadata.d.ts +26 -0
- package/dist/src/integrations/library-metadata.d.ts.map +1 -0
- package/dist/src/integrations/server-client.d.ts +4 -0
- package/dist/src/integrations/server-client.d.ts.map +1 -1
- package/dist/src/integrations/types.d.ts +8 -0
- package/dist/src/integrations/types.d.ts.map +1 -1
- package/dist/src/oauth/manager.d.ts.map +1 -1
- package/dist/src/oauth/types.d.ts +6 -0
- package/dist/src/oauth/types.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -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
|
-
|
|
451
|
-
|
|
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
|
}
|
|
@@ -624,6 +792,7 @@ class OAuthHandler {
|
|
|
624
792
|
if (this.config.setProviderToken) {
|
|
625
793
|
try {
|
|
626
794
|
const tokenData = {
|
|
795
|
+
sessionToken: result.sessionToken,
|
|
627
796
|
accessToken: result.accessToken,
|
|
628
797
|
refreshToken: result.refreshToken,
|
|
629
798
|
tokenType: result.tokenType,
|
|
@@ -841,6 +1010,7 @@ class OAuthHandler {
|
|
|
841
1010
|
}
|
|
842
1011
|
var SERVER_LOG_CONTEXT = "server", logger2, MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
|
|
843
1012
|
var init_base_handler = __esm(() => {
|
|
1013
|
+
init_integration_summary();
|
|
844
1014
|
init_email_fetcher();
|
|
845
1015
|
init_logger();
|
|
846
1016
|
logger2 = createLogger("OAuthHandler", SERVER_LOG_CONTEXT);
|
|
@@ -1339,7 +1509,7 @@ function createNextOAuthHandler(config) {
|
|
|
1339
1509
|
const codeModeHeader = req.headers.get("x-integrate-code-mode");
|
|
1340
1510
|
const tokensHeader = req.headers.get("x-integrate-tokens");
|
|
1341
1511
|
const toolName = typeof body?.name === "string" ? body.name : "";
|
|
1342
|
-
if (codeModeHeader === "1" && tokensHeader && toolName) {
|
|
1512
|
+
if (codeModeHeader === "1" && !authHeader && tokensHeader && toolName) {
|
|
1343
1513
|
try {
|
|
1344
1514
|
const tokens = JSON.parse(tokensHeader);
|
|
1345
1515
|
let best = null;
|
|
@@ -1696,6 +1866,8 @@ class HttpSessionTransport {
|
|
|
1696
1866
|
}
|
|
1697
1867
|
|
|
1698
1868
|
// ../client.ts
|
|
1869
|
+
init_integration_summary();
|
|
1870
|
+
init_library_metadata();
|
|
1699
1871
|
init_errors();
|
|
1700
1872
|
init_logger();
|
|
1701
1873
|
|
|
@@ -2204,6 +2376,7 @@ class OAuthManager {
|
|
|
2204
2376
|
}
|
|
2205
2377
|
const provider = tokenData.provider || pendingAuth.provider;
|
|
2206
2378
|
const tokenDataToStore = {
|
|
2379
|
+
sessionToken: tokenData.sessionToken,
|
|
2207
2380
|
accessToken: tokenData.accessToken,
|
|
2208
2381
|
refreshToken: tokenData.refreshToken,
|
|
2209
2382
|
tokenType: tokenData.tokenType,
|
|
@@ -2245,6 +2418,7 @@ class OAuthManager {
|
|
|
2245
2418
|
try {
|
|
2246
2419
|
const response = await this.exchangeCodeForToken(pendingAuth.provider, code, pendingAuth.codeVerifier, state);
|
|
2247
2420
|
const tokenData = {
|
|
2421
|
+
sessionToken: response.sessionToken,
|
|
2248
2422
|
accessToken: response.accessToken,
|
|
2249
2423
|
refreshToken: response.refreshToken,
|
|
2250
2424
|
tokenType: response.tokenType,
|
|
@@ -2816,6 +2990,7 @@ class MCPClientBase {
|
|
|
2816
2990
|
authState = new Map;
|
|
2817
2991
|
oauthManager;
|
|
2818
2992
|
eventEmitter = new SimpleEventEmitter;
|
|
2993
|
+
sessionToken;
|
|
2819
2994
|
apiRouteBase;
|
|
2820
2995
|
apiBaseUrl;
|
|
2821
2996
|
databaseDetected = false;
|
|
@@ -2860,6 +3035,7 @@ class MCPClientBase {
|
|
|
2860
3035
|
setProviderToken: config.setProviderToken,
|
|
2861
3036
|
removeProviderToken: config.removeProviderToken
|
|
2862
3037
|
});
|
|
3038
|
+
this.setSessionToken(config.sessionToken || this.loadSessionTokenFromStorage());
|
|
2863
3039
|
for (const integration of this.integrations) {
|
|
2864
3040
|
for (const toolName of integration.tools) {
|
|
2865
3041
|
this.enabledToolNames.add(toolName);
|
|
@@ -2882,6 +3058,9 @@ class MCPClientBase {
|
|
|
2882
3058
|
const provider = integration.oauth.provider;
|
|
2883
3059
|
try {
|
|
2884
3060
|
const tokenData = await this.oauthManager.getProviderToken(provider);
|
|
3061
|
+
if (tokenData?.sessionToken && !this.sessionToken) {
|
|
3062
|
+
this.setSessionToken(tokenData.sessionToken);
|
|
3063
|
+
}
|
|
2885
3064
|
const currentState = this.authState.get(provider);
|
|
2886
3065
|
if (currentState && !currentState.authenticated && !currentState.lastError) {
|
|
2887
3066
|
this.authState.set(provider, { authenticated: !!tokenData });
|
|
@@ -2906,6 +3085,9 @@ class MCPClientBase {
|
|
|
2906
3085
|
const provider = integration.oauth.provider;
|
|
2907
3086
|
const tokenData = this.oauthManager.getProviderTokenFromCache(provider);
|
|
2908
3087
|
if (tokenData) {
|
|
3088
|
+
if (tokenData.sessionToken && !this.sessionToken) {
|
|
3089
|
+
this.setSessionToken(tokenData.sessionToken);
|
|
3090
|
+
}
|
|
2909
3091
|
this.authState.set(provider, { authenticated: true });
|
|
2910
3092
|
}
|
|
2911
3093
|
}
|
|
@@ -3011,31 +3193,14 @@ class MCPClientBase {
|
|
|
3011
3193
|
const serverConfig = this.__oauthConfig;
|
|
3012
3194
|
const localIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
3013
3195
|
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
|
-
}))
|
|
3196
|
+
integrations: integrations.map((integration) => toConfiguredIntegrationSummary(integration))
|
|
3023
3197
|
});
|
|
3024
3198
|
if (hasApiKey || !this.__useServerConfig) {
|
|
3025
3199
|
if (options?.includeToolMetadata && hasApiKey) {
|
|
3026
3200
|
await this.ensureConnected();
|
|
3027
3201
|
const integrationsWithMetadata = localIntegrations.map((integration) => {
|
|
3028
3202
|
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
|
-
};
|
|
3203
|
+
return toConfiguredIntegrationWithToolMetadata(integration, toolMetadata);
|
|
3039
3204
|
});
|
|
3040
3205
|
return { integrations: integrationsWithMetadata };
|
|
3041
3206
|
}
|
|
@@ -3061,28 +3226,10 @@ class MCPClientBase {
|
|
|
3061
3226
|
}
|
|
3062
3227
|
}
|
|
3063
3228
|
}
|
|
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
|
-
};
|
|
3229
|
+
return toConfiguredIntegrationWithToolMetadata(integration, toolMetadata);
|
|
3074
3230
|
} catch (error) {
|
|
3075
3231
|
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
|
-
};
|
|
3232
|
+
return toConfiguredIntegrationWithToolMetadata(integration, []);
|
|
3086
3233
|
}
|
|
3087
3234
|
}, 3);
|
|
3088
3235
|
return { integrations: integrationsWithMetadata };
|
|
@@ -3102,6 +3249,12 @@ class MCPClientBase {
|
|
|
3102
3249
|
return formatLocalIntegrations(localIntegrations);
|
|
3103
3250
|
}
|
|
3104
3251
|
const result = await response.json();
|
|
3252
|
+
if (result.integrations && Array.isArray(result.integrations)) {
|
|
3253
|
+
result.integrations = result.integrations.map((row) => ({
|
|
3254
|
+
...row,
|
|
3255
|
+
...integrationLibraryPresentationFields(row)
|
|
3256
|
+
}));
|
|
3257
|
+
}
|
|
3105
3258
|
if (options?.includeToolMetadata && result.integrations) {
|
|
3106
3259
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
3107
3260
|
const integrationsWithMetadata = await parallelWithLimit2(result.integrations, async (integration) => {
|
|
@@ -3126,12 +3279,14 @@ class MCPClientBase {
|
|
|
3126
3279
|
}
|
|
3127
3280
|
return {
|
|
3128
3281
|
...integration,
|
|
3282
|
+
...integrationLibraryPresentationFields(integration),
|
|
3129
3283
|
toolMetadata
|
|
3130
3284
|
};
|
|
3131
3285
|
} catch (error) {
|
|
3132
3286
|
logger7.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
3133
3287
|
return {
|
|
3134
3288
|
...integration,
|
|
3289
|
+
...integrationLibraryPresentationFields(integration),
|
|
3135
3290
|
toolMetadata: []
|
|
3136
3291
|
};
|
|
3137
3292
|
}
|
|
@@ -3274,17 +3429,15 @@ class MCPClientBase {
|
|
|
3274
3429
|
const headers = {
|
|
3275
3430
|
"Content-Type": "application/json"
|
|
3276
3431
|
};
|
|
3432
|
+
if (this.sessionToken) {
|
|
3433
|
+
headers["Authorization"] = `Bearer ${this.sessionToken}`;
|
|
3434
|
+
headers["X-Session-Token"] = this.sessionToken;
|
|
3435
|
+
}
|
|
3277
3436
|
const integrationsHeader = this.getIntegrationHeaderValue();
|
|
3278
3437
|
if (integrationsHeader) {
|
|
3279
3438
|
headers["X-Integrations"] = integrationsHeader;
|
|
3280
3439
|
}
|
|
3281
3440
|
Object.assign(headers, integrationHeaders);
|
|
3282
|
-
if (provider) {
|
|
3283
|
-
const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
|
|
3284
|
-
if (tokenData) {
|
|
3285
|
-
headers["Authorization"] = `Bearer ${tokenData.accessToken}`;
|
|
3286
|
-
}
|
|
3287
|
-
}
|
|
3288
3441
|
const response = await fetch(url, {
|
|
3289
3442
|
method: "POST",
|
|
3290
3443
|
headers,
|
|
@@ -3483,7 +3636,35 @@ class MCPClientBase {
|
|
|
3483
3636
|
off(event, handler) {
|
|
3484
3637
|
this.eventEmitter.off(event, handler);
|
|
3485
3638
|
}
|
|
3639
|
+
loadSessionTokenFromStorage() {
|
|
3640
|
+
if (typeof window === "undefined" || !window.sessionStorage) {
|
|
3641
|
+
return;
|
|
3642
|
+
}
|
|
3643
|
+
try {
|
|
3644
|
+
return window.sessionStorage.getItem("integrate_session_token") || undefined;
|
|
3645
|
+
} catch {
|
|
3646
|
+
return;
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
setSessionToken(sessionToken) {
|
|
3650
|
+
this.sessionToken = sessionToken;
|
|
3651
|
+
if (sessionToken) {
|
|
3652
|
+
this.transport.setHeader("X-Session-Token", sessionToken);
|
|
3653
|
+
} else {
|
|
3654
|
+
this.transport.removeHeader("X-Session-Token");
|
|
3655
|
+
}
|
|
3656
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
3657
|
+
try {
|
|
3658
|
+
if (sessionToken) {
|
|
3659
|
+
window.sessionStorage.setItem("integrate_session_token", sessionToken);
|
|
3660
|
+
} else {
|
|
3661
|
+
window.sessionStorage.removeItem("integrate_session_token");
|
|
3662
|
+
}
|
|
3663
|
+
} catch {}
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3486
3666
|
clearSessionToken() {
|
|
3667
|
+
this.setSessionToken(undefined);
|
|
3487
3668
|
this.oauthManager.clearAllProviderTokens();
|
|
3488
3669
|
for (const integration of this.integrations) {
|
|
3489
3670
|
if (integration.oauth) {
|
|
@@ -3625,6 +3806,7 @@ class MCPClientBase {
|
|
|
3625
3806
|
if (tokenData) {
|
|
3626
3807
|
this.eventEmitter.emit("auth:complete", {
|
|
3627
3808
|
provider,
|
|
3809
|
+
sessionToken: tokenData.sessionToken || this.sessionToken,
|
|
3628
3810
|
accessToken: tokenData.accessToken,
|
|
3629
3811
|
expiresAt: tokenData.expiresAt
|
|
3630
3812
|
});
|
|
@@ -3640,6 +3822,7 @@ class MCPClientBase {
|
|
|
3640
3822
|
if (tokenData) {
|
|
3641
3823
|
this.eventEmitter.emit("auth:complete", {
|
|
3642
3824
|
provider,
|
|
3825
|
+
sessionToken: tokenData.sessionToken || this.sessionToken,
|
|
3643
3826
|
accessToken: tokenData.accessToken,
|
|
3644
3827
|
expiresAt: tokenData.expiresAt
|
|
3645
3828
|
});
|
|
@@ -3653,9 +3836,13 @@ class MCPClientBase {
|
|
|
3653
3836
|
async handleOAuthCallback(params) {
|
|
3654
3837
|
try {
|
|
3655
3838
|
const result = params.tokenData ? await this.oauthManager.handleCallbackWithToken(params.code, params.state, params.tokenData) : await this.oauthManager.handleCallback(params.code, params.state);
|
|
3839
|
+
if (result.sessionToken) {
|
|
3840
|
+
this.setSessionToken(result.sessionToken);
|
|
3841
|
+
}
|
|
3656
3842
|
this.authState.set(result.provider, { authenticated: true });
|
|
3657
3843
|
this.eventEmitter.emit("auth:complete", {
|
|
3658
3844
|
provider: result.provider,
|
|
3845
|
+
sessionToken: result.sessionToken || this.sessionToken,
|
|
3659
3846
|
accessToken: result.accessToken,
|
|
3660
3847
|
expiresAt: result.expiresAt
|
|
3661
3848
|
});
|
|
@@ -3705,7 +3892,9 @@ class MCPClientBase {
|
|
|
3705
3892
|
return success;
|
|
3706
3893
|
}
|
|
3707
3894
|
}
|
|
3895
|
+
|
|
3708
3896
|
// ../server.ts
|
|
3897
|
+
init_integration_summary();
|
|
3709
3898
|
init_logger();
|
|
3710
3899
|
|
|
3711
3900
|
// ../integrations/github.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../../../src/adapters/nextjs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAU1E,KAAK,WAAW,GAAG,GAAG,CAAC;AACvB,KAAK,YAAY,GAAG,GAAG,CAAC;AAExB;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;qCAC8B;QAC/B,6DAA6D;QAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,iEAAiE;QACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;QAKG;;WAEG;kBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC,CAAA;SAAE,GAClE,OAAO,CAAC,YAAY,CAAC;QA0CxB;;WAEG;iBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC,CAAA;SAAE,GAClE,OAAO,CAAC,YAAY,CAAC;;EAqG/B"}
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -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
|
-
|
|
451
|
-
|
|
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
|
}
|
|
@@ -624,6 +792,7 @@ class OAuthHandler {
|
|
|
624
792
|
if (this.config.setProviderToken) {
|
|
625
793
|
try {
|
|
626
794
|
const tokenData = {
|
|
795
|
+
sessionToken: result.sessionToken,
|
|
627
796
|
accessToken: result.accessToken,
|
|
628
797
|
refreshToken: result.refreshToken,
|
|
629
798
|
tokenType: result.tokenType,
|
|
@@ -841,6 +1010,7 @@ class OAuthHandler {
|
|
|
841
1010
|
}
|
|
842
1011
|
var SERVER_LOG_CONTEXT = "server", logger2, MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
|
|
843
1012
|
var init_base_handler = __esm(() => {
|
|
1013
|
+
init_integration_summary();
|
|
844
1014
|
init_email_fetcher();
|
|
845
1015
|
init_logger();
|
|
846
1016
|
logger2 = createLogger("OAuthHandler", SERVER_LOG_CONTEXT);
|
|
@@ -1084,7 +1254,7 @@ function createNextOAuthHandler(config) {
|
|
|
1084
1254
|
const codeModeHeader = req.headers.get("x-integrate-code-mode");
|
|
1085
1255
|
const tokensHeader = req.headers.get("x-integrate-tokens");
|
|
1086
1256
|
const toolName = typeof body?.name === "string" ? body.name : "";
|
|
1087
|
-
if (codeModeHeader === "1" && tokensHeader && toolName) {
|
|
1257
|
+
if (codeModeHeader === "1" && !authHeader && tokensHeader && toolName) {
|
|
1088
1258
|
try {
|
|
1089
1259
|
const tokens = JSON.parse(tokensHeader);
|
|
1090
1260
|
let best = null;
|