integrate-sdk 0.7.11 → 0.7.14

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.
@@ -1735,9 +1735,9 @@ class MCPClient {
1735
1735
  }
1736
1736
  }
1737
1737
  // src/server.ts
1738
- function toSolidStartHandler(handlerOrOptions) {
1739
- if (typeof handlerOrOptions === "function") {
1740
- const baseHandler = handlerOrOptions;
1738
+ function toSolidStartHandler(clientOrHandlerOrOptions, _redirectOptions) {
1739
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
1740
+ const baseHandler = clientOrHandlerOrOptions.handler;
1741
1741
  const handler2 = async (event) => {
1742
1742
  return baseHandler(event.request);
1743
1743
  };
@@ -1749,7 +1749,20 @@ function toSolidStartHandler(handlerOrOptions) {
1749
1749
  DELETE: handler2
1750
1750
  };
1751
1751
  }
1752
- const options = handlerOrOptions;
1752
+ if (typeof clientOrHandlerOrOptions === "function") {
1753
+ const baseHandler = clientOrHandlerOrOptions;
1754
+ const handler2 = async (event) => {
1755
+ return baseHandler(event.request);
1756
+ };
1757
+ return {
1758
+ GET: handler2,
1759
+ POST: handler2,
1760
+ PATCH: handler2,
1761
+ PUT: handler2,
1762
+ DELETE: handler2
1763
+ };
1764
+ }
1765
+ const options = clientOrHandlerOrOptions;
1753
1766
  if (!options.providers || Object.keys(options.providers).length === 0) {
1754
1767
  throw new Error("toSolidStartHandler requires either a handler function or a providers config object");
1755
1768
  }
@@ -1788,15 +1801,22 @@ function toSolidStartHandler(handlerOrOptions) {
1788
1801
  DELETE: handler
1789
1802
  };
1790
1803
  }
1791
- function toSvelteKitHandler(handlerOrOptions) {
1792
- if (typeof handlerOrOptions === "function") {
1793
- const baseHandler = handlerOrOptions;
1804
+ function toSvelteKitHandler(clientOrHandlerOrOptions, _redirectOptions) {
1805
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
1806
+ const baseHandler = clientOrHandlerOrOptions.handler;
1807
+ return async (event) => {
1808
+ const all = event.params?.all;
1809
+ return baseHandler(event.request, { params: { all } });
1810
+ };
1811
+ }
1812
+ if (typeof clientOrHandlerOrOptions === "function") {
1813
+ const baseHandler = clientOrHandlerOrOptions;
1794
1814
  return async (event) => {
1795
1815
  const all = event.params?.all;
1796
1816
  return baseHandler(event.request, { params: { all } });
1797
1817
  };
1798
1818
  }
1799
- const options = handlerOrOptions;
1819
+ const options = clientOrHandlerOrOptions;
1800
1820
  if (!options.providers || Object.keys(options.providers).length === 0) {
1801
1821
  throw new Error("toSvelteKitHandler requires either a handler function or a providers config object");
1802
1822
  }
@@ -1735,9 +1735,9 @@ class MCPClient {
1735
1735
  }
1736
1736
  }
1737
1737
  // src/server.ts
1738
- function toSolidStartHandler(handlerOrOptions) {
1739
- if (typeof handlerOrOptions === "function") {
1740
- const baseHandler = handlerOrOptions;
1738
+ function toSolidStartHandler(clientOrHandlerOrOptions, _redirectOptions) {
1739
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
1740
+ const baseHandler = clientOrHandlerOrOptions.handler;
1741
1741
  const handler2 = async (event) => {
1742
1742
  return baseHandler(event.request);
1743
1743
  };
@@ -1749,7 +1749,20 @@ function toSolidStartHandler(handlerOrOptions) {
1749
1749
  DELETE: handler2
1750
1750
  };
1751
1751
  }
1752
- const options = handlerOrOptions;
1752
+ if (typeof clientOrHandlerOrOptions === "function") {
1753
+ const baseHandler = clientOrHandlerOrOptions;
1754
+ const handler2 = async (event) => {
1755
+ return baseHandler(event.request);
1756
+ };
1757
+ return {
1758
+ GET: handler2,
1759
+ POST: handler2,
1760
+ PATCH: handler2,
1761
+ PUT: handler2,
1762
+ DELETE: handler2
1763
+ };
1764
+ }
1765
+ const options = clientOrHandlerOrOptions;
1753
1766
  if (!options.providers || Object.keys(options.providers).length === 0) {
1754
1767
  throw new Error("toSolidStartHandler requires either a handler function or a providers config object");
1755
1768
  }
@@ -1788,15 +1801,22 @@ function toSolidStartHandler(handlerOrOptions) {
1788
1801
  DELETE: handler
1789
1802
  };
1790
1803
  }
1791
- function toSvelteKitHandler(handlerOrOptions) {
1792
- if (typeof handlerOrOptions === "function") {
1793
- const baseHandler = handlerOrOptions;
1804
+ function toSvelteKitHandler(clientOrHandlerOrOptions, _redirectOptions) {
1805
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
1806
+ const baseHandler = clientOrHandlerOrOptions.handler;
1807
+ return async (event) => {
1808
+ const all = event.params?.all;
1809
+ return baseHandler(event.request, { params: { all } });
1810
+ };
1811
+ }
1812
+ if (typeof clientOrHandlerOrOptions === "function") {
1813
+ const baseHandler = clientOrHandlerOrOptions;
1794
1814
  return async (event) => {
1795
1815
  const all = event.params?.all;
1796
1816
  return baseHandler(event.request, { params: { all } });
1797
1817
  };
1798
1818
  }
1799
- const options = handlerOrOptions;
1819
+ const options = clientOrHandlerOrOptions;
1800
1820
  if (!options.providers || Object.keys(options.providers).length === 0) {
1801
1821
  throw new Error("toSvelteKitHandler requires either a handler function or a providers config object");
1802
1822
  }
package/dist/index.js CHANGED
@@ -2378,11 +2378,13 @@ function createMCPServer(config) {
2378
2378
  return Response.json({ error: `Method ${method} not allowed` }, { status: 405 });
2379
2379
  }
2380
2380
  };
2381
+ client.handler = handler;
2382
+ client.POST = POST;
2383
+ client.GET = GET;
2381
2384
  return {
2382
2385
  client,
2383
2386
  POST,
2384
- GET,
2385
- handler
2387
+ GET
2386
2388
  };
2387
2389
  }
2388
2390
  function createOAuthRouteHandlers(config) {
@@ -2452,61 +2454,22 @@ function toNextJsHandler(clientOrOptions, redirectOptions) {
2452
2454
  };
2453
2455
  return { POST: POST2, GET: GET2 };
2454
2456
  }
2455
- function toAstroHandler(baseHandler, options) {
2456
- const defaultRedirectUrl = options?.redirectUrl || "/";
2457
- const errorRedirectUrl = options?.errorRedirectUrl || "/auth-error";
2458
- return async (ctx) => {
2459
- const wrappedHandler = async (request, context) => {
2460
- const url = new URL(request.url);
2461
- const method = request.method.toUpperCase();
2462
- const pathParts = url.pathname.split("/").filter(Boolean);
2463
- const oauthIndex = pathParts.indexOf("oauth");
2464
- if (method === "GET" && oauthIndex >= 0 && pathParts[oauthIndex + 1] === "callback") {
2465
- const searchParams = url.searchParams;
2466
- const code = searchParams.get("code");
2467
- const state = searchParams.get("state");
2468
- const error = searchParams.get("error");
2469
- const errorDescription = searchParams.get("error_description");
2470
- if (error) {
2471
- const errorMsg = errorDescription || error;
2472
- console.error("[OAuth Redirect] Error:", errorMsg);
2473
- return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
2474
- }
2475
- if (!code || !state) {
2476
- console.error("[OAuth Redirect] Missing code or state parameter");
2477
- return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
2478
- }
2479
- let returnUrl = defaultRedirectUrl;
2480
- try {
2481
- const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
2482
- const stateData = parseState2(state);
2483
- if (stateData.returnUrl) {
2484
- returnUrl = stateData.returnUrl;
2485
- }
2486
- } catch (e) {
2487
- try {
2488
- const referrer = request.headers.get("referer") || request.headers.get("referrer");
2489
- if (referrer) {
2490
- const referrerUrl = new URL(referrer);
2491
- const currentUrl = new URL(request.url);
2492
- if (referrerUrl.origin === currentUrl.origin) {
2493
- returnUrl = referrerUrl.pathname + referrerUrl.search;
2494
- }
2495
- }
2496
- } catch {}
2497
- }
2498
- const targetUrl = new URL(returnUrl, request.url);
2499
- targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
2500
- return Response.redirect(targetUrl);
2501
- }
2502
- return baseHandler(request, context);
2457
+ function toSolidStartHandler(clientOrHandlerOrOptions, _redirectOptions) {
2458
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
2459
+ const baseHandler = clientOrHandlerOrOptions.handler;
2460
+ const handler2 = async (event) => {
2461
+ return baseHandler(event.request);
2503
2462
  };
2504
- return wrappedHandler(ctx.request, { params: { all: ctx.params.all } });
2505
- };
2506
- }
2507
- function toSolidStartHandler(handlerOrOptions) {
2508
- if (typeof handlerOrOptions === "function") {
2509
- const baseHandler = handlerOrOptions;
2463
+ return {
2464
+ GET: handler2,
2465
+ POST: handler2,
2466
+ PATCH: handler2,
2467
+ PUT: handler2,
2468
+ DELETE: handler2
2469
+ };
2470
+ }
2471
+ if (typeof clientOrHandlerOrOptions === "function") {
2472
+ const baseHandler = clientOrHandlerOrOptions;
2510
2473
  const handler2 = async (event) => {
2511
2474
  return baseHandler(event.request);
2512
2475
  };
@@ -2518,7 +2481,7 @@ function toSolidStartHandler(handlerOrOptions) {
2518
2481
  DELETE: handler2
2519
2482
  };
2520
2483
  }
2521
- const options = handlerOrOptions;
2484
+ const options = clientOrHandlerOrOptions;
2522
2485
  if (!options.providers || Object.keys(options.providers).length === 0) {
2523
2486
  throw new Error("toSolidStartHandler requires either a handler function or a providers config object");
2524
2487
  }
@@ -2557,15 +2520,22 @@ function toSolidStartHandler(handlerOrOptions) {
2557
2520
  DELETE: handler
2558
2521
  };
2559
2522
  }
2560
- function toSvelteKitHandler(handlerOrOptions) {
2561
- if (typeof handlerOrOptions === "function") {
2562
- const baseHandler = handlerOrOptions;
2523
+ function toSvelteKitHandler(clientOrHandlerOrOptions, _redirectOptions) {
2524
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
2525
+ const baseHandler = clientOrHandlerOrOptions.handler;
2526
+ return async (event) => {
2527
+ const all = event.params?.all;
2528
+ return baseHandler(event.request, { params: { all } });
2529
+ };
2530
+ }
2531
+ if (typeof clientOrHandlerOrOptions === "function") {
2532
+ const baseHandler = clientOrHandlerOrOptions;
2563
2533
  return async (event) => {
2564
2534
  const all = event.params?.all;
2565
2535
  return baseHandler(event.request, { params: { all } });
2566
2536
  };
2567
2537
  }
2568
- const options = handlerOrOptions;
2538
+ const options = clientOrHandlerOrOptions;
2569
2539
  if (!options.providers || Object.keys(options.providers).length === 0) {
2570
2540
  throw new Error("toSvelteKitHandler requires either a handler function or a providers config object");
2571
2541
  }
package/dist/server.js CHANGED
@@ -2204,11 +2204,13 @@ function createMCPServer(config) {
2204
2204
  return Response.json({ error: `Method ${method} not allowed` }, { status: 405 });
2205
2205
  }
2206
2206
  };
2207
+ client.handler = handler;
2208
+ client.POST = POST;
2209
+ client.GET = GET;
2207
2210
  return {
2208
2211
  client,
2209
2212
  POST,
2210
- GET,
2211
- handler
2213
+ GET
2212
2214
  };
2213
2215
  }
2214
2216
  function createOAuthRouteHandlers(config) {
@@ -2278,61 +2280,22 @@ function toNextJsHandler(clientOrOptions, redirectOptions) {
2278
2280
  };
2279
2281
  return { POST: POST2, GET: GET2 };
2280
2282
  }
2281
- function toAstroHandler(baseHandler, options) {
2282
- const defaultRedirectUrl = options?.redirectUrl || "/";
2283
- const errorRedirectUrl = options?.errorRedirectUrl || "/auth-error";
2284
- return async (ctx) => {
2285
- const wrappedHandler = async (request, context) => {
2286
- const url = new URL(request.url);
2287
- const method = request.method.toUpperCase();
2288
- const pathParts = url.pathname.split("/").filter(Boolean);
2289
- const oauthIndex = pathParts.indexOf("oauth");
2290
- if (method === "GET" && oauthIndex >= 0 && pathParts[oauthIndex + 1] === "callback") {
2291
- const searchParams = url.searchParams;
2292
- const code = searchParams.get("code");
2293
- const state = searchParams.get("state");
2294
- const error = searchParams.get("error");
2295
- const errorDescription = searchParams.get("error_description");
2296
- if (error) {
2297
- const errorMsg = errorDescription || error;
2298
- console.error("[OAuth Redirect] Error:", errorMsg);
2299
- return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
2300
- }
2301
- if (!code || !state) {
2302
- console.error("[OAuth Redirect] Missing code or state parameter");
2303
- return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
2304
- }
2305
- let returnUrl = defaultRedirectUrl;
2306
- try {
2307
- const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
2308
- const stateData = parseState2(state);
2309
- if (stateData.returnUrl) {
2310
- returnUrl = stateData.returnUrl;
2311
- }
2312
- } catch (e) {
2313
- try {
2314
- const referrer = request.headers.get("referer") || request.headers.get("referrer");
2315
- if (referrer) {
2316
- const referrerUrl = new URL(referrer);
2317
- const currentUrl = new URL(request.url);
2318
- if (referrerUrl.origin === currentUrl.origin) {
2319
- returnUrl = referrerUrl.pathname + referrerUrl.search;
2320
- }
2321
- }
2322
- } catch {}
2323
- }
2324
- const targetUrl = new URL(returnUrl, request.url);
2325
- targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
2326
- return Response.redirect(targetUrl);
2327
- }
2328
- return baseHandler(request, context);
2283
+ function toSolidStartHandler(clientOrHandlerOrOptions, _redirectOptions) {
2284
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
2285
+ const baseHandler = clientOrHandlerOrOptions.handler;
2286
+ const handler2 = async (event) => {
2287
+ return baseHandler(event.request);
2329
2288
  };
2330
- return wrappedHandler(ctx.request, { params: { all: ctx.params.all } });
2331
- };
2332
- }
2333
- function toSolidStartHandler(handlerOrOptions) {
2334
- if (typeof handlerOrOptions === "function") {
2335
- const baseHandler = handlerOrOptions;
2289
+ return {
2290
+ GET: handler2,
2291
+ POST: handler2,
2292
+ PATCH: handler2,
2293
+ PUT: handler2,
2294
+ DELETE: handler2
2295
+ };
2296
+ }
2297
+ if (typeof clientOrHandlerOrOptions === "function") {
2298
+ const baseHandler = clientOrHandlerOrOptions;
2336
2299
  const handler2 = async (event) => {
2337
2300
  return baseHandler(event.request);
2338
2301
  };
@@ -2344,7 +2307,7 @@ function toSolidStartHandler(handlerOrOptions) {
2344
2307
  DELETE: handler2
2345
2308
  };
2346
2309
  }
2347
- const options = handlerOrOptions;
2310
+ const options = clientOrHandlerOrOptions;
2348
2311
  if (!options.providers || Object.keys(options.providers).length === 0) {
2349
2312
  throw new Error("toSolidStartHandler requires either a handler function or a providers config object");
2350
2313
  }
@@ -2383,15 +2346,22 @@ function toSolidStartHandler(handlerOrOptions) {
2383
2346
  DELETE: handler
2384
2347
  };
2385
2348
  }
2386
- function toSvelteKitHandler(handlerOrOptions) {
2387
- if (typeof handlerOrOptions === "function") {
2388
- const baseHandler = handlerOrOptions;
2349
+ function toSvelteKitHandler(clientOrHandlerOrOptions, _redirectOptions) {
2350
+ if (clientOrHandlerOrOptions && clientOrHandlerOrOptions.handler && typeof clientOrHandlerOrOptions.handler === "function") {
2351
+ const baseHandler = clientOrHandlerOrOptions.handler;
2352
+ return async (event) => {
2353
+ const all = event.params?.all;
2354
+ return baseHandler(event.request, { params: { all } });
2355
+ };
2356
+ }
2357
+ if (typeof clientOrHandlerOrOptions === "function") {
2358
+ const baseHandler = clientOrHandlerOrOptions;
2389
2359
  return async (event) => {
2390
2360
  const all = event.params?.all;
2391
2361
  return baseHandler(event.request, { params: { all } });
2392
2362
  };
2393
2363
  }
2394
- const options = handlerOrOptions;
2364
+ const options = clientOrHandlerOrOptions;
2395
2365
  if (!options.providers || Object.keys(options.providers).length === 0) {
2396
2366
  throw new Error("toSvelteKitHandler requires either a handler function or a providers config object");
2397
2367
  }
@@ -2424,7 +2394,6 @@ export {
2424
2394
  toSvelteKitHandler,
2425
2395
  toSolidStartHandler,
2426
2396
  toNextJsHandler,
2427
- toAstroHandler,
2428
2397
  gmailPlugin,
2429
2398
  githubPlugin,
2430
2399
  genericOAuthPlugin,
@@ -14,6 +14,8 @@ import type { MCPPlugin } from './plugins/types.js';
14
14
  * The redirectUri can be specified globally and will be used for all plugins.
15
15
  * If not provided, it will auto-detect from INTEGRATE_URL or VERCEL_URL
16
16
  *
17
+ * The returned client has `handler`, `POST`, and `GET` attached for easy access.
18
+ *
17
19
  * ⚠️ SECURITY: The API key should NEVER be exposed to client-side code.
18
20
  * Use environment variables WITHOUT the NEXT_PUBLIC_ prefix.
19
21
  *
@@ -43,14 +45,28 @@ import type { MCPPlugin } from './plugins/types.js';
43
45
  * });
44
46
  * ```
45
47
  *
46
- * Then in your route file:
48
+ * Then use the handler directly from the client:
47
49
  * ```typescript
48
- * // app/api/integrate/oauth/[action]/route.ts
49
- * export { POST, GET } from 'integrate-sdk/server';
50
+ * // routes/api/integrate/[...all]/+server.ts (SvelteKit)
51
+ * import { serverClient } from '$lib/integrate-server';
52
+ *
53
+ * export const POST = serverClient.handler;
54
+ * export const GET = serverClient.handler;
55
+ * ```
56
+ *
57
+ * Or for Astro:
58
+ * ```typescript
59
+ * // pages/api/integrate/[...all].ts (Astro)
60
+ * import { serverClient } from '@/lib/integrate-server';
61
+ * import type { APIRoute } from 'astro';
62
+ *
63
+ * export const ALL: APIRoute = async (ctx) => {
64
+ * return serverClient.handler(ctx.request);
65
+ * };
50
66
  * ```
51
67
  */
52
68
  export declare function createMCPServer<TPlugins extends readonly MCPPlugin[]>(config: MCPServerConfig<TPlugins>): {
53
- /** Server-side MCP client instance with auto-connection */
69
+ /** Server-side MCP client instance with auto-connection and attached handler */
54
70
  client: MCPClient<TPlugins>;
55
71
  /** OAuth POST handler - export this from your route file */
56
72
  POST: (req: any, context: {
@@ -68,13 +84,6 @@ export declare function createMCPServer<TPlugins extends readonly MCPPlugin[]>(c
68
84
  action: string;
69
85
  }>;
70
86
  }) => Promise<any>;
71
- /** Unified handler function - handles both POST and GET requests */
72
- handler: (request: Request, context?: {
73
- params?: {
74
- action?: string;
75
- all?: string | string[];
76
- };
77
- }) => Promise<Response>;
78
87
  };
79
88
  export type { MCPPlugin } from './plugins/types.js';
80
89
  export type { MCPClientConfig } from './config/types.js';
@@ -212,55 +221,6 @@ export declare function toNextJsHandler(clientOrOptions?: any | {
212
221
  }>;
213
222
  }) => Promise<any>;
214
223
  };
215
- /**
216
- * Create Astro handler with configurable redirect URLs
217
- *
218
- * Wraps the unified handler with redirect URL configuration
219
- *
220
- * @param baseHandler - Handler function from createMCPServer
221
- * @param options - Redirect URL configuration
222
- * @returns Wrapped handler function for Astro
223
- *
224
- * @example
225
- * ```typescript
226
- * // lib/integrate-server.ts
227
- * import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
228
- *
229
- * export const { handler } = createMCPServer({
230
- * plugins: [
231
- * githubPlugin({
232
- * clientId: import.meta.env.GITHUB_CLIENT_ID!,
233
- * clientSecret: import.meta.env.GITHUB_CLIENT_SECRET!,
234
- * }),
235
- * ],
236
- * });
237
- *
238
- * // pages/api/integrate/[...all].ts
239
- * import { toAstroHandler } from 'integrate-sdk/server';
240
- * import { handler } from '@/lib/integrate-server';
241
- *
242
- * export const ALL = toAstroHandler(handler, {
243
- * redirectUrl: '/dashboard',
244
- * errorRedirectUrl: '/auth-error',
245
- * });
246
- * ```
247
- */
248
- export declare function toAstroHandler(baseHandler: (request: Request, context?: {
249
- params?: {
250
- action?: string;
251
- all?: string | string[];
252
- };
253
- }) => Promise<Response>, options?: {
254
- /** URL to redirect to after successful OAuth callback (default: '/') */
255
- redirectUrl?: string;
256
- /** URL to redirect to on OAuth error (default: '/auth-error') */
257
- errorRedirectUrl?: string;
258
- }): (ctx: {
259
- request: Request;
260
- params: {
261
- all?: string | string[];
262
- };
263
- }) => Promise<Response>;
264
224
  /**
265
225
  * Create SolidStart handler with configurable redirect URLs
266
226
  *
@@ -273,12 +233,12 @@ export declare function toAstroHandler(baseHandler: (request: Request, context?:
273
233
  * @returns Object with GET, POST, PATCH, PUT, DELETE handlers
274
234
  *
275
235
  * @example
276
- * **Pattern 1: Using handler from createMCPServer (Recommended)**
236
+ * **Pattern 1: Using serverClient from createMCPServer (Recommended)**
277
237
  * ```typescript
278
238
  * // lib/integrate-server.ts
279
239
  * import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
280
240
  *
281
- * export const { handler } = createMCPServer({
241
+ * export const { client: serverClient } = createMCPServer({
282
242
  * plugins: [
283
243
  * githubPlugin({
284
244
  * clientId: process.env.GITHUB_CLIENT_ID!,
@@ -289,9 +249,9 @@ export declare function toAstroHandler(baseHandler: (request: Request, context?:
289
249
  *
290
250
  * // src/routes/api/integrate/[...all].ts
291
251
  * import { toSolidStartHandler } from 'integrate-sdk/server';
292
- * import { handler } from '@/lib/integrate-server';
252
+ * import { serverClient } from '@/lib/integrate-server';
293
253
  *
294
- * const handlers = toSolidStartHandler(handler, {
254
+ * const handlers = toSolidStartHandler(serverClient, {
295
255
  * redirectUrl: '/dashboard',
296
256
  * errorRedirectUrl: '/auth-error',
297
257
  * });
@@ -319,7 +279,7 @@ export declare function toAstroHandler(baseHandler: (request: Request, context?:
319
279
  * export const { GET, POST, PATCH, PUT, DELETE } = handlers;
320
280
  * ```
321
281
  */
322
- export declare function toSolidStartHandler(handlerOrOptions: ((request: Request, context?: {
282
+ export declare function toSolidStartHandler(clientOrHandlerOrOptions: any | ((request: Request, context?: {
323
283
  params?: {
324
284
  action?: string;
325
285
  all?: string | string[];
@@ -339,6 +299,11 @@ export declare function toSolidStartHandler(handlerOrOptions: ((request: Request
339
299
  redirectUrl?: string;
340
300
  /** URL to redirect to on OAuth error (default: '/auth-error') */
341
301
  errorRedirectUrl?: string;
302
+ }, _redirectOptions?: {
303
+ /** URL to redirect to after successful OAuth callback (default: '/') */
304
+ redirectUrl?: string;
305
+ /** URL to redirect to on OAuth error (default: '/auth-error') */
306
+ errorRedirectUrl?: string;
342
307
  }): {
343
308
  GET: (event: {
344
309
  request: Request;
@@ -368,12 +333,12 @@ export declare function toSolidStartHandler(handlerOrOptions: ((request: Request
368
333
  * @returns Handler function for SvelteKit routes
369
334
  *
370
335
  * @example
371
- * **Pattern 1: Using handler from createMCPServer (Recommended)**
336
+ * **Pattern 1: Using serverClient from createMCPServer (Recommended)**
372
337
  * ```typescript
373
338
  * // lib/integrate-server.ts
374
339
  * import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
375
340
  *
376
- * export const { handler } = createMCPServer({
341
+ * export const { client: serverClient } = createMCPServer({
377
342
  * plugins: [
378
343
  * githubPlugin({
379
344
  * clientId: process.env.GITHUB_CLIENT_ID!,
@@ -384,9 +349,9 @@ export declare function toSolidStartHandler(handlerOrOptions: ((request: Request
384
349
  *
385
350
  * // routes/api/integrate/[...all]/+server.ts
386
351
  * import { toSvelteKitHandler } from 'integrate-sdk/server';
387
- * import { handler } from '$lib/integrate-server';
352
+ * import { serverClient } from '$lib/integrate-server';
388
353
  *
389
- * const svelteKitRoute = toSvelteKitHandler(handler, {
354
+ * const svelteKitRoute = toSvelteKitHandler(serverClient, {
390
355
  * redirectUrl: '/dashboard',
391
356
  * errorRedirectUrl: '/auth-error',
392
357
  * });
@@ -416,7 +381,7 @@ export declare function toSolidStartHandler(handlerOrOptions: ((request: Request
416
381
  * export const GET = handler;
417
382
  * ```
418
383
  */
419
- export declare function toSvelteKitHandler(handlerOrOptions: ((request: Request, context?: {
384
+ export declare function toSvelteKitHandler(clientOrHandlerOrOptions: any | ((request: Request, context?: {
420
385
  params?: {
421
386
  action?: string;
422
387
  all?: string | string[];
@@ -436,5 +401,10 @@ export declare function toSvelteKitHandler(handlerOrOptions: ((request: Request,
436
401
  redirectUrl?: string;
437
402
  /** URL to redirect to on OAuth error (default: '/auth-error') */
438
403
  errorRedirectUrl?: string;
404
+ }, _redirectOptions?: {
405
+ /** URL to redirect to after successful OAuth callback (default: '/') */
406
+ redirectUrl?: string;
407
+ /** URL to redirect to on OAuth error (default: '/auth-error') */
408
+ errorRedirectUrl?: string;
439
409
  }): (event: any) => Promise<Response>;
440
410
  //# sourceMappingURL=server.d.ts.map
@@ -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;AACxC,OAAO,KAAK,EAAE,eAAe,E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Y,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integrate-sdk",
3
- "version": "0.7.11",
3
+ "version": "0.7.14",
4
4
  "description": "Type-safe 3rd party integration SDK for the Integrate MCP server",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",