integrate-sdk 0.8.42 → 0.8.44-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.
- package/dist/adapters/auto-routes.d.ts.map +1 -1
- package/dist/adapters/auto-routes.js +309 -143
- package/dist/adapters/base-handler.d.ts.map +1 -1
- package/dist/adapters/index.js +305 -141
- package/dist/adapters/nextjs-oauth-redirect.d.ts.map +1 -1
- package/dist/adapters/nextjs-oauth-redirect.js +47 -2
- package/dist/adapters/nextjs.d.ts.map +1 -1
- package/dist/adapters/nextjs.js +304 -141
- package/dist/adapters/node.js +304 -141
- package/dist/adapters/svelte-kit.js +304 -141
- package/dist/adapters/tanstack-start.js +304 -141
- package/dist/index.d.ts +19 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +319 -183
- package/dist/oauth.js +309 -143
- package/dist/react.js +59 -14
- package/dist/server.js +308 -141
- package/dist/src/adapters/auto-routes.d.ts.map +1 -1
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- package/dist/src/adapters/nextjs-oauth-redirect.d.ts.map +1 -1
- package/dist/src/adapters/nextjs.d.ts.map +1 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +15 -0
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/integrations/airtable.d.ts.map +1 -1
- package/dist/src/integrations/calcom.d.ts.map +1 -1
- package/dist/src/integrations/cursor.d.ts.map +1 -1
- package/dist/src/integrations/figma.d.ts.map +1 -1
- package/dist/src/integrations/gcal.d.ts.map +1 -1
- package/dist/src/integrations/github.d.ts.map +1 -1
- package/dist/src/integrations/gmail.d.ts.map +1 -1
- package/dist/src/integrations/gworkspace.d.ts.map +1 -1
- package/dist/src/integrations/hubspot.d.ts.map +1 -1
- package/dist/src/integrations/intercom.d.ts.map +1 -1
- package/dist/src/integrations/linear.d.ts.map +1 -1
- package/dist/src/integrations/notion.d.ts.map +1 -1
- package/dist/src/integrations/onedrive.d.ts.map +1 -1
- package/dist/src/integrations/outlook.d.ts.map +1 -1
- package/dist/src/integrations/polar.d.ts.map +1 -1
- package/dist/src/integrations/ramp.d.ts.map +1 -1
- package/dist/src/integrations/server-client.d.ts +15 -1
- package/dist/src/integrations/server-client.d.ts.map +1 -1
- package/dist/src/integrations/slack.d.ts.map +1 -1
- package/dist/src/integrations/stripe.d.ts.map +1 -1
- package/dist/src/integrations/todoist.d.ts.map +1 -1
- package/dist/src/integrations/vercel.d.ts.map +1 -1
- package/dist/src/integrations/whatsapp.d.ts.map +1 -1
- package/dist/src/integrations/youtube.d.ts.map +1 -1
- package/dist/src/integrations/zendesk.d.ts.map +1 -1
- package/dist/src/oauth/email-fetcher.d.ts.map +1 -1
- package/dist/src/oauth/manager.d.ts.map +1 -1
- package/dist/src/oauth/window-manager.d.ts.map +1 -1
- package/dist/src/react/hooks.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/transport/http-session.d.ts.map +1 -1
- package/dist/src/transport/http-stream.d.ts.map +1 -1
- package/dist/src/utils/logger.d.ts +37 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/index.ts +20 -72
- package/package.json +2 -2
- package/dist/adapters/base-handler.js +0 -561
- package/dist/ai/cloudflare.d.ts +0 -158
- package/dist/ai/cloudflare.d.ts.map +0 -1
- package/dist/ai/cloudflare.js +0 -4249
- package/dist/ai/langchain.d.ts +0 -139
- package/dist/ai/langchain.d.ts.map +0 -1
- package/dist/ai/langchain.js +0 -4237
- package/dist/ai/llamaindex.d.ts +0 -125
- package/dist/ai/llamaindex.d.ts.map +0 -1
- package/dist/ai/llamaindex.js +0 -4236
- package/dist/ai/mastra.d.ts +0 -138
- package/dist/ai/mastra.d.ts.map +0 -1
- package/dist/ai/mastra.js +0 -4240
- package/dist/src/ai/cloudflare.d.ts +0 -158
- package/dist/src/ai/cloudflare.d.ts.map +0 -1
- package/dist/src/ai/langchain.d.ts +0 -139
- package/dist/src/ai/langchain.d.ts.map +0 -1
- package/dist/src/ai/llamaindex.d.ts +0 -125
- package/dist/src/ai/llamaindex.d.ts.map +0 -1
- package/dist/src/ai/mastra.d.ts +0 -138
- package/dist/src/ai/mastra.d.ts.map +0 -1
- package/dist/src/integrations/vercel-ai.d.ts +0 -127
- package/dist/src/integrations/vercel-ai.d.ts.map +0 -1
- package/dist/src/plugins/generic.d.ts +0 -99
- package/dist/src/plugins/generic.d.ts.map +0 -1
- package/dist/src/plugins/github-client.d.ts +0 -320
- package/dist/src/plugins/github-client.d.ts.map +0 -1
- package/dist/src/plugins/github.d.ts +0 -89
- package/dist/src/plugins/github.d.ts.map +0 -1
- package/dist/src/plugins/gmail-client.d.ts +0 -106
- package/dist/src/plugins/gmail-client.d.ts.map +0 -1
- package/dist/src/plugins/gmail.d.ts +0 -87
- package/dist/src/plugins/gmail.d.ts.map +0 -1
- package/dist/src/plugins/server-client.d.ts +0 -18
- package/dist/src/plugins/server-client.d.ts.map +0 -1
- package/dist/src/plugins/types.d.ts +0 -70
- package/dist/src/plugins/types.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -19,6 +19,49 @@ function parseMessage(message) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// src/utils/logger.ts
|
|
23
|
+
function shouldLog(level) {
|
|
24
|
+
return logLevelHierarchy[level] <= logLevelHierarchy[globalLogLevel];
|
|
25
|
+
}
|
|
26
|
+
function setLogLevel(level) {
|
|
27
|
+
globalLogLevel = level;
|
|
28
|
+
}
|
|
29
|
+
function createLogger(namespace) {
|
|
30
|
+
const prefix = `[${namespace}]`;
|
|
31
|
+
return {
|
|
32
|
+
debug: (...args) => {
|
|
33
|
+
if (shouldLog("debug")) {
|
|
34
|
+
console.log(prefix, ...args);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
info: (...args) => {
|
|
38
|
+
if (shouldLog("info")) {
|
|
39
|
+
console.log(prefix, ...args);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
warn: (...args) => {
|
|
43
|
+
if (shouldLog("warn")) {
|
|
44
|
+
console.warn(prefix, ...args);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
error: (...args) => {
|
|
48
|
+
if (shouldLog("error")) {
|
|
49
|
+
console.error(prefix, ...args);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var globalLogLevel = "error", logLevelHierarchy;
|
|
55
|
+
var init_logger = __esm(() => {
|
|
56
|
+
logLevelHierarchy = {
|
|
57
|
+
none: 0,
|
|
58
|
+
error: 1,
|
|
59
|
+
warn: 2,
|
|
60
|
+
info: 3,
|
|
61
|
+
debug: 4
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
|
|
22
65
|
// src/transport/http-session.ts
|
|
23
66
|
class HttpSessionTransport {
|
|
24
67
|
url;
|
|
@@ -75,7 +118,7 @@ class HttpSessionTransport {
|
|
|
75
118
|
const sid = response.headers.get("mcp-session-id");
|
|
76
119
|
if (sid) {
|
|
77
120
|
this.sessionId = sid;
|
|
78
|
-
|
|
121
|
+
logger.debug("Session established:", sid);
|
|
79
122
|
this.startSSEListener();
|
|
80
123
|
}
|
|
81
124
|
}
|
|
@@ -125,7 +168,7 @@ class HttpSessionTransport {
|
|
|
125
168
|
if (error instanceof Error && error.name === "AbortError") {
|
|
126
169
|
return;
|
|
127
170
|
}
|
|
128
|
-
|
|
171
|
+
logger.error("SSE connection error:", error);
|
|
129
172
|
}
|
|
130
173
|
}
|
|
131
174
|
async processSSEStream(body) {
|
|
@@ -154,7 +197,7 @@ class HttpSessionTransport {
|
|
|
154
197
|
if (error instanceof Error && error.name === "AbortError") {
|
|
155
198
|
return;
|
|
156
199
|
}
|
|
157
|
-
|
|
200
|
+
logger.error("SSE stream error:", error);
|
|
158
201
|
} finally {
|
|
159
202
|
reader.releaseLock();
|
|
160
203
|
}
|
|
@@ -166,11 +209,11 @@ class HttpSessionTransport {
|
|
|
166
209
|
try {
|
|
167
210
|
handler(message);
|
|
168
211
|
} catch (error) {
|
|
169
|
-
|
|
212
|
+
logger.error("Error in message handler:", error);
|
|
170
213
|
}
|
|
171
214
|
});
|
|
172
215
|
} catch (error) {
|
|
173
|
-
|
|
216
|
+
logger.error("Failed to parse notification:", error);
|
|
174
217
|
}
|
|
175
218
|
}
|
|
176
219
|
onMessage(handler) {
|
|
@@ -207,7 +250,11 @@ class HttpSessionTransport {
|
|
|
207
250
|
return { ...this.headers };
|
|
208
251
|
}
|
|
209
252
|
}
|
|
210
|
-
var
|
|
253
|
+
var logger;
|
|
254
|
+
var init_http_session = __esm(() => {
|
|
255
|
+
init_logger();
|
|
256
|
+
logger = createLogger("HTTPSession");
|
|
257
|
+
});
|
|
211
258
|
|
|
212
259
|
// src/protocol/messages.ts
|
|
213
260
|
var MCPMethod;
|
|
@@ -577,7 +624,7 @@ class OAuthWindowManager {
|
|
|
577
624
|
const windowName = `oauth_popup_${Date.now()}`;
|
|
578
625
|
this.popupWindow = window.open(url, windowName, features);
|
|
579
626
|
if (!this.popupWindow) {
|
|
580
|
-
|
|
627
|
+
logger2.warn("Popup was blocked by the browser. Please allow popups for this site.");
|
|
581
628
|
return null;
|
|
582
629
|
}
|
|
583
630
|
this.popupWindow.focus();
|
|
@@ -587,7 +634,7 @@ class OAuthWindowManager {
|
|
|
587
634
|
if (!isBrowser()) {
|
|
588
635
|
throw new Error("OAuthWindowManager.openRedirect() can only be used in browser environments");
|
|
589
636
|
}
|
|
590
|
-
|
|
637
|
+
logger2.debug("[OAuthWindowManager] Redirecting to:", url.substring(0, 100) + (url.length > 100 ? "..." : ""));
|
|
591
638
|
window.location.href = url;
|
|
592
639
|
}
|
|
593
640
|
listenForCallback(mode, timeoutMs = 5 * 60 * 1000) {
|
|
@@ -666,7 +713,7 @@ class OAuthWindowManager {
|
|
|
666
713
|
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
667
714
|
}
|
|
668
715
|
} catch (e) {
|
|
669
|
-
|
|
716
|
+
logger2.error("Failed to parse OAuth callback params from hash:", e);
|
|
670
717
|
}
|
|
671
718
|
}
|
|
672
719
|
if (!code && !error) {
|
|
@@ -679,7 +726,7 @@ class OAuthWindowManager {
|
|
|
679
726
|
sessionStorage.removeItem("oauth_callback_params");
|
|
680
727
|
}
|
|
681
728
|
} catch (e) {
|
|
682
|
-
|
|
729
|
+
logger2.error("Failed to parse OAuth callback params from sessionStorage:", e);
|
|
683
730
|
}
|
|
684
731
|
}
|
|
685
732
|
if (error) {
|
|
@@ -714,11 +761,11 @@ class OAuthWindowManager {
|
|
|
714
761
|
}
|
|
715
762
|
function sendCallbackToOpener(params) {
|
|
716
763
|
if (!isBrowser()) {
|
|
717
|
-
|
|
764
|
+
logger2.error("sendCallbackToOpener() can only be used in browser environments");
|
|
718
765
|
return;
|
|
719
766
|
}
|
|
720
767
|
if (!window.opener) {
|
|
721
|
-
|
|
768
|
+
logger2.error("No opener window found. This function should only be called from a popup window.");
|
|
722
769
|
return;
|
|
723
770
|
}
|
|
724
771
|
window.opener.postMessage({
|
|
@@ -729,6 +776,11 @@ function sendCallbackToOpener(params) {
|
|
|
729
776
|
}, "*");
|
|
730
777
|
window.close();
|
|
731
778
|
}
|
|
779
|
+
var logger2;
|
|
780
|
+
var init_window_manager = __esm(() => {
|
|
781
|
+
init_logger();
|
|
782
|
+
logger2 = createLogger("OAuthWindowManager");
|
|
783
|
+
});
|
|
732
784
|
|
|
733
785
|
// src/oauth/indexeddb-storage.ts
|
|
734
786
|
class IndexedDBStorage {
|
|
@@ -919,7 +971,7 @@ async function fetchUserEmail(provider, tokenData) {
|
|
|
919
971
|
return tokenData.email;
|
|
920
972
|
}
|
|
921
973
|
} catch (error) {
|
|
922
|
-
|
|
974
|
+
logger3.error(`Failed to fetch email for ${provider}:`, error);
|
|
923
975
|
return;
|
|
924
976
|
}
|
|
925
977
|
}
|
|
@@ -961,7 +1013,7 @@ async function fetchGitHubEmail(accessToken) {
|
|
|
961
1013
|
}
|
|
962
1014
|
return;
|
|
963
1015
|
} catch (error) {
|
|
964
|
-
|
|
1016
|
+
logger3.error("Failed to fetch GitHub email:", error);
|
|
965
1017
|
return;
|
|
966
1018
|
}
|
|
967
1019
|
}
|
|
@@ -978,7 +1030,7 @@ async function fetchGoogleEmail(accessToken) {
|
|
|
978
1030
|
const user = await response.json();
|
|
979
1031
|
return user.email;
|
|
980
1032
|
} catch (error) {
|
|
981
|
-
|
|
1033
|
+
logger3.error("Failed to fetch Google email:", error);
|
|
982
1034
|
return;
|
|
983
1035
|
}
|
|
984
1036
|
}
|
|
@@ -996,10 +1048,15 @@ async function fetchNotionEmail(accessToken) {
|
|
|
996
1048
|
const user = await response.json();
|
|
997
1049
|
return user.person?.email;
|
|
998
1050
|
} catch (error) {
|
|
999
|
-
|
|
1051
|
+
logger3.error("Failed to fetch Notion email:", error);
|
|
1000
1052
|
return;
|
|
1001
1053
|
}
|
|
1002
1054
|
}
|
|
1055
|
+
var logger3;
|
|
1056
|
+
var init_email_fetcher = __esm(() => {
|
|
1057
|
+
init_logger();
|
|
1058
|
+
logger3 = createLogger("EmailFetcher");
|
|
1059
|
+
});
|
|
1003
1060
|
|
|
1004
1061
|
// src/oauth/manager.ts
|
|
1005
1062
|
class OAuthManager {
|
|
@@ -1112,7 +1169,7 @@ class OAuthManager {
|
|
|
1112
1169
|
try {
|
|
1113
1170
|
await this.flowConfig.onAuthCallback(pendingAuth.provider, code, state);
|
|
1114
1171
|
} catch (error) {
|
|
1115
|
-
|
|
1172
|
+
logger4.error("Custom OAuth callback handler failed:", error);
|
|
1116
1173
|
}
|
|
1117
1174
|
}
|
|
1118
1175
|
try {
|
|
@@ -1160,20 +1217,20 @@ class OAuthManager {
|
|
|
1160
1217
|
try {
|
|
1161
1218
|
await this.removeTokenCallback(provider, email, context);
|
|
1162
1219
|
} catch (error) {
|
|
1163
|
-
|
|
1220
|
+
logger4.error(`Failed to delete token for ${provider} (${email}) from database:`, error);
|
|
1164
1221
|
}
|
|
1165
1222
|
} else if (this.setTokenCallback) {
|
|
1166
1223
|
try {
|
|
1167
1224
|
await this.setTokenCallback(provider, null, email, context);
|
|
1168
1225
|
} catch (error) {
|
|
1169
|
-
|
|
1226
|
+
logger4.error(`Failed to delete token for ${provider} (${email}) from database:`, error);
|
|
1170
1227
|
}
|
|
1171
1228
|
}
|
|
1172
1229
|
if (!this.setTokenCallback && !this.removeTokenCallback) {
|
|
1173
1230
|
try {
|
|
1174
1231
|
await this.indexedDBStorage.deleteToken(provider, email);
|
|
1175
1232
|
} catch (error) {
|
|
1176
|
-
|
|
1233
|
+
logger4.error(`Failed to delete token from IndexedDB for ${provider} (${email}):`, error);
|
|
1177
1234
|
}
|
|
1178
1235
|
}
|
|
1179
1236
|
this.providerTokens.delete(provider);
|
|
@@ -1183,13 +1240,13 @@ class OAuthManager {
|
|
|
1183
1240
|
try {
|
|
1184
1241
|
await this.removeTokenCallback(provider, undefined, context);
|
|
1185
1242
|
} catch (error) {
|
|
1186
|
-
|
|
1243
|
+
logger4.error(`Failed to delete tokens for ${provider} from database:`, error);
|
|
1187
1244
|
}
|
|
1188
1245
|
} else if (this.setTokenCallback) {
|
|
1189
1246
|
try {
|
|
1190
1247
|
await this.setTokenCallback(provider, null, undefined, context);
|
|
1191
1248
|
} catch (error) {
|
|
1192
|
-
|
|
1249
|
+
logger4.error(`Failed to delete tokens for ${provider} from database:`, error);
|
|
1193
1250
|
}
|
|
1194
1251
|
}
|
|
1195
1252
|
if (!this.setTokenCallback && !this.removeTokenCallback) {
|
|
@@ -1222,7 +1279,7 @@ class OAuthManager {
|
|
|
1222
1279
|
try {
|
|
1223
1280
|
return await this.indexedDBStorage.listAccounts(provider);
|
|
1224
1281
|
} catch (error) {
|
|
1225
|
-
|
|
1282
|
+
logger4.error(`Failed to list accounts for ${provider}:`, error);
|
|
1226
1283
|
return [];
|
|
1227
1284
|
}
|
|
1228
1285
|
}
|
|
@@ -1237,7 +1294,7 @@ class OAuthManager {
|
|
|
1237
1294
|
}
|
|
1238
1295
|
return tokenData;
|
|
1239
1296
|
} catch (error) {
|
|
1240
|
-
|
|
1297
|
+
logger4.error(`Failed to get token for ${provider} via callback:`, error);
|
|
1241
1298
|
return;
|
|
1242
1299
|
}
|
|
1243
1300
|
}
|
|
@@ -1249,7 +1306,7 @@ class OAuthManager {
|
|
|
1249
1306
|
}
|
|
1250
1307
|
return tokenData;
|
|
1251
1308
|
} catch (error) {
|
|
1252
|
-
|
|
1309
|
+
logger4.error(`Failed to get token from IndexedDB for ${provider}:`, error);
|
|
1253
1310
|
}
|
|
1254
1311
|
}
|
|
1255
1312
|
return this.providerTokens.get(provider);
|
|
@@ -1277,7 +1334,7 @@ class OAuthManager {
|
|
|
1277
1334
|
this.providerTokens.delete(provider);
|
|
1278
1335
|
if (!this.setTokenCallback && !this.removeTokenCallback && !this.skipLocalStorage) {
|
|
1279
1336
|
this.indexedDBStorage.deleteTokensByProvider(provider).catch((error) => {
|
|
1280
|
-
|
|
1337
|
+
logger4.error(`Failed to clear tokens for ${provider} from IndexedDB:`, error);
|
|
1281
1338
|
});
|
|
1282
1339
|
}
|
|
1283
1340
|
}
|
|
@@ -1297,7 +1354,7 @@ class OAuthManager {
|
|
|
1297
1354
|
} catch (localStorageError) {}
|
|
1298
1355
|
}
|
|
1299
1356
|
this.indexedDBStorage.clearAll().catch((error) => {
|
|
1300
|
-
|
|
1357
|
+
logger4.error("Failed to clear all tokens from IndexedDB:", error);
|
|
1301
1358
|
});
|
|
1302
1359
|
}
|
|
1303
1360
|
}
|
|
@@ -1315,7 +1372,7 @@ class OAuthManager {
|
|
|
1315
1372
|
}
|
|
1316
1373
|
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
1317
1374
|
} catch (error) {
|
|
1318
|
-
|
|
1375
|
+
logger4.error("Failed to clear pending auths from localStorage:", error);
|
|
1319
1376
|
}
|
|
1320
1377
|
}
|
|
1321
1378
|
}
|
|
@@ -1324,7 +1381,7 @@ class OAuthManager {
|
|
|
1324
1381
|
try {
|
|
1325
1382
|
await this.setTokenCallback(provider, tokenData, email, context);
|
|
1326
1383
|
} catch (error) {
|
|
1327
|
-
|
|
1384
|
+
logger4.error(`Failed to ${tokenData === null ? "delete" : "save"} token for ${provider} via callback:`, error);
|
|
1328
1385
|
throw error;
|
|
1329
1386
|
}
|
|
1330
1387
|
return;
|
|
@@ -1365,10 +1422,10 @@ class OAuthManager {
|
|
|
1365
1422
|
const key = `integrate_token_${provider}`;
|
|
1366
1423
|
window.localStorage.setItem(key, JSON.stringify(tokenData));
|
|
1367
1424
|
} catch (localStorageError) {
|
|
1368
|
-
|
|
1425
|
+
logger4.error(`Failed to save token for ${provider} to localStorage:`, localStorageError);
|
|
1369
1426
|
}
|
|
1370
1427
|
} else {
|
|
1371
|
-
|
|
1428
|
+
logger4.error(`Failed to save token for ${provider} to IndexedDB:`, error);
|
|
1372
1429
|
}
|
|
1373
1430
|
}
|
|
1374
1431
|
} else {
|
|
@@ -1377,7 +1434,7 @@ class OAuthManager {
|
|
|
1377
1434
|
const key = `integrate_token_${provider}`;
|
|
1378
1435
|
window.localStorage.setItem(key, JSON.stringify(tokenData));
|
|
1379
1436
|
} catch (localStorageError) {
|
|
1380
|
-
|
|
1437
|
+
logger4.error(`Failed to save token for ${provider} to localStorage:`, localStorageError);
|
|
1381
1438
|
}
|
|
1382
1439
|
}
|
|
1383
1440
|
}
|
|
@@ -1387,7 +1444,7 @@ class OAuthManager {
|
|
|
1387
1444
|
try {
|
|
1388
1445
|
return await this.getTokenCallback(provider, email, context);
|
|
1389
1446
|
} catch (error) {
|
|
1390
|
-
|
|
1447
|
+
logger4.error(`Failed to load token for ${provider} via callback:`, error);
|
|
1391
1448
|
return;
|
|
1392
1449
|
}
|
|
1393
1450
|
}
|
|
@@ -1464,7 +1521,7 @@ class OAuthManager {
|
|
|
1464
1521
|
const key = `integrate_oauth_pending_${state}`;
|
|
1465
1522
|
window.localStorage.setItem(key, JSON.stringify(pendingAuth));
|
|
1466
1523
|
} catch (error) {
|
|
1467
|
-
|
|
1524
|
+
logger4.error("Failed to save pending auth to localStorage:", error);
|
|
1468
1525
|
}
|
|
1469
1526
|
}
|
|
1470
1527
|
}
|
|
@@ -1477,7 +1534,7 @@ class OAuthManager {
|
|
|
1477
1534
|
return JSON.parse(stored);
|
|
1478
1535
|
}
|
|
1479
1536
|
} catch (error) {
|
|
1480
|
-
|
|
1537
|
+
logger4.error("Failed to load pending auth from localStorage:", error);
|
|
1481
1538
|
}
|
|
1482
1539
|
}
|
|
1483
1540
|
return;
|
|
@@ -1488,7 +1545,7 @@ class OAuthManager {
|
|
|
1488
1545
|
const key = `integrate_oauth_pending_${state}`;
|
|
1489
1546
|
window.localStorage.removeItem(key);
|
|
1490
1547
|
} catch (error) {
|
|
1491
|
-
|
|
1548
|
+
logger4.error("Failed to remove pending auth from localStorage:", error);
|
|
1492
1549
|
}
|
|
1493
1550
|
}
|
|
1494
1551
|
}
|
|
@@ -1517,7 +1574,7 @@ class OAuthManager {
|
|
|
1517
1574
|
}
|
|
1518
1575
|
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
1519
1576
|
} catch (error) {
|
|
1520
|
-
|
|
1577
|
+
logger4.error("Failed to cleanup expired pending auths:", error);
|
|
1521
1578
|
}
|
|
1522
1579
|
}
|
|
1523
1580
|
}
|
|
@@ -1585,7 +1642,13 @@ class OAuthManager {
|
|
|
1585
1642
|
this.windowManager.close();
|
|
1586
1643
|
}
|
|
1587
1644
|
}
|
|
1588
|
-
var
|
|
1645
|
+
var logger4;
|
|
1646
|
+
var init_manager = __esm(() => {
|
|
1647
|
+
init_window_manager();
|
|
1648
|
+
init_email_fetcher();
|
|
1649
|
+
init_logger();
|
|
1650
|
+
logger4 = createLogger("OAuth");
|
|
1651
|
+
});
|
|
1589
1652
|
|
|
1590
1653
|
// src/client.ts
|
|
1591
1654
|
class SimpleEventEmitter {
|
|
@@ -1609,7 +1672,7 @@ class SimpleEventEmitter {
|
|
|
1609
1672
|
try {
|
|
1610
1673
|
handler(payload);
|
|
1611
1674
|
} catch (error) {
|
|
1612
|
-
|
|
1675
|
+
logger5.error(`Error in event handler for ${event}:`, error);
|
|
1613
1676
|
}
|
|
1614
1677
|
});
|
|
1615
1678
|
}
|
|
@@ -1701,7 +1764,7 @@ class MCPClientBase {
|
|
|
1701
1764
|
this.authState.set(provider, { authenticated: !!tokenData });
|
|
1702
1765
|
}
|
|
1703
1766
|
} catch (error) {
|
|
1704
|
-
|
|
1767
|
+
logger5.error(`Failed to check token for ${provider}:`, error);
|
|
1705
1768
|
const currentState = this.authState.get(provider);
|
|
1706
1769
|
if (currentState && !currentState.authenticated && !currentState.lastError) {
|
|
1707
1770
|
this.authState.set(provider, { authenticated: false });
|
|
@@ -1710,7 +1773,7 @@ class MCPClientBase {
|
|
|
1710
1773
|
}
|
|
1711
1774
|
}
|
|
1712
1775
|
}).catch((error) => {
|
|
1713
|
-
|
|
1776
|
+
logger5.error("Failed to load provider tokens:", error);
|
|
1714
1777
|
});
|
|
1715
1778
|
} else {
|
|
1716
1779
|
this.oauthManager.loadAllProviderTokensSync(providers);
|
|
@@ -1805,16 +1868,56 @@ class MCPClientBase {
|
|
|
1805
1868
|
return new Proxy({}, {
|
|
1806
1869
|
get: (_target, methodName) => {
|
|
1807
1870
|
if (methodName === "listConfiguredIntegrations") {
|
|
1808
|
-
return async () =>
|
|
1809
|
-
|
|
1871
|
+
return async () => {
|
|
1872
|
+
const localIntegrations = this.integrations.map((integration) => ({
|
|
1810
1873
|
id: integration.id,
|
|
1811
1874
|
name: integration.name || integration.id,
|
|
1812
1875
|
tools: integration.tools,
|
|
1813
1876
|
hasOAuth: !!integration.oauth,
|
|
1814
1877
|
scopes: integration.oauth?.scopes,
|
|
1815
1878
|
provider: integration.oauth?.provider
|
|
1816
|
-
}))
|
|
1817
|
-
|
|
1879
|
+
}));
|
|
1880
|
+
let serverMetadataMap = new Map;
|
|
1881
|
+
try {
|
|
1882
|
+
const serverResponse = await this.callServerToolInternal("list_all_providers");
|
|
1883
|
+
if (serverResponse.content && serverResponse.content.length > 0) {
|
|
1884
|
+
const textContent = serverResponse.content[0]?.text;
|
|
1885
|
+
if (textContent) {
|
|
1886
|
+
try {
|
|
1887
|
+
const parsed = JSON.parse(textContent);
|
|
1888
|
+
const integrations = parsed.integrations || [];
|
|
1889
|
+
for (const metadata of integrations) {
|
|
1890
|
+
const key = metadata.name.toLowerCase();
|
|
1891
|
+
serverMetadataMap.set(key, metadata);
|
|
1892
|
+
}
|
|
1893
|
+
} catch (parseError) {
|
|
1894
|
+
logger5.debug("Failed to parse server metadata response:", parseError);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
} catch (error) {
|
|
1899
|
+
logger5.debug("Failed to fetch server metadata, returning local-only data:", error);
|
|
1900
|
+
return { integrations: localIntegrations };
|
|
1901
|
+
}
|
|
1902
|
+
const mergedIntegrations = localIntegrations.map((local) => {
|
|
1903
|
+
const metadataKey = local.name.toLowerCase();
|
|
1904
|
+
const serverMetadata = serverMetadataMap.get(metadataKey);
|
|
1905
|
+
const idKey = local.id.toLowerCase();
|
|
1906
|
+
const serverMetadataById = serverMetadataMap.get(idKey) || serverMetadata;
|
|
1907
|
+
if (serverMetadataById) {
|
|
1908
|
+
return {
|
|
1909
|
+
...local,
|
|
1910
|
+
name: serverMetadataById.name || local.name,
|
|
1911
|
+
logoUrl: serverMetadataById.logo_url,
|
|
1912
|
+
description: serverMetadataById.description,
|
|
1913
|
+
owner: serverMetadataById.owner,
|
|
1914
|
+
exampleUsage: serverMetadataById.example_usage
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
return local;
|
|
1918
|
+
});
|
|
1919
|
+
return { integrations: mergedIntegrations };
|
|
1920
|
+
};
|
|
1818
1921
|
}
|
|
1819
1922
|
return async (args, options) => {
|
|
1820
1923
|
const toolName = methodToToolName(methodName, "");
|
|
@@ -1873,7 +1976,7 @@ class MCPClientBase {
|
|
|
1873
1976
|
this.availableTools.set(tool.name, tool);
|
|
1874
1977
|
}
|
|
1875
1978
|
const enabledTools = response.tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
1876
|
-
|
|
1979
|
+
logger5.debug(`Discovered ${response.tools.length} tools, ${enabledTools.length} enabled by integrations`);
|
|
1877
1980
|
}
|
|
1878
1981
|
async _callToolByName(name, args, options) {
|
|
1879
1982
|
return await this.callToolWithRetry(name, args, 0, options);
|
|
@@ -2279,7 +2382,7 @@ function registerCleanupHandlers() {
|
|
|
2279
2382
|
await client.disconnect();
|
|
2280
2383
|
}
|
|
2281
2384
|
} catch (error) {
|
|
2282
|
-
|
|
2385
|
+
logger5.error("Error disconnecting client:", error);
|
|
2283
2386
|
}
|
|
2284
2387
|
}));
|
|
2285
2388
|
};
|
|
@@ -2311,6 +2414,7 @@ function generateCacheKey(config) {
|
|
|
2311
2414
|
return parts.join("|");
|
|
2312
2415
|
}
|
|
2313
2416
|
function createMCPClient(config) {
|
|
2417
|
+
setLogLevel(config.debug ? "debug" : "error");
|
|
2314
2418
|
const useSingleton = config.singleton ?? true;
|
|
2315
2419
|
const connectionMode = config.connectionMode ?? "lazy";
|
|
2316
2420
|
const autoCleanup = config.autoCleanup ?? true;
|
|
@@ -2332,7 +2436,7 @@ function createMCPClient(config) {
|
|
|
2332
2436
|
}
|
|
2333
2437
|
if (connectionMode === "eager") {
|
|
2334
2438
|
client.connect().catch((error) => {
|
|
2335
|
-
|
|
2439
|
+
logger5.error("Failed to connect client:", error);
|
|
2336
2440
|
});
|
|
2337
2441
|
}
|
|
2338
2442
|
if (config.autoHandleOAuthCallback !== false) {
|
|
@@ -2347,7 +2451,7 @@ function createMCPClient(config) {
|
|
|
2347
2451
|
}
|
|
2348
2452
|
if (connectionMode === "eager") {
|
|
2349
2453
|
client.connect().catch((error) => {
|
|
2350
|
-
|
|
2454
|
+
logger5.error("Failed to connect client:", error);
|
|
2351
2455
|
});
|
|
2352
2456
|
}
|
|
2353
2457
|
if (config.autoHandleOAuthCallback !== false) {
|
|
@@ -2375,7 +2479,7 @@ function processOAuthCallbackFromHash(client, errorBehavior) {
|
|
|
2375
2479
|
}
|
|
2376
2480
|
}).catch((error) => {
|
|
2377
2481
|
if (mode === "console") {
|
|
2378
|
-
|
|
2482
|
+
logger5.error("Failed to process OAuth callback:", error);
|
|
2379
2483
|
} else if (mode === "redirect" && errorBehavior?.redirectUrl) {
|
|
2380
2484
|
window.location.href = errorBehavior.redirectUrl;
|
|
2381
2485
|
return;
|
|
@@ -2389,7 +2493,7 @@ function processOAuthCallbackFromHash(client, errorBehavior) {
|
|
|
2389
2493
|
}
|
|
2390
2494
|
} catch (error) {
|
|
2391
2495
|
if (mode === "console") {
|
|
2392
|
-
|
|
2496
|
+
logger5.error("Failed to process OAuth callback from hash:", error);
|
|
2393
2497
|
} else if (mode === "redirect" && errorBehavior?.redirectUrl) {
|
|
2394
2498
|
window.location.href = errorBehavior.redirectUrl;
|
|
2395
2499
|
return null;
|
|
@@ -2411,16 +2515,18 @@ async function clearClientCache() {
|
|
|
2411
2515
|
await client.disconnect();
|
|
2412
2516
|
}
|
|
2413
2517
|
} catch (error) {
|
|
2414
|
-
|
|
2518
|
+
logger5.error("Error disconnecting client during cache clear:", error);
|
|
2415
2519
|
}
|
|
2416
2520
|
}));
|
|
2417
2521
|
}
|
|
2418
|
-
var MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp", clientCache, cleanupClients, cleanupHandlersRegistered = false;
|
|
2522
|
+
var MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp", logger5, clientCache, cleanupClients, cleanupHandlersRegistered = false;
|
|
2419
2523
|
var init_client = __esm(() => {
|
|
2420
2524
|
init_http_session();
|
|
2421
2525
|
init_messages();
|
|
2422
2526
|
init_errors();
|
|
2527
|
+
init_logger();
|
|
2423
2528
|
init_manager();
|
|
2529
|
+
logger5 = createLogger("MCPClient");
|
|
2424
2530
|
clientCache = new Map;
|
|
2425
2531
|
cleanupClients = new Set;
|
|
2426
2532
|
});
|
|
@@ -2441,7 +2547,7 @@ function createNextOAuthHandler(config) {
|
|
|
2441
2547
|
}
|
|
2442
2548
|
return response;
|
|
2443
2549
|
} catch (error) {
|
|
2444
|
-
|
|
2550
|
+
logger6.error("[OAuth Authorize] Error:", error);
|
|
2445
2551
|
return Response.json({ error: error.message || "Failed to get authorization URL" }, { status: 500 });
|
|
2446
2552
|
}
|
|
2447
2553
|
},
|
|
@@ -2457,7 +2563,7 @@ function createNextOAuthHandler(config) {
|
|
|
2457
2563
|
}
|
|
2458
2564
|
return response;
|
|
2459
2565
|
} catch (error) {
|
|
2460
|
-
|
|
2566
|
+
logger6.error("[OAuth Callback] Error:", error);
|
|
2461
2567
|
return Response.json({ error: error.message || "Failed to exchange authorization code" }, { status: 500 });
|
|
2462
2568
|
}
|
|
2463
2569
|
},
|
|
@@ -2479,7 +2585,7 @@ function createNextOAuthHandler(config) {
|
|
|
2479
2585
|
}
|
|
2480
2586
|
return response;
|
|
2481
2587
|
} catch (error) {
|
|
2482
|
-
|
|
2588
|
+
logger6.error("[OAuth Status] Error:", error);
|
|
2483
2589
|
return Response.json({ error: error.message || "Failed to check authorization status" }, { status: 500 });
|
|
2484
2590
|
}
|
|
2485
2591
|
},
|
|
@@ -2502,7 +2608,7 @@ function createNextOAuthHandler(config) {
|
|
|
2502
2608
|
}
|
|
2503
2609
|
return response;
|
|
2504
2610
|
} catch (error) {
|
|
2505
|
-
|
|
2611
|
+
logger6.error("[OAuth Disconnect] Error:", error);
|
|
2506
2612
|
return Response.json({ error: error.message || "Failed to disconnect provider" }, { status: 500 });
|
|
2507
2613
|
}
|
|
2508
2614
|
},
|
|
@@ -2543,7 +2649,7 @@ function createNextOAuthHandler(config) {
|
|
|
2543
2649
|
const result = await handler.handleToolCall(body, authHeader, integrationsHeader);
|
|
2544
2650
|
return Response.json(result);
|
|
2545
2651
|
} catch (error) {
|
|
2546
|
-
|
|
2652
|
+
logger6.error("[MCP Tool Call] Error:", error);
|
|
2547
2653
|
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
2548
2654
|
}
|
|
2549
2655
|
},
|
|
@@ -2588,11 +2694,11 @@ function createNextOAuthHandler(config) {
|
|
|
2588
2694
|
const errorDescription = searchParams.get("error_description");
|
|
2589
2695
|
if (error) {
|
|
2590
2696
|
const errorMsg = errorDescription || error;
|
|
2591
|
-
|
|
2697
|
+
logger6.error("[OAuth Redirect] Error:", errorMsg);
|
|
2592
2698
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, req.url));
|
|
2593
2699
|
}
|
|
2594
2700
|
if (!code || !state) {
|
|
2595
|
-
|
|
2701
|
+
logger6.error("[OAuth Redirect] Missing code or state parameter");
|
|
2596
2702
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, req.url));
|
|
2597
2703
|
}
|
|
2598
2704
|
let returnUrl = defaultRedirectUrl;
|
|
@@ -2627,7 +2733,12 @@ function createNextOAuthHandler(config) {
|
|
|
2627
2733
|
};
|
|
2628
2734
|
return handlers;
|
|
2629
2735
|
}
|
|
2630
|
-
var
|
|
2736
|
+
var logger6;
|
|
2737
|
+
var init_nextjs = __esm(() => {
|
|
2738
|
+
init_base_handler();
|
|
2739
|
+
init_logger();
|
|
2740
|
+
logger6 = createLogger("NextJSOAuth");
|
|
2741
|
+
});
|
|
2631
2742
|
|
|
2632
2743
|
// src/utils/env.ts
|
|
2633
2744
|
function getEnv(key) {
|
|
@@ -2711,15 +2822,17 @@ function githubIntegration(config = {}) {
|
|
|
2711
2822
|
tools: [...GITHUB_TOOLS],
|
|
2712
2823
|
oauth,
|
|
2713
2824
|
async onInit(_client) {
|
|
2714
|
-
|
|
2825
|
+
logger7.debug("GitHub integration initialized");
|
|
2715
2826
|
},
|
|
2716
2827
|
async onAfterConnect(_client) {
|
|
2717
|
-
|
|
2828
|
+
logger7.debug("GitHub integration connected");
|
|
2718
2829
|
}
|
|
2719
2830
|
};
|
|
2720
2831
|
}
|
|
2721
|
-
var GITHUB_TOOLS;
|
|
2832
|
+
var logger7, GITHUB_TOOLS;
|
|
2722
2833
|
var init_github = __esm(() => {
|
|
2834
|
+
init_logger();
|
|
2835
|
+
logger7 = createLogger("GitHub");
|
|
2723
2836
|
GITHUB_TOOLS = [
|
|
2724
2837
|
"github_create_issue",
|
|
2725
2838
|
"github_list_issues",
|
|
@@ -2762,15 +2875,17 @@ function gmailIntegration(config = {}) {
|
|
|
2762
2875
|
tools: [...GMAIL_TOOLS],
|
|
2763
2876
|
oauth,
|
|
2764
2877
|
async onInit(_client) {
|
|
2765
|
-
|
|
2878
|
+
logger8.debug("Gmail integration initialized");
|
|
2766
2879
|
},
|
|
2767
2880
|
async onAfterConnect(_client) {
|
|
2768
|
-
|
|
2881
|
+
logger8.debug("Gmail integration connected");
|
|
2769
2882
|
}
|
|
2770
2883
|
};
|
|
2771
2884
|
}
|
|
2772
|
-
var GMAIL_TOOLS;
|
|
2885
|
+
var logger8, GMAIL_TOOLS;
|
|
2773
2886
|
var init_gmail = __esm(() => {
|
|
2887
|
+
init_logger();
|
|
2888
|
+
logger8 = createLogger("Gmail");
|
|
2774
2889
|
GMAIL_TOOLS = [
|
|
2775
2890
|
"gmail_send_message",
|
|
2776
2891
|
"gmail_list_messages",
|
|
@@ -2799,15 +2914,17 @@ function notionIntegration(config = {}) {
|
|
|
2799
2914
|
tools: [...NOTION_TOOLS],
|
|
2800
2915
|
oauth,
|
|
2801
2916
|
async onInit(_client) {
|
|
2802
|
-
|
|
2917
|
+
logger9.debug("Notion integration initialized");
|
|
2803
2918
|
},
|
|
2804
2919
|
async onAfterConnect(_client) {
|
|
2805
|
-
|
|
2920
|
+
logger9.debug("Notion integration connected");
|
|
2806
2921
|
}
|
|
2807
2922
|
};
|
|
2808
2923
|
}
|
|
2809
|
-
var NOTION_TOOLS;
|
|
2924
|
+
var logger9, NOTION_TOOLS;
|
|
2810
2925
|
var init_notion = __esm(() => {
|
|
2926
|
+
init_logger();
|
|
2927
|
+
logger9 = createLogger("Notion");
|
|
2811
2928
|
NOTION_TOOLS = [
|
|
2812
2929
|
"notion_search",
|
|
2813
2930
|
"notion_get_page"
|
|
@@ -2831,15 +2948,17 @@ function slackIntegration(config = {}) {
|
|
|
2831
2948
|
tools: [...SLACK_TOOLS],
|
|
2832
2949
|
oauth,
|
|
2833
2950
|
async onInit(_client) {
|
|
2834
|
-
|
|
2951
|
+
logger10.debug("Slack integration initialized");
|
|
2835
2952
|
},
|
|
2836
2953
|
async onAfterConnect(_client) {
|
|
2837
|
-
|
|
2954
|
+
logger10.debug("Slack integration connected");
|
|
2838
2955
|
}
|
|
2839
2956
|
};
|
|
2840
2957
|
}
|
|
2841
|
-
var SLACK_TOOLS;
|
|
2958
|
+
var logger10, SLACK_TOOLS;
|
|
2842
2959
|
var init_slack = __esm(() => {
|
|
2960
|
+
init_logger();
|
|
2961
|
+
logger10 = createLogger("Slack");
|
|
2843
2962
|
SLACK_TOOLS = [
|
|
2844
2963
|
"slack_send_message",
|
|
2845
2964
|
"slack_list_channels",
|
|
@@ -2870,15 +2989,17 @@ function linearIntegration(config = {}) {
|
|
|
2870
2989
|
tools: [...LINEAR_TOOLS],
|
|
2871
2990
|
oauth,
|
|
2872
2991
|
async onInit(_client) {
|
|
2873
|
-
|
|
2992
|
+
logger11.debug("Linear integration initialized");
|
|
2874
2993
|
},
|
|
2875
2994
|
async onAfterConnect(_client) {
|
|
2876
|
-
|
|
2995
|
+
logger11.debug("Linear integration connected");
|
|
2877
2996
|
}
|
|
2878
2997
|
};
|
|
2879
2998
|
}
|
|
2880
|
-
var LINEAR_TOOLS;
|
|
2999
|
+
var logger11, LINEAR_TOOLS;
|
|
2881
3000
|
var init_linear = __esm(() => {
|
|
3001
|
+
init_logger();
|
|
3002
|
+
logger11 = createLogger("Linear");
|
|
2882
3003
|
LINEAR_TOOLS = [
|
|
2883
3004
|
"linear_create_issue",
|
|
2884
3005
|
"linear_list_issues",
|
|
@@ -2909,15 +3030,17 @@ function vercelIntegration(config = {}) {
|
|
|
2909
3030
|
tools: [...VERCEL_TOOLS],
|
|
2910
3031
|
oauth,
|
|
2911
3032
|
async onInit(_client) {
|
|
2912
|
-
|
|
3033
|
+
logger12.debug("Vercel integration initialized");
|
|
2913
3034
|
},
|
|
2914
3035
|
async onAfterConnect(_client) {
|
|
2915
|
-
|
|
3036
|
+
logger12.debug("Vercel integration connected");
|
|
2916
3037
|
}
|
|
2917
3038
|
};
|
|
2918
3039
|
}
|
|
2919
|
-
var VERCEL_TOOLS;
|
|
3040
|
+
var logger12, VERCEL_TOOLS;
|
|
2920
3041
|
var init_vercel = __esm(() => {
|
|
3042
|
+
init_logger();
|
|
3043
|
+
logger12 = createLogger("Vercel");
|
|
2921
3044
|
VERCEL_TOOLS = [
|
|
2922
3045
|
"vercel_list_projects",
|
|
2923
3046
|
"vercel_get_project",
|
|
@@ -2949,15 +3072,17 @@ function zendeskIntegration(config = {}) {
|
|
|
2949
3072
|
tools: [...ZENDESK_TOOLS],
|
|
2950
3073
|
oauth,
|
|
2951
3074
|
async onInit(_client) {
|
|
2952
|
-
|
|
3075
|
+
logger13.debug("Zendesk integration initialized");
|
|
2953
3076
|
},
|
|
2954
3077
|
async onAfterConnect(_client) {
|
|
2955
|
-
|
|
3078
|
+
logger13.debug("Zendesk integration connected");
|
|
2956
3079
|
}
|
|
2957
3080
|
};
|
|
2958
3081
|
}
|
|
2959
|
-
var ZENDESK_TOOLS;
|
|
3082
|
+
var logger13, ZENDESK_TOOLS;
|
|
2960
3083
|
var init_zendesk = __esm(() => {
|
|
3084
|
+
init_logger();
|
|
3085
|
+
logger13 = createLogger("Zendesk");
|
|
2961
3086
|
ZENDESK_TOOLS = [
|
|
2962
3087
|
"zendesk_list_tickets",
|
|
2963
3088
|
"zendesk_get_ticket",
|
|
@@ -2988,15 +3113,17 @@ function stripeIntegration(config = {}) {
|
|
|
2988
3113
|
tools: [...STRIPE_TOOLS],
|
|
2989
3114
|
oauth,
|
|
2990
3115
|
async onInit(_client) {
|
|
2991
|
-
|
|
3116
|
+
logger14.debug("Stripe integration initialized");
|
|
2992
3117
|
},
|
|
2993
3118
|
async onAfterConnect(_client) {
|
|
2994
|
-
|
|
3119
|
+
logger14.debug("Stripe integration connected");
|
|
2995
3120
|
}
|
|
2996
3121
|
};
|
|
2997
3122
|
}
|
|
2998
|
-
var STRIPE_TOOLS;
|
|
3123
|
+
var logger14, STRIPE_TOOLS;
|
|
2999
3124
|
var init_stripe = __esm(() => {
|
|
3125
|
+
init_logger();
|
|
3126
|
+
logger14 = createLogger("Stripe");
|
|
3000
3127
|
STRIPE_TOOLS = [
|
|
3001
3128
|
"stripe_list_customers",
|
|
3002
3129
|
"stripe_get_customer",
|
|
@@ -3027,15 +3154,17 @@ function gcalIntegration(config = {}) {
|
|
|
3027
3154
|
tools: [...GCAL_TOOLS],
|
|
3028
3155
|
oauth,
|
|
3029
3156
|
async onInit(_client) {
|
|
3030
|
-
|
|
3157
|
+
logger15.debug("Google Calendar integration initialized");
|
|
3031
3158
|
},
|
|
3032
3159
|
async onAfterConnect(_client) {
|
|
3033
|
-
|
|
3160
|
+
logger15.debug("Google Calendar integration connected");
|
|
3034
3161
|
}
|
|
3035
3162
|
};
|
|
3036
3163
|
}
|
|
3037
|
-
var GCAL_TOOLS;
|
|
3164
|
+
var logger15, GCAL_TOOLS;
|
|
3038
3165
|
var init_gcal = __esm(() => {
|
|
3166
|
+
init_logger();
|
|
3167
|
+
logger15 = createLogger("Google Calendar");
|
|
3039
3168
|
GCAL_TOOLS = [
|
|
3040
3169
|
"gcal_list_calendars",
|
|
3041
3170
|
"gcal_get_calendar",
|
|
@@ -3066,15 +3195,17 @@ function outlookIntegration(config = {}) {
|
|
|
3066
3195
|
tools: [...OUTLOOK_TOOLS],
|
|
3067
3196
|
oauth,
|
|
3068
3197
|
async onInit(_client) {
|
|
3069
|
-
|
|
3198
|
+
logger16.debug("Outlook integration initialized");
|
|
3070
3199
|
},
|
|
3071
3200
|
async onAfterConnect(_client) {
|
|
3072
|
-
|
|
3201
|
+
logger16.debug("Outlook integration connected");
|
|
3073
3202
|
}
|
|
3074
3203
|
};
|
|
3075
3204
|
}
|
|
3076
|
-
var OUTLOOK_TOOLS;
|
|
3205
|
+
var logger16, OUTLOOK_TOOLS;
|
|
3077
3206
|
var init_outlook = __esm(() => {
|
|
3207
|
+
init_logger();
|
|
3208
|
+
logger16 = createLogger("Outlook");
|
|
3078
3209
|
OUTLOOK_TOOLS = [
|
|
3079
3210
|
"outlook_list_messages",
|
|
3080
3211
|
"outlook_get_message",
|
|
@@ -3105,15 +3236,17 @@ function airtableIntegration(config = {}) {
|
|
|
3105
3236
|
tools: [...AIRTABLE_TOOLS],
|
|
3106
3237
|
oauth,
|
|
3107
3238
|
async onInit(_client) {
|
|
3108
|
-
|
|
3239
|
+
logger17.debug("Airtable integration initialized");
|
|
3109
3240
|
},
|
|
3110
3241
|
async onAfterConnect(_client) {
|
|
3111
|
-
|
|
3242
|
+
logger17.debug("Airtable integration connected");
|
|
3112
3243
|
}
|
|
3113
3244
|
};
|
|
3114
3245
|
}
|
|
3115
|
-
var AIRTABLE_TOOLS;
|
|
3246
|
+
var logger17, AIRTABLE_TOOLS;
|
|
3116
3247
|
var init_airtable = __esm(() => {
|
|
3248
|
+
init_logger();
|
|
3249
|
+
logger17 = createLogger("Airtable");
|
|
3117
3250
|
AIRTABLE_TOOLS = [
|
|
3118
3251
|
"airtable_list_bases",
|
|
3119
3252
|
"airtable_get_base",
|
|
@@ -3144,15 +3277,17 @@ function todoistIntegration(config = {}) {
|
|
|
3144
3277
|
tools: [...TODOIST_TOOLS],
|
|
3145
3278
|
oauth,
|
|
3146
3279
|
async onInit(_client) {
|
|
3147
|
-
|
|
3280
|
+
logger18.debug("Todoist integration initialized");
|
|
3148
3281
|
},
|
|
3149
3282
|
async onAfterConnect(_client) {
|
|
3150
|
-
|
|
3283
|
+
logger18.debug("Todoist integration connected");
|
|
3151
3284
|
}
|
|
3152
3285
|
};
|
|
3153
3286
|
}
|
|
3154
|
-
var TODOIST_TOOLS;
|
|
3287
|
+
var logger18, TODOIST_TOOLS;
|
|
3155
3288
|
var init_todoist = __esm(() => {
|
|
3289
|
+
init_logger();
|
|
3290
|
+
logger18 = createLogger("Todoist");
|
|
3156
3291
|
TODOIST_TOOLS = [
|
|
3157
3292
|
"todoist_list_projects",
|
|
3158
3293
|
"todoist_get_project",
|
|
@@ -3184,15 +3319,17 @@ function whatsappIntegration(config = {}) {
|
|
|
3184
3319
|
tools: [...WHATSAPP_TOOLS],
|
|
3185
3320
|
oauth,
|
|
3186
3321
|
async onInit(_client) {
|
|
3187
|
-
|
|
3322
|
+
logger19.debug("WhatsApp Business integration initialized");
|
|
3188
3323
|
},
|
|
3189
3324
|
async onAfterConnect(_client) {
|
|
3190
|
-
|
|
3325
|
+
logger19.debug("WhatsApp Business integration connected");
|
|
3191
3326
|
}
|
|
3192
3327
|
};
|
|
3193
3328
|
}
|
|
3194
|
-
var WHATSAPP_TOOLS;
|
|
3329
|
+
var logger19, WHATSAPP_TOOLS;
|
|
3195
3330
|
var init_whatsapp = __esm(() => {
|
|
3331
|
+
init_logger();
|
|
3332
|
+
logger19 = createLogger("WhatsApp");
|
|
3196
3333
|
WHATSAPP_TOOLS = [
|
|
3197
3334
|
"whatsapp_send_message",
|
|
3198
3335
|
"whatsapp_send_template",
|
|
@@ -3223,15 +3360,17 @@ function calcomIntegration(config = {}) {
|
|
|
3223
3360
|
tools: [...CALCOM_TOOLS],
|
|
3224
3361
|
oauth,
|
|
3225
3362
|
async onInit(_client) {
|
|
3226
|
-
|
|
3363
|
+
logger20.debug("Cal.com integration initialized");
|
|
3227
3364
|
},
|
|
3228
3365
|
async onAfterConnect(_client) {
|
|
3229
|
-
|
|
3366
|
+
logger20.debug("Cal.com integration connected");
|
|
3230
3367
|
}
|
|
3231
3368
|
};
|
|
3232
3369
|
}
|
|
3233
|
-
var CALCOM_TOOLS;
|
|
3370
|
+
var logger20, CALCOM_TOOLS;
|
|
3234
3371
|
var init_calcom = __esm(() => {
|
|
3372
|
+
init_logger();
|
|
3373
|
+
logger20 = createLogger("Cal.com");
|
|
3235
3374
|
CALCOM_TOOLS = [
|
|
3236
3375
|
"calcom_list_bookings",
|
|
3237
3376
|
"calcom_get_booking",
|
|
@@ -3263,15 +3402,17 @@ function rampIntegration(config = {}) {
|
|
|
3263
3402
|
tools: [...RAMP_TOOLS],
|
|
3264
3403
|
oauth,
|
|
3265
3404
|
async onInit(_client) {
|
|
3266
|
-
|
|
3405
|
+
logger21.debug("Ramp integration initialized");
|
|
3267
3406
|
},
|
|
3268
3407
|
async onAfterConnect(_client) {
|
|
3269
|
-
|
|
3408
|
+
logger21.debug("Ramp integration connected");
|
|
3270
3409
|
}
|
|
3271
3410
|
};
|
|
3272
3411
|
}
|
|
3273
|
-
var RAMP_TOOLS;
|
|
3412
|
+
var logger21, RAMP_TOOLS;
|
|
3274
3413
|
var init_ramp = __esm(() => {
|
|
3414
|
+
init_logger();
|
|
3415
|
+
logger21 = createLogger("Ramp");
|
|
3275
3416
|
RAMP_TOOLS = [
|
|
3276
3417
|
"ramp_list_transactions",
|
|
3277
3418
|
"ramp_get_transaction",
|
|
@@ -3302,15 +3443,17 @@ function onedriveIntegration(config = {}) {
|
|
|
3302
3443
|
tools: [...ONEDRIVE_TOOLS],
|
|
3303
3444
|
oauth,
|
|
3304
3445
|
async onInit(_client) {
|
|
3305
|
-
|
|
3446
|
+
logger22.debug("OneDrive integration initialized");
|
|
3306
3447
|
},
|
|
3307
3448
|
async onAfterConnect(_client) {
|
|
3308
|
-
|
|
3449
|
+
logger22.debug("OneDrive integration connected");
|
|
3309
3450
|
}
|
|
3310
3451
|
};
|
|
3311
3452
|
}
|
|
3312
|
-
var ONEDRIVE_TOOLS;
|
|
3453
|
+
var logger22, ONEDRIVE_TOOLS;
|
|
3313
3454
|
var init_onedrive = __esm(() => {
|
|
3455
|
+
init_logger();
|
|
3456
|
+
logger22 = createLogger("OneDrive");
|
|
3314
3457
|
ONEDRIVE_TOOLS = [
|
|
3315
3458
|
"onedrive_list_files",
|
|
3316
3459
|
"onedrive_get_file",
|
|
@@ -3349,15 +3492,17 @@ function gworkspaceIntegration(config = {}) {
|
|
|
3349
3492
|
tools: [...GWORKSPACE_TOOLS],
|
|
3350
3493
|
oauth,
|
|
3351
3494
|
async onInit(_client) {
|
|
3352
|
-
|
|
3495
|
+
logger23.debug("Google Workspace integration initialized");
|
|
3353
3496
|
},
|
|
3354
3497
|
async onAfterConnect(_client) {
|
|
3355
|
-
|
|
3498
|
+
logger23.debug("Google Workspace integration connected");
|
|
3356
3499
|
}
|
|
3357
3500
|
};
|
|
3358
3501
|
}
|
|
3359
|
-
var GWORKSPACE_TOOLS;
|
|
3502
|
+
var logger23, GWORKSPACE_TOOLS;
|
|
3360
3503
|
var init_gworkspace = __esm(() => {
|
|
3504
|
+
init_logger();
|
|
3505
|
+
logger23 = createLogger("Google Workspace");
|
|
3361
3506
|
GWORKSPACE_TOOLS = [
|
|
3362
3507
|
"gworkspace_sheets_list",
|
|
3363
3508
|
"gworkspace_sheets_get",
|
|
@@ -3392,15 +3537,17 @@ function polarIntegration(config = {}) {
|
|
|
3392
3537
|
tools: [...POLAR_TOOLS],
|
|
3393
3538
|
oauth,
|
|
3394
3539
|
async onInit(_client) {
|
|
3395
|
-
|
|
3540
|
+
logger24.debug("Polar integration initialized");
|
|
3396
3541
|
},
|
|
3397
3542
|
async onAfterConnect(_client) {
|
|
3398
|
-
|
|
3543
|
+
logger24.debug("Polar integration connected");
|
|
3399
3544
|
}
|
|
3400
3545
|
};
|
|
3401
3546
|
}
|
|
3402
|
-
var POLAR_TOOLS;
|
|
3547
|
+
var logger24, POLAR_TOOLS;
|
|
3403
3548
|
var init_polar = __esm(() => {
|
|
3549
|
+
init_logger();
|
|
3550
|
+
logger24 = createLogger("Polar");
|
|
3404
3551
|
POLAR_TOOLS = [
|
|
3405
3552
|
"polar_list_products",
|
|
3406
3553
|
"polar_get_product",
|
|
@@ -3431,15 +3578,17 @@ function figmaIntegration(config = {}) {
|
|
|
3431
3578
|
tools: [...FIGMA_TOOLS],
|
|
3432
3579
|
oauth,
|
|
3433
3580
|
async onInit(_client) {
|
|
3434
|
-
|
|
3581
|
+
logger25.debug("Figma integration initialized");
|
|
3435
3582
|
},
|
|
3436
3583
|
async onAfterConnect(_client) {
|
|
3437
|
-
|
|
3584
|
+
logger25.debug("Figma integration connected");
|
|
3438
3585
|
}
|
|
3439
3586
|
};
|
|
3440
3587
|
}
|
|
3441
|
-
var FIGMA_TOOLS;
|
|
3588
|
+
var logger25, FIGMA_TOOLS;
|
|
3442
3589
|
var init_figma = __esm(() => {
|
|
3590
|
+
init_logger();
|
|
3591
|
+
logger25 = createLogger("Figma");
|
|
3443
3592
|
FIGMA_TOOLS = [
|
|
3444
3593
|
"figma_get_file",
|
|
3445
3594
|
"figma_get_file_nodes",
|
|
@@ -3470,15 +3619,17 @@ function intercomIntegration(config = {}) {
|
|
|
3470
3619
|
tools: [...INTERCOM_TOOLS],
|
|
3471
3620
|
oauth,
|
|
3472
3621
|
async onInit(_client) {
|
|
3473
|
-
|
|
3622
|
+
logger26.debug("Intercom integration initialized");
|
|
3474
3623
|
},
|
|
3475
3624
|
async onAfterConnect(_client) {
|
|
3476
|
-
|
|
3625
|
+
logger26.debug("Intercom integration connected");
|
|
3477
3626
|
}
|
|
3478
3627
|
};
|
|
3479
3628
|
}
|
|
3480
|
-
var INTERCOM_TOOLS;
|
|
3629
|
+
var logger26, INTERCOM_TOOLS;
|
|
3481
3630
|
var init_intercom = __esm(() => {
|
|
3631
|
+
init_logger();
|
|
3632
|
+
logger26 = createLogger("Intercom");
|
|
3482
3633
|
INTERCOM_TOOLS = [
|
|
3483
3634
|
"intercom_list_contacts",
|
|
3484
3635
|
"intercom_get_contact",
|
|
@@ -3517,15 +3668,17 @@ function hubspotIntegration(config = {}) {
|
|
|
3517
3668
|
tools: [...HUBSPOT_TOOLS],
|
|
3518
3669
|
oauth,
|
|
3519
3670
|
async onInit(_client) {
|
|
3520
|
-
|
|
3671
|
+
logger27.debug("HubSpot integration initialized");
|
|
3521
3672
|
},
|
|
3522
3673
|
async onAfterConnect(_client) {
|
|
3523
|
-
|
|
3674
|
+
logger27.debug("HubSpot integration connected");
|
|
3524
3675
|
}
|
|
3525
3676
|
};
|
|
3526
3677
|
}
|
|
3527
|
-
var HUBSPOT_TOOLS;
|
|
3678
|
+
var logger27, HUBSPOT_TOOLS;
|
|
3528
3679
|
var init_hubspot = __esm(() => {
|
|
3680
|
+
init_logger();
|
|
3681
|
+
logger27 = createLogger("HubSpot");
|
|
3529
3682
|
HUBSPOT_TOOLS = [
|
|
3530
3683
|
"hubspot_list_contacts",
|
|
3531
3684
|
"hubspot_get_contact",
|
|
@@ -3559,15 +3712,17 @@ function youtubeIntegration(config = {}) {
|
|
|
3559
3712
|
tools: [...YOUTUBE_TOOLS],
|
|
3560
3713
|
oauth,
|
|
3561
3714
|
async onInit(_client) {
|
|
3562
|
-
|
|
3715
|
+
logger28.debug("YouTube integration initialized");
|
|
3563
3716
|
},
|
|
3564
3717
|
async onAfterConnect(_client) {
|
|
3565
|
-
|
|
3718
|
+
logger28.debug("YouTube integration connected");
|
|
3566
3719
|
}
|
|
3567
3720
|
};
|
|
3568
3721
|
}
|
|
3569
|
-
var YOUTUBE_TOOLS;
|
|
3722
|
+
var logger28, YOUTUBE_TOOLS;
|
|
3570
3723
|
var init_youtube = __esm(() => {
|
|
3724
|
+
init_logger();
|
|
3725
|
+
logger28 = createLogger("YouTube");
|
|
3571
3726
|
YOUTUBE_TOOLS = [
|
|
3572
3727
|
"youtube_search",
|
|
3573
3728
|
"youtube_get_video",
|
|
@@ -3587,15 +3742,17 @@ function cursorIntegration(_config = {}) {
|
|
|
3587
3742
|
id: "cursor",
|
|
3588
3743
|
tools: [...CURSOR_TOOLS],
|
|
3589
3744
|
async onInit(_client) {
|
|
3590
|
-
|
|
3745
|
+
logger29.debug("Cursor integration initialized");
|
|
3591
3746
|
},
|
|
3592
3747
|
async onAfterConnect(_client) {
|
|
3593
|
-
|
|
3748
|
+
logger29.debug("Cursor integration connected");
|
|
3594
3749
|
}
|
|
3595
3750
|
};
|
|
3596
3751
|
}
|
|
3597
|
-
var CURSOR_TOOLS;
|
|
3752
|
+
var logger29, CURSOR_TOOLS;
|
|
3598
3753
|
var init_cursor = __esm(() => {
|
|
3754
|
+
init_logger();
|
|
3755
|
+
logger29 = createLogger("Cursor");
|
|
3599
3756
|
CURSOR_TOOLS = [
|
|
3600
3757
|
"cursor_list_agents",
|
|
3601
3758
|
"cursor_get_agent",
|
|
@@ -9431,6 +9588,7 @@ var init_zodToJsonSchema = __esm(() => {
|
|
|
9431
9588
|
|
|
9432
9589
|
// node_modules/zod-to-json-schema/dist/esm/index.js
|
|
9433
9590
|
var init_esm = __esm(() => {
|
|
9591
|
+
init_zodToJsonSchema();
|
|
9434
9592
|
init_Options();
|
|
9435
9593
|
init_Refs();
|
|
9436
9594
|
init_parseDef();
|
|
@@ -9462,7 +9620,6 @@ var init_esm = __esm(() => {
|
|
|
9462
9620
|
init_unknown();
|
|
9463
9621
|
init_selectParser();
|
|
9464
9622
|
init_zodToJsonSchema();
|
|
9465
|
-
init_zodToJsonSchema();
|
|
9466
9623
|
});
|
|
9467
9624
|
|
|
9468
9625
|
// src/ai/openai.ts
|
|
@@ -9947,6 +10104,7 @@ function getDefaultRedirectUri() {
|
|
|
9947
10104
|
return "http://localhost:3000/api/integrate/oauth/callback";
|
|
9948
10105
|
}
|
|
9949
10106
|
function createMCPServer(config) {
|
|
10107
|
+
setLogLevel(config.debug ? "debug" : "error");
|
|
9950
10108
|
if (typeof window !== "undefined") {
|
|
9951
10109
|
throw new Error("createMCPServer() should only be called on the server-side. " + "Use createMCPClient() for client-side code.");
|
|
9952
10110
|
}
|
|
@@ -9955,7 +10113,7 @@ function createMCPServer(config) {
|
|
|
9955
10113
|
if (integration.oauth) {
|
|
9956
10114
|
const { clientId, clientSecret, redirectUri: integrationRedirectUri, config: oauthConfig } = integration.oauth;
|
|
9957
10115
|
if (!clientId || !clientSecret) {
|
|
9958
|
-
|
|
10116
|
+
logger30.warn(`Warning: Integration "${integration.id}" is missing OAuth credentials. ` + `Provide clientId and clientSecret in the integration configuration.`);
|
|
9959
10117
|
return integration;
|
|
9960
10118
|
}
|
|
9961
10119
|
const redirectUri = integrationRedirectUri || config.redirectUri || getDefaultRedirectUri();
|
|
@@ -10068,7 +10226,7 @@ function createMCPServer(config) {
|
|
|
10068
10226
|
const body = await webRequest.json();
|
|
10069
10227
|
const authHeader = webRequest.headers.get("authorization");
|
|
10070
10228
|
const integrationsHeader = webRequest.headers.get("x-integrations");
|
|
10071
|
-
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => exports_base_handler);
|
|
10229
|
+
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
|
|
10072
10230
|
const oauthHandler = new OAuthHandler2({
|
|
10073
10231
|
providers,
|
|
10074
10232
|
serverUrl: config.serverUrl,
|
|
@@ -10084,7 +10242,7 @@ function createMCPServer(config) {
|
|
|
10084
10242
|
}
|
|
10085
10243
|
return response2;
|
|
10086
10244
|
} catch (error) {
|
|
10087
|
-
|
|
10245
|
+
logger30.error("[MCP Tool Call] Error:", error);
|
|
10088
10246
|
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
10089
10247
|
}
|
|
10090
10248
|
}
|
|
@@ -10148,7 +10306,7 @@ function createMCPServer(config) {
|
|
|
10148
10306
|
})
|
|
10149
10307
|
});
|
|
10150
10308
|
} catch (scheduleError) {
|
|
10151
|
-
|
|
10309
|
+
logger30.error("[Trigger] Failed to register with scheduler:", scheduleError);
|
|
10152
10310
|
}
|
|
10153
10311
|
return Response.json(created, { status: 201 });
|
|
10154
10312
|
}
|
|
@@ -10183,7 +10341,7 @@ function createMCPServer(config) {
|
|
|
10183
10341
|
body: JSON.stringify({ triggerId })
|
|
10184
10342
|
});
|
|
10185
10343
|
} catch (error) {
|
|
10186
|
-
|
|
10344
|
+
logger30.error("[Trigger] Failed to pause in scheduler:", error);
|
|
10187
10345
|
}
|
|
10188
10346
|
return Response.json(updated);
|
|
10189
10347
|
} else if (subAction === "resume" && method === "POST") {
|
|
@@ -10211,7 +10369,7 @@ function createMCPServer(config) {
|
|
|
10211
10369
|
body: JSON.stringify({ triggerId })
|
|
10212
10370
|
});
|
|
10213
10371
|
} catch (error) {
|
|
10214
|
-
|
|
10372
|
+
logger30.error("[Trigger] Failed to resume in scheduler:", error);
|
|
10215
10373
|
}
|
|
10216
10374
|
return Response.json(updated);
|
|
10217
10375
|
} else if (subAction === "run" && method === "POST") {
|
|
@@ -10226,7 +10384,7 @@ function createMCPServer(config) {
|
|
|
10226
10384
|
if (!providerToken) {
|
|
10227
10385
|
return Response.json({ error: "No OAuth token available for this trigger" }, { status: 401 });
|
|
10228
10386
|
}
|
|
10229
|
-
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => exports_base_handler);
|
|
10387
|
+
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
|
|
10230
10388
|
const oauthHandler = new OAuthHandler2({
|
|
10231
10389
|
providers,
|
|
10232
10390
|
serverUrl: config.serverUrl,
|
|
@@ -10352,7 +10510,7 @@ function createMCPServer(config) {
|
|
|
10352
10510
|
})
|
|
10353
10511
|
});
|
|
10354
10512
|
} catch (error) {
|
|
10355
|
-
|
|
10513
|
+
logger30.error("[Trigger] Failed to update scheduler:", error);
|
|
10356
10514
|
}
|
|
10357
10515
|
}
|
|
10358
10516
|
return Response.json(updated);
|
|
@@ -10369,14 +10527,14 @@ function createMCPServer(config) {
|
|
|
10369
10527
|
body: JSON.stringify({ triggerId })
|
|
10370
10528
|
});
|
|
10371
10529
|
} catch (error) {
|
|
10372
|
-
|
|
10530
|
+
logger30.error("[Trigger] Failed to unregister from scheduler:", error);
|
|
10373
10531
|
}
|
|
10374
10532
|
return new Response(null, { status: 204 });
|
|
10375
10533
|
}
|
|
10376
10534
|
}
|
|
10377
10535
|
return Response.json({ error: "Invalid trigger route or method" }, { status: 404 });
|
|
10378
10536
|
} catch (error) {
|
|
10379
|
-
|
|
10537
|
+
logger30.error("[Trigger] Error:", error);
|
|
10380
10538
|
return Response.json({ error: error.message || "Failed to process trigger request" }, { status: error.statusCode || 500 });
|
|
10381
10539
|
}
|
|
10382
10540
|
}
|
|
@@ -10402,11 +10560,11 @@ function createMCPServer(config) {
|
|
|
10402
10560
|
const errorRedirectUrl = "/auth-error";
|
|
10403
10561
|
if (error) {
|
|
10404
10562
|
const errorMsg = errorDescription || error;
|
|
10405
|
-
|
|
10563
|
+
logger30.error("[OAuth Redirect] Error:", errorMsg);
|
|
10406
10564
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, webRequest.url));
|
|
10407
10565
|
}
|
|
10408
10566
|
if (!code || !state) {
|
|
10409
|
-
|
|
10567
|
+
logger30.error("[OAuth Redirect] Missing code or state parameter");
|
|
10410
10568
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, webRequest.url));
|
|
10411
10569
|
}
|
|
10412
10570
|
let returnUrl = defaultRedirectUrl;
|
|
@@ -10438,7 +10596,7 @@ function createMCPServer(config) {
|
|
|
10438
10596
|
if (codeVerifierEntry) {
|
|
10439
10597
|
try {
|
|
10440
10598
|
const { codeVerifier, provider, frontendOrigin: storedFrontendOrigin } = codeVerifierEntry;
|
|
10441
|
-
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => exports_base_handler);
|
|
10599
|
+
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
|
|
10442
10600
|
const oauthHandler = new OAuthHandler2({
|
|
10443
10601
|
providers,
|
|
10444
10602
|
serverUrl: config.serverUrl,
|
|
@@ -10482,7 +10640,7 @@ function createMCPServer(config) {
|
|
|
10482
10640
|
frontendUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state, tokenData }))}`;
|
|
10483
10641
|
return Response.redirect(frontendUrl);
|
|
10484
10642
|
} catch (error2) {
|
|
10485
|
-
|
|
10643
|
+
logger30.error("[OAuth Backend Callback] Error:", error2);
|
|
10486
10644
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(error2.message || "Failed to exchange token")}`, webRequest.url));
|
|
10487
10645
|
}
|
|
10488
10646
|
} else {
|
|
@@ -10701,7 +10859,7 @@ function toSvelteKitHandler(clientOrHandlerOrOptions, _redirectOptions) {
|
|
|
10701
10859
|
}
|
|
10702
10860
|
};
|
|
10703
10861
|
}
|
|
10704
|
-
var globalServerConfig = null, codeVerifierStorage, POST = async (req, context) => {
|
|
10862
|
+
var logger30, globalServerConfig = null, codeVerifierStorage, POST = async (req, context) => {
|
|
10705
10863
|
if (!globalServerConfig) {
|
|
10706
10864
|
return Response.json({ error: "OAuth not configured. Call createMCPServer() in your server initialization file first." }, { status: 500 });
|
|
10707
10865
|
}
|
|
@@ -10719,6 +10877,7 @@ var globalServerConfig = null, codeVerifierStorage, POST = async (req, context)
|
|
|
10719
10877
|
var init_server = __esm(() => {
|
|
10720
10878
|
init_client();
|
|
10721
10879
|
init_nextjs();
|
|
10880
|
+
init_logger();
|
|
10722
10881
|
init_github();
|
|
10723
10882
|
init_gmail();
|
|
10724
10883
|
init_notion();
|
|
@@ -10748,6 +10907,7 @@ var init_server = __esm(() => {
|
|
|
10748
10907
|
init_anthropic();
|
|
10749
10908
|
init_google();
|
|
10750
10909
|
init_ai();
|
|
10910
|
+
logger30 = createLogger("MCPServer");
|
|
10751
10911
|
codeVerifierStorage = new Map;
|
|
10752
10912
|
});
|
|
10753
10913
|
|
|
@@ -11246,11 +11406,11 @@ class OAuthHandler {
|
|
|
11246
11406
|
try {
|
|
11247
11407
|
await this.config.removeProviderToken(request.provider, undefined, context);
|
|
11248
11408
|
} catch (error) {
|
|
11249
|
-
|
|
11409
|
+
logger31.error(`Failed to delete token for ${request.provider} from database via removeProviderToken:`, error);
|
|
11250
11410
|
}
|
|
11251
11411
|
}
|
|
11252
11412
|
} catch (error) {
|
|
11253
|
-
|
|
11413
|
+
logger31.error(`Failed to extract context for disconnect:`, error);
|
|
11254
11414
|
}
|
|
11255
11415
|
}
|
|
11256
11416
|
const url = new URL("/oauth/disconnect", this.serverUrl);
|
|
@@ -11310,14 +11470,22 @@ class OAuthHandler {
|
|
|
11310
11470
|
return jsonRpcResponse.result;
|
|
11311
11471
|
}
|
|
11312
11472
|
}
|
|
11313
|
-
var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
|
|
11473
|
+
var logger31, MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
|
|
11474
|
+
var init_base_handler = __esm(() => {
|
|
11475
|
+
init_logger();
|
|
11476
|
+
logger31 = createLogger("OAuthHandler");
|
|
11477
|
+
});
|
|
11314
11478
|
|
|
11315
11479
|
// src/index.ts
|
|
11316
11480
|
init_client();
|
|
11317
11481
|
init_manager();
|
|
11482
|
+
init_window_manager();
|
|
11483
|
+
init_base_handler();
|
|
11318
11484
|
init_nextjs();
|
|
11319
11485
|
|
|
11320
11486
|
// src/adapters/nextjs-oauth-redirect.ts
|
|
11487
|
+
init_logger();
|
|
11488
|
+
var logger32 = createLogger("OAuthRedirect");
|
|
11321
11489
|
function createOAuthRedirectHandler(config) {
|
|
11322
11490
|
const defaultRedirectUrl = config?.redirectUrl || "/";
|
|
11323
11491
|
const errorRedirectUrl = config?.errorRedirectUrl || "/auth-error";
|
|
@@ -11329,11 +11497,11 @@ function createOAuthRedirectHandler(config) {
|
|
|
11329
11497
|
const errorDescription = searchParams.get("error_description");
|
|
11330
11498
|
if (error) {
|
|
11331
11499
|
const errorMsg = errorDescription || error;
|
|
11332
|
-
|
|
11500
|
+
logger32.error("[OAuth Redirect] Error:", errorMsg);
|
|
11333
11501
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, req.url));
|
|
11334
11502
|
}
|
|
11335
11503
|
if (!code || !state) {
|
|
11336
|
-
|
|
11504
|
+
logger32.error("[OAuth Redirect] Missing code or state parameter");
|
|
11337
11505
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, req.url));
|
|
11338
11506
|
}
|
|
11339
11507
|
let returnUrl = defaultRedirectUrl;
|
|
@@ -11416,37 +11584,6 @@ init_cursor();
|
|
|
11416
11584
|
init_generic();
|
|
11417
11585
|
init_messages();
|
|
11418
11586
|
init_http_session();
|
|
11419
|
-
|
|
11420
|
-
// index.ts
|
|
11421
|
-
init_client();
|
|
11422
|
-
init_github();
|
|
11423
|
-
init_gmail();
|
|
11424
|
-
init_notion();
|
|
11425
|
-
init_slack();
|
|
11426
|
-
init_linear();
|
|
11427
|
-
init_vercel();
|
|
11428
|
-
init_zendesk();
|
|
11429
|
-
init_stripe();
|
|
11430
|
-
init_gcal();
|
|
11431
|
-
init_outlook();
|
|
11432
|
-
init_airtable();
|
|
11433
|
-
init_todoist();
|
|
11434
|
-
var client = createMCPClient({
|
|
11435
|
-
integrations: [
|
|
11436
|
-
githubIntegration(),
|
|
11437
|
-
gmailIntegration(),
|
|
11438
|
-
notionIntegration(),
|
|
11439
|
-
slackIntegration(),
|
|
11440
|
-
linearIntegration(),
|
|
11441
|
-
vercelIntegration(),
|
|
11442
|
-
zendeskIntegration(),
|
|
11443
|
-
stripeIntegration(),
|
|
11444
|
-
gcalIntegration(),
|
|
11445
|
-
outlookIntegration(),
|
|
11446
|
-
airtableIntegration(),
|
|
11447
|
-
todoistIntegration()
|
|
11448
|
-
]
|
|
11449
|
-
});
|
|
11450
11587
|
export {
|
|
11451
11588
|
zendeskIntegration,
|
|
11452
11589
|
youtubeIntegration,
|
|
@@ -11491,7 +11628,6 @@ export {
|
|
|
11491
11628
|
createOAuthRedirectHandler,
|
|
11492
11629
|
createNextOAuthHandler,
|
|
11493
11630
|
createMCPClient,
|
|
11494
|
-
client,
|
|
11495
11631
|
clearClientCache,
|
|
11496
11632
|
calcomIntegration,
|
|
11497
11633
|
airtableIntegration,
|