@lovable.dev/mcp-js 0.21.1-rc.1 → 0.22.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.
Files changed (87) hide show
  1. package/dist/authorize-BMeXd_Sh.d.ts +25 -0
  2. package/dist/base-CM-KCpp6.d.ts +28 -0
  3. package/dist/chunk-4EHZUUS5.js +141 -0
  4. package/dist/chunk-6DXGZZA4.js +6 -0
  5. package/dist/chunk-6KNM7RGD.js +79 -0
  6. package/dist/chunk-6QFZYYUV.js +11 -0
  7. package/dist/chunk-EOFPMSND.js +6 -0
  8. package/dist/chunk-H37EB22A.js +125 -0
  9. package/dist/chunk-MA5H6PSF.js +46 -0
  10. package/dist/chunk-P43FIUMZ.js +114 -0
  11. package/dist/chunk-RK62EMPY.js +741 -0
  12. package/dist/chunk-RLE4UE63.js +58 -0
  13. package/dist/chunk-UQK5UO6C.js +26 -0
  14. package/dist/chunk-XQWJN6DC.js +14 -0
  15. package/dist/chunk-Y3ZFPEQH.js +8 -0
  16. package/dist/cli/extract-manifest.cjs +201 -116
  17. package/dist/cli/extract-manifest.d.cts +1 -1
  18. package/dist/cli/extract-manifest.d.ts +1 -1
  19. package/dist/cli/extract-manifest.js +156 -117
  20. package/dist/index.cjs +329 -129
  21. package/dist/index.d.cts +26 -26
  22. package/dist/index.d.ts +26 -26
  23. package/dist/index.js +177 -118
  24. package/dist/{io-CS4UL6_A.d.ts → io-D4srzRKc.d.ts} +4 -6
  25. package/dist/protocols/mcp/index.cjs +750 -3
  26. package/dist/protocols/mcp/index.d.cts +7 -6
  27. package/dist/protocols/mcp/index.d.ts +7 -6
  28. package/dist/protocols/mcp/index.js +12 -2
  29. package/dist/protocols/oauth-metadata.cjs +539 -48
  30. package/dist/protocols/oauth-metadata.d.cts +6 -5
  31. package/dist/protocols/oauth-metadata.d.ts +6 -5
  32. package/dist/protocols/oauth-metadata.js +10 -52
  33. package/dist/protocols/rest/index.cjs +843 -5
  34. package/dist/protocols/rest/index.d.cts +10 -7
  35. package/dist/protocols/rest/index.d.ts +10 -7
  36. package/dist/protocols/rest/index.js +16 -3
  37. package/dist/stacks/supabase/index.cjs +1318 -76
  38. package/dist/stacks/supabase/index.d.cts +30 -29
  39. package/dist/stacks/supabase/index.d.ts +30 -29
  40. package/dist/stacks/supabase/index.js +89 -73
  41. package/dist/stacks/supabase/vite.cjs +287 -258
  42. package/dist/stacks/supabase/vite.d.cts +24 -24
  43. package/dist/stacks/supabase/vite.d.ts +24 -24
  44. package/dist/stacks/supabase/vite.js +252 -252
  45. package/dist/stacks/tanstack/index.cjs +1272 -42
  46. package/dist/stacks/tanstack/index.d.cts +9 -8
  47. package/dist/stacks/tanstack/index.d.ts +9 -8
  48. package/dist/stacks/tanstack/index.js +41 -36
  49. package/dist/stacks/tanstack/vite.cjs +312 -223
  50. package/dist/stacks/tanstack/vite.d.cts +81 -80
  51. package/dist/stacks/tanstack/vite.d.ts +81 -80
  52. package/dist/stacks/tanstack/vite.js +282 -216
  53. package/dist/types-qqrmJ736.d.ts +321 -0
  54. package/package.json +28 -71
  55. package/dist/authorize-CumVyk7p.d.cts +0 -27
  56. package/dist/authorize-D6p4-9_D.d.ts +0 -27
  57. package/dist/base-CoIFvAmS.d.cts +0 -26
  58. package/dist/base-CoIFvAmS.d.ts +0 -26
  59. package/dist/content-D5LJAHyM.js +0 -12
  60. package/dist/content-NCYIGgOb.cjs +0 -17
  61. package/dist/context-BweeEcoA.cjs +0 -56
  62. package/dist/context-CIpPzN7P.js +0 -51
  63. package/dist/cors-B7CTXIHD.js +0 -829
  64. package/dist/cors-BebjKPrc.cjs +0 -912
  65. package/dist/forwarded--h4efJy-.js +0 -43
  66. package/dist/forwarded-Pi8Hs5Ps.cjs +0 -48
  67. package/dist/fs-errors-CWNzOV75.cjs +0 -11
  68. package/dist/fs-errors-PA2t1TIp.js +0 -6
  69. package/dist/io-CbbUbPY3.d.cts +0 -15
  70. package/dist/list-tools-CBCuS1Tv.cjs +0 -57
  71. package/dist/list-tools-CsWgiRy1.d.ts +0 -8
  72. package/dist/list-tools-CtZHOuPv.d.cts +0 -8
  73. package/dist/list-tools-D75RGtgs.js +0 -46
  74. package/dist/logger-2OXtfiIW.js +0 -141
  75. package/dist/logger-BqPOa_E1.cjs +0 -194
  76. package/dist/mcp-Cdj0AYst.cjs +0 -123
  77. package/dist/mcp-GngXbcqN.js +0 -118
  78. package/dist/metadata-path-CAkNcfyY.js +0 -12
  79. package/dist/metadata-path-zd7NSNoa.cjs +0 -17
  80. package/dist/package-7EUptuSJ.js +0 -4
  81. package/dist/package-BwCGVRcB.cjs +0 -9
  82. package/dist/paths-IS65L6TA.js +0 -7
  83. package/dist/paths-OP318a6c.cjs +0 -18
  84. package/dist/rest-CXH6-zv9.js +0 -113
  85. package/dist/rest-CyV8LHeB.cjs +0 -118
  86. package/dist/types-BYdYYTjk.d.cts +0 -321
  87. package/dist/types-BYdYYTjk.d.ts +0 -321
