integrate-sdk 0.8.61-dev.0 → 0.8.64-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.js +263 -189
- package/dist/adapters/base-handler.d.ts.map +1 -1
- package/dist/adapters/index.js +260 -186
- package/dist/adapters/nextjs.js +260 -186
- package/dist/adapters/node.js +260 -186
- package/dist/adapters/svelte-kit.js +260 -186
- package/dist/adapters/tanstack-start.js +260 -186
- package/dist/index.js +254 -180
- package/dist/oauth.js +254 -180
- package/dist/server.js +247 -173
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- package/dist/src/client.d.ts +7 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/triggers/executor.d.ts +50 -0
- package/dist/src/triggers/executor.d.ts.map +1 -0
- package/dist/src/triggers/index.d.ts +2 -0
- package/dist/src/triggers/index.d.ts.map +1 -1
- package/dist/src/triggers/types.d.ts +11 -4
- package/dist/src/triggers/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1703,6 +1703,7 @@ class MCPClientBase {
|
|
|
1703
1703
|
apiRouteBase;
|
|
1704
1704
|
apiBaseUrl;
|
|
1705
1705
|
databaseDetected = false;
|
|
1706
|
+
_connectingPromise = null;
|
|
1706
1707
|
__configuredIntegrations;
|
|
1707
1708
|
__useServerConfig;
|
|
1708
1709
|
oauthCallbackPromise;
|
|
@@ -2016,6 +2017,17 @@ class MCPClientBase {
|
|
|
2016
2017
|
throw parsedError;
|
|
2017
2018
|
}
|
|
2018
2019
|
}
|
|
2020
|
+
async ensureConnected() {
|
|
2021
|
+
if (this.isConnected()) {
|
|
2022
|
+
return;
|
|
2023
|
+
}
|
|
2024
|
+
if (!this._connectingPromise) {
|
|
2025
|
+
this._connectingPromise = this.connect().finally(() => {
|
|
2026
|
+
this._connectingPromise = null;
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
return this._connectingPromise;
|
|
2030
|
+
}
|
|
2019
2031
|
async initializeIntegrations() {
|
|
2020
2032
|
for (const integration of this.integrations) {
|
|
2021
2033
|
if (integration.onInit) {
|
|
@@ -2074,6 +2086,7 @@ class MCPClientBase {
|
|
|
2074
2086
|
const transportHeaders = this.transport.headers || {};
|
|
2075
2087
|
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
2076
2088
|
if (hasApiKey) {
|
|
2089
|
+
await this.ensureConnected();
|
|
2077
2090
|
if (provider) {
|
|
2078
2091
|
const tokenData = await this.oauthManager.getProviderToken(provider, undefined, options?.context);
|
|
2079
2092
|
if (tokenData && this.transport.setHeader) {
|
|
@@ -2871,7 +2884,7 @@ class OAuthHandler {
|
|
|
2871
2884
|
url.searchParams.set("state", authorizeRequest.state);
|
|
2872
2885
|
url.searchParams.set("code_challenge", authorizeRequest.codeChallenge);
|
|
2873
2886
|
url.searchParams.set("code_challenge_method", authorizeRequest.codeChallengeMethod);
|
|
2874
|
-
const redirectUri =
|
|
2887
|
+
const redirectUri = providerConfig.redirectUri;
|
|
2875
2888
|
if (redirectUri) {
|
|
2876
2889
|
url.searchParams.set("redirect_uri", redirectUri);
|
|
2877
2890
|
}
|
|
@@ -2983,7 +2996,7 @@ class OAuthHandler {
|
|
|
2983
2996
|
tokenType: result.tokenType,
|
|
2984
2997
|
expiresIn: result.expiresIn,
|
|
2985
2998
|
expiresAt: result.expiresAt,
|
|
2986
|
-
scopes: result.scopes
|
|
2999
|
+
scopes: result.scopes ? result.scopes.flatMap((s) => s.split(" ").filter(Boolean)) : result.scopes
|
|
2987
3000
|
};
|
|
2988
3001
|
await this.config.setProviderToken(callbackRequest.provider, tokenData, undefined, context);
|
|
2989
3002
|
} catch (error) {}
|
|
@@ -10760,21 +10773,7 @@ var init_ai = __esm(() => {
|
|
|
10760
10773
|
init_trigger_tools();
|
|
10761
10774
|
});
|
|
10762
10775
|
|
|
10763
|
-
// src/triggers/types.ts
|
|
10764
|
-
var exports_types = {};
|
|
10765
|
-
__export(exports_types, {
|
|
10766
|
-
WEBHOOK_DELIVERY_TIMEOUT_MS: () => WEBHOOK_DELIVERY_TIMEOUT_MS,
|
|
10767
|
-
MAX_TRIGGER_STEPS: () => MAX_TRIGGER_STEPS
|
|
10768
|
-
});
|
|
10769
|
-
var MAX_TRIGGER_STEPS = 20, WEBHOOK_DELIVERY_TIMEOUT_MS = 1e4;
|
|
10770
|
-
|
|
10771
10776
|
// src/triggers/webhooks.ts
|
|
10772
|
-
var exports_webhooks = {};
|
|
10773
|
-
__export(exports_webhooks, {
|
|
10774
|
-
signPayload: () => signPayload,
|
|
10775
|
-
deliverWebhooks: () => deliverWebhooks,
|
|
10776
|
-
deliverWebhook: () => deliverWebhook
|
|
10777
|
-
});
|
|
10778
10777
|
async function signPayload(payload, secret) {
|
|
10779
10778
|
const encoder = new TextEncoder;
|
|
10780
10779
|
const data = encoder.encode(JSON.stringify(payload));
|
|
@@ -10823,6 +10822,155 @@ var init_webhooks = __esm(() => {
|
|
|
10823
10822
|
logger31 = createLogger("Webhooks", "server");
|
|
10824
10823
|
});
|
|
10825
10824
|
|
|
10825
|
+
// src/triggers/types.ts
|
|
10826
|
+
var MAX_TRIGGER_STEPS = 20, WEBHOOK_DELIVERY_TIMEOUT_MS = 1e4;
|
|
10827
|
+
|
|
10828
|
+
// src/triggers/executor.ts
|
|
10829
|
+
var exports_executor = {};
|
|
10830
|
+
__export(exports_executor, {
|
|
10831
|
+
executeTrigger: () => executeTrigger
|
|
10832
|
+
});
|
|
10833
|
+
async function executeTrigger(trigger, config, context) {
|
|
10834
|
+
const steps = [];
|
|
10835
|
+
let currentToolName = trigger.toolName;
|
|
10836
|
+
let currentToolArguments = trigger.toolArguments;
|
|
10837
|
+
let currentProvider = trigger.provider;
|
|
10838
|
+
let stepIndex = 0;
|
|
10839
|
+
while (stepIndex < MAX_TRIGGER_STEPS) {
|
|
10840
|
+
const stepValidation = validateStepLimit(stepIndex, MAX_TRIGGER_STEPS);
|
|
10841
|
+
if (!stepValidation.valid) {
|
|
10842
|
+
logger32.error(`[Trigger ${trigger.id}] ${stepValidation.error}`);
|
|
10843
|
+
break;
|
|
10844
|
+
}
|
|
10845
|
+
const providerToken = await config.getProviderToken(currentProvider, undefined, context);
|
|
10846
|
+
if (!providerToken) {
|
|
10847
|
+
const error = `No OAuth token available for provider '${currentProvider}'`;
|
|
10848
|
+
logger32.error(`[Trigger ${trigger.id}] ${error}`);
|
|
10849
|
+
steps.push({
|
|
10850
|
+
stepIndex,
|
|
10851
|
+
toolName: currentToolName,
|
|
10852
|
+
success: false,
|
|
10853
|
+
error,
|
|
10854
|
+
duration: 0,
|
|
10855
|
+
executedAt: new Date().toISOString()
|
|
10856
|
+
});
|
|
10857
|
+
await config.triggers.update(trigger.id, {
|
|
10858
|
+
lastRunAt: new Date().toISOString(),
|
|
10859
|
+
runCount: (trigger.runCount || 0) + 1,
|
|
10860
|
+
lastError: error,
|
|
10861
|
+
status: "failed"
|
|
10862
|
+
}, context);
|
|
10863
|
+
return { success: false, steps, error };
|
|
10864
|
+
}
|
|
10865
|
+
const startTime = Date.now();
|
|
10866
|
+
let toolResult;
|
|
10867
|
+
let stepSuccess = true;
|
|
10868
|
+
let stepError;
|
|
10869
|
+
try {
|
|
10870
|
+
toolResult = await config.handleToolCall({ name: currentToolName, arguments: currentToolArguments }, `${providerToken.tokenType || "Bearer"} ${providerToken.accessToken}`, null);
|
|
10871
|
+
} catch (err) {
|
|
10872
|
+
stepSuccess = false;
|
|
10873
|
+
stepError = err.message || "Tool execution failed";
|
|
10874
|
+
logger32.error(`[Trigger ${trigger.id}] Step ${stepIndex} failed:`, err);
|
|
10875
|
+
}
|
|
10876
|
+
const duration = Date.now() - startTime;
|
|
10877
|
+
const executedAt = new Date().toISOString();
|
|
10878
|
+
steps.push({
|
|
10879
|
+
stepIndex,
|
|
10880
|
+
toolName: currentToolName,
|
|
10881
|
+
success: stepSuccess,
|
|
10882
|
+
result: stepSuccess ? toolResult : undefined,
|
|
10883
|
+
error: stepError,
|
|
10884
|
+
duration,
|
|
10885
|
+
executedAt
|
|
10886
|
+
});
|
|
10887
|
+
if (!config.triggers.onComplete || !stepSuccess) {
|
|
10888
|
+
const updates = {
|
|
10889
|
+
lastRunAt: executedAt,
|
|
10890
|
+
runCount: (trigger.runCount || 0) + 1
|
|
10891
|
+
};
|
|
10892
|
+
if (stepSuccess) {
|
|
10893
|
+
updates.lastResult = toolResult;
|
|
10894
|
+
updates.lastError = undefined;
|
|
10895
|
+
if (trigger.schedule.type === "once") {
|
|
10896
|
+
updates.status = "completed";
|
|
10897
|
+
}
|
|
10898
|
+
} else {
|
|
10899
|
+
updates.lastError = stepError;
|
|
10900
|
+
updates.status = "failed";
|
|
10901
|
+
}
|
|
10902
|
+
await config.triggers.update(trigger.id, updates, context);
|
|
10903
|
+
return { success: stepSuccess, steps, error: stepError };
|
|
10904
|
+
}
|
|
10905
|
+
const completeRequest = {
|
|
10906
|
+
success: stepSuccess,
|
|
10907
|
+
result: stepSuccess ? toolResult : undefined,
|
|
10908
|
+
error: stepError,
|
|
10909
|
+
executedAt,
|
|
10910
|
+
duration,
|
|
10911
|
+
stepIndex,
|
|
10912
|
+
previousResults: steps,
|
|
10913
|
+
final: false
|
|
10914
|
+
};
|
|
10915
|
+
const completeResponse = await config.triggers.onComplete({
|
|
10916
|
+
trigger,
|
|
10917
|
+
request: completeRequest,
|
|
10918
|
+
context
|
|
10919
|
+
});
|
|
10920
|
+
if (completeResponse.hasMore && completeResponse.nextStep) {
|
|
10921
|
+
currentToolName = completeResponse.nextStep.toolName;
|
|
10922
|
+
currentToolArguments = completeResponse.nextStep.toolArguments;
|
|
10923
|
+
currentProvider = completeResponse.nextStep.provider;
|
|
10924
|
+
stepIndex++;
|
|
10925
|
+
continue;
|
|
10926
|
+
}
|
|
10927
|
+
const finalUpdates = {
|
|
10928
|
+
lastRunAt: executedAt,
|
|
10929
|
+
runCount: (trigger.runCount || 0) + 1
|
|
10930
|
+
};
|
|
10931
|
+
if (stepSuccess) {
|
|
10932
|
+
finalUpdates.lastResult = toolResult;
|
|
10933
|
+
finalUpdates.lastError = undefined;
|
|
10934
|
+
if (trigger.schedule.type === "once") {
|
|
10935
|
+
finalUpdates.status = "completed";
|
|
10936
|
+
}
|
|
10937
|
+
} else {
|
|
10938
|
+
finalUpdates.lastError = stepError;
|
|
10939
|
+
finalUpdates.status = "failed";
|
|
10940
|
+
}
|
|
10941
|
+
await config.triggers.update(trigger.id, finalUpdates, context);
|
|
10942
|
+
if (completeResponse.webhooks && completeResponse.webhooks.length > 0) {
|
|
10943
|
+
const totalDuration = steps.reduce((sum, s) => sum + (s.duration || 0), 0);
|
|
10944
|
+
const payload = {
|
|
10945
|
+
triggerId: trigger.id,
|
|
10946
|
+
success: steps.every((s) => s.success),
|
|
10947
|
+
steps,
|
|
10948
|
+
totalSteps: steps.length,
|
|
10949
|
+
totalDuration,
|
|
10950
|
+
executedAt
|
|
10951
|
+
};
|
|
10952
|
+
deliverWebhooks(completeResponse.webhooks, payload, WEBHOOK_DELIVERY_TIMEOUT_MS).catch(() => {});
|
|
10953
|
+
}
|
|
10954
|
+
return { success: stepSuccess, steps, error: stepError };
|
|
10955
|
+
}
|
|
10956
|
+
const limitError = `Trigger execution exceeded maximum of ${MAX_TRIGGER_STEPS} steps`;
|
|
10957
|
+
logger32.error(`[Trigger ${trigger.id}] ${limitError}`);
|
|
10958
|
+
await config.triggers.update(trigger.id, {
|
|
10959
|
+
lastRunAt: new Date().toISOString(),
|
|
10960
|
+
runCount: (trigger.runCount || 0) + 1,
|
|
10961
|
+
lastError: limitError,
|
|
10962
|
+
status: "failed"
|
|
10963
|
+
}, context);
|
|
10964
|
+
return { success: false, steps, error: limitError };
|
|
10965
|
+
}
|
|
10966
|
+
var logger32;
|
|
10967
|
+
var init_executor = __esm(() => {
|
|
10968
|
+
init_logger();
|
|
10969
|
+
init_utils2();
|
|
10970
|
+
init_webhooks();
|
|
10971
|
+
logger32 = createLogger("TriggerExecutor", "server");
|
|
10972
|
+
});
|
|
10973
|
+
|
|
10826
10974
|
// src/server.ts
|
|
10827
10975
|
var exports_server = {};
|
|
10828
10976
|
__export(exports_server, {
|
|
@@ -10916,7 +11064,7 @@ function createMCPServer(config) {
|
|
|
10916
11064
|
if (integration.oauth) {
|
|
10917
11065
|
const { clientId, clientSecret, redirectUri: integrationRedirectUri, config: oauthConfig } = integration.oauth;
|
|
10918
11066
|
if (!clientId || !clientSecret) {
|
|
10919
|
-
|
|
11067
|
+
logger33.warn(`Warning: Integration "${integration.id}" is missing OAuth credentials. ` + `Provide clientId and clientSecret in the integration configuration.`);
|
|
10920
11068
|
return integration;
|
|
10921
11069
|
}
|
|
10922
11070
|
const redirectUri = integrationRedirectUri || config.redirectUri || getDefaultRedirectUri();
|
|
@@ -11047,7 +11195,7 @@ function createMCPServer(config) {
|
|
|
11047
11195
|
}
|
|
11048
11196
|
return response2;
|
|
11049
11197
|
} catch (error) {
|
|
11050
|
-
|
|
11198
|
+
logger33.error("[MCP Tool Call] Error:", error);
|
|
11051
11199
|
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
11052
11200
|
}
|
|
11053
11201
|
}
|
|
@@ -11063,6 +11211,57 @@ function createMCPServer(config) {
|
|
|
11063
11211
|
}));
|
|
11064
11212
|
return Response.json({ integrations });
|
|
11065
11213
|
}
|
|
11214
|
+
if (segments.length === 2 && segments[0] === "triggers" && segments[1] === "notify" && method === "POST") {
|
|
11215
|
+
if (!config.triggers) {
|
|
11216
|
+
return Response.json({ error: "Triggers not configured. Add triggers callbacks to createMCPServer config." }, { status: 501 });
|
|
11217
|
+
}
|
|
11218
|
+
try {
|
|
11219
|
+
const apiKey = webRequest.headers.get("x-api-key");
|
|
11220
|
+
if (!apiKey || apiKey !== config.apiKey) {
|
|
11221
|
+
return Response.json({ error: "Unauthorized" }, { status: 401 });
|
|
11222
|
+
}
|
|
11223
|
+
const body = await webRequest.json();
|
|
11224
|
+
const { triggerId } = body;
|
|
11225
|
+
if (!triggerId) {
|
|
11226
|
+
return Response.json({ error: "triggerId is required" }, { status: 400 });
|
|
11227
|
+
}
|
|
11228
|
+
const trigger = await config.triggers.get(triggerId);
|
|
11229
|
+
if (!trigger) {
|
|
11230
|
+
return Response.json({ error: "Trigger not found" }, { status: 404 });
|
|
11231
|
+
}
|
|
11232
|
+
if (!trigger.provider) {
|
|
11233
|
+
return Response.json({ error: "Trigger has no provider configured" }, { status: 400 });
|
|
11234
|
+
}
|
|
11235
|
+
const triggerContext = trigger.userId ? { userId: trigger.userId } : undefined;
|
|
11236
|
+
const { executeTrigger: executeTrigger2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
|
|
11237
|
+
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
|
|
11238
|
+
const oauthHandler = new OAuthHandler2({
|
|
11239
|
+
providers,
|
|
11240
|
+
serverUrl: config.serverUrl,
|
|
11241
|
+
apiKey: config.apiKey,
|
|
11242
|
+
setProviderToken: config.setProviderToken,
|
|
11243
|
+
removeProviderToken: config.removeProviderToken,
|
|
11244
|
+
getSessionContext: config.getSessionContext
|
|
11245
|
+
});
|
|
11246
|
+
const executionResult = await executeTrigger2(trigger, {
|
|
11247
|
+
triggers: config.triggers,
|
|
11248
|
+
getProviderToken: async (provider, email, ctx) => {
|
|
11249
|
+
return config.getProviderToken ? await config.getProviderToken(provider, email, ctx) : undefined;
|
|
11250
|
+
},
|
|
11251
|
+
handleToolCall: (toolBody, authHeader, integrationsHeader) => {
|
|
11252
|
+
return oauthHandler.handleToolCall(toolBody, authHeader, integrationsHeader);
|
|
11253
|
+
}
|
|
11254
|
+
}, triggerContext);
|
|
11255
|
+
return Response.json({
|
|
11256
|
+
success: executionResult.success,
|
|
11257
|
+
steps: executionResult.steps,
|
|
11258
|
+
error: executionResult.error
|
|
11259
|
+
});
|
|
11260
|
+
} catch (error) {
|
|
11261
|
+
logger33.error("[Trigger Notify] Error:", error);
|
|
11262
|
+
return Response.json({ error: error.message || "Failed to execute trigger" }, { status: 500 });
|
|
11263
|
+
}
|
|
11264
|
+
}
|
|
11066
11265
|
if (segments.length >= 1 && segments[0] === "triggers") {
|
|
11067
11266
|
if (!config.triggers) {
|
|
11068
11267
|
return Response.json({ error: "Triggers not configured. Add triggers callbacks to createMCPServer config." }, { status: 501 });
|
|
@@ -11103,8 +11302,9 @@ function createMCPServer(config) {
|
|
|
11103
11302
|
};
|
|
11104
11303
|
const created = await config.triggers.create(trigger, context2);
|
|
11105
11304
|
const schedulerUrl = config.schedulerUrl || config.serverUrl || "https://mcp.integrate.dev";
|
|
11106
|
-
const
|
|
11305
|
+
const defaultCallbackBaseUrl = process.env.INTEGRATE_URL || (typeof window !== "undefined" ? window.location.origin : "http://localhost:3000");
|
|
11107
11306
|
try {
|
|
11307
|
+
const callbackBaseUrl = config.triggers.getCallbackUrl ? await config.triggers.getCallbackUrl(context2) : defaultCallbackBaseUrl;
|
|
11108
11308
|
await fetch(`${schedulerUrl}/scheduler/register`, {
|
|
11109
11309
|
method: "POST",
|
|
11110
11310
|
headers: {
|
|
@@ -11114,8 +11314,7 @@ function createMCPServer(config) {
|
|
|
11114
11314
|
body: JSON.stringify({
|
|
11115
11315
|
triggerId: created.id,
|
|
11116
11316
|
schedule: created.schedule,
|
|
11117
|
-
callbackUrl: `${callbackBaseUrl}/api/integrate/triggers
|
|
11118
|
-
completeUrl: `${callbackBaseUrl}/api/integrate/triggers/${created.id}/complete`,
|
|
11317
|
+
callbackUrl: `${callbackBaseUrl}/api/integrate/triggers/notify`,
|
|
11119
11318
|
metadata: {
|
|
11120
11319
|
userId: context2?.userId,
|
|
11121
11320
|
provider: created.provider
|
|
@@ -11123,7 +11322,7 @@ function createMCPServer(config) {
|
|
|
11123
11322
|
})
|
|
11124
11323
|
});
|
|
11125
11324
|
} catch (scheduleError) {
|
|
11126
|
-
|
|
11325
|
+
logger33.error("[Trigger] Failed to register with scheduler:", scheduleError);
|
|
11127
11326
|
}
|
|
11128
11327
|
return Response.json(created, { status: 201 });
|
|
11129
11328
|
}
|
|
@@ -11158,7 +11357,7 @@ function createMCPServer(config) {
|
|
|
11158
11357
|
body: JSON.stringify({ triggerId })
|
|
11159
11358
|
});
|
|
11160
11359
|
} catch (error) {
|
|
11161
|
-
|
|
11360
|
+
logger33.error("[Trigger] Failed to pause in scheduler:", error);
|
|
11162
11361
|
}
|
|
11163
11362
|
return Response.json(updated);
|
|
11164
11363
|
} else if (subAction === "resume" && method === "POST") {
|
|
@@ -11186,7 +11385,7 @@ function createMCPServer(config) {
|
|
|
11186
11385
|
body: JSON.stringify({ triggerId })
|
|
11187
11386
|
});
|
|
11188
11387
|
} catch (error) {
|
|
11189
|
-
|
|
11388
|
+
logger33.error("[Trigger] Failed to resume in scheduler:", error);
|
|
11190
11389
|
}
|
|
11191
11390
|
return Response.json(updated);
|
|
11192
11391
|
} else if (subAction === "run" && method === "POST") {
|
|
@@ -11197,10 +11396,7 @@ function createMCPServer(config) {
|
|
|
11197
11396
|
if (!trigger.provider) {
|
|
11198
11397
|
return Response.json({ error: "Trigger has no provider configured" }, { status: 400 });
|
|
11199
11398
|
}
|
|
11200
|
-
const
|
|
11201
|
-
if (!providerToken) {
|
|
11202
|
-
return Response.json({ error: "No OAuth token available for this trigger" }, { status: 401 });
|
|
11203
|
-
}
|
|
11399
|
+
const { executeTrigger: executeTrigger2 } = await Promise.resolve().then(() => (init_executor(), exports_executor));
|
|
11204
11400
|
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => (init_base_handler(), exports_base_handler));
|
|
11205
11401
|
const oauthHandler = new OAuthHandler2({
|
|
11206
11402
|
providers,
|
|
@@ -11210,145 +11406,23 @@ function createMCPServer(config) {
|
|
|
11210
11406
|
removeProviderToken: config.removeProviderToken,
|
|
11211
11407
|
getSessionContext: config.getSessionContext
|
|
11212
11408
|
});
|
|
11213
|
-
const
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
const executionResult = {
|
|
11218
|
-
success: true,
|
|
11219
|
-
result,
|
|
11220
|
-
executedAt: new Date().toISOString(),
|
|
11221
|
-
duration
|
|
11222
|
-
};
|
|
11223
|
-
await config.triggers.update(triggerId, {
|
|
11224
|
-
lastRunAt: executionResult.executedAt,
|
|
11225
|
-
runCount: (trigger.runCount || 0) + 1,
|
|
11226
|
-
lastResult: result,
|
|
11227
|
-
lastError: undefined
|
|
11228
|
-
}, context2);
|
|
11229
|
-
return Response.json(executionResult);
|
|
11230
|
-
} catch (error) {
|
|
11231
|
-
const duration = Date.now() - startTime;
|
|
11232
|
-
const executionResult = {
|
|
11233
|
-
success: false,
|
|
11234
|
-
error: error.message || "Tool execution failed",
|
|
11235
|
-
executedAt: new Date().toISOString(),
|
|
11236
|
-
duration
|
|
11237
|
-
};
|
|
11238
|
-
await config.triggers.update(triggerId, {
|
|
11239
|
-
lastRunAt: executionResult.executedAt,
|
|
11240
|
-
runCount: (trigger.runCount || 0) + 1,
|
|
11241
|
-
lastError: error.message,
|
|
11242
|
-
status: "failed"
|
|
11243
|
-
}, context2);
|
|
11244
|
-
return Response.json(executionResult, { status: 500 });
|
|
11245
|
-
}
|
|
11246
|
-
} else if (subAction === "execute" && method === "GET") {
|
|
11247
|
-
const apiKey = webRequest.headers.get("x-api-key");
|
|
11248
|
-
if (!apiKey || apiKey !== config.apiKey) {
|
|
11249
|
-
return Response.json({ error: "Unauthorized" }, { status: 401 });
|
|
11250
|
-
}
|
|
11251
|
-
const trigger = await config.triggers.get(triggerId, context2);
|
|
11252
|
-
if (!trigger) {
|
|
11253
|
-
return Response.json({ error: "Trigger not found" }, { status: 404 });
|
|
11254
|
-
}
|
|
11255
|
-
if (!trigger.provider) {
|
|
11256
|
-
return Response.json({ error: "Trigger has no provider configured" }, { status: 400 });
|
|
11257
|
-
}
|
|
11258
|
-
const providerToken = config.getProviderToken ? await config.getProviderToken(trigger.provider, undefined, context2) : undefined;
|
|
11259
|
-
if (!providerToken) {
|
|
11260
|
-
return Response.json({ error: "No OAuth token available for this trigger" }, { status: 401 });
|
|
11261
|
-
}
|
|
11262
|
-
return Response.json({
|
|
11263
|
-
trigger: {
|
|
11264
|
-
id: trigger.id,
|
|
11265
|
-
toolName: trigger.toolName,
|
|
11266
|
-
toolArguments: trigger.toolArguments,
|
|
11267
|
-
provider: trigger.provider
|
|
11409
|
+
const executionResult = await executeTrigger2(trigger, {
|
|
11410
|
+
triggers: config.triggers,
|
|
11411
|
+
getProviderToken: async (provider, email, ctx) => {
|
|
11412
|
+
return config.getProviderToken ? await config.getProviderToken(provider, email, ctx) : undefined;
|
|
11268
11413
|
},
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
});
|
|
11272
|
-
} else if (subAction === "complete" && method === "POST") {
|
|
11273
|
-
const apiKey = webRequest.headers.get("x-api-key");
|
|
11274
|
-
if (!apiKey || apiKey !== config.apiKey) {
|
|
11275
|
-
return Response.json({ error: "Unauthorized" }, { status: 401 });
|
|
11276
|
-
}
|
|
11277
|
-
const body = await webRequest.json();
|
|
11278
|
-
const trigger = await config.triggers.get(triggerId, context2);
|
|
11279
|
-
if (!trigger) {
|
|
11280
|
-
return Response.json({ error: "Trigger not found" }, { status: 404 });
|
|
11281
|
-
}
|
|
11282
|
-
if (body.stepIndex != null) {
|
|
11283
|
-
const { validateStepLimit: validateStepLimit2 } = await Promise.resolve().then(() => (init_utils2(), exports_utils));
|
|
11284
|
-
const { MAX_TRIGGER_STEPS: MAX_TRIGGER_STEPS2 } = await Promise.resolve().then(() => exports_types);
|
|
11285
|
-
const stepValidation = validateStepLimit2(body.stepIndex, MAX_TRIGGER_STEPS2);
|
|
11286
|
-
if (!stepValidation.valid) {
|
|
11287
|
-
return Response.json({ error: stepValidation.error }, { status: 400 });
|
|
11414
|
+
handleToolCall: (toolBody, authHeader, integrationsHeader) => {
|
|
11415
|
+
return oauthHandler.handleToolCall(toolBody, authHeader, integrationsHeader);
|
|
11288
11416
|
}
|
|
11289
|
-
}
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
return Response.json(completeResponse);
|
|
11299
|
-
}
|
|
11300
|
-
const updates2 = {
|
|
11301
|
-
lastRunAt: body.executedAt,
|
|
11302
|
-
runCount: (trigger.runCount || 0) + 1
|
|
11303
|
-
};
|
|
11304
|
-
if (body.success) {
|
|
11305
|
-
updates2.lastResult = body.result;
|
|
11306
|
-
updates2.lastError = undefined;
|
|
11307
|
-
if (trigger.schedule.type === "once") {
|
|
11308
|
-
updates2.status = "completed";
|
|
11309
|
-
}
|
|
11310
|
-
} else {
|
|
11311
|
-
updates2.lastError = body.error;
|
|
11312
|
-
updates2.status = "failed";
|
|
11313
|
-
}
|
|
11314
|
-
await config.triggers.update(triggerId, updates2, context2);
|
|
11315
|
-
if (completeResponse.webhooks && completeResponse.webhooks.length > 0) {
|
|
11316
|
-
const { deliverWebhooks: deliverWebhooks2 } = await Promise.resolve().then(() => (init_webhooks(), exports_webhooks));
|
|
11317
|
-
const { WEBHOOK_DELIVERY_TIMEOUT_MS: WEBHOOK_DELIVERY_TIMEOUT_MS2 } = await Promise.resolve().then(() => exports_types);
|
|
11318
|
-
const steps = body.previousResults || [];
|
|
11319
|
-
const totalDuration = steps.reduce((sum, s) => sum + (s.duration || 0), 0);
|
|
11320
|
-
const payload = {
|
|
11321
|
-
triggerId,
|
|
11322
|
-
success: body.success,
|
|
11323
|
-
steps,
|
|
11324
|
-
totalSteps: steps.length,
|
|
11325
|
-
totalDuration,
|
|
11326
|
-
executedAt: body.executedAt
|
|
11327
|
-
};
|
|
11328
|
-
deliverWebhooks2(completeResponse.webhooks, payload, WEBHOOK_DELIVERY_TIMEOUT_MS2).catch(() => {});
|
|
11329
|
-
}
|
|
11330
|
-
return Response.json(completeResponse);
|
|
11331
|
-
} catch (error) {
|
|
11332
|
-
logger32.error("onComplete callback error:", error);
|
|
11333
|
-
return Response.json({ error: "Internal server error in onComplete callback" }, { status: 500 });
|
|
11334
|
-
}
|
|
11335
|
-
}
|
|
11336
|
-
const updates = {
|
|
11337
|
-
lastRunAt: body.executedAt,
|
|
11338
|
-
runCount: (trigger.runCount || 0) + 1
|
|
11339
|
-
};
|
|
11340
|
-
if (body.success) {
|
|
11341
|
-
updates.lastResult = body.result;
|
|
11342
|
-
updates.lastError = undefined;
|
|
11343
|
-
if (trigger.schedule.type === "once") {
|
|
11344
|
-
updates.status = "completed";
|
|
11345
|
-
}
|
|
11346
|
-
} else {
|
|
11347
|
-
updates.lastError = body.error;
|
|
11348
|
-
updates.status = "failed";
|
|
11349
|
-
}
|
|
11350
|
-
await config.triggers.update(triggerId, updates, context2);
|
|
11351
|
-
return Response.json({ success: true });
|
|
11417
|
+
}, context2);
|
|
11418
|
+
return Response.json({
|
|
11419
|
+
success: executionResult.success,
|
|
11420
|
+
result: executionResult.steps[0]?.result,
|
|
11421
|
+
executedAt: executionResult.steps[0]?.executedAt || new Date().toISOString(),
|
|
11422
|
+
duration: executionResult.steps[0]?.duration,
|
|
11423
|
+
error: executionResult.error,
|
|
11424
|
+
steps: executionResult.steps
|
|
11425
|
+
}, { status: executionResult.success ? 200 : 500 });
|
|
11352
11426
|
} else if (!subAction && method === "GET") {
|
|
11353
11427
|
const trigger = await config.triggers.get(triggerId, context2);
|
|
11354
11428
|
if (!trigger) {
|
|
@@ -11381,7 +11455,7 @@ function createMCPServer(config) {
|
|
|
11381
11455
|
})
|
|
11382
11456
|
});
|
|
11383
11457
|
} catch (error) {
|
|
11384
|
-
|
|
11458
|
+
logger33.error("[Trigger] Failed to update scheduler:", error);
|
|
11385
11459
|
}
|
|
11386
11460
|
}
|
|
11387
11461
|
return Response.json(updated);
|
|
@@ -11398,14 +11472,14 @@ function createMCPServer(config) {
|
|
|
11398
11472
|
body: JSON.stringify({ triggerId })
|
|
11399
11473
|
});
|
|
11400
11474
|
} catch (error) {
|
|
11401
|
-
|
|
11475
|
+
logger33.error("[Trigger] Failed to unregister from scheduler:", error);
|
|
11402
11476
|
}
|
|
11403
11477
|
return new Response(null, { status: 204 });
|
|
11404
11478
|
}
|
|
11405
11479
|
}
|
|
11406
11480
|
return Response.json({ error: "Invalid trigger route or method" }, { status: 404 });
|
|
11407
11481
|
} catch (error) {
|
|
11408
|
-
|
|
11482
|
+
logger33.error("[Trigger] Error:", error);
|
|
11409
11483
|
return Response.json({ error: error.message || "Failed to process trigger request" }, { status: error.statusCode || 500 });
|
|
11410
11484
|
}
|
|
11411
11485
|
}
|
|
@@ -11431,11 +11505,11 @@ function createMCPServer(config) {
|
|
|
11431
11505
|
const errorRedirectUrl = "/auth-error";
|
|
11432
11506
|
if (error) {
|
|
11433
11507
|
const errorMsg = errorDescription || error;
|
|
11434
|
-
|
|
11508
|
+
logger33.error("[OAuth Redirect] Error:", errorMsg);
|
|
11435
11509
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, webRequest.url));
|
|
11436
11510
|
}
|
|
11437
11511
|
if (!code || !state) {
|
|
11438
|
-
|
|
11512
|
+
logger33.error("[OAuth Redirect] Missing code or state parameter");
|
|
11439
11513
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, webRequest.url));
|
|
11440
11514
|
}
|
|
11441
11515
|
let returnUrl = defaultRedirectUrl;
|
|
@@ -11511,7 +11585,7 @@ function createMCPServer(config) {
|
|
|
11511
11585
|
frontendUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state, tokenData }))}`;
|
|
11512
11586
|
return Response.redirect(frontendUrl);
|
|
11513
11587
|
} catch (error2) {
|
|
11514
|
-
|
|
11588
|
+
logger33.error("[OAuth Backend Callback] Error:", error2);
|
|
11515
11589
|
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(error2.message || "Failed to exchange token")}`, webRequest.url));
|
|
11516
11590
|
}
|
|
11517
11591
|
} else {
|
|
@@ -11730,7 +11804,7 @@ function toSvelteKitHandler(clientOrHandlerOrOptions, _redirectOptions) {
|
|
|
11730
11804
|
}
|
|
11731
11805
|
};
|
|
11732
11806
|
}
|
|
11733
|
-
var SERVER_LOG_CONTEXT3 = "server",
|
|
11807
|
+
var SERVER_LOG_CONTEXT3 = "server", logger33, globalServerConfig = null, codeVerifierStorage, POST = async (req, context) => {
|
|
11734
11808
|
if (!globalServerConfig) {
|
|
11735
11809
|
return Response.json({ error: "OAuth not configured. Call createMCPServer() in your server initialization file first." }, { status: 500 });
|
|
11736
11810
|
}
|
|
@@ -11778,7 +11852,7 @@ var init_server = __esm(() => {
|
|
|
11778
11852
|
init_anthropic();
|
|
11779
11853
|
init_google();
|
|
11780
11854
|
init_ai();
|
|
11781
|
-
|
|
11855
|
+
logger33 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);
|
|
11782
11856
|
codeVerifierStorage = new Map;
|
|
11783
11857
|
});
|
|
11784
11858
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-handler.d.ts","sourceRoot":"","sources":["../../../src/adapters/base-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAc3D;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,iDAAiD;QACjD,QAAQ,EAAE,MAAM,CAAC;QACjB,qDAAqD;QACrD,YAAY,EAAE,MAAM,CAAC;QACrB,qCAAqC;QACrC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,8CAA8C;QAC9C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,kFAAkF;QAClF,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC9B,CAAC,CAA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EAAE,SAAS,MAAM,EAAE,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE;IAehL;;OAEG;IACH,OAAO,CAAC,UAAU;IAalB;;;OAGG;IACH,oBAAoB,IAAI,OAAO;IAI/B;;;;;;;;;;OAUG;IACG,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6HtF;;;;;;;;;;OAUG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiHnF;;;;;;;;;OASG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BlF;;;;;;;;;;;OAWG;IACG,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4D1H;;;;;;;;;;;;;;OAcG;IACG,cAAc,CAClB,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GACjC,OAAO,CAAC,gBAAgB,CAAC;CAuD7B"}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export declare class MCPClientBase<TIntegrations extends readonly MCPIntegration
|
|
|
82
82
|
private apiRouteBase;
|
|
83
83
|
private apiBaseUrl?;
|
|
84
84
|
private databaseDetected;
|
|
85
|
+
private _connectingPromise;
|
|
85
86
|
/**
|
|
86
87
|
* Explicitly configured integrations passed to createMCPClient
|
|
87
88
|
* Used by listConfiguredIntegrations to return only configured integrations
|
|
@@ -132,6 +133,12 @@ export declare class MCPClientBase<TIntegrations extends readonly MCPIntegration
|
|
|
132
133
|
* Internal implementation for calling server tools
|
|
133
134
|
*/
|
|
134
135
|
private callServerToolInternal;
|
|
136
|
+
/**
|
|
137
|
+
* Ensure the client is connected before making transport requests.
|
|
138
|
+
* Safe to call concurrently — deduplicates in-flight connect() calls.
|
|
139
|
+
* Only needed for server-side clients that use transport.sendRequest() directly.
|
|
140
|
+
*/
|
|
141
|
+
private ensureConnected;
|
|
135
142
|
/**
|
|
136
143
|
* Initialize all integrations
|
|
137
144
|
*/
|