integrate-sdk 0.7.28 → 0.7.31
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/index.js +21 -10
- package/dist/adapters/solid-start.js +21 -10
- package/dist/adapters/svelte-kit.js +21 -10
- package/dist/index.d.ts +42 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -13
- package/dist/server.js +22 -11
- package/dist/src/client.d.ts +11 -8
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +38 -3
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/integrations/types.d.ts +5 -5
- package/dist/src/integrations/types.d.ts.map +1 -1
- package/dist/src/oauth/manager.d.ts +2 -1
- package/dist/src/oauth/manager.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/index.ts +53 -6
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -1113,8 +1113,10 @@ class OAuthManager {
|
|
|
1113
1113
|
windowManager;
|
|
1114
1114
|
flowConfig;
|
|
1115
1115
|
oauthApiBase;
|
|
1116
|
-
|
|
1116
|
+
apiBaseUrl;
|
|
1117
|
+
constructor(oauthApiBase, flowConfig, apiBaseUrl) {
|
|
1117
1118
|
this.oauthApiBase = oauthApiBase;
|
|
1119
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
1118
1120
|
this.windowManager = new OAuthWindowManager;
|
|
1119
1121
|
this.flowConfig = {
|
|
1120
1122
|
mode: flowConfig?.mode || "redirect",
|
|
@@ -1365,7 +1367,7 @@ class OAuthManager {
|
|
|
1365
1367
|
}
|
|
1366
1368
|
}
|
|
1367
1369
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
1368
|
-
const url = `${this.oauthApiBase}/authorize`;
|
|
1370
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/authorize` : `${this.oauthApiBase}/authorize`;
|
|
1369
1371
|
const response = await fetch(url, {
|
|
1370
1372
|
method: "POST",
|
|
1371
1373
|
headers: {
|
|
@@ -1388,7 +1390,7 @@ class OAuthManager {
|
|
|
1388
1390
|
return data.authorizationUrl;
|
|
1389
1391
|
}
|
|
1390
1392
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
1391
|
-
const url = `${this.oauthApiBase}/callback`;
|
|
1393
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/callback` : `${this.oauthApiBase}/callback`;
|
|
1392
1394
|
const response = await fetch(url, {
|
|
1393
1395
|
method: "POST",
|
|
1394
1396
|
headers: {
|
|
@@ -1451,7 +1453,7 @@ class SimpleEventEmitter {
|
|
|
1451
1453
|
var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
|
|
1452
1454
|
var clientCache = new Map;
|
|
1453
1455
|
var cleanupClients = new Set;
|
|
1454
|
-
class
|
|
1456
|
+
class MCPClientBase {
|
|
1455
1457
|
transport;
|
|
1456
1458
|
integrations;
|
|
1457
1459
|
availableTools = new Map;
|
|
@@ -1464,8 +1466,7 @@ class MCPClient {
|
|
|
1464
1466
|
oauthManager;
|
|
1465
1467
|
eventEmitter = new SimpleEventEmitter;
|
|
1466
1468
|
apiRouteBase;
|
|
1467
|
-
|
|
1468
|
-
gmail;
|
|
1469
|
+
apiBaseUrl;
|
|
1469
1470
|
server;
|
|
1470
1471
|
constructor(config) {
|
|
1471
1472
|
this.transport = new HttpSessionTransport({
|
|
@@ -1476,6 +1477,7 @@ class MCPClient {
|
|
|
1476
1477
|
const oauthApiBase = config.oauthApiBase || "/api/integrate/oauth";
|
|
1477
1478
|
const defaultRedirectUri = this.getDefaultRedirectUri(oauthApiBase);
|
|
1478
1479
|
this.apiRouteBase = config.apiRouteBase || "/api/integrate";
|
|
1480
|
+
this.apiBaseUrl = config.apiBaseUrl;
|
|
1479
1481
|
this.integrations = config.integrations.map((integration) => {
|
|
1480
1482
|
if (integration.oauth && !integration.oauth.redirectUri) {
|
|
1481
1483
|
return {
|
|
@@ -1494,7 +1496,7 @@ class MCPClient {
|
|
|
1494
1496
|
};
|
|
1495
1497
|
this.onReauthRequired = config.onReauthRequired;
|
|
1496
1498
|
this.maxReauthRetries = config.maxReauthRetries ?? 1;
|
|
1497
|
-
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow);
|
|
1499
|
+
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow, this.apiBaseUrl);
|
|
1498
1500
|
const providers = this.integrations.filter((p) => p.oauth).map((p) => p.oauth.provider);
|
|
1499
1501
|
this.oauthManager.loadAllProviderTokens(providers);
|
|
1500
1502
|
for (const integration of this.integrations) {
|
|
@@ -1506,8 +1508,13 @@ class MCPClient {
|
|
|
1506
1508
|
this.authState.set(integration.oauth.provider, { authenticated: hasToken });
|
|
1507
1509
|
}
|
|
1508
1510
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
+
const integrationIds = this.integrations.map((i) => i.id);
|
|
1512
|
+
if (integrationIds.includes("github")) {
|
|
1513
|
+
this.github = this.createIntegrationProxy("github");
|
|
1514
|
+
}
|
|
1515
|
+
if (integrationIds.includes("gmail")) {
|
|
1516
|
+
this.gmail = this.createIntegrationProxy("gmail");
|
|
1517
|
+
}
|
|
1511
1518
|
this.server = this.createServerProxy();
|
|
1512
1519
|
this.initializeIntegrations();
|
|
1513
1520
|
}
|
|
@@ -1520,6 +1527,10 @@ class MCPClient {
|
|
|
1520
1527
|
return `${origin}${normalizedPath}/callback`;
|
|
1521
1528
|
}
|
|
1522
1529
|
createIntegrationProxy(integrationId) {
|
|
1530
|
+
const hasIntegration = this.integrations.some((integration) => integration.id === integrationId);
|
|
1531
|
+
if (!hasIntegration) {
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1523
1534
|
return new Proxy({}, {
|
|
1524
1535
|
get: (_target, methodName) => {
|
|
1525
1536
|
return async (args) => {
|
|
@@ -1633,7 +1644,7 @@ class MCPClient {
|
|
|
1633
1644
|
});
|
|
1634
1645
|
return result2;
|
|
1635
1646
|
}
|
|
1636
|
-
const url = `${this.apiRouteBase}/mcp`;
|
|
1647
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
|
|
1637
1648
|
const headers = {
|
|
1638
1649
|
"Content-Type": "application/json"
|
|
1639
1650
|
};
|
|
@@ -978,8 +978,10 @@ class OAuthManager {
|
|
|
978
978
|
windowManager;
|
|
979
979
|
flowConfig;
|
|
980
980
|
oauthApiBase;
|
|
981
|
-
|
|
981
|
+
apiBaseUrl;
|
|
982
|
+
constructor(oauthApiBase, flowConfig, apiBaseUrl) {
|
|
982
983
|
this.oauthApiBase = oauthApiBase;
|
|
984
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
983
985
|
this.windowManager = new OAuthWindowManager;
|
|
984
986
|
this.flowConfig = {
|
|
985
987
|
mode: flowConfig?.mode || "redirect",
|
|
@@ -1230,7 +1232,7 @@ class OAuthManager {
|
|
|
1230
1232
|
}
|
|
1231
1233
|
}
|
|
1232
1234
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
1233
|
-
const url = `${this.oauthApiBase}/authorize`;
|
|
1235
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/authorize` : `${this.oauthApiBase}/authorize`;
|
|
1234
1236
|
const response = await fetch(url, {
|
|
1235
1237
|
method: "POST",
|
|
1236
1238
|
headers: {
|
|
@@ -1253,7 +1255,7 @@ class OAuthManager {
|
|
|
1253
1255
|
return data.authorizationUrl;
|
|
1254
1256
|
}
|
|
1255
1257
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
1256
|
-
const url = `${this.oauthApiBase}/callback`;
|
|
1258
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/callback` : `${this.oauthApiBase}/callback`;
|
|
1257
1259
|
const response = await fetch(url, {
|
|
1258
1260
|
method: "POST",
|
|
1259
1261
|
headers: {
|
|
@@ -1316,7 +1318,7 @@ class SimpleEventEmitter {
|
|
|
1316
1318
|
var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
|
|
1317
1319
|
var clientCache = new Map;
|
|
1318
1320
|
var cleanupClients = new Set;
|
|
1319
|
-
class
|
|
1321
|
+
class MCPClientBase {
|
|
1320
1322
|
transport;
|
|
1321
1323
|
integrations;
|
|
1322
1324
|
availableTools = new Map;
|
|
@@ -1329,8 +1331,7 @@ class MCPClient {
|
|
|
1329
1331
|
oauthManager;
|
|
1330
1332
|
eventEmitter = new SimpleEventEmitter;
|
|
1331
1333
|
apiRouteBase;
|
|
1332
|
-
|
|
1333
|
-
gmail;
|
|
1334
|
+
apiBaseUrl;
|
|
1334
1335
|
server;
|
|
1335
1336
|
constructor(config) {
|
|
1336
1337
|
this.transport = new HttpSessionTransport({
|
|
@@ -1341,6 +1342,7 @@ class MCPClient {
|
|
|
1341
1342
|
const oauthApiBase = config.oauthApiBase || "/api/integrate/oauth";
|
|
1342
1343
|
const defaultRedirectUri = this.getDefaultRedirectUri(oauthApiBase);
|
|
1343
1344
|
this.apiRouteBase = config.apiRouteBase || "/api/integrate";
|
|
1345
|
+
this.apiBaseUrl = config.apiBaseUrl;
|
|
1344
1346
|
this.integrations = config.integrations.map((integration) => {
|
|
1345
1347
|
if (integration.oauth && !integration.oauth.redirectUri) {
|
|
1346
1348
|
return {
|
|
@@ -1359,7 +1361,7 @@ class MCPClient {
|
|
|
1359
1361
|
};
|
|
1360
1362
|
this.onReauthRequired = config.onReauthRequired;
|
|
1361
1363
|
this.maxReauthRetries = config.maxReauthRetries ?? 1;
|
|
1362
|
-
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow);
|
|
1364
|
+
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow, this.apiBaseUrl);
|
|
1363
1365
|
const providers = this.integrations.filter((p) => p.oauth).map((p) => p.oauth.provider);
|
|
1364
1366
|
this.oauthManager.loadAllProviderTokens(providers);
|
|
1365
1367
|
for (const integration of this.integrations) {
|
|
@@ -1371,8 +1373,13 @@ class MCPClient {
|
|
|
1371
1373
|
this.authState.set(integration.oauth.provider, { authenticated: hasToken });
|
|
1372
1374
|
}
|
|
1373
1375
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
+
const integrationIds = this.integrations.map((i) => i.id);
|
|
1377
|
+
if (integrationIds.includes("github")) {
|
|
1378
|
+
this.github = this.createIntegrationProxy("github");
|
|
1379
|
+
}
|
|
1380
|
+
if (integrationIds.includes("gmail")) {
|
|
1381
|
+
this.gmail = this.createIntegrationProxy("gmail");
|
|
1382
|
+
}
|
|
1376
1383
|
this.server = this.createServerProxy();
|
|
1377
1384
|
this.initializeIntegrations();
|
|
1378
1385
|
}
|
|
@@ -1385,6 +1392,10 @@ class MCPClient {
|
|
|
1385
1392
|
return `${origin}${normalizedPath}/callback`;
|
|
1386
1393
|
}
|
|
1387
1394
|
createIntegrationProxy(integrationId) {
|
|
1395
|
+
const hasIntegration = this.integrations.some((integration) => integration.id === integrationId);
|
|
1396
|
+
if (!hasIntegration) {
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1388
1399
|
return new Proxy({}, {
|
|
1389
1400
|
get: (_target, methodName) => {
|
|
1390
1401
|
return async (args) => {
|
|
@@ -1498,7 +1509,7 @@ class MCPClient {
|
|
|
1498
1509
|
});
|
|
1499
1510
|
return result2;
|
|
1500
1511
|
}
|
|
1501
|
-
const url = `${this.apiRouteBase}/mcp`;
|
|
1512
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
|
|
1502
1513
|
const headers = {
|
|
1503
1514
|
"Content-Type": "application/json"
|
|
1504
1515
|
};
|
|
@@ -978,8 +978,10 @@ class OAuthManager {
|
|
|
978
978
|
windowManager;
|
|
979
979
|
flowConfig;
|
|
980
980
|
oauthApiBase;
|
|
981
|
-
|
|
981
|
+
apiBaseUrl;
|
|
982
|
+
constructor(oauthApiBase, flowConfig, apiBaseUrl) {
|
|
982
983
|
this.oauthApiBase = oauthApiBase;
|
|
984
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
983
985
|
this.windowManager = new OAuthWindowManager;
|
|
984
986
|
this.flowConfig = {
|
|
985
987
|
mode: flowConfig?.mode || "redirect",
|
|
@@ -1230,7 +1232,7 @@ class OAuthManager {
|
|
|
1230
1232
|
}
|
|
1231
1233
|
}
|
|
1232
1234
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
1233
|
-
const url = `${this.oauthApiBase}/authorize`;
|
|
1235
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/authorize` : `${this.oauthApiBase}/authorize`;
|
|
1234
1236
|
const response = await fetch(url, {
|
|
1235
1237
|
method: "POST",
|
|
1236
1238
|
headers: {
|
|
@@ -1253,7 +1255,7 @@ class OAuthManager {
|
|
|
1253
1255
|
return data.authorizationUrl;
|
|
1254
1256
|
}
|
|
1255
1257
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
1256
|
-
const url = `${this.oauthApiBase}/callback`;
|
|
1258
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/callback` : `${this.oauthApiBase}/callback`;
|
|
1257
1259
|
const response = await fetch(url, {
|
|
1258
1260
|
method: "POST",
|
|
1259
1261
|
headers: {
|
|
@@ -1316,7 +1318,7 @@ class SimpleEventEmitter {
|
|
|
1316
1318
|
var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
|
|
1317
1319
|
var clientCache = new Map;
|
|
1318
1320
|
var cleanupClients = new Set;
|
|
1319
|
-
class
|
|
1321
|
+
class MCPClientBase {
|
|
1320
1322
|
transport;
|
|
1321
1323
|
integrations;
|
|
1322
1324
|
availableTools = new Map;
|
|
@@ -1329,8 +1331,7 @@ class MCPClient {
|
|
|
1329
1331
|
oauthManager;
|
|
1330
1332
|
eventEmitter = new SimpleEventEmitter;
|
|
1331
1333
|
apiRouteBase;
|
|
1332
|
-
|
|
1333
|
-
gmail;
|
|
1334
|
+
apiBaseUrl;
|
|
1334
1335
|
server;
|
|
1335
1336
|
constructor(config) {
|
|
1336
1337
|
this.transport = new HttpSessionTransport({
|
|
@@ -1341,6 +1342,7 @@ class MCPClient {
|
|
|
1341
1342
|
const oauthApiBase = config.oauthApiBase || "/api/integrate/oauth";
|
|
1342
1343
|
const defaultRedirectUri = this.getDefaultRedirectUri(oauthApiBase);
|
|
1343
1344
|
this.apiRouteBase = config.apiRouteBase || "/api/integrate";
|
|
1345
|
+
this.apiBaseUrl = config.apiBaseUrl;
|
|
1344
1346
|
this.integrations = config.integrations.map((integration) => {
|
|
1345
1347
|
if (integration.oauth && !integration.oauth.redirectUri) {
|
|
1346
1348
|
return {
|
|
@@ -1359,7 +1361,7 @@ class MCPClient {
|
|
|
1359
1361
|
};
|
|
1360
1362
|
this.onReauthRequired = config.onReauthRequired;
|
|
1361
1363
|
this.maxReauthRetries = config.maxReauthRetries ?? 1;
|
|
1362
|
-
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow);
|
|
1364
|
+
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow, this.apiBaseUrl);
|
|
1363
1365
|
const providers = this.integrations.filter((p) => p.oauth).map((p) => p.oauth.provider);
|
|
1364
1366
|
this.oauthManager.loadAllProviderTokens(providers);
|
|
1365
1367
|
for (const integration of this.integrations) {
|
|
@@ -1371,8 +1373,13 @@ class MCPClient {
|
|
|
1371
1373
|
this.authState.set(integration.oauth.provider, { authenticated: hasToken });
|
|
1372
1374
|
}
|
|
1373
1375
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
+
const integrationIds = this.integrations.map((i) => i.id);
|
|
1377
|
+
if (integrationIds.includes("github")) {
|
|
1378
|
+
this.github = this.createIntegrationProxy("github");
|
|
1379
|
+
}
|
|
1380
|
+
if (integrationIds.includes("gmail")) {
|
|
1381
|
+
this.gmail = this.createIntegrationProxy("gmail");
|
|
1382
|
+
}
|
|
1376
1383
|
this.server = this.createServerProxy();
|
|
1377
1384
|
this.initializeIntegrations();
|
|
1378
1385
|
}
|
|
@@ -1385,6 +1392,10 @@ class MCPClient {
|
|
|
1385
1392
|
return `${origin}${normalizedPath}/callback`;
|
|
1386
1393
|
}
|
|
1387
1394
|
createIntegrationProxy(integrationId) {
|
|
1395
|
+
const hasIntegration = this.integrations.some((integration) => integration.id === integrationId);
|
|
1396
|
+
if (!hasIntegration) {
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1388
1399
|
return new Proxy({}, {
|
|
1389
1400
|
get: (_target, methodName) => {
|
|
1390
1401
|
return async (args) => {
|
|
@@ -1498,7 +1509,7 @@ class MCPClient {
|
|
|
1498
1509
|
});
|
|
1499
1510
|
return result2;
|
|
1500
1511
|
}
|
|
1501
|
-
const url = `${this.apiRouteBase}/mcp`;
|
|
1512
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
|
|
1502
1513
|
const headers = {
|
|
1503
1514
|
"Content-Type": "application/json"
|
|
1504
1515
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,16 +5,52 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
+
* // Use the default client with all integrations
|
|
9
|
+
* import { client } from 'integrate-sdk';
|
|
10
|
+
*
|
|
11
|
+
* await client.github.listOwnRepos({});
|
|
12
|
+
*
|
|
13
|
+
* // Or create a custom client with different API configuration
|
|
8
14
|
* import { createMCPClient, githubIntegration } from 'integrate-sdk';
|
|
9
15
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* // Example 1: Different API path (same origin)
|
|
17
|
+
* const customClient = createMCPClient({
|
|
18
|
+
* apiRouteBase: '/custom/api/path', // Calls /custom/api/path/mcp
|
|
19
|
+
* integrations: [githubIntegration()],
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Example 2: Different API domain (cross-origin)
|
|
23
|
+
* const crossOriginClient = createMCPClient({
|
|
24
|
+
* apiBaseUrl: 'https://api.example.com', // API on different domain
|
|
25
|
+
* apiRouteBase: '/api/integrate', // Calls https://api.example.com/api/integrate/mcp
|
|
26
|
+
* integrations: [githubIntegration()],
|
|
16
27
|
* });
|
|
17
28
|
* ```
|
|
18
29
|
*/
|
|
19
30
|
export * from './src/index.js';
|
|
31
|
+
/**
|
|
32
|
+
* Default MCP Client with all integrations pre-configured
|
|
33
|
+
*
|
|
34
|
+
* This is a singleton client instance that includes GitHub and Gmail integrations.
|
|
35
|
+
* You can use it directly without having to configure integrations.
|
|
36
|
+
*
|
|
37
|
+
* Default configuration:
|
|
38
|
+
* - Calls API routes at: {window.location.origin}/api/integrate/mcp
|
|
39
|
+
* - OAuth routes at: {window.location.origin}/api/integrate/oauth/*
|
|
40
|
+
*
|
|
41
|
+
* For custom configuration (different apiBaseUrl, apiRouteBase, etc.),
|
|
42
|
+
* use `createMCPClient()` instead.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { client } from 'integrate-sdk';
|
|
47
|
+
*
|
|
48
|
+
* // Use GitHub integration
|
|
49
|
+
* const repos = await client.github.listOwnRepos({});
|
|
50
|
+
*
|
|
51
|
+
* // Use Gmail integration
|
|
52
|
+
* const messages = await client.gmail.listMessages({});
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const client: import("./index.js").MCPClient<import("./index.js").MCPIntegration[]>;
|
|
20
56
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,cAAc,gBAAgB,CAAC;AAO/B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,MAAM,uEAKjB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -825,8 +825,10 @@ class OAuthManager {
|
|
|
825
825
|
windowManager;
|
|
826
826
|
flowConfig;
|
|
827
827
|
oauthApiBase;
|
|
828
|
-
|
|
828
|
+
apiBaseUrl;
|
|
829
|
+
constructor(oauthApiBase, flowConfig, apiBaseUrl) {
|
|
829
830
|
this.oauthApiBase = oauthApiBase;
|
|
831
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
830
832
|
this.windowManager = new OAuthWindowManager;
|
|
831
833
|
this.flowConfig = {
|
|
832
834
|
mode: flowConfig?.mode || "redirect",
|
|
@@ -1077,7 +1079,7 @@ class OAuthManager {
|
|
|
1077
1079
|
}
|
|
1078
1080
|
}
|
|
1079
1081
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
1080
|
-
const url = `${this.oauthApiBase}/authorize`;
|
|
1082
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/authorize` : `${this.oauthApiBase}/authorize`;
|
|
1081
1083
|
const response = await fetch(url, {
|
|
1082
1084
|
method: "POST",
|
|
1083
1085
|
headers: {
|
|
@@ -1100,7 +1102,7 @@ class OAuthManager {
|
|
|
1100
1102
|
return data.authorizationUrl;
|
|
1101
1103
|
}
|
|
1102
1104
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
1103
|
-
const url = `${this.oauthApiBase}/callback`;
|
|
1105
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/callback` : `${this.oauthApiBase}/callback`;
|
|
1104
1106
|
const response = await fetch(url, {
|
|
1105
1107
|
method: "POST",
|
|
1106
1108
|
headers: {
|
|
@@ -1165,7 +1167,7 @@ var clientCache = new Map;
|
|
|
1165
1167
|
var cleanupClients = new Set;
|
|
1166
1168
|
var cleanupHandlersRegistered = false;
|
|
1167
1169
|
|
|
1168
|
-
class
|
|
1170
|
+
class MCPClientBase {
|
|
1169
1171
|
transport;
|
|
1170
1172
|
integrations;
|
|
1171
1173
|
availableTools = new Map;
|
|
@@ -1178,8 +1180,7 @@ class MCPClient {
|
|
|
1178
1180
|
oauthManager;
|
|
1179
1181
|
eventEmitter = new SimpleEventEmitter;
|
|
1180
1182
|
apiRouteBase;
|
|
1181
|
-
|
|
1182
|
-
gmail;
|
|
1183
|
+
apiBaseUrl;
|
|
1183
1184
|
server;
|
|
1184
1185
|
constructor(config) {
|
|
1185
1186
|
this.transport = new HttpSessionTransport({
|
|
@@ -1190,6 +1191,7 @@ class MCPClient {
|
|
|
1190
1191
|
const oauthApiBase = config.oauthApiBase || "/api/integrate/oauth";
|
|
1191
1192
|
const defaultRedirectUri = this.getDefaultRedirectUri(oauthApiBase);
|
|
1192
1193
|
this.apiRouteBase = config.apiRouteBase || "/api/integrate";
|
|
1194
|
+
this.apiBaseUrl = config.apiBaseUrl;
|
|
1193
1195
|
this.integrations = config.integrations.map((integration) => {
|
|
1194
1196
|
if (integration.oauth && !integration.oauth.redirectUri) {
|
|
1195
1197
|
return {
|
|
@@ -1208,7 +1210,7 @@ class MCPClient {
|
|
|
1208
1210
|
};
|
|
1209
1211
|
this.onReauthRequired = config.onReauthRequired;
|
|
1210
1212
|
this.maxReauthRetries = config.maxReauthRetries ?? 1;
|
|
1211
|
-
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow);
|
|
1213
|
+
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow, this.apiBaseUrl);
|
|
1212
1214
|
const providers = this.integrations.filter((p) => p.oauth).map((p) => p.oauth.provider);
|
|
1213
1215
|
this.oauthManager.loadAllProviderTokens(providers);
|
|
1214
1216
|
for (const integration of this.integrations) {
|
|
@@ -1220,8 +1222,13 @@ class MCPClient {
|
|
|
1220
1222
|
this.authState.set(integration.oauth.provider, { authenticated: hasToken });
|
|
1221
1223
|
}
|
|
1222
1224
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
+
const integrationIds = this.integrations.map((i) => i.id);
|
|
1226
|
+
if (integrationIds.includes("github")) {
|
|
1227
|
+
this.github = this.createIntegrationProxy("github");
|
|
1228
|
+
}
|
|
1229
|
+
if (integrationIds.includes("gmail")) {
|
|
1230
|
+
this.gmail = this.createIntegrationProxy("gmail");
|
|
1231
|
+
}
|
|
1225
1232
|
this.server = this.createServerProxy();
|
|
1226
1233
|
this.initializeIntegrations();
|
|
1227
1234
|
}
|
|
@@ -1234,6 +1241,10 @@ class MCPClient {
|
|
|
1234
1241
|
return `${origin}${normalizedPath}/callback`;
|
|
1235
1242
|
}
|
|
1236
1243
|
createIntegrationProxy(integrationId) {
|
|
1244
|
+
const hasIntegration = this.integrations.some((integration) => integration.id === integrationId);
|
|
1245
|
+
if (!hasIntegration) {
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1237
1248
|
return new Proxy({}, {
|
|
1238
1249
|
get: (_target, methodName) => {
|
|
1239
1250
|
return async (args) => {
|
|
@@ -1347,7 +1358,7 @@ class MCPClient {
|
|
|
1347
1358
|
});
|
|
1348
1359
|
return result2;
|
|
1349
1360
|
}
|
|
1350
|
-
const url = `${this.apiRouteBase}/mcp`;
|
|
1361
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
|
|
1351
1362
|
const headers = {
|
|
1352
1363
|
"Content-Type": "application/json"
|
|
1353
1364
|
};
|
|
@@ -1670,7 +1681,7 @@ function createMCPClient(config) {
|
|
|
1670
1681
|
clientCache.delete(cacheKey);
|
|
1671
1682
|
cleanupClients.delete(existing);
|
|
1672
1683
|
}
|
|
1673
|
-
const client = new
|
|
1684
|
+
const client = new MCPClientBase(config);
|
|
1674
1685
|
clientCache.set(cacheKey, client);
|
|
1675
1686
|
if (autoCleanup) {
|
|
1676
1687
|
cleanupClients.add(client);
|
|
@@ -1686,7 +1697,7 @@ function createMCPClient(config) {
|
|
|
1686
1697
|
}
|
|
1687
1698
|
return client;
|
|
1688
1699
|
} else {
|
|
1689
|
-
const client = new
|
|
1700
|
+
const client = new MCPClientBase(config);
|
|
1690
1701
|
if (autoCleanup) {
|
|
1691
1702
|
cleanupClients.add(client);
|
|
1692
1703
|
registerCleanupHandlers();
|
|
@@ -2362,6 +2373,13 @@ var createTanStackOAuthHandler = toTanStackStartHandler;
|
|
|
2362
2373
|
|
|
2363
2374
|
// src/index.ts
|
|
2364
2375
|
init_errors();
|
|
2376
|
+
// index.ts
|
|
2377
|
+
var client = createMCPClient({
|
|
2378
|
+
integrations: [
|
|
2379
|
+
githubIntegration(),
|
|
2380
|
+
gmailIntegration()
|
|
2381
|
+
]
|
|
2382
|
+
});
|
|
2365
2383
|
export {
|
|
2366
2384
|
toTanStackStartHandler,
|
|
2367
2385
|
toSvelteKitHandler,
|
|
@@ -2387,6 +2405,7 @@ export {
|
|
|
2387
2405
|
createOAuthRedirectHandler,
|
|
2388
2406
|
createNextOAuthHandler,
|
|
2389
2407
|
createMCPClient,
|
|
2408
|
+
client,
|
|
2390
2409
|
clearClientCache,
|
|
2391
2410
|
ToolCallError,
|
|
2392
2411
|
TokenExpiredError,
|
|
@@ -2394,7 +2413,7 @@ export {
|
|
|
2394
2413
|
OAuthManager,
|
|
2395
2414
|
OAuthHandler,
|
|
2396
2415
|
MCPMethod,
|
|
2397
|
-
|
|
2416
|
+
MCPClientBase,
|
|
2398
2417
|
IntegrateSDKError,
|
|
2399
2418
|
HttpSessionTransport,
|
|
2400
2419
|
ConnectionError,
|
package/dist/server.js
CHANGED
|
@@ -818,8 +818,10 @@ class OAuthManager {
|
|
|
818
818
|
windowManager;
|
|
819
819
|
flowConfig;
|
|
820
820
|
oauthApiBase;
|
|
821
|
-
|
|
821
|
+
apiBaseUrl;
|
|
822
|
+
constructor(oauthApiBase, flowConfig, apiBaseUrl) {
|
|
822
823
|
this.oauthApiBase = oauthApiBase;
|
|
824
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
823
825
|
this.windowManager = new OAuthWindowManager;
|
|
824
826
|
this.flowConfig = {
|
|
825
827
|
mode: flowConfig?.mode || "redirect",
|
|
@@ -1070,7 +1072,7 @@ class OAuthManager {
|
|
|
1070
1072
|
}
|
|
1071
1073
|
}
|
|
1072
1074
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
1073
|
-
const url = `${this.oauthApiBase}/authorize`;
|
|
1075
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/authorize` : `${this.oauthApiBase}/authorize`;
|
|
1074
1076
|
const response = await fetch(url, {
|
|
1075
1077
|
method: "POST",
|
|
1076
1078
|
headers: {
|
|
@@ -1093,7 +1095,7 @@ class OAuthManager {
|
|
|
1093
1095
|
return data.authorizationUrl;
|
|
1094
1096
|
}
|
|
1095
1097
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
1096
|
-
const url = `${this.oauthApiBase}/callback`;
|
|
1098
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.oauthApiBase}/callback` : `${this.oauthApiBase}/callback`;
|
|
1097
1099
|
const response = await fetch(url, {
|
|
1098
1100
|
method: "POST",
|
|
1099
1101
|
headers: {
|
|
@@ -1156,7 +1158,7 @@ class SimpleEventEmitter {
|
|
|
1156
1158
|
var MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
|
|
1157
1159
|
var clientCache = new Map;
|
|
1158
1160
|
var cleanupClients = new Set;
|
|
1159
|
-
class
|
|
1161
|
+
class MCPClientBase {
|
|
1160
1162
|
transport;
|
|
1161
1163
|
integrations;
|
|
1162
1164
|
availableTools = new Map;
|
|
@@ -1169,8 +1171,7 @@ class MCPClient {
|
|
|
1169
1171
|
oauthManager;
|
|
1170
1172
|
eventEmitter = new SimpleEventEmitter;
|
|
1171
1173
|
apiRouteBase;
|
|
1172
|
-
|
|
1173
|
-
gmail;
|
|
1174
|
+
apiBaseUrl;
|
|
1174
1175
|
server;
|
|
1175
1176
|
constructor(config) {
|
|
1176
1177
|
this.transport = new HttpSessionTransport({
|
|
@@ -1181,6 +1182,7 @@ class MCPClient {
|
|
|
1181
1182
|
const oauthApiBase = config.oauthApiBase || "/api/integrate/oauth";
|
|
1182
1183
|
const defaultRedirectUri = this.getDefaultRedirectUri(oauthApiBase);
|
|
1183
1184
|
this.apiRouteBase = config.apiRouteBase || "/api/integrate";
|
|
1185
|
+
this.apiBaseUrl = config.apiBaseUrl;
|
|
1184
1186
|
this.integrations = config.integrations.map((integration) => {
|
|
1185
1187
|
if (integration.oauth && !integration.oauth.redirectUri) {
|
|
1186
1188
|
return {
|
|
@@ -1199,7 +1201,7 @@ class MCPClient {
|
|
|
1199
1201
|
};
|
|
1200
1202
|
this.onReauthRequired = config.onReauthRequired;
|
|
1201
1203
|
this.maxReauthRetries = config.maxReauthRetries ?? 1;
|
|
1202
|
-
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow);
|
|
1204
|
+
this.oauthManager = new OAuthManager(oauthApiBase, config.oauthFlow, this.apiBaseUrl);
|
|
1203
1205
|
const providers = this.integrations.filter((p) => p.oauth).map((p) => p.oauth.provider);
|
|
1204
1206
|
this.oauthManager.loadAllProviderTokens(providers);
|
|
1205
1207
|
for (const integration of this.integrations) {
|
|
@@ -1211,8 +1213,13 @@ class MCPClient {
|
|
|
1211
1213
|
this.authState.set(integration.oauth.provider, { authenticated: hasToken });
|
|
1212
1214
|
}
|
|
1213
1215
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
+
const integrationIds = this.integrations.map((i) => i.id);
|
|
1217
|
+
if (integrationIds.includes("github")) {
|
|
1218
|
+
this.github = this.createIntegrationProxy("github");
|
|
1219
|
+
}
|
|
1220
|
+
if (integrationIds.includes("gmail")) {
|
|
1221
|
+
this.gmail = this.createIntegrationProxy("gmail");
|
|
1222
|
+
}
|
|
1216
1223
|
this.server = this.createServerProxy();
|
|
1217
1224
|
this.initializeIntegrations();
|
|
1218
1225
|
}
|
|
@@ -1225,6 +1232,10 @@ class MCPClient {
|
|
|
1225
1232
|
return `${origin}${normalizedPath}/callback`;
|
|
1226
1233
|
}
|
|
1227
1234
|
createIntegrationProxy(integrationId) {
|
|
1235
|
+
const hasIntegration = this.integrations.some((integration) => integration.id === integrationId);
|
|
1236
|
+
if (!hasIntegration) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1228
1239
|
return new Proxy({}, {
|
|
1229
1240
|
get: (_target, methodName) => {
|
|
1230
1241
|
return async (args) => {
|
|
@@ -1338,7 +1349,7 @@ class MCPClient {
|
|
|
1338
1349
|
});
|
|
1339
1350
|
return result2;
|
|
1340
1351
|
}
|
|
1341
|
-
const url = `${this.apiRouteBase}/mcp`;
|
|
1352
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/mcp` : `${this.apiRouteBase}/mcp`;
|
|
1342
1353
|
const headers = {
|
|
1343
1354
|
"Content-Type": "application/json"
|
|
1344
1355
|
};
|
|
@@ -1970,7 +1981,7 @@ function createMCPServer(config) {
|
|
|
1970
1981
|
connectionMode: config.connectionMode || "lazy",
|
|
1971
1982
|
singleton: config.singleton ?? true
|
|
1972
1983
|
};
|
|
1973
|
-
const client = new
|
|
1984
|
+
const client = new MCPClientBase(clientConfig);
|
|
1974
1985
|
if (config.apiKey) {
|
|
1975
1986
|
client.setRequestHeader("X-API-KEY", config.apiKey);
|
|
1976
1987
|
}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -41,9 +41,16 @@ type IntegrationNamespaces<TIntegrations extends readonly MCPIntegration[]> = (H
|
|
|
41
41
|
/**
|
|
42
42
|
* MCP Client Class
|
|
43
43
|
*
|
|
44
|
-
* Provides type-safe access to MCP server tools with integration-based configuration
|
|
44
|
+
* Provides type-safe access to MCP server tools with integration-based configuration.
|
|
45
|
+
* Integration namespaces (github, gmail, etc.) are only available when configured.
|
|
45
46
|
*/
|
|
46
|
-
export
|
|
47
|
+
export type MCPClient<TIntegrations extends readonly MCPIntegration[] = readonly MCPIntegration[]> = MCPClientBase<TIntegrations> & IntegrationNamespaces<TIntegrations>;
|
|
48
|
+
/**
|
|
49
|
+
* Base MCP Client Class (without integration namespaces)
|
|
50
|
+
* Integration namespaces are added dynamically at runtime and via type intersection
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export declare class MCPClientBase<TIntegrations extends readonly MCPIntegration[] = readonly MCPIntegration[]> {
|
|
47
54
|
private transport;
|
|
48
55
|
private integrations;
|
|
49
56
|
private availableTools;
|
|
@@ -56,12 +63,7 @@ export declare class MCPClient<TIntegrations extends readonly MCPIntegration[] =
|
|
|
56
63
|
private oauthManager;
|
|
57
64
|
private eventEmitter;
|
|
58
65
|
private apiRouteBase;
|
|
59
|
-
|
|
60
|
-
github: GitHubIntegrationClient;
|
|
61
|
-
} ? GitHubIntegrationClient : never;
|
|
62
|
-
readonly gmail: IntegrationNamespaces<TIntegrations> extends {
|
|
63
|
-
gmail: GmailIntegrationClient;
|
|
64
|
-
} ? GmailIntegrationClient : never;
|
|
66
|
+
private apiBaseUrl?;
|
|
65
67
|
readonly server: ServerIntegrationClient;
|
|
66
68
|
constructor(config: MCPClientConfig<TIntegrations>);
|
|
67
69
|
/**
|
|
@@ -75,6 +77,7 @@ export declare class MCPClient<TIntegrations extends readonly MCPIntegration[] =
|
|
|
75
77
|
/**
|
|
76
78
|
* Create a proxy for a integration namespace that intercepts method calls
|
|
77
79
|
* and routes them to the appropriate tool
|
|
80
|
+
* Returns undefined if the integration is not configured
|
|
78
81
|
*/
|
|
79
82
|
private createIntegrationProxy;
|
|
80
83
|
/**
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|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,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,kBAAkB,EAAE,iBAAiB,GAAG,IAAI;IAKjG;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAW9C;;;OAGG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CA2BzD;AAmED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,eAAe,CAAC,aAAa,SAAS,SAAS,cAAc,EAAE,EAC7E,MAAM,EAAE,eAAe,CAAC,aAAa,CAAC,GACrC,SAAS,CAAC,aAAa,CAAC,CAkE1B;AA0CD;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAetD"}
|
|
@@ -59,20 +59,55 @@ export interface MCPClientConfig<TIntegrations extends readonly MCPIntegration[]
|
|
|
59
59
|
/** Array of integrations to enable */
|
|
60
60
|
integrations: TIntegrations;
|
|
61
61
|
/**
|
|
62
|
-
* MCP Server URL
|
|
62
|
+
* MCP Server URL (SERVER-SIDE ONLY - for createMCPServer)
|
|
63
|
+
*
|
|
64
|
+
* ⚠️ DO NOT configure this in client-side code (createMCPClient)!
|
|
65
|
+
* The client calls YOUR API routes at apiRouteBase/mcp, which then call the MCP server.
|
|
66
|
+
*
|
|
67
|
+
* This is only used server-side to specify which MCP backend to connect to.
|
|
63
68
|
*
|
|
64
69
|
* @default 'https://mcp.integrate.dev/api/v1/mcp'
|
|
65
70
|
*
|
|
66
71
|
* @example
|
|
67
72
|
* ```typescript
|
|
68
|
-
* //
|
|
69
|
-
*
|
|
73
|
+
* // Server-side only - point to a different MCP backend
|
|
74
|
+
* createMCPServer({
|
|
70
75
|
* serverUrl: 'http://localhost:8080/api/v1/mcp',
|
|
71
76
|
* integrations: [githubIntegration({ ... })]
|
|
72
77
|
* })
|
|
73
78
|
* ```
|
|
79
|
+
*
|
|
80
|
+
* @internal This is primarily for server configuration
|
|
74
81
|
*/
|
|
75
82
|
serverUrl?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Base origin URL for your API routes (client-side configuration)
|
|
85
|
+
* Use this when your API routes are hosted on a different domain than your frontend
|
|
86
|
+
*
|
|
87
|
+
* The client will make requests to:
|
|
88
|
+
* - {apiBaseUrl}{apiRouteBase}/mcp (for tool calls)
|
|
89
|
+
* - {apiBaseUrl}{oauthApiBase}/authorize (for OAuth)
|
|
90
|
+
*
|
|
91
|
+
* @default window.location.origin (browser) or undefined (server)
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Frontend on localhost:3000, API on localhost:4000
|
|
96
|
+
* createMCPClient({
|
|
97
|
+
* apiBaseUrl: 'http://localhost:4000',
|
|
98
|
+
* integrations: [githubIntegration({ ... })]
|
|
99
|
+
* })
|
|
100
|
+
* // Will call: http://localhost:4000/api/integrate/mcp
|
|
101
|
+
*
|
|
102
|
+
* // Frontend on app.example.com, API on api.example.com
|
|
103
|
+
* createMCPClient({
|
|
104
|
+
* apiBaseUrl: 'https://api.example.com',
|
|
105
|
+
* integrations: [githubIntegration({ ... })]
|
|
106
|
+
* })
|
|
107
|
+
* // Will call: https://api.example.com/api/integrate/mcp
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
apiBaseUrl?: string;
|
|
76
111
|
/** Optional HTTP headers to include in requests */
|
|
77
112
|
headers?: Record<string, string>;
|
|
78
113
|
/** Request timeout in milliseconds (default: 30000) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD;;GAEG;AACH,MAAM,WA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AAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACnF,CAAC;IAEF;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;;;OAaG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,aAAa,SAAS,SAAS,cAAc,EAAE,IAC3E,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,aAAa,SAAS,SAAS,cAAc,EAAE,IAAI;KAC7E,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,IAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;CACnD,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Integrate SDK
|
|
3
3
|
* Type-safe TypeScript SDK for MCP Client
|
|
4
4
|
*/
|
|
5
|
-
export { MCPClient
|
|
5
|
+
export type { MCPClient } from "./client.js";
|
|
6
|
+
export { MCPClientBase, createMCPClient, clearClientCache } from "./client.js";
|
|
6
7
|
export type { ToolInvocationOptions } from "./client.js";
|
|
7
8
|
export { OAuthManager } from "./oauth/manager.js";
|
|
8
9
|
export { OAuthWindowManager, sendCallbackToOpener } from "./oauth/window-manager.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],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2BAA2B,GAC5B,MAAM,6BAA6B,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Integration System Types
|
|
3
3
|
* Inspired by BetterAuth's provider pattern
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { MCPClientBase } from "../client.js";
|
|
6
6
|
/**
|
|
7
7
|
* OAuth Configuration for a integration
|
|
8
8
|
*
|
|
@@ -45,13 +45,13 @@ export interface MCPIntegration {
|
|
|
45
45
|
/** OAuth configuration for this integration */
|
|
46
46
|
oauth?: OAuthConfig;
|
|
47
47
|
/** Called when the integration is initialized with the client */
|
|
48
|
-
onInit?: (client:
|
|
48
|
+
onInit?: (client: MCPClientBase<any>) => Promise<void> | void;
|
|
49
49
|
/** Called before the client connects to the server */
|
|
50
|
-
onBeforeConnect?: (client:
|
|
50
|
+
onBeforeConnect?: (client: MCPClientBase<any>) => Promise<void> | void;
|
|
51
51
|
/** Called after the client successfully connects */
|
|
52
|
-
onAfterConnect?: (client:
|
|
52
|
+
onAfterConnect?: (client: MCPClientBase<any>) => Promise<void> | void;
|
|
53
53
|
/** Called when the client disconnects */
|
|
54
|
-
onDisconnect?: (client:
|
|
54
|
+
onDisconnect?: (client: MCPClientBase<any>) => Promise<void> | void;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Helper type to extract integration IDs from an array of integrations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/integrations/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/integrations/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IAEjB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OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtG;;GAEG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,cAAc,GAC1B,WAAW,IAAI,cAAc,GAAG;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,CAExD"}
|
|
@@ -14,7 +14,8 @@ export declare class OAuthManager {
|
|
|
14
14
|
private windowManager;
|
|
15
15
|
private flowConfig;
|
|
16
16
|
private oauthApiBase;
|
|
17
|
-
|
|
17
|
+
private apiBaseUrl?;
|
|
18
|
+
constructor(oauthApiBase: string, flowConfig?: Partial<OAuthFlowConfig>, apiBaseUrl?: string);
|
|
18
19
|
/**
|
|
19
20
|
* Initiate OAuth authorization flow
|
|
20
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/oauth/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EACV,eAAe,EAEf,UAAU,EAGV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,cAAc,CAA6C;IACnE,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,YAAY,CAAS;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/oauth/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EACV,eAAe,EAEf,UAAU,EAGV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,cAAc,CAA6C;IACnE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;OAEG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAShD;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAWhC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAelC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAWpC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAoClC;;;OAGG;YACW,mBAAmB;IAqCjC;;;OAGG;YACW,oBAAoB;IAkClC;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
package/dist/src/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAI9D;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,aAAa,SAAS,SAAS,cAAc,EAAE,IAAI,SAAS,CAAC,aAAa,CAAC,GAAG;IACxG,uEAAuE;IACvE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtH,qDAAqD;IACrD,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE;YAAE,MAAM,EAA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,KAAG,OAAO,CAAC,QAAQ,CAAC;EAyFzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,SAAS,SAAS,cAAc,EAAE,GAAG,GAAG,EACtF,wBAAwB,EACpB,eAAe,CAAC,aAAa,CAAC,GAC9B,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAC9G;IACA,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IACH,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,EACH,gBAAgB,CAAC,EAAE;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,WAOsB,GAAG,KAAG,OAAO,CAAC,QAAQ,CAAC,CAgE/C"}
|
package/index.ts
CHANGED
|
@@ -5,17 +5,64 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
+
* // Use the default client with all integrations
|
|
9
|
+
* import { client } from 'integrate-sdk';
|
|
10
|
+
*
|
|
11
|
+
* await client.github.listOwnRepos({});
|
|
12
|
+
*
|
|
13
|
+
* // Or create a custom client with different API configuration
|
|
8
14
|
* import { createMCPClient, githubIntegration } from 'integrate-sdk';
|
|
9
15
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* // Example 1: Different API path (same origin)
|
|
17
|
+
* const customClient = createMCPClient({
|
|
18
|
+
* apiRouteBase: '/custom/api/path', // Calls /custom/api/path/mcp
|
|
19
|
+
* integrations: [githubIntegration()],
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Example 2: Different API domain (cross-origin)
|
|
23
|
+
* const crossOriginClient = createMCPClient({
|
|
24
|
+
* apiBaseUrl: 'https://api.example.com', // API on different domain
|
|
25
|
+
* apiRouteBase: '/api/integrate', // Calls https://api.example.com/api/integrate/mcp
|
|
26
|
+
* integrations: [githubIntegration()],
|
|
16
27
|
* });
|
|
17
28
|
* ```
|
|
18
29
|
*/
|
|
19
30
|
|
|
20
31
|
export * from './src/index.js';
|
|
21
32
|
|
|
33
|
+
// Export default client with all integrations pre-configured
|
|
34
|
+
import { createMCPClient } from './src/client.js';
|
|
35
|
+
import { githubIntegration } from './src/integrations/github.js';
|
|
36
|
+
import { gmailIntegration } from './src/integrations/gmail.js';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Default MCP Client with all integrations pre-configured
|
|
40
|
+
*
|
|
41
|
+
* This is a singleton client instance that includes GitHub and Gmail integrations.
|
|
42
|
+
* You can use it directly without having to configure integrations.
|
|
43
|
+
*
|
|
44
|
+
* Default configuration:
|
|
45
|
+
* - Calls API routes at: {window.location.origin}/api/integrate/mcp
|
|
46
|
+
* - OAuth routes at: {window.location.origin}/api/integrate/oauth/*
|
|
47
|
+
*
|
|
48
|
+
* For custom configuration (different apiBaseUrl, apiRouteBase, etc.),
|
|
49
|
+
* use `createMCPClient()` instead.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { client } from 'integrate-sdk';
|
|
54
|
+
*
|
|
55
|
+
* // Use GitHub integration
|
|
56
|
+
* const repos = await client.github.listOwnRepos({});
|
|
57
|
+
*
|
|
58
|
+
* // Use Gmail integration
|
|
59
|
+
* const messages = await client.gmail.listMessages({});
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export const client = createMCPClient({
|
|
63
|
+
integrations: [
|
|
64
|
+
githubIntegration(),
|
|
65
|
+
gmailIntegration(),
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
|