@@ -1,32 +1,33 @@
1
- import { c as McpDefinition } from "../../types-BYdYYTjk.cjs";
2
- //#region src/stacks/supabase/handler.d.ts
1
+ import { d as McpDefinition } from '../../types-qqrmJ736.js';
2
+ import 'zod';
3
+
3
4
  type SupabaseHandler = (request: Request) => Promise<Response>;
4
5
  interface SupabaseHandlerOptions {
5
- /**
6
- * Supabase function directory name (the segment under `supabase/functions/`).
7
- * Used to derive `resourcePath: /functions/v1/<functionName>` so OAuth
8
- * protected-resource metadata binds to the canonical public MCP URL rather
9
- * than the request path the dispatcher was reached through.
10
- *
11
- * Either `functionName` or `resourcePath` is required when OAuth auth is
12
- * configured and `auth.resource` is not pinned.
13
- */
14
- functionName?: string;
15
- /**
16
- * Explicit override for the public MCP route path. Wins over `functionName`
17
- * when both are set. Use when the function is fronted by a custom router or
18
- * a Lovable Cloud–style host that rewrites the public URL.
19
- */
20
- resourcePath?: string;
21
- /**
22
- * Derive the advertised `resource`/metadata host from `X-Forwarded-Host`
23
- * instead of the request `Host`, so a function fronted by a custom-domain
24
- * proxy advertises the public host. Off by default: enable only behind a
25
- * proxy that overwrites the header (an unsanitized one lets a client spoof
26
- * the advertised resource). `X-Forwarded-Proto` is trusted regardless —
27
- * Supabase terminates TLS upstream and forwards over http.
28
- */
29
- trustForwardedHost?: boolean;
6
+ /**
7
+ * Supabase function directory name (the segment under `supabase/functions/`).
8
+ * Used to derive `resourcePath: /functions/v1/<functionName>` so OAuth
9
+ * protected-resource metadata binds to the canonical public MCP URL rather
10
+ * than the request path the dispatcher was reached through.
11
+ *
12
+ * Either `functionName` or `resourcePath` is required when OAuth auth is
13
+ * configured and `auth.resource` is not pinned.
14
+ */
15
+ functionName?: string;
16
+ /**
17
+ * Explicit override for the public MCP route path. Wins over `functionName`
18
+ * when both are set. Use when the function is fronted by a custom router or
19
+ * a Lovable Cloud–style host that rewrites the public URL.
20
+ */
21
+ resourcePath?: string;
22
+ /**
23
+ * Derive the advertised `resource`/metadata host from `X-Forwarded-Host`
24
+ * instead of the request `Host`, so a function fronted by a custom-domain
25
+ * proxy advertises the public host. Off by default: enable only behind a
26
+ * proxy that overwrites the header (an unsanitized one lets a client spoof
27
+ * the advertised resource). `X-Forwarded-Proto` is trusted regardless —
28
+ * Supabase terminates TLS upstream and forwards over http.
29
+ */
30
+ trustForwardedHost?: boolean;
30
31
  }
