integrate-sdk 0.8.46-dev.0 → 0.8.48-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 +93 -11
- package/dist/adapters/index.js +93 -11
- package/dist/adapters/nextjs.js +93 -11
- package/dist/adapters/node.js +93 -11
- package/dist/adapters/svelte-kit.js +93 -11
- package/dist/adapters/tanstack-start.js +93 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -12
- package/dist/oauth.js +93 -11
- package/dist/server.js +93 -11
- package/dist/src/client.d.ts +6 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/integrations/server-client.d.ts +20 -2
- package/dist/src/integrations/server-client.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/utils/concurrency.d.ts +24 -0
- package/dist/src/utils/concurrency.d.ts.map +1 -0
- package/index.ts +22 -0
- package/package.json +1 -1
|
@@ -1622,6 +1622,32 @@ var init_manager = __esm(() => {
|
|
|
1622
1622
|
logger4 = createLogger("OAuth");
|
|
1623
1623
|
});
|
|
1624
1624
|
|
|
1625
|
+
// ../utils/concurrency.ts
|
|
1626
|
+
var exports_concurrency = {};
|
|
1627
|
+
__export(exports_concurrency, {
|
|
1628
|
+
parallelWithLimit: () => parallelWithLimit
|
|
1629
|
+
});
|
|
1630
|
+
async function parallelWithLimit(items, fn, limit = 3) {
|
|
1631
|
+
const results = [];
|
|
1632
|
+
const executing = [];
|
|
1633
|
+
for (let i = 0;i < items.length; i++) {
|
|
1634
|
+
const item = items[i];
|
|
1635
|
+
const index = i;
|
|
1636
|
+
const promise = fn(item).then((result) => {
|
|
1637
|
+
results[index] = result;
|
|
1638
|
+
}).catch(() => {
|
|
1639
|
+
results[index] = undefined;
|
|
1640
|
+
});
|
|
1641
|
+
executing.push(promise);
|
|
1642
|
+
if (executing.length >= limit) {
|
|
1643
|
+
const completedIndex = await Promise.race(executing.map((p, idx) => p.then(() => idx).catch(() => idx)));
|
|
1644
|
+
executing.splice(completedIndex, 1);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
await Promise.all(executing);
|
|
1648
|
+
return results;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1625
1651
|
// ../client.ts
|
|
1626
1652
|
class SimpleEventEmitter {
|
|
1627
1653
|
handlers = new Map;
|
|
@@ -1673,6 +1699,7 @@ class MCPClientBase {
|
|
|
1673
1699
|
apiRouteBase;
|
|
1674
1700
|
apiBaseUrl;
|
|
1675
1701
|
databaseDetected = false;
|
|
1702
|
+
__configuredIntegrations;
|
|
1676
1703
|
oauthCallbackPromise;
|
|
1677
1704
|
server;
|
|
1678
1705
|
trigger;
|
|
@@ -1698,6 +1725,7 @@ class MCPClientBase {
|
|
|
1698
1725
|
}
|
|
1699
1726
|
return integration;
|
|
1700
1727
|
});
|
|
1728
|
+
this.__configuredIntegrations = this.integrations;
|
|
1701
1729
|
this.clientInfo = config.clientInfo || {
|
|
1702
1730
|
name: "integrate-sdk",
|
|
1703
1731
|
version: "0.1.0"
|
|
@@ -1840,16 +1868,68 @@ class MCPClientBase {
|
|
|
1840
1868
|
return new Proxy({}, {
|
|
1841
1869
|
get: (_target, methodName) => {
|
|
1842
1870
|
if (methodName === "listConfiguredIntegrations") {
|
|
1843
|
-
return async () =>
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1871
|
+
return async (options) => {
|
|
1872
|
+
const serverConfig = this.__oauthConfig;
|
|
1873
|
+
const configuredIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
1874
|
+
if (options?.includeToolMetadata) {
|
|
1875
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1876
|
+
const integrationsWithMetadata = await parallelWithLimit2(configuredIntegrations, async (integration) => {
|
|
1877
|
+
try {
|
|
1878
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1879
|
+
integration: integration.id
|
|
1880
|
+
});
|
|
1881
|
+
let toolMetadata = [];
|
|
1882
|
+
if (response.content && Array.isArray(response.content)) {
|
|
1883
|
+
for (const item of response.content) {
|
|
1884
|
+
if (item.type === "text" && item.text) {
|
|
1885
|
+
try {
|
|
1886
|
+
const parsed = JSON.parse(item.text);
|
|
1887
|
+
if (Array.isArray(parsed)) {
|
|
1888
|
+
toolMetadata = parsed;
|
|
1889
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1890
|
+
toolMetadata = parsed.tools;
|
|
1891
|
+
}
|
|
1892
|
+
} catch {}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
return {
|
|
1897
|
+
id: integration.id,
|
|
1898
|
+
name: integration.name || integration.id,
|
|
1899
|
+
tools: integration.tools,
|
|
1900
|
+
hasOAuth: !!integration.oauth,
|
|
1901
|
+
scopes: integration.oauth?.scopes,
|
|
1902
|
+
provider: integration.oauth?.provider,
|
|
1903
|
+
toolMetadata
|
|
1904
|
+
};
|
|
1905
|
+
} catch (error) {
|
|
1906
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1907
|
+
return {
|
|
1908
|
+
id: integration.id,
|
|
1909
|
+
name: integration.name || integration.id,
|
|
1910
|
+
tools: integration.tools,
|
|
1911
|
+
hasOAuth: !!integration.oauth,
|
|
1912
|
+
scopes: integration.oauth?.scopes,
|
|
1913
|
+
provider: integration.oauth?.provider,
|
|
1914
|
+
toolMetadata: []
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
}, 3);
|
|
1918
|
+
return {
|
|
1919
|
+
integrations: integrationsWithMetadata
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
return {
|
|
1923
|
+
integrations: configuredIntegrations.map((integration) => ({
|
|
1924
|
+
id: integration.id,
|
|
1925
|
+
name: integration.name || integration.id,
|
|
1926
|
+
tools: integration.tools,
|
|
1927
|
+
hasOAuth: !!integration.oauth,
|
|
1928
|
+
scopes: integration.oauth?.scopes,
|
|
1929
|
+
provider: integration.oauth?.provider
|
|
1930
|
+
}))
|
|
1931
|
+
};
|
|
1932
|
+
};
|
|
1853
1933
|
}
|
|
1854
1934
|
return async (args, options) => {
|
|
1855
1935
|
const toolName = methodToToolName(methodName, "");
|
|
@@ -9721,7 +9801,8 @@ function createMCPServer(config) {
|
|
|
9721
9801
|
globalServerConfig = {
|
|
9722
9802
|
providers,
|
|
9723
9803
|
serverUrl: config.serverUrl,
|
|
9724
|
-
apiKey: config.apiKey
|
|
9804
|
+
apiKey: config.apiKey,
|
|
9805
|
+
integrations: updatedIntegrations
|
|
9725
9806
|
};
|
|
9726
9807
|
const clientConfig = {
|
|
9727
9808
|
...config,
|
|
@@ -9737,6 +9818,7 @@ function createMCPServer(config) {
|
|
|
9737
9818
|
providers,
|
|
9738
9819
|
serverUrl: config.serverUrl,
|
|
9739
9820
|
apiKey: config.apiKey,
|
|
9821
|
+
integrations: updatedIntegrations,
|
|
9740
9822
|
getSessionContext: config.getSessionContext,
|
|
9741
9823
|
setProviderToken: config.setProviderToken,
|
|
9742
9824
|
removeProviderToken: config.removeProviderToken
|
package/dist/adapters/index.js
CHANGED
|
@@ -1622,6 +1622,32 @@ var init_manager = __esm(() => {
|
|
|
1622
1622
|
logger4 = createLogger("OAuth");
|
|
1623
1623
|
});
|
|
1624
1624
|
|
|
1625
|
+
// ../utils/concurrency.ts
|
|
1626
|
+
var exports_concurrency = {};
|
|
1627
|
+
__export(exports_concurrency, {
|
|
1628
|
+
parallelWithLimit: () => parallelWithLimit
|
|
1629
|
+
});
|
|
1630
|
+
async function parallelWithLimit(items, fn, limit = 3) {
|
|
1631
|
+
const results = [];
|
|
1632
|
+
const executing = [];
|
|
1633
|
+
for (let i = 0;i < items.length; i++) {
|
|
1634
|
+
const item = items[i];
|
|
1635
|
+
const index = i;
|
|
1636
|
+
const promise = fn(item).then((result) => {
|
|
1637
|
+
results[index] = result;
|
|
1638
|
+
}).catch(() => {
|
|
1639
|
+
results[index] = undefined;
|
|
1640
|
+
});
|
|
1641
|
+
executing.push(promise);
|
|
1642
|
+
if (executing.length >= limit) {
|
|
1643
|
+
const completedIndex = await Promise.race(executing.map((p, idx) => p.then(() => idx).catch(() => idx)));
|
|
1644
|
+
executing.splice(completedIndex, 1);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
await Promise.all(executing);
|
|
1648
|
+
return results;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1625
1651
|
// ../client.ts
|
|
1626
1652
|
class SimpleEventEmitter {
|
|
1627
1653
|
handlers = new Map;
|
|
@@ -1673,6 +1699,7 @@ class MCPClientBase {
|
|
|
1673
1699
|
apiRouteBase;
|
|
1674
1700
|
apiBaseUrl;
|
|
1675
1701
|
databaseDetected = false;
|
|
1702
|
+
__configuredIntegrations;
|
|
1676
1703
|
oauthCallbackPromise;
|
|
1677
1704
|
server;
|
|
1678
1705
|
trigger;
|
|
@@ -1698,6 +1725,7 @@ class MCPClientBase {
|
|
|
1698
1725
|
}
|
|
1699
1726
|
return integration;
|
|
1700
1727
|
});
|
|
1728
|
+
this.__configuredIntegrations = this.integrations;
|
|
1701
1729
|
this.clientInfo = config.clientInfo || {
|
|
1702
1730
|
name: "integrate-sdk",
|
|
1703
1731
|
version: "0.1.0"
|
|
@@ -1840,16 +1868,68 @@ class MCPClientBase {
|
|
|
1840
1868
|
return new Proxy({}, {
|
|
1841
1869
|
get: (_target, methodName) => {
|
|
1842
1870
|
if (methodName === "listConfiguredIntegrations") {
|
|
1843
|
-
return async () =>
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1871
|
+
return async (options) => {
|
|
1872
|
+
const serverConfig = this.__oauthConfig;
|
|
1873
|
+
const configuredIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
1874
|
+
if (options?.includeToolMetadata) {
|
|
1875
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1876
|
+
const integrationsWithMetadata = await parallelWithLimit2(configuredIntegrations, async (integration) => {
|
|
1877
|
+
try {
|
|
1878
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1879
|
+
integration: integration.id
|
|
1880
|
+
});
|
|
1881
|
+
let toolMetadata = [];
|
|
1882
|
+
if (response.content && Array.isArray(response.content)) {
|
|
1883
|
+
for (const item of response.content) {
|
|
1884
|
+
if (item.type === "text" && item.text) {
|
|
1885
|
+
try {
|
|
1886
|
+
const parsed = JSON.parse(item.text);
|
|
1887
|
+
if (Array.isArray(parsed)) {
|
|
1888
|
+
toolMetadata = parsed;
|
|
1889
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1890
|
+
toolMetadata = parsed.tools;
|
|
1891
|
+
}
|
|
1892
|
+
} catch {}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
return {
|
|
1897
|
+
id: integration.id,
|
|
1898
|
+
name: integration.name || integration.id,
|
|
1899
|
+
tools: integration.tools,
|
|
1900
|
+
hasOAuth: !!integration.oauth,
|
|
1901
|
+
scopes: integration.oauth?.scopes,
|
|
1902
|
+
provider: integration.oauth?.provider,
|
|
1903
|
+
toolMetadata
|
|
1904
|
+
};
|
|
1905
|
+
} catch (error) {
|
|
1906
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1907
|
+
return {
|
|
1908
|
+
id: integration.id,
|
|
1909
|
+
name: integration.name || integration.id,
|
|
1910
|
+
tools: integration.tools,
|
|
1911
|
+
hasOAuth: !!integration.oauth,
|
|
1912
|
+
scopes: integration.oauth?.scopes,
|
|
1913
|
+
provider: integration.oauth?.provider,
|
|
1914
|
+
toolMetadata: []
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
}, 3);
|
|
1918
|
+
return {
|
|
1919
|
+
integrations: integrationsWithMetadata
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
return {
|
|
1923
|
+
integrations: configuredIntegrations.map((integration) => ({
|
|
1924
|
+
id: integration.id,
|
|
1925
|
+
name: integration.name || integration.id,
|
|
1926
|
+
tools: integration.tools,
|
|
1927
|
+
hasOAuth: !!integration.oauth,
|
|
1928
|
+
scopes: integration.oauth?.scopes,
|
|
1929
|
+
provider: integration.oauth?.provider
|
|
1930
|
+
}))
|
|
1931
|
+
};
|
|
1932
|
+
};
|
|
1853
1933
|
}
|
|
1854
1934
|
return async (args, options) => {
|
|
1855
1935
|
const toolName = methodToToolName(methodName, "");
|
|
@@ -9721,7 +9801,8 @@ function createMCPServer(config) {
|
|
|
9721
9801
|
globalServerConfig = {
|
|
9722
9802
|
providers,
|
|
9723
9803
|
serverUrl: config.serverUrl,
|
|
9724
|
-
apiKey: config.apiKey
|
|
9804
|
+
apiKey: config.apiKey,
|
|
9805
|
+
integrations: updatedIntegrations
|
|
9725
9806
|
};
|
|
9726
9807
|
const clientConfig = {
|
|
9727
9808
|
...config,
|
|
@@ -9737,6 +9818,7 @@ function createMCPServer(config) {
|
|
|
9737
9818
|
providers,
|
|
9738
9819
|
serverUrl: config.serverUrl,
|
|
9739
9820
|
apiKey: config.apiKey,
|
|
9821
|
+
integrations: updatedIntegrations,
|
|
9740
9822
|
getSessionContext: config.getSessionContext,
|
|
9741
9823
|
setProviderToken: config.setProviderToken,
|
|
9742
9824
|
removeProviderToken: config.removeProviderToken
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -1622,6 +1622,32 @@ var init_manager = __esm(() => {
|
|
|
1622
1622
|
logger4 = createLogger("OAuth");
|
|
1623
1623
|
});
|
|
1624
1624
|
|
|
1625
|
+
// ../utils/concurrency.ts
|
|
1626
|
+
var exports_concurrency = {};
|
|
1627
|
+
__export(exports_concurrency, {
|
|
1628
|
+
parallelWithLimit: () => parallelWithLimit
|
|
1629
|
+
});
|
|
1630
|
+
async function parallelWithLimit(items, fn, limit = 3) {
|
|
1631
|
+
const results = [];
|
|
1632
|
+
const executing = [];
|
|
1633
|
+
for (let i = 0;i < items.length; i++) {
|
|
1634
|
+
const item = items[i];
|
|
1635
|
+
const index = i;
|
|
1636
|
+
const promise = fn(item).then((result) => {
|
|
1637
|
+
results[index] = result;
|
|
1638
|
+
}).catch(() => {
|
|
1639
|
+
results[index] = undefined;
|
|
1640
|
+
});
|
|
1641
|
+
executing.push(promise);
|
|
1642
|
+
if (executing.length >= limit) {
|
|
1643
|
+
const completedIndex = await Promise.race(executing.map((p, idx) => p.then(() => idx).catch(() => idx)));
|
|
1644
|
+
executing.splice(completedIndex, 1);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
await Promise.all(executing);
|
|
1648
|
+
return results;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1625
1651
|
// ../client.ts
|
|
1626
1652
|
class SimpleEventEmitter {
|
|
1627
1653
|
handlers = new Map;
|
|
@@ -1673,6 +1699,7 @@ class MCPClientBase {
|
|
|
1673
1699
|
apiRouteBase;
|
|
1674
1700
|
apiBaseUrl;
|
|
1675
1701
|
databaseDetected = false;
|
|
1702
|
+
__configuredIntegrations;
|
|
1676
1703
|
oauthCallbackPromise;
|
|
1677
1704
|
server;
|
|
1678
1705
|
trigger;
|
|
@@ -1698,6 +1725,7 @@ class MCPClientBase {
|
|
|
1698
1725
|
}
|
|
1699
1726
|
return integration;
|
|
1700
1727
|
});
|
|
1728
|
+
this.__configuredIntegrations = this.integrations;
|
|
1701
1729
|
this.clientInfo = config.clientInfo || {
|
|
1702
1730
|
name: "integrate-sdk",
|
|
1703
1731
|
version: "0.1.0"
|
|
@@ -1840,16 +1868,68 @@ class MCPClientBase {
|
|
|
1840
1868
|
return new Proxy({}, {
|
|
1841
1869
|
get: (_target, methodName) => {
|
|
1842
1870
|
if (methodName === "listConfiguredIntegrations") {
|
|
1843
|
-
return async () =>
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1871
|
+
return async (options) => {
|
|
1872
|
+
const serverConfig = this.__oauthConfig;
|
|
1873
|
+
const configuredIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
1874
|
+
if (options?.includeToolMetadata) {
|
|
1875
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1876
|
+
const integrationsWithMetadata = await parallelWithLimit2(configuredIntegrations, async (integration) => {
|
|
1877
|
+
try {
|
|
1878
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1879
|
+
integration: integration.id
|
|
1880
|
+
});
|
|
1881
|
+
let toolMetadata = [];
|
|
1882
|
+
if (response.content && Array.isArray(response.content)) {
|
|
1883
|
+
for (const item of response.content) {
|
|
1884
|
+
if (item.type === "text" && item.text) {
|
|
1885
|
+
try {
|
|
1886
|
+
const parsed = JSON.parse(item.text);
|
|
1887
|
+
if (Array.isArray(parsed)) {
|
|
1888
|
+
toolMetadata = parsed;
|
|
1889
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1890
|
+
toolMetadata = parsed.tools;
|
|
1891
|
+
}
|
|
1892
|
+
} catch {}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
return {
|
|
1897
|
+
id: integration.id,
|
|
1898
|
+
name: integration.name || integration.id,
|
|
1899
|
+
tools: integration.tools,
|
|
1900
|
+
hasOAuth: !!integration.oauth,
|
|
1901
|
+
scopes: integration.oauth?.scopes,
|
|
1902
|
+
provider: integration.oauth?.provider,
|
|
1903
|
+
toolMetadata
|
|
1904
|
+
};
|
|
1905
|
+
} catch (error) {
|
|
1906
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1907
|
+
return {
|
|
1908
|
+
id: integration.id,
|
|
1909
|
+
name: integration.name || integration.id,
|
|
1910
|
+
tools: integration.tools,
|
|
1911
|
+
hasOAuth: !!integration.oauth,
|
|
1912
|
+
scopes: integration.oauth?.scopes,
|
|
1913
|
+
provider: integration.oauth?.provider,
|
|
1914
|
+
toolMetadata: []
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
}, 3);
|
|
1918
|
+
return {
|
|
1919
|
+
integrations: integrationsWithMetadata
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
return {
|
|
1923
|
+
integrations: configuredIntegrations.map((integration) => ({
|
|
1924
|
+
id: integration.id,
|
|
1925
|
+
name: integration.name || integration.id,
|
|
1926
|
+
tools: integration.tools,
|
|
1927
|
+
hasOAuth: !!integration.oauth,
|
|
1928
|
+
scopes: integration.oauth?.scopes,
|
|
1929
|
+
provider: integration.oauth?.provider
|
|
1930
|
+
}))
|
|
1931
|
+
};
|
|
1932
|
+
};
|
|
1853
1933
|
}
|
|
1854
1934
|
return async (args, options) => {
|
|
1855
1935
|
const toolName = methodToToolName(methodName, "");
|
|
@@ -9721,7 +9801,8 @@ function createMCPServer(config) {
|
|
|
9721
9801
|
globalServerConfig = {
|
|
9722
9802
|
providers,
|
|
9723
9803
|
serverUrl: config.serverUrl,
|
|
9724
|
-
apiKey: config.apiKey
|
|
9804
|
+
apiKey: config.apiKey,
|
|
9805
|
+
integrations: updatedIntegrations
|
|
9725
9806
|
};
|
|
9726
9807
|
const clientConfig = {
|
|
9727
9808
|
...config,
|
|
@@ -9737,6 +9818,7 @@ function createMCPServer(config) {
|
|
|
9737
9818
|
providers,
|
|
9738
9819
|
serverUrl: config.serverUrl,
|
|
9739
9820
|
apiKey: config.apiKey,
|
|
9821
|
+
integrations: updatedIntegrations,
|
|
9740
9822
|
getSessionContext: config.getSessionContext,
|
|
9741
9823
|
setProviderToken: config.setProviderToken,
|
|
9742
9824
|
removeProviderToken: config.removeProviderToken
|
package/dist/adapters/node.js
CHANGED
|
@@ -1622,6 +1622,32 @@ var init_manager = __esm(() => {
|
|
|
1622
1622
|
logger4 = createLogger("OAuth");
|
|
1623
1623
|
});
|
|
1624
1624
|
|
|
1625
|
+
// ../utils/concurrency.ts
|
|
1626
|
+
var exports_concurrency = {};
|
|
1627
|
+
__export(exports_concurrency, {
|
|
1628
|
+
parallelWithLimit: () => parallelWithLimit
|
|
1629
|
+
});
|
|
1630
|
+
async function parallelWithLimit(items, fn, limit = 3) {
|
|
1631
|
+
const results = [];
|
|
1632
|
+
const executing = [];
|
|
1633
|
+
for (let i = 0;i < items.length; i++) {
|
|
1634
|
+
const item = items[i];
|
|
1635
|
+
const index = i;
|
|
1636
|
+
const promise = fn(item).then((result) => {
|
|
1637
|
+
results[index] = result;
|
|
1638
|
+
}).catch(() => {
|
|
1639
|
+
results[index] = undefined;
|
|
1640
|
+
});
|
|
1641
|
+
executing.push(promise);
|
|
1642
|
+
if (executing.length >= limit) {
|
|
1643
|
+
const completedIndex = await Promise.race(executing.map((p, idx) => p.then(() => idx).catch(() => idx)));
|
|
1644
|
+
executing.splice(completedIndex, 1);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
await Promise.all(executing);
|
|
1648
|
+
return results;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1625
1651
|
// ../client.ts
|
|
1626
1652
|
class SimpleEventEmitter {
|
|
1627
1653
|
handlers = new Map;
|
|
@@ -1673,6 +1699,7 @@ class MCPClientBase {
|
|
|
1673
1699
|
apiRouteBase;
|
|
1674
1700
|
apiBaseUrl;
|
|
1675
1701
|
databaseDetected = false;
|
|
1702
|
+
__configuredIntegrations;
|
|
1676
1703
|
oauthCallbackPromise;
|
|
1677
1704
|
server;
|
|
1678
1705
|
trigger;
|
|
@@ -1698,6 +1725,7 @@ class MCPClientBase {
|
|
|
1698
1725
|
}
|
|
1699
1726
|
return integration;
|
|
1700
1727
|
});
|
|
1728
|
+
this.__configuredIntegrations = this.integrations;
|
|
1701
1729
|
this.clientInfo = config.clientInfo || {
|
|
1702
1730
|
name: "integrate-sdk",
|
|
1703
1731
|
version: "0.1.0"
|
|
@@ -1840,16 +1868,68 @@ class MCPClientBase {
|
|
|
1840
1868
|
return new Proxy({}, {
|
|
1841
1869
|
get: (_target, methodName) => {
|
|
1842
1870
|
if (methodName === "listConfiguredIntegrations") {
|
|
1843
|
-
return async () =>
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1871
|
+
return async (options) => {
|
|
1872
|
+
const serverConfig = this.__oauthConfig;
|
|
1873
|
+
const configuredIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
1874
|
+
if (options?.includeToolMetadata) {
|
|
1875
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1876
|
+
const integrationsWithMetadata = await parallelWithLimit2(configuredIntegrations, async (integration) => {
|
|
1877
|
+
try {
|
|
1878
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1879
|
+
integration: integration.id
|
|
1880
|
+
});
|
|
1881
|
+
let toolMetadata = [];
|
|
1882
|
+
if (response.content && Array.isArray(response.content)) {
|
|
1883
|
+
for (const item of response.content) {
|
|
1884
|
+
if (item.type === "text" && item.text) {
|
|
1885
|
+
try {
|
|
1886
|
+
const parsed = JSON.parse(item.text);
|
|
1887
|
+
if (Array.isArray(parsed)) {
|
|
1888
|
+
toolMetadata = parsed;
|
|
1889
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1890
|
+
toolMetadata = parsed.tools;
|
|
1891
|
+
}
|
|
1892
|
+
} catch {}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
return {
|
|
1897
|
+
id: integration.id,
|
|
1898
|
+
name: integration.name || integration.id,
|
|
1899
|
+
tools: integration.tools,
|
|
1900
|
+
hasOAuth: !!integration.oauth,
|
|
1901
|
+
scopes: integration.oauth?.scopes,
|
|
1902
|
+
provider: integration.oauth?.provider,
|
|
1903
|
+
toolMetadata
|
|
1904
|
+
};
|
|
1905
|
+
} catch (error) {
|
|
1906
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1907
|
+
return {
|
|
1908
|
+
id: integration.id,
|
|
1909
|
+
name: integration.name || integration.id,
|
|
1910
|
+
tools: integration.tools,
|
|
1911
|
+
hasOAuth: !!integration.oauth,
|
|
1912
|
+
scopes: integration.oauth?.scopes,
|
|
1913
|
+
provider: integration.oauth?.provider,
|
|
1914
|
+
toolMetadata: []
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
}, 3);
|
|
1918
|
+
return {
|
|
1919
|
+
integrations: integrationsWithMetadata
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
return {
|
|
1923
|
+
integrations: configuredIntegrations.map((integration) => ({
|
|
1924
|
+
id: integration.id,
|
|
1925
|
+
name: integration.name || integration.id,
|
|
1926
|
+
tools: integration.tools,
|
|
1927
|
+
hasOAuth: !!integration.oauth,
|
|
1928
|
+
scopes: integration.oauth?.scopes,
|
|
1929
|
+
provider: integration.oauth?.provider
|
|
1930
|
+
}))
|
|
1931
|
+
};
|
|
1932
|
+
};
|
|
1853
1933
|
}
|
|
1854
1934
|
return async (args, options) => {
|
|
1855
1935
|
const toolName = methodToToolName(methodName, "");
|
|
@@ -9721,7 +9801,8 @@ function createMCPServer(config) {
|
|
|
9721
9801
|
globalServerConfig = {
|
|
9722
9802
|
providers,
|
|
9723
9803
|
serverUrl: config.serverUrl,
|
|
9724
|
-
apiKey: config.apiKey
|
|
9804
|
+
apiKey: config.apiKey,
|
|
9805
|
+
integrations: updatedIntegrations
|
|
9725
9806
|
};
|
|
9726
9807
|
const clientConfig = {
|
|
9727
9808
|
...config,
|
|
@@ -9737,6 +9818,7 @@ function createMCPServer(config) {
|
|
|
9737
9818
|
providers,
|
|
9738
9819
|
serverUrl: config.serverUrl,
|
|
9739
9820
|
apiKey: config.apiKey,
|
|
9821
|
+
integrations: updatedIntegrations,
|
|
9740
9822
|
getSessionContext: config.getSessionContext,
|
|
9741
9823
|
setProviderToken: config.setProviderToken,
|
|
9742
9824
|
removeProviderToken: config.removeProviderToken
|