integrate-sdk 0.6.8 → 0.7.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 +36 -0
- package/dist/adapters/base-handler.js +36 -0
- package/dist/adapters/nextjs-oauth-redirect.js +1 -0
- package/dist/adapters/nextjs.js +53 -0
- package/dist/adapters/node.js +36 -0
- package/dist/adapters/solid-start.js +1829 -3
- package/dist/adapters/svelte-kit.js +1840 -5
- package/dist/adapters/tanstack-start.js +1 -0
- package/dist/index.js +421 -82
- package/dist/oauth.js +35 -0
- package/dist/server.js +248 -38
- package/dist/src/adapters/base-handler.d.ts +34 -0
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- package/dist/src/adapters/nextjs.d.ts +26 -0
- package/dist/src/adapters/nextjs.d.ts.map +1 -1
- package/dist/src/adapters/solid-start.d.ts +2 -48
- package/dist/src/adapters/solid-start.d.ts.map +1 -1
- package/dist/src/adapters/svelte-kit.d.ts +7 -6
- package/dist/src/adapters/svelte-kit.d.ts.map +1 -1
- package/dist/src/client.d.ts +6 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +18 -0
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/server.d.ts +158 -0
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/utils/env.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1014,6 +1014,7 @@ class MCPClient {
|
|
|
1014
1014
|
connecting = null;
|
|
1015
1015
|
oauthManager;
|
|
1016
1016
|
eventEmitter = new SimpleEventEmitter;
|
|
1017
|
+
apiRouteBase;
|
|
1017
1018
|
github;
|
|
1018
1019
|
gmail;
|
|
1019
1020
|
server;
|
|
@@ -1025,6 +1026,7 @@ class MCPClient {
|
|
|
1025
1026
|
});
|
|
1026
1027
|
const oauthApiBase = config.oauthApiBase || "/api/integrate/oauth";
|
|
1027
1028
|
const defaultRedirectUri = this.getDefaultRedirectUri(oauthApiBase);
|
|
1029
|
+
this.apiRouteBase = config.apiRouteBase || "/api/integrate";
|
|
1028
1030
|
this.plugins = config.plugins.map((plugin) => {
|
|
1029
1031
|
if (plugin.oauth && !plugin.oauth.redirectUri) {
|
|
1030
1032
|
return {
|
|
@@ -1116,12 +1118,8 @@ class MCPClient {
|
|
|
1116
1118
|
if (!this.availableTools.has(name)) {
|
|
1117
1119
|
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
1118
1120
|
}
|
|
1119
|
-
const params = {
|
|
1120
|
-
name,
|
|
1121
|
-
arguments: args
|
|
1122
|
-
};
|
|
1123
1121
|
try {
|
|
1124
|
-
const response = await this.
|
|
1122
|
+
const response = await this.callToolThroughHandler(name, args);
|
|
1125
1123
|
return response;
|
|
1126
1124
|
} catch (error) {
|
|
1127
1125
|
const parsedError = parseServerError(error, { toolName: name });
|
|
@@ -1180,18 +1178,58 @@ class MCPClient {
|
|
|
1180
1178
|
if (!this.availableTools.has(name)) {
|
|
1181
1179
|
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
1182
1180
|
}
|
|
1183
|
-
const params = {
|
|
1184
|
-
name,
|
|
1185
|
-
arguments: args
|
|
1186
|
-
};
|
|
1187
1181
|
try {
|
|
1188
|
-
const response = await this.
|
|
1182
|
+
const response = await this.callToolThroughHandler(name, args);
|
|
1189
1183
|
return response;
|
|
1190
1184
|
} catch (error) {
|
|
1191
1185
|
const parsedError = parseServerError(error, { toolName: name });
|
|
1192
1186
|
throw parsedError;
|
|
1193
1187
|
}
|
|
1194
1188
|
}
|
|
1189
|
+
async callToolThroughHandler(name, args, provider) {
|
|
1190
|
+
const url = `${this.apiRouteBase}/mcp`;
|
|
1191
|
+
const headers = {
|
|
1192
|
+
"Content-Type": "application/json"
|
|
1193
|
+
};
|
|
1194
|
+
if (provider) {
|
|
1195
|
+
const tokenData = this.oauthManager.getProviderToken(provider);
|
|
1196
|
+
if (tokenData) {
|
|
1197
|
+
headers["Authorization"] = `Bearer ${tokenData.accessToken}`;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
const response = await fetch(url, {
|
|
1201
|
+
method: "POST",
|
|
1202
|
+
headers,
|
|
1203
|
+
body: JSON.stringify({
|
|
1204
|
+
name,
|
|
1205
|
+
arguments: args
|
|
1206
|
+
})
|
|
1207
|
+
});
|
|
1208
|
+
if (!response.ok) {
|
|
1209
|
+
let errorMessage = `Request failed: ${response.statusText}`;
|
|
1210
|
+
const error = new Error(errorMessage);
|
|
1211
|
+
error.statusCode = response.status;
|
|
1212
|
+
try {
|
|
1213
|
+
const errorData = await response.json();
|
|
1214
|
+
if (errorData.error) {
|
|
1215
|
+
errorMessage = typeof errorData.error === "string" ? errorData.error : errorData.error.message || errorMessage;
|
|
1216
|
+
error.message = errorMessage;
|
|
1217
|
+
}
|
|
1218
|
+
if (errorData.code) {
|
|
1219
|
+
error.code = errorData.code;
|
|
1220
|
+
}
|
|
1221
|
+
if (errorData.data) {
|
|
1222
|
+
error.data = errorData.data;
|
|
1223
|
+
}
|
|
1224
|
+
if (errorData.error && typeof errorData.error === "object") {
|
|
1225
|
+
error.jsonrpcError = errorData.error;
|
|
1226
|
+
}
|
|
1227
|
+
} catch {}
|
|
1228
|
+
throw error;
|
|
1229
|
+
}
|
|
1230
|
+
const result = await response.json();
|
|
1231
|
+
return result;
|
|
1232
|
+
}
|
|
1195
1233
|
async callToolWithRetry(name, args, retryCount = 0) {
|
|
1196
1234
|
if (!this.initialized) {
|
|
1197
1235
|
throw new Error("Client not initialized. Call connect() first.");
|
|
@@ -1203,35 +1241,24 @@ class MCPClient {
|
|
|
1203
1241
|
throw new Error(`Tool "${name}" is not available on the server. Available tools: ${Array.from(this.availableTools.keys()).join(", ")}`);
|
|
1204
1242
|
}
|
|
1205
1243
|
const provider = this.getProviderForTool(name);
|
|
1206
|
-
if (provider) {
|
|
1207
|
-
const tokenData = this.oauthManager.getProviderToken(provider);
|
|
1208
|
-
if (tokenData) {
|
|
1209
|
-
this.transport.setHeader("Authorization", `Bearer ${tokenData.accessToken}`);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
const params = {
|
|
1213
|
-
name,
|
|
1214
|
-
arguments: args
|
|
1215
|
-
};
|
|
1216
1244
|
try {
|
|
1217
|
-
const response = await this.
|
|
1245
|
+
const response = await this.callToolThroughHandler(name, args, provider);
|
|
1218
1246
|
if (provider) {
|
|
1219
1247
|
this.authState.set(provider, { authenticated: true });
|
|
1220
1248
|
}
|
|
1221
1249
|
return response;
|
|
1222
1250
|
} catch (error) {
|
|
1223
|
-
const
|
|
1224
|
-
const parsedError = parseServerError(error, { toolName: name, provider: provider2 });
|
|
1251
|
+
const parsedError = parseServerError(error, { toolName: name, provider });
|
|
1225
1252
|
if (isAuthError(parsedError) && retryCount < this.maxReauthRetries) {
|
|
1226
|
-
if (
|
|
1227
|
-
this.authState.set(
|
|
1253
|
+
if (provider) {
|
|
1254
|
+
this.authState.set(provider, {
|
|
1228
1255
|
authenticated: false,
|
|
1229
1256
|
lastError: parsedError
|
|
1230
1257
|
});
|
|
1231
1258
|
}
|
|
1232
|
-
if (this.onReauthRequired &&
|
|
1259
|
+
if (this.onReauthRequired && provider) {
|
|
1233
1260
|
const reauthSuccess = await this.onReauthRequired({
|
|
1234
|
-
provider
|
|
1261
|
+
provider,
|
|
1235
1262
|
error: parsedError,
|
|
1236
1263
|
toolName: name
|
|
1237
1264
|
});
|
|
@@ -1685,6 +1712,41 @@ class OAuthHandler {
|
|
|
1685
1712
|
const data = await response.json();
|
|
1686
1713
|
return data;
|
|
1687
1714
|
}
|
|
1715
|
+
async handleToolCall(request, authHeader) {
|
|
1716
|
+
const url = new URL("/tools/call", this.serverUrl);
|
|
1717
|
+
const headers = this.getHeaders({
|
|
1718
|
+
"Content-Type": "application/json"
|
|
1719
|
+
});
|
|
1720
|
+
if (authHeader && authHeader.startsWith("Bearer ")) {
|
|
1721
|
+
headers["Authorization"] = authHeader;
|
|
1722
|
+
}
|
|
1723
|
+
const jsonRpcRequest = {
|
|
1724
|
+
jsonrpc: "2.0",
|
|
1725
|
+
id: Date.now() + Math.random(),
|
|
1726
|
+
method: "tools/call",
|
|
1727
|
+
params: {
|
|
1728
|
+
name: request.name,
|
|
1729
|
+
arguments: request.arguments || {}
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
const response = await fetch(url.toString(), {
|
|
1733
|
+
method: "POST",
|
|
1734
|
+
headers,
|
|
1735
|
+
body: JSON.stringify(jsonRpcRequest)
|
|
1736
|
+
});
|
|
1737
|
+
if (!response.ok) {
|
|
1738
|
+
const error = await response.text();
|
|
1739
|
+
throw new Error(`MCP server failed to execute tool call: ${error}`);
|
|
1740
|
+
}
|
|
1741
|
+
const jsonRpcResponse = await response.json();
|
|
1742
|
+
if (jsonRpcResponse.error) {
|
|
1743
|
+
const error = new Error(jsonRpcResponse.error.message || "Tool call failed");
|
|
1744
|
+
error.code = jsonRpcResponse.error.code;
|
|
1745
|
+
error.data = jsonRpcResponse.error.data;
|
|
1746
|
+
throw error;
|
|
1747
|
+
}
|
|
1748
|
+
return jsonRpcResponse.result;
|
|
1749
|
+
}
|
|
1688
1750
|
}
|
|
1689
1751
|
|
|
1690
1752
|
// src/adapters/nextjs.ts
|
|
@@ -1762,6 +1824,9 @@ function createNextOAuthHandler(config) {
|
|
|
1762
1824
|
if (action === "disconnect") {
|
|
1763
1825
|
return handlers.disconnect(req);
|
|
1764
1826
|
}
|
|
1827
|
+
if (action === "mcp") {
|
|
1828
|
+
return handlers.mcp(req);
|
|
1829
|
+
}
|
|
1765
1830
|
return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
|
|
1766
1831
|
},
|
|
1767
1832
|
async GET(req, context) {
|
|
@@ -1774,6 +1839,17 @@ function createNextOAuthHandler(config) {
|
|
|
1774
1839
|
}
|
|
1775
1840
|
};
|
|
1776
1841
|
},
|
|
1842
|
+
async mcp(req) {
|
|
1843
|
+
try {
|
|
1844
|
+
const body = await req.json();
|
|
1845
|
+
const authHeader = req.headers.get("authorization");
|
|
1846
|
+
const result = await handler.handleToolCall(body, authHeader);
|
|
1847
|
+
return Response.json(result);
|
|
1848
|
+
} catch (error) {
|
|
1849
|
+
console.error("[MCP Tool Call] Error:", error);
|
|
1850
|
+
return Response.json({ error: error.message || "Failed to execute tool call" }, { status: error.statusCode || 500 });
|
|
1851
|
+
}
|
|
1852
|
+
},
|
|
1777
1853
|
toNextJsHandler(redirectConfig) {
|
|
1778
1854
|
const defaultRedirectUrl = redirectConfig?.redirectUrl || "/";
|
|
1779
1855
|
const errorRedirectUrl = redirectConfig?.errorRedirectUrl || "/auth-error";
|
|
@@ -1794,6 +1870,9 @@ function createNextOAuthHandler(config) {
|
|
|
1794
1870
|
}
|
|
1795
1871
|
return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
|
|
1796
1872
|
}
|
|
1873
|
+
if (segments.length === 1 && segments[0] === "mcp") {
|
|
1874
|
+
return handlers.mcp(req);
|
|
1875
|
+
}
|
|
1797
1876
|
return Response.json({ error: `Invalid route: /${segments.join("/")}` }, { status: 404 });
|
|
1798
1877
|
},
|
|
1799
1878
|
async GET(req, context) {
|
|
@@ -1855,14 +1934,7 @@ function createNextOAuthHandler(config) {
|
|
|
1855
1934
|
// src/utils/env.ts
|
|
1856
1935
|
function getEnv(key) {
|
|
1857
1936
|
try {
|
|
1858
|
-
const
|
|
1859
|
-
try {
|
|
1860
|
-
return typeof import.meta !== "undefined" ? import.meta.env : undefined;
|
|
1861
|
-
} catch {
|
|
1862
|
-
return;
|
|
1863
|
-
}
|
|
1864
|
-
};
|
|
1865
|
-
const metaEnv = getMetaEnv();
|
|
1937
|
+
const metaEnv = import.meta.env;
|
|
1866
1938
|
if (metaEnv && typeof metaEnv === "object" && metaEnv !== null) {
|
|
1867
1939
|
const value = metaEnv[key];
|
|
1868
1940
|
if (value !== undefined && value !== null && value !== "") {
|
|
@@ -2059,19 +2131,82 @@ function createMCPServer(config) {
|
|
|
2059
2131
|
const handler = async (request, context) => {
|
|
2060
2132
|
const method = request.method.toUpperCase();
|
|
2061
2133
|
let action;
|
|
2134
|
+
let segments = [];
|
|
2062
2135
|
if (context?.params?.action) {
|
|
2063
2136
|
action = context.params.action;
|
|
2064
2137
|
} else if (context?.params?.all) {
|
|
2065
2138
|
const all = context.params.all;
|
|
2066
2139
|
if (Array.isArray(all)) {
|
|
2067
|
-
|
|
2140
|
+
segments = all;
|
|
2068
2141
|
} else if (typeof all === "string") {
|
|
2069
|
-
|
|
2142
|
+
segments = all.split("/").filter(Boolean);
|
|
2143
|
+
}
|
|
2144
|
+
if (segments.length === 2 && segments[0] === "oauth") {
|
|
2145
|
+
action = segments[1];
|
|
2146
|
+
} else if (segments.length === 1) {
|
|
2147
|
+
action = segments[0];
|
|
2148
|
+
} else if (segments.length > 0) {
|
|
2149
|
+
action = segments[segments.length - 1];
|
|
2070
2150
|
}
|
|
2071
2151
|
} else {
|
|
2072
2152
|
const url = new URL(request.url);
|
|
2073
2153
|
const pathParts = url.pathname.split("/").filter(Boolean);
|
|
2074
|
-
|
|
2154
|
+
segments = pathParts;
|
|
2155
|
+
const oauthIndex = pathParts.indexOf("oauth");
|
|
2156
|
+
if (oauthIndex >= 0 && oauthIndex < pathParts.length - 1) {
|
|
2157
|
+
action = pathParts[oauthIndex + 1];
|
|
2158
|
+
} else if (pathParts.length > 0) {
|
|
2159
|
+
action = pathParts[pathParts.length - 1];
|
|
2160
|
+
} else {
|
|
2161
|
+
action = "callback";
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
if (segments.length > 0) {
|
|
2165
|
+
if (segments.length === 2 && segments[0] !== "oauth") {
|
|
2166
|
+
return Response.json({ error: `Invalid route: /${segments.join("/")}` }, { status: 404 });
|
|
2167
|
+
}
|
|
2168
|
+
if (segments.length === 1 && segments[0] === "mcp") {}
|
|
2169
|
+
}
|
|
2170
|
+
if (method === "GET" && action === "callback") {
|
|
2171
|
+
const url = new URL(request.url);
|
|
2172
|
+
const searchParams = url.searchParams;
|
|
2173
|
+
const code = searchParams.get("code");
|
|
2174
|
+
const state = searchParams.get("state");
|
|
2175
|
+
const error = searchParams.get("error");
|
|
2176
|
+
const errorDescription = searchParams.get("error_description");
|
|
2177
|
+
const defaultRedirectUrl = "/";
|
|
2178
|
+
const errorRedirectUrl = "/auth-error";
|
|
2179
|
+
if (error) {
|
|
2180
|
+
const errorMsg = errorDescription || error;
|
|
2181
|
+
console.error("[OAuth Redirect] Error:", errorMsg);
|
|
2182
|
+
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
|
|
2183
|
+
}
|
|
2184
|
+
if (!code || !state) {
|
|
2185
|
+
console.error("[OAuth Redirect] Missing code or state parameter");
|
|
2186
|
+
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
|
|
2187
|
+
}
|
|
2188
|
+
let returnUrl = defaultRedirectUrl;
|
|
2189
|
+
try {
|
|
2190
|
+
const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
|
|
2191
|
+
const stateData = parseState2(state);
|
|
2192
|
+
if (stateData.returnUrl) {
|
|
2193
|
+
returnUrl = stateData.returnUrl;
|
|
2194
|
+
}
|
|
2195
|
+
} catch (e) {
|
|
2196
|
+
try {
|
|
2197
|
+
const referrer = request.headers.get("referer") || request.headers.get("referrer");
|
|
2198
|
+
if (referrer) {
|
|
2199
|
+
const referrerUrl = new URL(referrer);
|
|
2200
|
+
const currentUrl = new URL(request.url);
|
|
2201
|
+
if (referrerUrl.origin === currentUrl.origin) {
|
|
2202
|
+
returnUrl = referrerUrl.pathname + referrerUrl.search;
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
} catch {}
|
|
2206
|
+
}
|
|
2207
|
+
const targetUrl = new URL(returnUrl, request.url);
|
|
2208
|
+
targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
|
|
2209
|
+
return Response.redirect(targetUrl);
|
|
2075
2210
|
}
|
|
2076
2211
|
const handlerContext = { params: { action: action || "callback" } };
|
|
2077
2212
|
if (method === "POST") {
|
|
@@ -2136,8 +2271,83 @@ function toNextJsHandler(options) {
|
|
|
2136
2271
|
};
|
|
2137
2272
|
return { POST: POST2, GET: GET2 };
|
|
2138
2273
|
}
|
|
2274
|
+
function toAstroHandler(baseHandler, options) {
|
|
2275
|
+
const defaultRedirectUrl = options?.redirectUrl || "/";
|
|
2276
|
+
const errorRedirectUrl = options?.errorRedirectUrl || "/auth-error";
|
|
2277
|
+
return async (ctx) => {
|
|
2278
|
+
const wrappedHandler = async (request, context) => {
|
|
2279
|
+
const url = new URL(request.url);
|
|
2280
|
+
const method = request.method.toUpperCase();
|
|
2281
|
+
const pathParts = url.pathname.split("/").filter(Boolean);
|
|
2282
|
+
const oauthIndex = pathParts.indexOf("oauth");
|
|
2283
|
+
if (method === "GET" && oauthIndex >= 0 && pathParts[oauthIndex + 1] === "callback") {
|
|
2284
|
+
const searchParams = url.searchParams;
|
|
2285
|
+
const code = searchParams.get("code");
|
|
2286
|
+
const state = searchParams.get("state");
|
|
2287
|
+
const error = searchParams.get("error");
|
|
2288
|
+
const errorDescription = searchParams.get("error_description");
|
|
2289
|
+
if (error) {
|
|
2290
|
+
const errorMsg = errorDescription || error;
|
|
2291
|
+
console.error("[OAuth Redirect] Error:", errorMsg);
|
|
2292
|
+
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
|
|
2293
|
+
}
|
|
2294
|
+
if (!code || !state) {
|
|
2295
|
+
console.error("[OAuth Redirect] Missing code or state parameter");
|
|
2296
|
+
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
|
|
2297
|
+
}
|
|
2298
|
+
let returnUrl = defaultRedirectUrl;
|
|
2299
|
+
try {
|
|
2300
|
+
const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
|
|
2301
|
+
const stateData = parseState2(state);
|
|
2302
|
+
if (stateData.returnUrl) {
|
|
2303
|
+
returnUrl = stateData.returnUrl;
|
|
2304
|
+
}
|
|
2305
|
+
} catch (e) {
|
|
2306
|
+
try {
|
|
2307
|
+
const referrer = request.headers.get("referer") || request.headers.get("referrer");
|
|
2308
|
+
if (referrer) {
|
|
2309
|
+
const referrerUrl = new URL(referrer);
|
|
2310
|
+
const currentUrl = new URL(request.url);
|
|
2311
|
+
if (referrerUrl.origin === currentUrl.origin) {
|
|
2312
|
+
returnUrl = referrerUrl.pathname + referrerUrl.search;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
} catch {}
|
|
2316
|
+
}
|
|
2317
|
+
const targetUrl = new URL(returnUrl, request.url);
|
|
2318
|
+
targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
|
|
2319
|
+
return Response.redirect(targetUrl);
|
|
2320
|
+
}
|
|
2321
|
+
return baseHandler(request, context);
|
|
2322
|
+
};
|
|
2323
|
+
return wrappedHandler(ctx.request, { params: { all: ctx.params.all } });
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
function toSolidStartHandler(baseHandler, options) {
|
|
2327
|
+
const wrappedHandler = toAstroHandler(baseHandler, options);
|
|
2328
|
+
const handler = async (event) => {
|
|
2329
|
+
return wrappedHandler({ request: event.request, params: {} });
|
|
2330
|
+
};
|
|
2331
|
+
return {
|
|
2332
|
+
GET: handler,
|
|
2333
|
+
POST: handler,
|
|
2334
|
+
PATCH: handler,
|
|
2335
|
+
PUT: handler,
|
|
2336
|
+
DELETE: handler
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
function toSvelteKitHandler(baseHandler, options) {
|
|
2340
|
+
const wrappedHandler = toAstroHandler(baseHandler, options);
|
|
2341
|
+
return async (event) => {
|
|
2342
|
+
const all = event.params?.all;
|
|
2343
|
+
return wrappedHandler({ request: event.request, params: { all } });
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2139
2346
|
export {
|
|
2347
|
+
toSvelteKitHandler,
|
|
2348
|
+
toSolidStartHandler,
|
|
2140
2349
|
toNextJsHandler,
|
|
2350
|
+
toAstroHandler,
|
|
2141
2351
|
gmailPlugin,
|
|
2142
2352
|
githubPlugin,
|
|
2143
2353
|
genericOAuthPlugin,
|
|
@@ -85,6 +85,29 @@ export interface DisconnectResponse {
|
|
|
85
85
|
success: boolean;
|
|
86
86
|
provider: string;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Request body for MCP tool call endpoint
|
|
90
|
+
*/
|
|
91
|
+
export interface ToolCallRequest {
|
|
92
|
+
name: string;
|
|
93
|
+
arguments?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Response from MCP tool call endpoint
|
|
97
|
+
* Matches MCPToolCallResponse structure
|
|
98
|
+
*/
|
|
99
|
+
export interface ToolCallResponse {
|
|
100
|
+
content: Array<{
|
|
101
|
+
type: "text" | "image" | "resource";
|
|
102
|
+
text?: string;
|
|
103
|
+
data?: string;
|
|
104
|
+
mimeType?: string;
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
}>;
|
|
107
|
+
isError?: boolean;
|
|
108
|
+
structuredContent?: Record<string, unknown>;
|
|
109
|
+
_meta?: Record<string, unknown>;
|
|
110
|
+
}
|
|
88
111
|
/**
|
|
89
112
|
* OAuth Handler
|
|
90
113
|
* Handles OAuth authorization flows by proxying requests to MCP server
|
|
@@ -144,5 +167,16 @@ export declare class OAuthHandler {
|
|
|
144
167
|
* @throws Error if MCP server request fails
|
|
145
168
|
*/
|
|
146
169
|
handleDisconnect(request: DisconnectRequest, accessToken: string): Promise<DisconnectResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Handle MCP tool call
|
|
172
|
+
* Forwards tool call requests to MCP server with API key and provider token
|
|
173
|
+
*
|
|
174
|
+
* @param request - Tool call request with name and arguments
|
|
175
|
+
* @param authHeader - Authorization header from client (Bearer token)
|
|
176
|
+
* @returns Tool call response
|
|
177
|
+
*
|
|
178
|
+
* @throws Error if MCP server request fails
|
|
179
|
+
*/
|
|
180
|
+
handleToolCall(request: ToolCallRequest, authHeader: string | null): Promise<ToolCallResponse>;
|
|
147
181
|
}
|
|
148
182
|
//# sourceMappingURL=base-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-handler.d.ts","sourceRoot":"","sources":["../../../src/adapters/base-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,iDAAiD;QACjD,QAAQ,EAAE,MAAM,CAAC;QACjB,qDAAqD;QACrD,YAAY,EAAE,MAAM,CAAC;QACrB,qCAAqC;QACrC,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IACH;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAE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,OAAO,CAAC,gBAAgB,CAAC;IA2CzE;;;;;;;;;OASG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BlF;;;;;;;;;;OAUG;IACG,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4BpG;;;;;;;;;OASG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAiDrG"}
|
|
@@ -265,6 +265,31 @@ export declare function createNextOAuthHandler(config: OAuthHandlerConfig): {
|
|
|
265
265
|
}>;
|
|
266
266
|
}): Promise<NextResponse>;
|
|
267
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* POST /api/integrate/mcp
|
|
270
|
+
*
|
|
271
|
+
* Handle MCP tool call requests from client
|
|
272
|
+
*
|
|
273
|
+
* Request body:
|
|
274
|
+
* ```json
|
|
275
|
+
* {
|
|
276
|
+
* "name": "github_list_own_repos",
|
|
277
|
+
* "arguments": {}
|
|
278
|
+
* }
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* Headers:
|
|
282
|
+
* - Authorization: Bearer <provider_access_token>
|
|
283
|
+
*
|
|
284
|
+
* Response:
|
|
285
|
+
* ```json
|
|
286
|
+
* {
|
|
287
|
+
* "content": [{"type": "text", "text": "..."}],
|
|
288
|
+
* "isError": false
|
|
289
|
+
* }
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
mcp(req: NextRequest): Promise<NextResponse>;
|
|
268
293
|
/**
|
|
269
294
|
* Create unified catch-all route handler
|
|
270
295
|
*
|
|
@@ -299,6 +324,7 @@ export declare function createNextOAuthHandler(config: OAuthHandlerConfig): {
|
|
|
299
324
|
* - GET /api/integrate/oauth/callback - Provider OAuth redirect
|
|
300
325
|
* - GET /api/integrate/oauth/status - Check authorization status
|
|
301
326
|
* - POST /api/integrate/oauth/disconnect - Disconnect provider
|
|
327
|
+
* - POST /api/integrate/mcp - Execute MCP tool calls
|
|
302
328
|
*/
|
|
303
329
|
toNextJsHandler(redirectConfig?: {
|
|
304
330
|
/** URL to redirect to after OAuth callback (default: '/') */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../../../src/adapters/nextjs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,KAAK,WAAW,GAAG,GAAG,CAAC;AACvB,KAAK,YAAY,GAAG,GAAG,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB;IAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;mBACkB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAcxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;kBACiB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAcvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;gBACe,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA+BrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;oBACmB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAiCzD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;QAGC;;WAEG;kBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,GACpE,OAAO,CAAC,YAAY,CAAC;
|
|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aACY,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAelD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;qCAC8B;QAC/B,6DAA6D;QAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,iEAAiE;QACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;QAKG;;WAEG;kBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC,CAAA;SAAE,GAClE,OAAO,CAAC,YAAY,CAAC;QAsCxB;;WAEG;iBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,GAAG,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC,CAAA;SAAE,GAClE,OAAO,CAAC,YAAY,CAAC;;EA+F/B"}
|
|
@@ -1,54 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SolidStart OAuth Route Adapter
|
|
3
3
|
* Provides OAuth route handlers for SolidStart
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Create SolidStart OAuth route handlers
|
|
7
|
-
*
|
|
8
|
-
* Use this to create secure OAuth API routes in your SolidStart application
|
|
9
|
-
* that handle authorization with server-side secrets.
|
|
10
|
-
*
|
|
11
|
-
* @param baseHandler - Handler function from createMCPServer
|
|
12
|
-
* @returns Object with GET, POST, PATCH, PUT, DELETE handlers
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* // lib/integrate-server.ts
|
|
17
|
-
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
18
|
-
*
|
|
19
|
-
* export const { client: serverClient, handler } = createMCPServer({
|
|
20
|
-
* plugins: [
|
|
21
|
-
* githubPlugin({
|
|
22
|
-
* clientId: process.env.GITHUB_CLIENT_ID!,
|
|
23
|
-
* clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
24
|
-
* }),
|
|
25
|
-
* ],
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // src/routes/api/integrate/[...all].ts
|
|
29
|
-
* import { toSolidStartHandler } from 'integrate-sdk/adapters/solid-start';
|
|
30
|
-
* import { handler } from '@/lib/integrate-server';
|
|
31
|
-
*
|
|
32
|
-
* const handlers = toSolidStartHandler(handler);
|
|
33
4
|
*
|
|
34
|
-
*
|
|
35
|
-
* ```
|
|
5
|
+
* Re-exports from server.ts for convenience
|
|
36
6
|
*/
|
|
37
|
-
export
|
|
38
|
-
GET: (event: {
|
|
39
|
-
request: Request;
|
|
40
|
-
}) => Promise<Response>;
|
|
41
|
-
POST: (event: {
|
|
42
|
-
request: Request;
|
|
43
|
-
}) => Promise<Response>;
|
|
44
|
-
PATCH: (event: {
|
|
45
|
-
request: Request;
|
|
46
|
-
}) => Promise<Response>;
|
|
47
|
-
PUT: (event: {
|
|
48
|
-
request: Request;
|
|
49
|
-
}) => Promise<Response>;
|
|
50
|
-
DELETE: (event: {
|
|
51
|
-
request: Request;
|
|
52
|
-
}) => Promise<Response>;
|
|
53
|
-
};
|
|
7
|
+
export { toSolidStartHandler } from '../server.js';
|
|
54
8
|
//# sourceMappingURL=solid-start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid-start.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"solid-start.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -50,8 +50,7 @@ export declare function svelteKitHandler({ authConfig, event, resolve, basePath,
|
|
|
50
50
|
* Use this to create secure OAuth API routes in your SvelteKit application
|
|
51
51
|
* that handle authorization with server-side secrets.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
* @returns Handler function for SvelteKit routes
|
|
53
|
+
* Re-exports from server.ts for convenience
|
|
55
54
|
*
|
|
56
55
|
* @example
|
|
57
56
|
* ```typescript
|
|
@@ -68,15 +67,17 @@ export declare function svelteKitHandler({ authConfig, event, resolve, basePath,
|
|
|
68
67
|
* });
|
|
69
68
|
*
|
|
70
69
|
* // routes/api/integrate/[...all]/+server.ts
|
|
71
|
-
* import { toSvelteKitHandler } from 'integrate-sdk/
|
|
70
|
+
* import { toSvelteKitHandler } from 'integrate-sdk/server';
|
|
72
71
|
* import { handler } from '$lib/integrate-server';
|
|
73
72
|
*
|
|
74
|
-
* const svelteKitRoute = toSvelteKitHandler(handler
|
|
73
|
+
* const svelteKitRoute = toSvelteKitHandler(handler, {
|
|
74
|
+
* redirectUrl: '/dashboard',
|
|
75
|
+
* errorRedirectUrl: '/auth-error',
|
|
76
|
+
* });
|
|
75
77
|
*
|
|
76
78
|
* export const POST = svelteKitRoute;
|
|
77
79
|
* export const GET = svelteKitRoute;
|
|
78
80
|
* ```
|
|
79
81
|
*/
|
|
80
|
-
export
|
|
81
|
-
export {};
|
|
82
|
+
export { toSvelteKitHandler } from '../server.js';
|
|
82
83
|
//# sourceMappingURL=svelte-kit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svelte-kit.d.ts","sourceRoot":"","sources":["../../../src/adapters/svelte-kit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,KAAK,YAAY,GAAG,GAAG,CAAC;AACxB,KAAK,eAAe,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,gBAAgB,CAAC,EACnC,UAAU,EACV,KAAK,EACL,OAAO,EACP,QAA2B,GAC9B,EAAE;IACC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWpB;AAED
|
|
1
|
+
{"version":3,"file":"svelte-kit.d.ts","sourceRoot":"","sources":["../../../src/adapters/svelte-kit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,KAAK,YAAY,GAAG,GAAG,CAAC;AACxB,KAAK,eAAe,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,gBAAgB,CAAC,EACnC,UAAU,EACV,KAAK,EACL,OAAO,EACP,QAA2B,GAC9B,EAAE;IACC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
57
57
|
private connecting;
|
|
58
58
|
private oauthManager;
|
|
59
59
|
private eventEmitter;
|
|
60
|
+
private apiRouteBase;
|
|
60
61
|
readonly github: PluginNamespaces<TPlugins> extends {
|
|
61
62
|
github: GitHubPluginClient;
|
|
62
63
|
} ? GitHubPluginClient : never;
|
|
@@ -125,6 +126,11 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
125
126
|
* ```
|
|
126
127
|
*/
|
|
127
128
|
callServerTool(name: string, args?: Record<string, unknown>): Promise<MCPToolCallResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* Call a tool through the API handler (server-side route)
|
|
131
|
+
* Routes tool calls through /api/integrate/mcp instead of directly to MCP server
|
|
132
|
+
*/
|
|
133
|
+
private callToolThroughHandler;
|
|
128
134
|
/**
|
|
129
135
|
* Internal method to call a tool with retry logic
|
|
130
136
|
*/
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,OAAO,EAEP,mBAAmB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,OAAO,EAEP,mBAAmB,EAGpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAgE1B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA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