31
32
  /**
32
33
  * Build a single Web-Standard handler that serves the full MCP surface from
@@ -43,5 +44,5 @@ interface SupabaseHandlerOptions {
43
44
  * The same OAuth bearer gate protects every dispatch target.
44
45
  */
45
46
  declare function createSupabaseHandler(mcp: McpDefinition, options?: SupabaseHandlerOptions): SupabaseHandler;
46
- //#endregion
47
- export { type SupabaseHandler, type SupabaseHandlerOptions, createSupabaseHandler };
47
+
48
+ export { type SupabaseHandler, type SupabaseHandlerOptions, createSupabaseHandler };
@@ -1,32 +1,33 @@
1
- import { c as McpDefinition } from "../../types-BYdYYTjk.js";
2
- //#region src/stacks/supabase/handler.d.ts
1
+ import { d as McpDefinition } from '../../types-qqrmJ736.js';
2
+ import 'zod';
3
+
3
4
  type SupabaseHandler = (request: Request) => Promise<Response>;
4
5
  interface SupabaseHandlerOptions {
5
- /**
6
- * Supabase function directory name (the segment under `supabase/functions/`).
7
- * Used to derive `resourcePath: /functions/v1/<functionName>` so OAuth
8
- * protected-resource metadata binds to the canonical public MCP URL rather
9
- * than the request path the dispatcher was reached through.
10
- *
11
- * Either `functionName` or `resourcePath` is required when OAuth auth is
12
- * configured and `auth.resource` is not pinned.
13
- */
14
- functionName?: string;
15
- /**
16
- * Explicit override for the public MCP route path. Wins over `functionName`
17
- * when both are set. Use when the function is fronted by a custom router or
18
- * a Lovable Cloud–style host that rewrites the public URL.
19
- */
20
- resourcePath?: string;
21
- /**
22
- * Derive the advertised `resource`/metadata host from `X-Forwarded-Host`
23
- * instead of the request `Host`, so a function fronted by a custom-domain
24
- * proxy advertises the public host. Off by default: enable only behind a
25
- * proxy that overwrites the header (an unsanitized one lets a client spoof
26
- * the advertised resource). `X-Forwarded-Proto` is trusted regardless —
27
- * Supabase terminates TLS upstream and forwards over http.
28
- */
29
- trustForwardedHost?: boolean;
6
+ /**
7
+ * Supabase function directory name (the segment under `supabase/functions/`).
8
+ * Used to derive `resourcePath: /functions/v1/<functionName>` so OAuth
9
+ * protected-resource metadata binds to the canonical public MCP URL rather
10
+ * than the request path the dispatcher was reached through.
11
+ *
12
+ * Either `functionName` or `resourcePath` is required when OAuth auth is
13
+ * configured and `auth.resource` is not pinned.
14
+ */
15
+ functionName?: string;
16
+ /**
17
+ * Explicit override for the public MCP route path. Wins over `functionName`
18
+ * when both are set. Use when the function is fronted by a custom router or
19
+ * a Lovable Cloud–style host that rewrites the public URL.
20
+ */
21
+ resourcePath?: string;
22
+ /**
23
+ * Derive the advertised `resource`/metadata host from `X-Forwarded-Host`
24
+ * instead of the request `Host`, so a function fronted by a custom-domain
25
+ * proxy advertises the public host. Off by default: enable only behind a
26
+ * proxy that overwrites the header (an unsanitized one lets a client spoof
27
+ * the advertised resource). `X-Forwarded-Proto` is trusted regardless —
28
+ * Supabase terminates TLS upstream and forwards over http.
29
+ */
30
+ trustForwardedHost?: boolean;
30
31
  }
31
32
  /**
32
33
  * Build a single Web-Standard handler that serves the full MCP surface from
@@ -43,5 +44,5 @@ interface SupabaseHandlerOptions {
43
44
  * The same OAuth bearer gate protects every dispatch target.
44
45
  */
45
46
  declare function createSupabaseHandler(mcp: McpDefinition, options?: SupabaseHandlerOptions): SupabaseHandler;
