integrate-sdk 0.6.9 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/auto-routes.js +36 -2
- package/dist/adapters/base-handler.js +36 -2
- package/dist/adapters/nextjs.js +149 -98
- package/dist/adapters/node.js +36 -2
- package/dist/adapters/solid-start.js +236 -158
- package/dist/adapters/svelte-kit.js +236 -158
- package/dist/index.js +258 -157
- package/dist/oauth.js +40 -1
- package/dist/server.js +258 -158
- package/dist/src/adapters/base-handler.d.ts +34 -0
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- package/dist/src/adapters/nextjs.d.ts +26 -0
- package/dist/src/adapters/nextjs.d.ts.map +1 -1
- package/dist/src/client.d.ts +6 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +18 -0
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -244,6 +244,176 @@ function base64UrlDecode(str) {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
// src/adapters/base-handler.ts
|
|
248
|
+
var exports_base_handler = {};
|
|
249
|
+
__export(exports_base_handler, {
|
|
250
|
+
OAuthHandler: () => OAuthHandler
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
class OAuthHandler {
|
|
254
|
+
config;
|
|
255
|
+
serverUrl;
|
|
256
|
+
apiKey;
|
|
257
|
+
constructor(config) {
|
|
258
|
+
this.config = config;
|
|
259
|
+
if (!config || !config.providers) {
|
|
260
|
+
throw new Error("OAuthHandler requires a valid config with providers");
|
|
261
|
+
}
|
|
262
|
+
this.serverUrl = config.serverUrl || MCP_SERVER_URL2;
|
|
263
|
+
this.apiKey = config.apiKey;
|
|
264
|
+
}
|
|
265
|
+
getHeaders(additionalHeaders) {
|
|
266
|
+
const headers = {
|
|
267
|
+
...additionalHeaders
|
|
268
|
+
};
|
|
269
|
+
if (this.apiKey) {
|
|
270
|
+
headers["X-API-KEY"] = this.apiKey;
|
|
271
|
+
}
|
|
272
|
+
return headers;
|
|
273
|
+
}
|
|
274
|
+
async handleAuthorize(request) {
|
|
275
|
+
const providerConfig = this.config.providers[request.provider];
|
|
276
|
+
if (!providerConfig) {
|
|
277
|
+
throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
278
|
+
}
|
|
279
|
+
if (!providerConfig.clientId || !providerConfig.clientSecret) {
|
|
280
|
+
throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
|
|
281
|
+
}
|
|
282
|
+
const url = new URL("/oauth/authorize", this.serverUrl);
|
|
283
|
+
url.searchParams.set("provider", request.provider);
|
|
284
|
+
url.searchParams.set("client_id", providerConfig.clientId);
|
|
285
|
+
url.searchParams.set("client_secret", providerConfig.clientSecret);
|
|
286
|
+
url.searchParams.set("scope", request.scopes.join(","));
|
|
287
|
+
url.searchParams.set("state", request.state);
|
|
288
|
+
url.searchParams.set("code_challenge", request.codeChallenge);
|
|
289
|
+
url.searchParams.set("code_challenge_method", request.codeChallengeMethod);
|
|
290
|
+
const redirectUri = request.redirectUri || providerConfig.redirectUri;
|
|
291
|
+
if (redirectUri) {
|
|
292
|
+
url.searchParams.set("redirect_uri", redirectUri);
|
|
293
|
+
}
|
|
294
|
+
const response = await fetch(url.toString(), {
|
|
295
|
+
method: "GET",
|
|
296
|
+
headers: this.getHeaders()
|
|
297
|
+
});
|
|
298
|
+
if (!response.ok) {
|
|
299
|
+
const error = await response.text();
|
|
300
|
+
throw new Error(`MCP server failed to generate authorization URL: ${error}`);
|
|
301
|
+
}
|
|
302
|
+
const data = await response.json();
|
|
303
|
+
return data;
|
|
304
|
+
}
|
|
305
|
+
async handleCallback(request) {
|
|
306
|
+
const providerConfig = this.config.providers[request.provider];
|
|
307
|
+
if (!providerConfig) {
|
|
308
|
+
throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
309
|
+
}
|
|
310
|
+
if (!providerConfig.clientId || !providerConfig.clientSecret) {
|
|
311
|
+
throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
|
|
312
|
+
}
|
|
313
|
+
const url = new URL("/oauth/callback", this.serverUrl);
|
|
314
|
+
const response = await fetch(url.toString(), {
|
|
315
|
+
method: "POST",
|
|
316
|
+
headers: this.getHeaders({
|
|
317
|
+
"Content-Type": "application/json"
|
|
318
|
+
}),
|
|
319
|
+
body: JSON.stringify({
|
|
320
|
+
provider: request.provider,
|
|
321
|
+
code: request.code,
|
|
322
|
+
code_verifier: request.codeVerifier,
|
|
323
|
+
state: request.state,
|
|
324
|
+
client_id: providerConfig.clientId,
|
|
325
|
+
client_secret: providerConfig.clientSecret,
|
|
326
|
+
redirect_uri: providerConfig.redirectUri
|
|
327
|
+
})
|
|
328
|
+
});
|
|
329
|
+
if (!response.ok) {
|
|
330
|
+
const error = await response.text();
|
|
331
|
+
throw new Error(`MCP server failed to exchange authorization code: ${error}`);
|
|
332
|
+
}
|
|
333
|
+
const data = await response.json();
|
|
334
|
+
return data;
|
|
335
|
+
}
|
|
336
|
+
async handleStatus(provider, accessToken) {
|
|
337
|
+
const url = new URL("/oauth/status", this.serverUrl);
|
|
338
|
+
url.searchParams.set("provider", provider);
|
|
339
|
+
const response = await fetch(url.toString(), {
|
|
340
|
+
method: "GET",
|
|
341
|
+
headers: this.getHeaders({
|
|
342
|
+
Authorization: `Bearer ${accessToken}`
|
|
343
|
+
})
|
|
344
|
+
});
|
|
345
|
+
if (!response.ok) {
|
|
346
|
+
if (response.status === 401) {
|
|
347
|
+
return {
|
|
348
|
+
authorized: false
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const error = await response.text();
|
|
352
|
+
throw new Error(`MCP server failed to check authorization status: ${error}`);
|
|
353
|
+
}
|
|
354
|
+
const data = await response.json();
|
|
355
|
+
return data;
|
|
356
|
+
}
|
|
357
|
+
async handleDisconnect(request, accessToken) {
|
|
358
|
+
if (!accessToken) {
|
|
359
|
+
throw new Error("No access token provided. Cannot disconnect provider.");
|
|
360
|
+
}
|
|
361
|
+
const url = new URL("/oauth/disconnect", this.serverUrl);
|
|
362
|
+
const response = await fetch(url.toString(), {
|
|
363
|
+
method: "POST",
|
|
364
|
+
headers: this.getHeaders({
|
|
365
|
+
"Content-Type": "application/json",
|
|
366
|
+
Authorization: `Bearer ${accessToken}`
|
|
367
|
+
}),
|
|
368
|
+
body: JSON.stringify({
|
|
369
|
+
provider: request.provider
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
if (!response.ok) {
|
|
373
|
+
const error = await response.text();
|
|
374
|
+
throw new Error(`MCP server failed to disconnect provider: ${error}`);
|
|
375
|
+
}
|
|
376
|
+
const data = await response.json();
|
|
377
|
+
return data;
|
|
378
|
+
}
|
|
379
|
+
async handleToolCall(request, authHeader) {
|
|
380
|
+
const url = new URL("/tools/call", this.serverUrl);
|
|
381
|
+
const headers = this.getHeaders({
|
|
382
|
+
"Content-Type": "application/json"
|
|
383
|
+
});
|
|
384
|
+
if (authHeader && authHeader.startsWith("Bearer ")) {
|
|
385
|
+
headers["Authorization"] = authHeader;
|
|
386
|
+
}
|
|
387
|
+
const jsonRpcRequest = {
|
|
388
|
+
jsonrpc: "2.0",
|
|
389
|
+
id: Date.now() + Math.random(),
|
|
390
|
+
method: "tools/call",
|
|
391
|
+
params: {
|
|
392
|
+
name: request.name,
|
|
393
|
+
arguments: request.arguments || {}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
const response = await fetch(url.toString(), {
|
|
397
|
+
method: "POST",
|
|
398
|
+
headers,
|
|
399
|
+
body: JSON.stringify(jsonRpcRequest)
|
|
400
|
+
});
|
|
401
|
+
if (!response.ok) {
|
|
402
|
+
const error = await response.text();
|
|
403
|
+
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
|
404
|
+
}
|
|
405
|
+
const jsonRpcResponse = await response.json();
|
|
406
|
+
if (jsonRpcResponse.error) {
|
|
407
|
+
const error = new Error(jsonRpcResponse.error.message || "Tool call failed");
|
|
408
|
+
error.code = jsonRpcResponse.error.code;
|
|
409
|
+
error.data = jsonRpcResponse.error.data;
|
|
410
|
+
throw error;
|
|
411
|
+
}
|
|
412
|
+
return jsonRpcResponse.result;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
|
|
416
|
+
|
|
247
417
|
// src/protocol/jsonrpc.ts
|
|
248
418
|
function parseMessage(message) {
|
|
249
419
|
try {
|
|
@@ -1014,6 +1184,7 @@ class MCPClient {
|
|
|
1014
1184
|
connecting = null;
|
|
1015
1185
|
oauthManager;
|
|
1016
1186
|
eventEmitter = new SimpleEventEmitter;
|
|
1187
|
+
apiRouteBase;
|
|
1017
1188
|
github;
|
|
1018
1189
|
gmail;
|
|
1019
1190
|
server;
|
|
@@ -1025,6 +1196,7 @@ class MCPClient {
|
|
|
1025
1196
|
});
|
|
1026
1197
|
const oauthApiBase = config.oauthApiBase || "/api/integrate/oauth";
|
|
1027
1198
|
const defaultRedirectUri = this.getDefaultRedirectUri(oauthApiBase);
|
|
1199
|
+
this.apiRouteBase = config.apiRouteBase || "/api/integrate";
|
|
1028
1200
|
this.plugins = config.plugins.map((plugin) => {
|
|
1029
1201
|
if (plugin.oauth && !plugin.oauth.redirectUri) {
|
|
1030
1202
|
return {
|
|
@@ -1116,12 +1288,8 @@ class MCPClient {
|
|
|
1116
1288
|
if (!this.availableTools.has(name)) {
|
|
1117
1289
|
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
1118
1290
|
}
|
|
1119
|
-
const params = {
|
|
1120
|
-
name,
|
|
1121
|
-
arguments: args
|
|
1122
|
-
};
|
|
1123
1291
|
try {
|
|
1124
|
-
const response = await this.
|
|
1292
|
+
const response = await this.callToolThroughHandler(name, args);
|
|
1125
1293
|
return response;
|
|
1126
1294
|
} catch (error) {
|
|
1127
1295
|
const parsedError = parseServerError(error, { toolName: name });
|
|
@@ -1180,18 +1348,58 @@ class MCPClient {
|
|
|
1180
1348
|
if (!this.availableTools.has(name)) {
|
|
1181
1349
|
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
1182
1350
|
}
|
|
1183
|
-
const params = {
|
|
1184
|
-
name,
|
|
1185
|
-
arguments: args
|
|
1186
|
-
};
|
|
1187
1351
|
try {
|
|
1188
|
-
const response = await this.
|
|
1352
|
+
const response = await this.callToolThroughHandler(name, args);
|
|
1189
1353
|
return response;
|
|
1190
1354
|
} catch (error) {
|
|
1191
1355
|
const parsedError = parseServerError(error, { toolName: name });
|
|
1192
1356
|
throw parsedError;
|
|
1193
1357
|
}
|
|
1194
1358
|
}
|
|
1359
|
+
async callToolThroughHandler(name, args, provider) {
|
|
1360
|
+
const url = `${this.apiRouteBase}/mcp`;
|
|
1361
|
+
const headers = {
|
|
1362
|
+
"Content-Type": "application/json"
|
|
1363
|
+
};
|
|
1364
|
+
if (provider) {
|
|
1365
|
+
const tokenData = this.oauthManager.getProviderToken(provider);
|
|
1366
|
+
if (tokenData) {
|
|
1367
|
+
headers["Authorization"] = `Bearer ${tokenData.accessToken}`;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
const response = await fetch(url, {
|
|
1371
|
+
method: "POST",
|
|
1372
|
+
headers,
|
|
1373
|
+
body: JSON.stringify({
|
|
1374
|
+
name,
|
|
1375
|
+
arguments: args
|
|
1376
|
+
})
|
|
1377
|
+
});
|
|
1378
|
+
if (!response.ok) {
|
|
1379
|
+
let errorMessage = `Request failed: ${response.statusText}`;
|
|
1380
|
+
const error = new Error(errorMessage);
|
|
1381
|
+
error.statusCode = response.status;
|
|
1382
|
+
try {
|
|
1383
|
+
const errorData = await response.json();
|
|
1384
|
+
if (errorData.error) {
|
|
1385
|
+
errorMessage = typeof errorData.error === "string" ? errorData.error : errorData.error.message || errorMessage;
|
|
1386
|
+
error.message = errorMessage;
|
|
1387
|
+
}
|
|
1388
|
+
if (errorData.code) {
|
|
1389
|
+
error.code = errorData.code;
|
|
1390
|
+
}
|
|
1391
|
+
if (errorData.data) {
|
|
1392
|
+
error.data = errorData.data;
|
|
1393
|
+
}
|
|
1394
|
+
if (errorData.error && typeof errorData.error === "object") {
|
|
1395
|
+
error.jsonrpcError = errorData.error;
|
|
1396
|
+
}
|
|
1397
|
+
} catch {}
|
|
1398
|
+
throw error;
|
|
1399
|
+
}
|
|
1400
|
+
const result = await response.json();
|
|
1401
|
+
return result;
|
|
1402
|
+
}
|
|
1195
1403
|
async callToolWithRetry(name, args, retryCount = 0) {
|
|
1196
1404
|
if (!this.initialized) {
|
|
1197
1405
|
throw new Error("Client not initialized. Call connect() first.");
|
|
@@ -1203,35 +1411,24 @@ class MCPClient {
|
|
|
1203
1411
|
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
1204
1412
|
}
|
|
1205
1413
|
const provider = this.getProviderForTool(name);
|
|
1206
|
-
if (provider) {
|
|
1207
|
-
const tokenData = this.oauthManager.getProviderToken(provider);
|
|
1208
|
-
if (tokenData) {
|
|
1209
|
-
this.transport.setHeader("Authorization", `Bearer ${tokenData.accessToken}`);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
const params = {
|
|
1213
|
-
name,
|
|
1214
|
-
arguments: args
|
|
1215
|
-
};
|
|
1216
1414
|
try {
|
|
1217
|
-
const response = await this.
|
|
1415
|
+
const response = await this.callToolThroughHandler(name, args, provider);
|
|
1218
1416
|
if (provider) {
|
|
1219
1417
|
this.authState.set(provider, { authenticated: true });
|
|
1220
1418
|
}
|
|
1221
1419
|
return response;
|
|
1222
1420
|
} catch (error) {
|
|
1223
|
-
const
|
|
1224
|
-
const parsedError = parseServerError(error, { toolName: name, provider: provider2 });
|
|
1421
|
+
const parsedError = parseServerError(error, { toolName: name, provider });
|
|
1225
1422
|
if (isAuthError(parsedError) && retryCount < this.maxReauthRetries) {
|
|
1226
|
-
if (
|
|
1227
|
-
this.authState.set(
|
|
1423
|
+
if (provider) {
|
|
1424
|
+
this.authState.set(provider, {
|
|
1228
1425
|
authenticated: false,
|
|
1229
1426
|
lastError: parsedError
|
|
1230
1427
|
});
|
|
1231
1428
|
}
|
|
1232
|
-
if (this.onReauthRequired &&
|
|
1429
|
+
if (this.onReauthRequired && provider) {
|
|
1233
1430
|
const reauthSuccess = await this.onReauthRequired({
|
|
1234
|
-
provider
|
|
1431
|
+
provider,
|
|
1235
1432
|
error: parsedError,
|
|
1236
1433
|
toolName: name
|
|
1237
1434
|
});
|
|
@@ -1556,137 +1753,6 @@ async function clearClientCache() {
|
|
|
1556
1753
|
}));
|
|
1557
1754
|
}
|
|
1558
1755
|
|
|
1559
|
-
// src/adapters/base-handler.ts
|
|
1560
|
-
var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
|
|
1561
|
-
|
|
1562
|
-
class OAuthHandler {
|
|
1563
|
-
config;
|
|
1564
|
-
serverUrl;
|
|
1565
|
-
apiKey;
|
|
1566
|
-
constructor(config) {
|
|
1567
|
-
this.config = config;
|
|
1568
|
-
if (!config || !config.providers) {
|
|
1569
|
-
throw new Error("OAuthHandler requires a valid config with providers");
|
|
1570
|
-
}
|
|
1571
|
-
this.serverUrl = config.serverUrl || MCP_SERVER_URL2;
|
|
1572
|
-
this.apiKey = config.apiKey;
|
|
1573
|
-
}
|
|
1574
|
-
getHeaders(additionalHeaders) {
|
|
1575
|
-
const headers = {
|
|
1576
|
-
...additionalHeaders
|
|
1577
|
-
};
|
|
1578
|
-
if (this.apiKey) {
|
|
1579
|
-
headers["X-API-KEY"] = this.apiKey;
|
|
1580
|
-
}
|
|
1581
|
-
return headers;
|
|
1582
|
-
}
|
|
1583
|
-
async handleAuthorize(request) {
|
|
1584
|
-
const providerConfig = this.config.providers[request.provider];
|
|
1585
|
-
if (!providerConfig) {
|
|
1586
|
-
throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
1587
|
-
}
|
|
1588
|
-
if (!providerConfig.clientId || !providerConfig.clientSecret) {
|
|
1589
|
-
throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
|
|
1590
|
-
}
|
|
1591
|
-
const url = new URL("/oauth/authorize", this.serverUrl);
|
|
1592
|
-
url.searchParams.set("provider", request.provider);
|
|
1593
|
-
url.searchParams.set("client_id", providerConfig.clientId);
|
|
1594
|
-
url.searchParams.set("client_secret", providerConfig.clientSecret);
|
|
1595
|
-
url.searchParams.set("scope", request.scopes.join(","));
|
|
1596
|
-
url.searchParams.set("state", request.state);
|
|
1597
|
-
url.searchParams.set("code_challenge", request.codeChallenge);
|
|
1598
|
-
url.searchParams.set("code_challenge_method", request.codeChallengeMethod);
|
|
1599
|
-
const redirectUri = request.redirectUri || providerConfig.redirectUri;
|
|
1600
|
-
if (redirectUri) {
|
|
1601
|
-
url.searchParams.set("redirect_uri", redirectUri);
|
|
1602
|
-
}
|
|
1603
|
-
const response = await fetch(url.toString(), {
|
|
1604
|
-
method: "GET",
|
|
1605
|
-
headers: this.getHeaders()
|
|
1606
|
-
});
|
|
1607
|
-
if (!response.ok) {
|
|
1608
|
-
const error = await response.text();
|
|
1609
|
-
throw new Error(`MCP server failed to generate authorization URL: ${error}`);
|
|
1610
|
-
}
|
|
1611
|
-
const data = await response.json();
|
|
1612
|
-
return data;
|
|
1613
|
-
}
|
|
1614
|
-
async handleCallback(request) {
|
|
1615
|
-
const providerConfig = this.config.providers[request.provider];
|
|
1616
|
-
if (!providerConfig) {
|
|
1617
|
-
throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
1618
|
-
}
|
|
1619
|
-
if (!providerConfig.clientId || !providerConfig.clientSecret) {
|
|
1620
|
-
throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
|
|
1621
|
-
}
|
|
1622
|
-
const url = new URL("/oauth/callback", this.serverUrl);
|
|
1623
|
-
const response = await fetch(url.toString(), {
|
|
1624
|
-
method: "POST",
|
|
1625
|
-
headers: this.getHeaders({
|
|
1626
|
-
"Content-Type": "application/json"
|
|
1627
|
-
}),
|
|
1628
|
-
body: JSON.stringify({
|
|
1629
|
-
provider: request.provider,
|
|
1630
|
-
code: request.code,
|
|
1631
|
-
code_verifier: request.codeVerifier,
|
|
1632
|
-
state: request.state,
|
|
1633
|
-
client_id: providerConfig.clientId,
|
|
1634
|
-
client_secret: providerConfig.clientSecret,
|
|
1635
|
-
redirect_uri: providerConfig.redirectUri
|
|
1636
|
-
})
|
|
1637
|
-
});
|
|
1638
|
-
if (!response.ok) {
|
|
1639
|
-
const error = await response.text();
|
|
1640
|
-
throw new Error(`MCP server failed to exchange authorization code: ${error}`);
|
|
1641
|
-
}
|
|
1642
|
-
const data = await response.json();
|
|
1643
|
-
return data;
|
|
1644
|
-
}
|
|
1645
|
-
async handleStatus(provider, accessToken) {
|
|
1646
|
-
const url = new URL("/oauth/status", this.serverUrl);
|
|
1647
|
-
url.searchParams.set("provider", provider);
|
|
1648
|
-
const response = await fetch(url.toString(), {
|
|
1649
|
-
method: "GET",
|
|
1650
|
-
headers: this.getHeaders({
|
|
1651
|
-
Authorization: `Bearer ${accessToken}`
|
|
1652
|
-
})
|
|
1653
|
-
});
|
|
1654
|
-
if (!response.ok) {
|
|
1655
|
-
if (response.status === 401) {
|
|
1656
|
-
return {
|
|
1657
|
-
authorized: false
|
|
1658
|
-
};
|
|
1659
|
-
}
|
|
1660
|
-
const error = await response.text();
|
|
1661
|
-
throw new Error(`MCP server failed to check authorization status: ${error}`);
|
|
1662
|
-
}
|
|
1663
|
-
const data = await response.json();
|
|
1664
|
-
return data;
|
|
1665
|
-
}
|
|
1666
|
-
async handleDisconnect(request, accessToken) {
|
|
1667
|
-
if (!accessToken) {
|
|
1668
|
-
throw new Error("No access token provided. Cannot disconnect provider.");
|
|
1669
|
-
}
|
|
1670
|
-
const url = new URL("/oauth/disconnect", this.serverUrl);
|
|
1671
|
-
const response = await fetch(url.toString(), {
|
|
1672
|
-
method: "POST",
|
|
1673
|
-
headers: this.getHeaders({
|
|
1674
|
-
"Content-Type": "application/json",
|
|
1675
|
-
Authorization: `Bearer ${accessToken}`
|
|
1676
|
-
}),
|
|
1677
|
-
body: JSON.stringify({
|
|
1678
|
-
provider: request.provider
|
|
1679
|
-
})
|
|
1680
|
-
});
|
|
1681
|
-
if (!response.ok) {
|
|
1682
|
-
const error = await response.text();
|
|
1683
|
-
throw new Error(`MCP server failed to disconnect provider: ${error}`);
|
|
1684
|
-
}
|
|
1685
|
-
const data = await response.json();
|
|
1686
|
-
return data;
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
1756
|
// src/adapters/nextjs.ts
|
|
1691
1757
|
function createNextOAuthHandler(config) {
|
|
1692
1758
|
const handler = new OAuthHandler(config);
|
|
@@ -1762,6 +1828,9 @@ function createNextOAuthHandler(config) {
|
|
|
1762
1828
|
if (action === "disconnect") {
|
|
1763
1829
|
return handlers.disconnect(req);
|
|
1764
1830
|
}
|
|
1831
|
+
if (action === "mcp") {
|
|
1832
|
+
return handlers.mcp(req);
|
|
1833
|
+
}
|
|
1765
1834
|
return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
|
|
1766
1835
|
},
|
|
1767
1836
|
async GET(req, context) {
|
|
@@ -1774,6 +1843,17 @@ function createNextOAuthHandler(config) {
|
|
|
1774
1843
|
}
|
|
1775
1844
|
};
|
|
1776
1845
|
},
|
|
1846
|
+
async mcp(req) {
|
|
1847
|
+
try {
|
|
1848
|
+
const body = await req.json();
|
|
1849
|
+
const authHeader = req.headers.get("authorization");
|
|
1850
|
+
const result = await handler.handleToolCall(body, authHeader);
|
|
1851
|
+
return Response.json(result);
|
|
1852
|
+
} catch (error) {
|
|
1853
|
+
console.error("[MCP Tool Call] Error:", error);
|
|
1854
|
+
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
1855
|
+
}
|
|
1856
|
+
},
|
|
1777
1857
|
toNextJsHandler(redirectConfig) {
|
|
1778
1858
|
const defaultRedirectUrl = redirectConfig?.redirectUrl || "/";
|
|
1779
1859
|
const errorRedirectUrl = redirectConfig?.errorRedirectUrl || "/auth-error";
|
|
@@ -1794,6 +1874,9 @@ function createNextOAuthHandler(config) {
|
|
|
1794
1874
|
}
|
|
1795
1875
|
return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
|
|
1796
1876
|
}
|
|
1877
|
+
if (segments.length === 1 && segments[0] === "mcp") {
|
|
1878
|
+
return handlers.mcp(req);
|
|
1879
|
+
}
|
|
1797
1880
|
return Response.json({ error: `Invalid route: /${segments.join("/")}` }, { status: 404 });
|
|
1798
1881
|
},
|
|
1799
1882
|
async GET(req, context) {
|
|
@@ -2086,6 +2169,23 @@ function createMCPServer(config) {
|
|
|
2086
2169
|
if (segments.length === 2 && segments[0] !== "oauth") {
|
|
2087
2170
|
return Response.json({ error: `Invalid route: /${segments.join("/")}` }, { status: 404 });
|
|
2088
2171
|
}
|
|
2172
|
+
if (segments.length === 1 && segments[0] === "mcp" && method === "POST") {
|
|
2173
|
+
try {
|
|
2174
|
+
const body = await request.json();
|
|
2175
|
+
const authHeader = request.headers.get("authorization");
|
|
2176
|
+
const { OAuthHandler: OAuthHandler2 } = await Promise.resolve().then(() => exports_base_handler);
|
|
2177
|
+
const oauthHandler = new OAuthHandler2({
|
|
2178
|
+
providers,
|
|
2179
|
+
serverUrl: config.serverUrl,
|
|
2180
|
+
apiKey: config.apiKey
|
|
2181
|
+
});
|
|
2182
|
+
const result = await oauthHandler.handleToolCall(body, authHeader);
|
|
2183
|
+
return Response.json(result);
|
|
2184
|
+
} catch (error) {
|
|
2185
|
+
console.error("[MCP Tool Call] Error:", error);
|
|
2186
|
+
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2089
2189
|
}
|
|
2090
2190
|
if (method === "GET" && action === "callback") {
|
|
2091
2191
|
const url = new URL(request.url);
|
|
@@ -85,6 +85,29 @@ export interface DisconnectResponse {
|
|
|
85
85
|
success: boolean;
|
|
86
86
|
provider: string;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Request body for MCP tool call endpoint
|
|
90
|
+
*/
|
|
91
|
+
export interface ToolCallRequest {
|
|
92
|
+
name: string;
|
|
93
|
+
arguments?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Response from MCP tool call endpoint
|
|
97
|
+
* Matches MCPToolCallResponse structure
|
|
98
|
+
*/
|
|
99
|
+
export interface ToolCallResponse {
|
|
100
|
+
content: Array<{
|
|
101
|
+
type: "text" | "image" | "resource";
|
|
102
|
+
text?: string;
|
|
103
|
+
data?: string;
|
|
104
|
+
mimeType?: string;
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}>;
|
|
107
|
+
isError?: boolean;
|
|
108
|
+
structuredContent?: Record<string, unknown>;
|
|
109
|
+
_meta?: Record<string, unknown>;
|
|
110
|
+
}
|
|
88
111
|
/**
|
|
89
112
|
* OAuth Handler
|
|
90
113
|
* Handles OAuth authorization flows by proxying requests to MCP server
|
|
@@ -144,5 +167,16 @@ export declare class OAuthHandler {
|
|
|
144
167
|
* @throws Error if MCP server request fails
|
|
145
168
|
*/
|
|
146
169
|
handleDisconnect(request: DisconnectRequest, accessToken: string): Promise<DisconnectResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Handle MCP tool call
|
|
172
|
+
* Forwards tool call requests to MCP server with API key and provider token
|
|
173
|
+
*
|
|
174
|
+
* @param request - Tool call request with name and arguments
|
|
175
|
+
* @param authHeader - Authorization header from client (Bearer token)
|
|
176
|
+
* @returns Tool call response
|
|
177
|
+
*
|
|
178
|
+
* @throws Error if MCP server request fails
|
|
179
|
+
*/
|
|
180
|
+
handleToolCall(request: ToolCallRequest, authHeader: string | null): Promise<ToolCallResponse>;
|
|
147
181
|
}
|
|
148
182
|
//# sourceMappingURL=base-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-handler.d.ts","sourceRoot":"","sources":["../../../src/adapters/base-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;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;KACtB,CAAC,CAAC;IACH;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE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,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4BpG;;;;;;;;;OASG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAiDrG"}
|
|
@@ -265,6 +265,31 @@ export declare function createNextOAuthHandler(config: OAuthHandlerConfig): {
|
|
|
265
265
|
}>;
|
|
266
266
|
}): Promise<NextResponse>;
|
|
267
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* POST /api/integrate/mcp
|
|
270
|
+
*
|
|
271
|
+
* Handle MCP tool call requests from client
|
|
272
|
+
*
|
|
273
|
+
* Request body:
|
|
274
|
+
* ```json
|
|
275
|
+
* {
|
|
276
|
+
* "name": "github_list_own_repos",
|
|
277
|
+
* "arguments": {}
|
|
278
|
+
* }
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* Headers:
|
|
282
|
+
* - Authorization: Bearer <provider_access_token>
|
|
283
|
+
*
|
|
284
|
+
* Response:
|
|
285
|
+
* ```json
|
|
286
|
+
* {
|
|
287
|
+
* "content": [{"type": "text", "text": "..."}],
|
|
288
|
+
* "isError": false
|
|
289
|
+
* }
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
mcp(req: NextRequest): Promise<NextResponse>;
|
|
268
293
|
/**
|
|
269
294
|
* Create unified catch-all route handler
|
|
270
295
|
*
|
|
@@ -299,6 +324,7 @@ export declare function createNextOAuthHandler(config: OAuthHandlerConfig): {
|
|
|
299
324
|
* - GET /api/integrate/oauth/callback - Provider OAuth redirect
|
|
300
325
|
* - GET /api/integrate/oauth/status - Check authorization status
|
|
301
326
|
* - POST /api/integrate/oauth/disconnect - Disconnect provider
|
|
327
|
+
* - POST /api/integrate/mcp - Execute MCP tool calls
|
|
302
328
|
*/
|
|
303
329
|
toNextJsHandler(redirectConfig?: {
|
|
304
330
|
/** URL to redirect to after OAuth callback (default: '/') */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../../../src/adapters/nextjs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,KAAK,WAAW,GAAG,GAAG,CAAC;AACvB,KAAK,YAAY,GAAG,GAAG,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB;IAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;mBACkB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAcxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;kBACiB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAcvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;gBACe,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA+BrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;oBACmB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAiCzD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;QAGC;;WAEG;kBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,GACpE,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../../../src/adapters/nextjs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,KAAK,WAA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BAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;QAKG;;WAEG;kBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC,CAAA;SAAE,GAClE,OAAO,CAAC,YAAY,CAAC;QAsCxB;;WAEG;iBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC,CAAA;SAAE,GAClE,OAAO,CAAC,YAAY,CAAC;;EA+F/B"}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
57
57
|
private connecting;
|
|
58
58
|
private oauthManager;
|
|
59
59
|
private eventEmitter;
|
|
60
|
+
private apiRouteBase;
|
|
60
61
|
readonly github: PluginNamespaces<TPlugins> extends {
|
|
61
62
|
github: GitHubPluginClient;
|
|
62
63
|
} ? GitHubPluginClient : never;
|
|
@@ -125,6 +126,11 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
125
126
|
* ```
|
|
126
127
|
*/
|
|
127
128
|
callServerTool(name: string, args?: Record<string, unknown>): Promise<MCPToolCallResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* Call a tool through the API handler (server-side route)
|
|
131
|
+
* Routes tool calls through /api/integrate/mcp instead of directly to MCP server
|
|
132
|
+
*/
|
|
133
|
+
private callToolThroughHandler;
|
|
128
134
|
/**
|
|
129
135
|
* Internal method to call a tool with retry logic
|
|
130
136
|
*/
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;GAG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