integrate-sdk 0.8.52-dev.0 → 0.8.53-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 +127 -54
- package/dist/adapters/index.js +127 -54
- package/dist/adapters/nextjs.js +127 -54
- package/dist/adapters/node.js +127 -54
- package/dist/adapters/svelte-kit.js +127 -54
- package/dist/adapters/tanstack-start.js +127 -54
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +129 -55
- package/dist/oauth.js +127 -54
- package/dist/server.js +127 -54
- package/dist/src/client.d.ts +6 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +32 -0
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/index.ts +3 -0
- package/package.json +1 -1
|
@@ -1700,6 +1700,7 @@ class MCPClientBase {
|
|
|
1700
1700
|
apiBaseUrl;
|
|
1701
1701
|
databaseDetected = false;
|
|
1702
1702
|
__configuredIntegrations;
|
|
1703
|
+
__useServerConfig;
|
|
1703
1704
|
oauthCallbackPromise;
|
|
1704
1705
|
server;
|
|
1705
1706
|
trigger;
|
|
@@ -1726,6 +1727,7 @@ class MCPClientBase {
|
|
|
1726
1727
|
return integration;
|
|
1727
1728
|
});
|
|
1728
1729
|
this.__configuredIntegrations = this.integrations;
|
|
1730
|
+
this.__useServerConfig = config.useServerConfig ?? false;
|
|
1729
1731
|
this.clientInfo = config.clientInfo || {
|
|
1730
1732
|
name: "integrate-sdk",
|
|
1731
1733
|
version: "0.1.0"
|
|
@@ -1869,60 +1871,12 @@ class MCPClientBase {
|
|
|
1869
1871
|
get: (_target, methodName) => {
|
|
1870
1872
|
if (methodName === "listConfiguredIntegrations") {
|
|
1871
1873
|
return async (options) => {
|
|
1874
|
+
const transportHeaders = this.transport.headers || {};
|
|
1875
|
+
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
1872
1876
|
const serverConfig = this.__oauthConfig;
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1875
|
-
|
|
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
|
-
logoUrl: integration.logoUrl,
|
|
1900
|
-
tools: integration.tools,
|
|
1901
|
-
hasOAuth: !!integration.oauth,
|
|
1902
|
-
scopes: integration.oauth?.scopes,
|
|
1903
|
-
provider: integration.oauth?.provider,
|
|
1904
|
-
toolMetadata
|
|
1905
|
-
};
|
|
1906
|
-
} catch (error) {
|
|
1907
|
-
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1908
|
-
return {
|
|
1909
|
-
id: integration.id,
|
|
1910
|
-
name: integration.name || integration.id,
|
|
1911
|
-
logoUrl: integration.logoUrl,
|
|
1912
|
-
tools: integration.tools,
|
|
1913
|
-
hasOAuth: !!integration.oauth,
|
|
1914
|
-
scopes: integration.oauth?.scopes,
|
|
1915
|
-
provider: integration.oauth?.provider,
|
|
1916
|
-
toolMetadata: []
|
|
1917
|
-
};
|
|
1918
|
-
}
|
|
1919
|
-
}, 3);
|
|
1920
|
-
return {
|
|
1921
|
-
integrations: integrationsWithMetadata
|
|
1922
|
-
};
|
|
1923
|
-
}
|
|
1924
|
-
return {
|
|
1925
|
-
integrations: configuredIntegrations.map((integration) => ({
|
|
1877
|
+
const localIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
1878
|
+
const formatLocalIntegrations = (integrations) => ({
|
|
1879
|
+
integrations: integrations.map((integration) => ({
|
|
1926
1880
|
id: integration.id,
|
|
1927
1881
|
name: integration.name || integration.id,
|
|
1928
1882
|
logoUrl: integration.logoUrl,
|
|
@@ -1931,7 +1885,114 @@ class MCPClientBase {
|
|
|
1931
1885
|
scopes: integration.oauth?.scopes,
|
|
1932
1886
|
provider: integration.oauth?.provider
|
|
1933
1887
|
}))
|
|
1934
|
-
};
|
|
1888
|
+
});
|
|
1889
|
+
if (hasApiKey || !this.__useServerConfig) {
|
|
1890
|
+
if (options?.includeToolMetadata) {
|
|
1891
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1892
|
+
const integrationsWithMetadata = await parallelWithLimit2(localIntegrations, async (integration) => {
|
|
1893
|
+
try {
|
|
1894
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1895
|
+
integration: integration.id
|
|
1896
|
+
});
|
|
1897
|
+
let toolMetadata = [];
|
|
1898
|
+
if (response.content && Array.isArray(response.content)) {
|
|
1899
|
+
for (const item of response.content) {
|
|
1900
|
+
if (item.type === "text" && item.text) {
|
|
1901
|
+
try {
|
|
1902
|
+
const parsed = JSON.parse(item.text);
|
|
1903
|
+
if (Array.isArray(parsed)) {
|
|
1904
|
+
toolMetadata = parsed;
|
|
1905
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1906
|
+
toolMetadata = parsed.tools;
|
|
1907
|
+
}
|
|
1908
|
+
} catch {}
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return {
|
|
1913
|
+
id: integration.id,
|
|
1914
|
+
name: integration.name || integration.id,
|
|
1915
|
+
logoUrl: integration.logoUrl,
|
|
1916
|
+
tools: integration.tools,
|
|
1917
|
+
hasOAuth: !!integration.oauth,
|
|
1918
|
+
scopes: integration.oauth?.scopes,
|
|
1919
|
+
provider: integration.oauth?.provider,
|
|
1920
|
+
toolMetadata
|
|
1921
|
+
};
|
|
1922
|
+
} catch (error) {
|
|
1923
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1924
|
+
return {
|
|
1925
|
+
id: integration.id,
|
|
1926
|
+
name: integration.name || integration.id,
|
|
1927
|
+
logoUrl: integration.logoUrl,
|
|
1928
|
+
tools: integration.tools,
|
|
1929
|
+
hasOAuth: !!integration.oauth,
|
|
1930
|
+
scopes: integration.oauth?.scopes,
|
|
1931
|
+
provider: integration.oauth?.provider,
|
|
1932
|
+
toolMetadata: []
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
}, 3);
|
|
1936
|
+
return {
|
|
1937
|
+
integrations: integrationsWithMetadata
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1941
|
+
}
|
|
1942
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/integrations` : `${this.apiRouteBase}/integrations`;
|
|
1943
|
+
try {
|
|
1944
|
+
const response = await fetch(url, {
|
|
1945
|
+
method: "GET",
|
|
1946
|
+
headers: {
|
|
1947
|
+
"Content-Type": "application/json"
|
|
1948
|
+
}
|
|
1949
|
+
});
|
|
1950
|
+
if (!response.ok) {
|
|
1951
|
+
logger5.error("Failed to fetch integrations from server, falling back to local config");
|
|
1952
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1953
|
+
}
|
|
1954
|
+
const result = await response.json();
|
|
1955
|
+
if (options?.includeToolMetadata && result.integrations) {
|
|
1956
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1957
|
+
const integrationsWithMetadata = await parallelWithLimit2(result.integrations, async (integration) => {
|
|
1958
|
+
try {
|
|
1959
|
+
const metadataResponse = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1960
|
+
integration: integration.id
|
|
1961
|
+
});
|
|
1962
|
+
let toolMetadata = [];
|
|
1963
|
+
if (metadataResponse.content && Array.isArray(metadataResponse.content)) {
|
|
1964
|
+
for (const item of metadataResponse.content) {
|
|
1965
|
+
if (item.type === "text" && item.text) {
|
|
1966
|
+
try {
|
|
1967
|
+
const parsed = JSON.parse(item.text);
|
|
1968
|
+
if (Array.isArray(parsed)) {
|
|
1969
|
+
toolMetadata = parsed;
|
|
1970
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1971
|
+
toolMetadata = parsed.tools;
|
|
1972
|
+
}
|
|
1973
|
+
} catch {}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
return {
|
|
1978
|
+
...integration,
|
|
1979
|
+
toolMetadata
|
|
1980
|
+
};
|
|
1981
|
+
} catch (error) {
|
|
1982
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1983
|
+
return {
|
|
1984
|
+
...integration,
|
|
1985
|
+
toolMetadata: []
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
}, 3);
|
|
1989
|
+
return { integrations: integrationsWithMetadata };
|
|
1990
|
+
}
|
|
1991
|
+
return result;
|
|
1992
|
+
} catch (error) {
|
|
1993
|
+
logger5.error("Failed to fetch integrations from server, falling back to local config:", error);
|
|
1994
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1995
|
+
}
|
|
1935
1996
|
};
|
|
1936
1997
|
}
|
|
1937
1998
|
return async (args, options) => {
|
|
@@ -9964,6 +10025,18 @@ function createMCPServer(config) {
|
|
|
9964
10025
|
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
9965
10026
|
}
|
|
9966
10027
|
}
|
|
10028
|
+
if (action === "integrations" && method === "GET") {
|
|
10029
|
+
const integrations = updatedIntegrations.map((integration) => ({
|
|
10030
|
+
id: integration.id,
|
|
10031
|
+
name: integration.name || integration.id,
|
|
10032
|
+
logoUrl: integration.logoUrl,
|
|
10033
|
+
tools: integration.tools,
|
|
10034
|
+
hasOAuth: !!integration.oauth,
|
|
10035
|
+
scopes: integration.oauth?.scopes,
|
|
10036
|
+
provider: integration.oauth?.provider
|
|
10037
|
+
}));
|
|
10038
|
+
return Response.json({ integrations });
|
|
10039
|
+
}
|
|
9967
10040
|
if (segments.length >= 1 && segments[0] === "triggers") {
|
|
9968
10041
|
if (!config.triggers) {
|
|
9969
10042
|
return Response.json({ error: "Triggers not configured. Add triggers callbacks to createMCPServer config." }, { status: 501 });
|
package/dist/adapters/index.js
CHANGED
|
@@ -1700,6 +1700,7 @@ class MCPClientBase {
|
|
|
1700
1700
|
apiBaseUrl;
|
|
1701
1701
|
databaseDetected = false;
|
|
1702
1702
|
__configuredIntegrations;
|
|
1703
|
+
__useServerConfig;
|
|
1703
1704
|
oauthCallbackPromise;
|
|
1704
1705
|
server;
|
|
1705
1706
|
trigger;
|
|
@@ -1726,6 +1727,7 @@ class MCPClientBase {
|
|
|
1726
1727
|
return integration;
|
|
1727
1728
|
});
|
|
1728
1729
|
this.__configuredIntegrations = this.integrations;
|
|
1730
|
+
this.__useServerConfig = config.useServerConfig ?? false;
|
|
1729
1731
|
this.clientInfo = config.clientInfo || {
|
|
1730
1732
|
name: "integrate-sdk",
|
|
1731
1733
|
version: "0.1.0"
|
|
@@ -1869,60 +1871,12 @@ class MCPClientBase {
|
|
|
1869
1871
|
get: (_target, methodName) => {
|
|
1870
1872
|
if (methodName === "listConfiguredIntegrations") {
|
|
1871
1873
|
return async (options) => {
|
|
1874
|
+
const transportHeaders = this.transport.headers || {};
|
|
1875
|
+
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
1872
1876
|
const serverConfig = this.__oauthConfig;
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1875
|
-
|
|
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
|
-
logoUrl: integration.logoUrl,
|
|
1900
|
-
tools: integration.tools,
|
|
1901
|
-
hasOAuth: !!integration.oauth,
|
|
1902
|
-
scopes: integration.oauth?.scopes,
|
|
1903
|
-
provider: integration.oauth?.provider,
|
|
1904
|
-
toolMetadata
|
|
1905
|
-
};
|
|
1906
|
-
} catch (error) {
|
|
1907
|
-
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1908
|
-
return {
|
|
1909
|
-
id: integration.id,
|
|
1910
|
-
name: integration.name || integration.id,
|
|
1911
|
-
logoUrl: integration.logoUrl,
|
|
1912
|
-
tools: integration.tools,
|
|
1913
|
-
hasOAuth: !!integration.oauth,
|
|
1914
|
-
scopes: integration.oauth?.scopes,
|
|
1915
|
-
provider: integration.oauth?.provider,
|
|
1916
|
-
toolMetadata: []
|
|
1917
|
-
};
|
|
1918
|
-
}
|
|
1919
|
-
}, 3);
|
|
1920
|
-
return {
|
|
1921
|
-
integrations: integrationsWithMetadata
|
|
1922
|
-
};
|
|
1923
|
-
}
|
|
1924
|
-
return {
|
|
1925
|
-
integrations: configuredIntegrations.map((integration) => ({
|
|
1877
|
+
const localIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
1878
|
+
const formatLocalIntegrations = (integrations) => ({
|
|
1879
|
+
integrations: integrations.map((integration) => ({
|
|
1926
1880
|
id: integration.id,
|
|
1927
1881
|
name: integration.name || integration.id,
|
|
1928
1882
|
logoUrl: integration.logoUrl,
|
|
@@ -1931,7 +1885,114 @@ class MCPClientBase {
|
|
|
1931
1885
|
scopes: integration.oauth?.scopes,
|
|
1932
1886
|
provider: integration.oauth?.provider
|
|
1933
1887
|
}))
|
|
1934
|
-
};
|
|
1888
|
+
});
|
|
1889
|
+
if (hasApiKey || !this.__useServerConfig) {
|
|
1890
|
+
if (options?.includeToolMetadata) {
|
|
1891
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1892
|
+
const integrationsWithMetadata = await parallelWithLimit2(localIntegrations, async (integration) => {
|
|
1893
|
+
try {
|
|
1894
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1895
|
+
integration: integration.id
|
|
1896
|
+
});
|
|
1897
|
+
let toolMetadata = [];
|
|
1898
|
+
if (response.content && Array.isArray(response.content)) {
|
|
1899
|
+
for (const item of response.content) {
|
|
1900
|
+
if (item.type === "text" && item.text) {
|
|
1901
|
+
try {
|
|
1902
|
+
const parsed = JSON.parse(item.text);
|
|
1903
|
+
if (Array.isArray(parsed)) {
|
|
1904
|
+
toolMetadata = parsed;
|
|
1905
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1906
|
+
toolMetadata = parsed.tools;
|
|
1907
|
+
}
|
|
1908
|
+
} catch {}
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return {
|
|
1913
|
+
id: integration.id,
|
|
1914
|
+
name: integration.name || integration.id,
|
|
1915
|
+
logoUrl: integration.logoUrl,
|
|
1916
|
+
tools: integration.tools,
|
|
1917
|
+
hasOAuth: !!integration.oauth,
|
|
1918
|
+
scopes: integration.oauth?.scopes,
|
|
1919
|
+
provider: integration.oauth?.provider,
|
|
1920
|
+
toolMetadata
|
|
1921
|
+
};
|
|
1922
|
+
} catch (error) {
|
|
1923
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1924
|
+
return {
|
|
1925
|
+
id: integration.id,
|
|
1926
|
+
name: integration.name || integration.id,
|
|
1927
|
+
logoUrl: integration.logoUrl,
|
|
1928
|
+
tools: integration.tools,
|
|
1929
|
+
hasOAuth: !!integration.oauth,
|
|
1930
|
+
scopes: integration.oauth?.scopes,
|
|
1931
|
+
provider: integration.oauth?.provider,
|
|
1932
|
+
toolMetadata: []
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
}, 3);
|
|
1936
|
+
return {
|
|
1937
|
+
integrations: integrationsWithMetadata
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1941
|
+
}
|
|
1942
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/integrations` : `${this.apiRouteBase}/integrations`;
|
|
1943
|
+
try {
|
|
1944
|
+
const response = await fetch(url, {
|
|
1945
|
+
method: "GET",
|
|
1946
|
+
headers: {
|
|
1947
|
+
"Content-Type": "application/json"
|
|
1948
|
+
}
|
|
1949
|
+
});
|
|
1950
|
+
if (!response.ok) {
|
|
1951
|
+
logger5.error("Failed to fetch integrations from server, falling back to local config");
|
|
1952
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1953
|
+
}
|
|
1954
|
+
const result = await response.json();
|
|
1955
|
+
if (options?.includeToolMetadata && result.integrations) {
|
|
1956
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1957
|
+
const integrationsWithMetadata = await parallelWithLimit2(result.integrations, async (integration) => {
|
|
1958
|
+
try {
|
|
1959
|
+
const metadataResponse = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1960
|
+
integration: integration.id
|
|
1961
|
+
});
|
|
1962
|
+
let toolMetadata = [];
|
|
1963
|
+
if (metadataResponse.content && Array.isArray(metadataResponse.content)) {
|
|
1964
|
+
for (const item of metadataResponse.content) {
|
|
1965
|
+
if (item.type === "text" && item.text) {
|
|
1966
|
+
try {
|
|
1967
|
+
const parsed = JSON.parse(item.text);
|
|
1968
|
+
if (Array.isArray(parsed)) {
|
|
1969
|
+
toolMetadata = parsed;
|
|
1970
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1971
|
+
toolMetadata = parsed.tools;
|
|
1972
|
+
}
|
|
1973
|
+
} catch {}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
return {
|
|
1978
|
+
...integration,
|
|
1979
|
+
toolMetadata
|
|
1980
|
+
};
|
|
1981
|
+
} catch (error) {
|
|
1982
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1983
|
+
return {
|
|
1984
|
+
...integration,
|
|
1985
|
+
toolMetadata: []
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
}, 3);
|
|
1989
|
+
return { integrations: integrationsWithMetadata };
|
|
1990
|
+
}
|
|
1991
|
+
return result;
|
|
1992
|
+
} catch (error) {
|
|
1993
|
+
logger5.error("Failed to fetch integrations from server, falling back to local config:", error);
|
|
1994
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1995
|
+
}
|
|
1935
1996
|
};
|
|
1936
1997
|
}
|
|
1937
1998
|
return async (args, options) => {
|
|
@@ -9964,6 +10025,18 @@ function createMCPServer(config) {
|
|
|
9964
10025
|
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
9965
10026
|
}
|
|
9966
10027
|
}
|
|
10028
|
+
if (action === "integrations" && method === "GET") {
|
|
10029
|
+
const integrations = updatedIntegrations.map((integration) => ({
|
|
10030
|
+
id: integration.id,
|
|
10031
|
+
name: integration.name || integration.id,
|
|
10032
|
+
logoUrl: integration.logoUrl,
|
|
10033
|
+
tools: integration.tools,
|
|
10034
|
+
hasOAuth: !!integration.oauth,
|
|
10035
|
+
scopes: integration.oauth?.scopes,
|
|
10036
|
+
provider: integration.oauth?.provider
|
|
10037
|
+
}));
|
|
10038
|
+
return Response.json({ integrations });
|
|
10039
|
+
}
|
|
9967
10040
|
if (segments.length >= 1 && segments[0] === "triggers") {
|
|
9968
10041
|
if (!config.triggers) {
|
|
9969
10042
|
return Response.json({ error: "Triggers not configured. Add triggers callbacks to createMCPServer config." }, { status: 501 });
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -1700,6 +1700,7 @@ class MCPClientBase {
|
|
|
1700
1700
|
apiBaseUrl;
|
|
1701
1701
|
databaseDetected = false;
|
|
1702
1702
|
__configuredIntegrations;
|
|
1703
|
+
__useServerConfig;
|
|
1703
1704
|
oauthCallbackPromise;
|
|
1704
1705
|
server;
|
|
1705
1706
|
trigger;
|
|
@@ -1726,6 +1727,7 @@ class MCPClientBase {
|
|
|
1726
1727
|
return integration;
|
|
1727
1728
|
});
|
|
1728
1729
|
this.__configuredIntegrations = this.integrations;
|
|
1730
|
+
this.__useServerConfig = config.useServerConfig ?? false;
|
|
1729
1731
|
this.clientInfo = config.clientInfo || {
|
|
1730
1732
|
name: "integrate-sdk",
|
|
1731
1733
|
version: "0.1.0"
|
|
@@ -1869,60 +1871,12 @@ class MCPClientBase {
|
|
|
1869
1871
|
get: (_target, methodName) => {
|
|
1870
1872
|
if (methodName === "listConfiguredIntegrations") {
|
|
1871
1873
|
return async (options) => {
|
|
1874
|
+
const transportHeaders = this.transport.headers || {};
|
|
1875
|
+
const hasApiKey = !!transportHeaders["X-API-KEY"];
|
|
1872
1876
|
const serverConfig = this.__oauthConfig;
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1875
|
-
|
|
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
|
-
logoUrl: integration.logoUrl,
|
|
1900
|
-
tools: integration.tools,
|
|
1901
|
-
hasOAuth: !!integration.oauth,
|
|
1902
|
-
scopes: integration.oauth?.scopes,
|
|
1903
|
-
provider: integration.oauth?.provider,
|
|
1904
|
-
toolMetadata
|
|
1905
|
-
};
|
|
1906
|
-
} catch (error) {
|
|
1907
|
-
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1908
|
-
return {
|
|
1909
|
-
id: integration.id,
|
|
1910
|
-
name: integration.name || integration.id,
|
|
1911
|
-
logoUrl: integration.logoUrl,
|
|
1912
|
-
tools: integration.tools,
|
|
1913
|
-
hasOAuth: !!integration.oauth,
|
|
1914
|
-
scopes: integration.oauth?.scopes,
|
|
1915
|
-
provider: integration.oauth?.provider,
|
|
1916
|
-
toolMetadata: []
|
|
1917
|
-
};
|
|
1918
|
-
}
|
|
1919
|
-
}, 3);
|
|
1920
|
-
return {
|
|
1921
|
-
integrations: integrationsWithMetadata
|
|
1922
|
-
};
|
|
1923
|
-
}
|
|
1924
|
-
return {
|
|
1925
|
-
integrations: configuredIntegrations.map((integration) => ({
|
|
1877
|
+
const localIntegrations = serverConfig?.integrations || this.__configuredIntegrations;
|
|
1878
|
+
const formatLocalIntegrations = (integrations) => ({
|
|
1879
|
+
integrations: integrations.map((integration) => ({
|
|
1926
1880
|
id: integration.id,
|
|
1927
1881
|
name: integration.name || integration.id,
|
|
1928
1882
|
logoUrl: integration.logoUrl,
|
|
@@ -1931,7 +1885,114 @@ class MCPClientBase {
|
|
|
1931
1885
|
scopes: integration.oauth?.scopes,
|
|
1932
1886
|
provider: integration.oauth?.provider
|
|
1933
1887
|
}))
|
|
1934
|
-
};
|
|
1888
|
+
});
|
|
1889
|
+
if (hasApiKey || !this.__useServerConfig) {
|
|
1890
|
+
if (options?.includeToolMetadata) {
|
|
1891
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1892
|
+
const integrationsWithMetadata = await parallelWithLimit2(localIntegrations, async (integration) => {
|
|
1893
|
+
try {
|
|
1894
|
+
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1895
|
+
integration: integration.id
|
|
1896
|
+
});
|
|
1897
|
+
let toolMetadata = [];
|
|
1898
|
+
if (response.content && Array.isArray(response.content)) {
|
|
1899
|
+
for (const item of response.content) {
|
|
1900
|
+
if (item.type === "text" && item.text) {
|
|
1901
|
+
try {
|
|
1902
|
+
const parsed = JSON.parse(item.text);
|
|
1903
|
+
if (Array.isArray(parsed)) {
|
|
1904
|
+
toolMetadata = parsed;
|
|
1905
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1906
|
+
toolMetadata = parsed.tools;
|
|
1907
|
+
}
|
|
1908
|
+
} catch {}
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return {
|
|
1913
|
+
id: integration.id,
|
|
1914
|
+
name: integration.name || integration.id,
|
|
1915
|
+
logoUrl: integration.logoUrl,
|
|
1916
|
+
tools: integration.tools,
|
|
1917
|
+
hasOAuth: !!integration.oauth,
|
|
1918
|
+
scopes: integration.oauth?.scopes,
|
|
1919
|
+
provider: integration.oauth?.provider,
|
|
1920
|
+
toolMetadata
|
|
1921
|
+
};
|
|
1922
|
+
} catch (error) {
|
|
1923
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1924
|
+
return {
|
|
1925
|
+
id: integration.id,
|
|
1926
|
+
name: integration.name || integration.id,
|
|
1927
|
+
logoUrl: integration.logoUrl,
|
|
1928
|
+
tools: integration.tools,
|
|
1929
|
+
hasOAuth: !!integration.oauth,
|
|
1930
|
+
scopes: integration.oauth?.scopes,
|
|
1931
|
+
provider: integration.oauth?.provider,
|
|
1932
|
+
toolMetadata: []
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
}, 3);
|
|
1936
|
+
return {
|
|
1937
|
+
integrations: integrationsWithMetadata
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1941
|
+
}
|
|
1942
|
+
const url = this.apiBaseUrl ? `${this.apiBaseUrl}${this.apiRouteBase}/integrations` : `${this.apiRouteBase}/integrations`;
|
|
1943
|
+
try {
|
|
1944
|
+
const response = await fetch(url, {
|
|
1945
|
+
method: "GET",
|
|
1946
|
+
headers: {
|
|
1947
|
+
"Content-Type": "application/json"
|
|
1948
|
+
}
|
|
1949
|
+
});
|
|
1950
|
+
if (!response.ok) {
|
|
1951
|
+
logger5.error("Failed to fetch integrations from server, falling back to local config");
|
|
1952
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1953
|
+
}
|
|
1954
|
+
const result = await response.json();
|
|
1955
|
+
if (options?.includeToolMetadata && result.integrations) {
|
|
1956
|
+
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
1957
|
+
const integrationsWithMetadata = await parallelWithLimit2(result.integrations, async (integration) => {
|
|
1958
|
+
try {
|
|
1959
|
+
const metadataResponse = await this.callServerToolInternal("list_tools_by_integration", {
|
|
1960
|
+
integration: integration.id
|
|
1961
|
+
});
|
|
1962
|
+
let toolMetadata = [];
|
|
1963
|
+
if (metadataResponse.content && Array.isArray(metadataResponse.content)) {
|
|
1964
|
+
for (const item of metadataResponse.content) {
|
|
1965
|
+
if (item.type === "text" && item.text) {
|
|
1966
|
+
try {
|
|
1967
|
+
const parsed = JSON.parse(item.text);
|
|
1968
|
+
if (Array.isArray(parsed)) {
|
|
1969
|
+
toolMetadata = parsed;
|
|
1970
|
+
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1971
|
+
toolMetadata = parsed.tools;
|
|
1972
|
+
}
|
|
1973
|
+
} catch {}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
return {
|
|
1978
|
+
...integration,
|
|
1979
|
+
toolMetadata
|
|
1980
|
+
};
|
|
1981
|
+
} catch (error) {
|
|
1982
|
+
logger5.error(`Failed to fetch tool metadata for ${integration.id}:`, error);
|
|
1983
|
+
return {
|
|
1984
|
+
...integration,
|
|
1985
|
+
toolMetadata: []
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
}, 3);
|
|
1989
|
+
return { integrations: integrationsWithMetadata };
|
|
1990
|
+
}
|
|
1991
|
+
return result;
|
|
1992
|
+
} catch (error) {
|
|
1993
|
+
logger5.error("Failed to fetch integrations from server, falling back to local config:", error);
|
|
1994
|
+
return formatLocalIntegrations(localIntegrations);
|
|
1995
|
+
}
|
|
1935
1996
|
};
|
|
1936
1997
|
}
|
|
1937
1998
|
return async (args, options) => {
|
|
@@ -9964,6 +10025,18 @@ function createMCPServer(config) {
|
|
|
9964
10025
|
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
9965
10026
|
}
|
|
9966
10027
|
}
|
|
10028
|
+
if (action === "integrations" && method === "GET") {
|
|
10029
|
+
const integrations = updatedIntegrations.map((integration) => ({
|
|
10030
|
+
id: integration.id,
|
|
10031
|
+
name: integration.name || integration.id,
|
|
10032
|
+
logoUrl: integration.logoUrl,
|
|
10033
|
+
tools: integration.tools,
|
|
10034
|
+
hasOAuth: !!integration.oauth,
|
|
10035
|
+
scopes: integration.oauth?.scopes,
|
|
10036
|
+
provider: integration.oauth?.provider
|
|
10037
|
+
}));
|
|
10038
|
+
return Response.json({ integrations });
|
|
10039
|
+
}
|
|
9967
10040
|
if (segments.length >= 1 && segments[0] === "triggers") {
|
|
9968
10041
|
if (!config.triggers) {
|
|
9969
10042
|
return Response.json({ error: "Triggers not configured. Add triggers callbacks to createMCPServer config." }, { status: 501 });
|