46
- //#endregion
47
- export { type SupabaseHandler, type SupabaseHandlerOptions, createSupabaseHandler };
47
+
48
+ export { type SupabaseHandler, type SupabaseHandlerOptions, createSupabaseHandler };
@@ -1,79 +1,95 @@
1
- import { s as trimTrailingSlash } from "../../logger-2OXtfiIW.js";
2
- import { l as createRecorderForRuntime, s as assertResourcePathShape } from "../../cors-B7CTXIHD.js";
3
- import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
4
- import { t as createMcpProtocolHandler } from "../../mcp-GngXbcqN.js";
5
- import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
6
- import { n as createListToolsHandler } from "../../list-tools-D75RGtgs.js";
7
- import { t as createInvokeToolHandler } from "../../rest-CXH6-zv9.js";
8
- import { t as applyForwardedOrigin } from "../../forwarded--h4efJy-.js";
9
- import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
10
- //#region src/stacks/supabase/handler.ts
1
+ import {
2
+ applyForwardedOrigin
3
+ } from "../../chunk-UQK5UO6C.js";
4
+ import {
5
+ createMcpProtocolHandler
6
+ } from "../../chunk-P43FIUMZ.js";
7
+ import {
8
+ createOAuthProtectedResourceMetadataHandler
9
+ } from "../../chunk-6KNM7RGD.js";
10
+ import {
11
+ createInvokeToolHandler
12
+ } from "../../chunk-4EHZUUS5.js";
13
+ import {
14
+ createListToolsHandler
15
+ } from "../../chunk-RLE4UE63.js";
16
+ import "../../chunk-6QFZYYUV.js";
17
+ import "../../chunk-MA5H6PSF.js";
18
+ import {
19
+ assertResourcePathShape,
20
+ createRecorderForRuntime
21
+ } from "../../chunk-RK62EMPY.js";
22
+ import {
23
+ trimTrailingSlash
24
+ } from "../../chunk-H37EB22A.js";
25
+ import {
26
+ OAUTH_PROTECTED_RESOURCE_METADATA_PATH
27
+ } from "../../chunk-6DXGZZA4.js";
28
+ import {
29
+ FUNCTIONS_MOUNT_PREFIX,
30
+ assertFunctionName
31
+ } from "../../chunk-XQWJN6DC.js";
32
+ import "../../chunk-EOFPMSND.js";
33
+
34
+ // src/stacks/supabase/handler.ts
11
35
  function deriveResourcePath(options) {
12
- if (options.resourcePath !== void 0) return options.resourcePath;
13
- if (options.functionName === void 0) return void 0;
14
- assertFunctionName(options.functionName);
15
- return `${FUNCTIONS_MOUNT_PREFIX}${options.functionName}`;
36
+ if (options.resourcePath !== void 0)
37
+ return options.resourcePath;
38
+ if (options.functionName === void 0)
39
+ return void 0;
40
+ assertFunctionName(options.functionName);
41
+ return `${FUNCTIONS_MOUNT_PREFIX}${options.functionName}`;
16
42
  }
17
43
  function dispatchFor(pathname) {
18
- const path = pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
19
- if (path.endsWith("/.well-known/oauth-protected-resource")) return { kind: "metadata" };
20
- if (path.endsWith("/.mcp/list-tools")) return { kind: "list-tools" };
21
- const invokeMatch = /\/\.mcp\/invoke-tool\/([^/]+)$/.exec(path);
22
- if (invokeMatch) {
23
- let toolName;
24
- try {
25
- toolName = decodeURIComponent(invokeMatch[1]);
26
- } catch {
27
- return { kind: "mcp" };
28
- }
29
- return {
30
- kind: "invoke-tool",
31
- toolName
32
- };
33
- }
34
- return { kind: "mcp" };
44
+ const path = pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
45
+ if (path.endsWith(OAUTH_PROTECTED_RESOURCE_METADATA_PATH)) {
46
+ return { kind: "metadata" };
47
+ }
48
+ if (path.endsWith("/.mcp/list-tools")) {
49
+ return { kind: "list-tools" };
50
+ }
51
+ const invokeMatch = /\/\.mcp\/invoke-tool\/([^/]+)$/.exec(path);
52
+ if (invokeMatch) {
53
+ let toolName;
54
+ try {
55
+ toolName = decodeURIComponent(invokeMatch[1]);
56
+ } catch {
57
+ return { kind: "mcp" };
58
+ }
59
+ return { kind: "invoke-tool", toolName };
60
+ }
61
+ return { kind: "mcp" };
35
62
  }
36
- /**
37
- * Build a single Web-Standard handler that serves the full MCP surface from
38
- * one Supabase Edge Function. The returned handler dispatches by URL suffix:
39
- *
40
- * | Suffix | Target |
41
- * | --- | --- |
42
- * | `/.well-known/oauth-protected-resource` | RFC 9728 metadata |
43
- * | `/.mcp/list-tools` | REST tool catalog |
44
- * | `/.mcp/invoke-tool/<tool>` | REST tool dispatcher |
45
- * | (anything else) | MCP streamable-HTTP protocol |
46
- *
47
- * Pass the handler to `Deno.serve(...)` in the emitted function entry.
48
- * The same OAuth bearer gate protects every dispatch target.
49
- */
50
63
  function createSupabaseHandler(mcp, options = {}) {
51
- const resourcePath = deriveResourcePath(options);
52
- if (resourcePath !== void 0) assertResourcePathShape(resourcePath);
53
- const servesOwnPrm = !(mcp.auth?.type === "oauth" && mcp.auth.protectedResourceMetadataUrl !== void 0);
54
- const metadataPath = resourcePath === void 0 || !servesOwnPrm ? void 0 : `${trimTrailingSlash(resourcePath)}${OAUTH_PROTECTED_RESOURCE_METADATA_PATH}`;
55
- const runtimeOptions = resourcePath === void 0 ? {} : {
56
- resourcePath,
57
- ...metadataPath ? { metadataPath } : {}
58
- };
59
- const mcpHandler = createMcpProtocolHandler(mcp, runtimeOptions);
60
- const listToolsHandler = createListToolsHandler(mcp, runtimeOptions);
61
- const invokeToolHandler = createInvokeToolHandler(mcp, runtimeOptions);
62
- const metadataHandler = createOAuthProtectedResourceMetadataHandler(mcp, runtimeOptions);
63
- return async (request) => {
64
- const req = applyForwardedOrigin(request, {
65
- trustForwardedProto: true,
66
- trustForwardedHost: options.trustForwardedHost
67
- });
68
- const recorder = createRecorderForRuntime(mcp, { stack: "supabase" });
69
- const target = dispatchFor(new URL(req.url).pathname);
70
- switch (target.kind) {
71
- case "metadata": return metadataHandler(req);
72
- case "list-tools": return listToolsHandler(req, recorder);
73
- case "invoke-tool": return invokeToolHandler(req, target.toolName, recorder);
74
- case "mcp": return mcpHandler(req, recorder);
75
- }
76
- };
64
+ const resourcePath = deriveResourcePath(options);
65
+ if (resourcePath !== void 0)
66
+ assertResourcePathShape(resourcePath);
67
+ const servesOwnPrm = !(mcp.auth?.type === "oauth" && mcp.auth.protectedResourceMetadataUrl !== void 0);
68
+ const metadataPath = resourcePath === void 0 || !servesOwnPrm ? void 0 : `${trimTrailingSlash(resourcePath)}${OAUTH_PROTECTED_RESOURCE_METADATA_PATH}`;
69
+ const runtimeOptions = resourcePath === void 0 ? {} : { resourcePath, ...metadataPath ? { metadataPath } : {} };
70
+ const mcpHandler = createMcpProtocolHandler(mcp, runtimeOptions);
71
+ const listToolsHandler = createListToolsHandler(mcp, runtimeOptions);
72
+ const invokeToolHandler = createInvokeToolHandler(mcp, runtimeOptions);
73
+ const metadataHandler = createOAuthProtectedResourceMetadataHandler(mcp, runtimeOptions);
74
+ return async (request) => {
75
+ const req = applyForwardedOrigin(request, {
76
+ trustForwardedProto: true,
77
+ trustForwardedHost: options.trustForwardedHost
78
+ });
79
+ const recorder = createRecorderForRuntime(mcp, { stack: "supabase" });
80
+ const target = dispatchFor(new URL(req.url).pathname);
81
+ switch (target.kind) {
82
+ case "metadata":
83
+ return metadataHandler(req);
84
+ case "list-tools":
85
+ return listToolsHandler(req, recorder);
86
+ case "invoke-tool":
87
+ return invokeToolHandler(req, target.toolName, recorder);
88
+ case "mcp":
89
+ return mcpHandler(req, recorder);
90
+ }
91
+ };
77
92
  }
78
- //#endregion
79
- export { createSupabaseHandler };
93
+ export {
94
+ createSupabaseHandler
95
+ };