@lovable.dev/mcp-js 0.28.0 → 0.29.0-rc.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 (69) hide show
  1. package/README.md +7 -1
  2. package/dist/{authorize-Cs1yyLrq.d.ts → authorize-BjNE3LPr.d.ts} +1 -1
  3. package/dist/{authorize-BcNuNPtP.d.cts → authorize-BzZFS0zi.d.cts} +1 -1
  4. package/dist/{base-CUkmyaXJ.d.cts → base-DSH8NnPj.d.cts} +4 -0
  5. package/dist/{base-CUkmyaXJ.d.ts → base-DSH8NnPj.d.ts} +4 -0
  6. package/dist/cli/extract-manifest.cjs +2 -2
  7. package/dist/cli/extract-manifest.js +2 -2
  8. package/dist/{authorize-ChY44o_1.cjs → cors-CmKzDN7k.cjs} +73 -29
  9. package/dist/{authorize--rUeMOGU.js → cors-D4YbODs-.js} +68 -24
  10. package/dist/{forwarded-BlLF3dfc.js → forwarded-B3EBjHnA.js} +3 -3
  11. package/dist/{forwarded-Bhwcj22u.cjs → forwarded-BC_RHnn5.cjs} +3 -3
  12. package/dist/{gate-CGZl0gjJ.cjs → gate-n_HX6eQ5.cjs} +6 -4
  13. package/dist/{gate-BiM6EBeA.js → gate-pGsVlY_4.js} +5 -3
  14. package/dist/index.cjs +37 -0
  15. package/dist/index.d.cts +3 -3
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +37 -0
  18. package/dist/{io-VBHO8YH_.d.cts → io-BEwvgN8s.d.cts} +1 -1
  19. package/dist/{io-SMlD5WeX.d.ts → io-CvALf9NE.d.ts} +1 -1
  20. package/dist/list-tools-Dkyyje7j.cjs +48 -0
  21. package/dist/{list-tools-BLGr7mot.js → list-tools-ePP9tXND.js} +9 -13
  22. package/dist/{list-tools-BAqQVIHk.d.ts → list-tools-qIvVJeWZ.d.ts} +3 -3
  23. package/dist/{list-tools-BN97L2Yv.d.cts → list-tools-zagoI477.d.cts} +3 -3
  24. package/dist/mcp-Cs4zfvSi.js +336 -0
  25. package/dist/mcp-DQ1Vdv4v.cjs +341 -0
  26. package/dist/{package-CGLPZwz-.cjs → package-C3YVYgxp.cjs} +1 -1
  27. package/dist/{package-DgiA0xuY.js → package-DzB_5Hur.js} +1 -1
  28. package/dist/protocols/mcp/index.cjs +1 -1
  29. package/dist/protocols/mcp/index.d.cts +3 -3
  30. package/dist/protocols/mcp/index.d.ts +3 -3
  31. package/dist/protocols/mcp/index.js +1 -1
  32. package/dist/protocols/oauth-metadata.cjs +11 -9
  33. package/dist/protocols/oauth-metadata.d.cts +2 -2
  34. package/dist/protocols/oauth-metadata.d.ts +2 -2
  35. package/dist/protocols/oauth-metadata.js +5 -3
  36. package/dist/protocols/rest/index.cjs +2 -2
  37. package/dist/protocols/rest/index.d.cts +4 -4
  38. package/dist/protocols/rest/index.d.ts +4 -4
  39. package/dist/protocols/rest/index.js +2 -2
  40. package/dist/{rest-BS7bBOd9.js → rest-DSclWpIt.js} +13 -12
  41. package/dist/{rest-BE05MUNS.cjs → rest-P6XZWP42.cjs} +28 -27
  42. package/dist/schema-CW1jKvio.js +65 -0
  43. package/dist/schema-D3vClxb7.cjs +76 -0
  44. package/dist/stacks/supabase/index.cjs +7 -7
  45. package/dist/stacks/supabase/index.d.cts +1 -1
  46. package/dist/stacks/supabase/index.d.ts +1 -1
  47. package/dist/stacks/supabase/index.js +5 -5
  48. package/dist/stacks/supabase/vite.cjs +1 -1
  49. package/dist/stacks/supabase/vite.d.cts +1 -1
  50. package/dist/stacks/supabase/vite.d.ts +1 -1
  51. package/dist/stacks/supabase/vite.js +1 -1
  52. package/dist/stacks/tanstack/index.cjs +8 -8
  53. package/dist/stacks/tanstack/index.d.cts +2 -2
  54. package/dist/stacks/tanstack/index.d.ts +2 -2
  55. package/dist/stacks/tanstack/index.js +5 -5
  56. package/dist/stacks/tanstack/vite.cjs +8 -4
  57. package/dist/stacks/tanstack/vite.d.cts +11 -1
  58. package/dist/stacks/tanstack/vite.d.ts +11 -1
  59. package/dist/stacks/tanstack/vite.js +8 -4
  60. package/dist/tool-result-CK6hXO43.cjs +89 -0
  61. package/dist/tool-result-DfCk445b.js +78 -0
  62. package/dist/{types-C0Wgm9zp.d.cts → types-D1cgsnPu.d.cts} +15 -7
  63. package/dist/{types-C0Wgm9zp.d.ts → types-D1cgsnPu.d.ts} +15 -7
  64. package/package.json +2 -1
  65. package/dist/content-D5LJAHyM.js +0 -12
  66. package/dist/content-NCYIGgOb.cjs +0 -17
  67. package/dist/list-tools-DCF6G4fn.cjs +0 -52
  68. package/dist/mcp-CUGwXkxb.cjs +0 -153
  69. package/dist/mcp-Czp-hHjN.js +0 -148
@@ -1,8 +1,8 @@
1
1
  const require_errors = require("./errors-CN6Da8iz.cjs");
2
- const require_authorize = require("./authorize-ChY44o_1.cjs");
3
- const require_content = require("./content-NCYIGgOb.cjs");
4
- const require_gate = require("./gate-CGZl0gjJ.cjs");
5
- require("./list-tools-DCF6G4fn.cjs");
2
+ const require_cors = require("./cors-CmKzDN7k.cjs");
3
+ const require_tool_result = require("./tool-result-CK6hXO43.cjs");
4
+ const require_gate = require("./gate-n_HX6eQ5.cjs");
5
+ require("./list-tools-Dkyyje7j.cjs");
6
6
  let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
7
7
  //#region src/protocols/rest/invoke-tool.ts
8
8
  const MAX_REFLECTED_TOOL_NAME = 256;
@@ -16,13 +16,13 @@ function isEmptyArgs(value) {
16
16
  return Object.keys(value).length === 0;
17
17
  }
18
18
  function createInvokeToolHandler(mcp, options = {}) {
19
- require_authorize.assertRestResourceBinding(mcp, options);
19
+ require_cors.assertRestResourceBinding(mcp, options);
20
20
  const handle = async (request, authResult, recorder, toolName) => {
21
21
  const endUserId = authResult.auth?.principal.sub;
22
22
  const tool = mcp.tools.find((t) => t.name === toolName);
23
23
  if (!tool) return new Response(JSON.stringify({ error: `unknown tool: ${safeReflectName(toolName)}` }), {
24
24
  status: 404,
25
- headers: require_authorize.JSON_HEADERS
25
+ headers: require_cors.JSON_HEADERS
26
26
  });
27
27
  let rawArgs = {};
28
28
  const text = await request.text();
@@ -31,7 +31,7 @@ function createInvokeToolHandler(mcp, options = {}) {
31
31
  } catch {
32
32
  return new Response(JSON.stringify({ error: "invalid JSON body" }), {
33
33
  status: 400,
34
- headers: require_authorize.JSON_HEADERS
34
+ headers: require_cors.JSON_HEADERS
35
35
  });
36
36
  }
37
37
  let args = rawArgs;
@@ -42,7 +42,7 @@ function createInvokeToolHandler(mcp, options = {}) {
42
42
  details: (0, _modelcontextprotocol_sdk_server_zod_compat_js.getParseErrorMessage)(parsed.error)
43
43
  }), {
44
44
  status: 400,
45
- headers: require_authorize.JSON_HEADERS
45
+ headers: require_cors.JSON_HEADERS
46
46
  });
47
47
  args = parsed.data;
48
48
  } catch {
@@ -51,15 +51,15 @@ function createInvokeToolHandler(mcp, options = {}) {
51
51
  tool: toolName
52
52
  }), {
53
53
  status: 500,
54
- headers: require_authorize.JSON_HEADERS
54
+ headers: require_cors.JSON_HEADERS
55
55
  });
56
56
  }
57
57
  else if (!isEmptyArgs(rawArgs)) return new Response(JSON.stringify({ error: "tool has no inputSchema; expected empty body" }), {
58
58
  status: 400,
59
- headers: require_authorize.JSON_HEADERS
59
+ headers: require_cors.JSON_HEADERS
60
60
  });
61
61
  let result;
62
- const start = require_authorize.nowMs();
62
+ const start = require_cors.nowMs();
63
63
  try {
64
64
  result = await tool.handler(args, new require_errors.ToolContext(authResult.auth));
65
65
  } catch (err) {
@@ -69,16 +69,17 @@ function createInvokeToolHandler(mcp, options = {}) {
69
69
  tool: tool.name,
70
70
  method: "tools/call",
71
71
  outcome: "handler_error",
72
- durationMs: require_authorize.nowMs() - start,
72
+ durationMs: require_cors.nowMs() - start,
73
73
  errorText: require_errors.errorSummary(err),
74
- endUserId
74
+ endUserId,
75
+ protocol: "rest"
75
76
  });
76
77
  return new Response(JSON.stringify({
77
78
  error: "handler threw",
78
79
  tool: toolName
79
80
  }), {
80
81
  status: 500,
81
- headers: require_authorize.JSON_HEADERS
82
+ headers: require_cors.JSON_HEADERS
82
83
  });
83
84
  }
84
85
  result = {
@@ -94,32 +95,32 @@ function createInvokeToolHandler(mcp, options = {}) {
94
95
  tool: tool.name,
95
96
  method: "tools/call",
96
97
  outcome: "handler_error",
97
- durationMs: require_authorize.nowMs() - start,
98
- endUserId
98
+ durationMs: require_cors.nowMs() - start,
99
+ endUserId,
100
+ protocol: "rest"
99
101
  });
100
102
  return new Response(JSON.stringify({ error: `tool "${toolName}" returned no result` }), {
101
103
  status: 500,
102
- headers: require_authorize.JSON_HEADERS
104
+ headers: require_cors.JSON_HEADERS
103
105
  });
104
106
  }
107
+ result = await require_tool_result.finalizeToolResult(tool, result);
105
108
  await recorder.emit({
106
109
  tool: tool.name,
107
110
  method: "tools/call",
108
111
  outcome: result.isError ? "tool_error" : "ok",
109
- durationMs: require_authorize.nowMs() - start,
110
- errorText: result.isError ? require_content.extractTextContent(result.content) : void 0,
111
- endUserId
112
- });
113
- return Response.json({
114
- content: result.content ?? [],
115
- structuredContent: result.structuredContent,
116
- isError: result.isError
112
+ durationMs: require_cors.nowMs() - start,
113
+ errorText: result.isError ? require_tool_result.extractTextContent(result.content) : void 0,
114
+ endUserId,
115
+ protocol: "rest"
117
116
  });
117
+ return Response.json(result);
118
118
  };
119
119
  const gated = require_gate.createGatedHandler({
120
- authorizer: require_authorize.createRequestAuthorizer(mcp, options),
120
+ authorizer: require_cors.createRequestAuthorizer(mcp, options),
121
+ allowedOrigins: mcp.allowedOrigins,
121
122
  methods: ["POST"],
122
- methodNotAllowed: require_authorize.methodNotAllowed,
123
+ methodNotAllowed: require_cors.methodNotAllowed,
123
124
  handle
124
125
  });
125
126
  return (request, toolName, recorder) => gated(request, recorder, toolName);
@@ -0,0 +1,65 @@
1
+ import { objectFromShape } from "@modelcontextprotocol/sdk/server/zod-compat.js";
2
+ import { toJsonSchemaCompat } from "@modelcontextprotocol/sdk/server/zod-json-schema-compat.js";
3
+ //#region src/core/schema.ts
4
+ function isZodSchema(definition) {
5
+ return (typeof definition === "object" || typeof definition === "function") && definition !== null && typeof definition.safeParse === "function";
6
+ }
7
+ function schemaFromDefinition(definition) {
8
+ return isZodSchema(definition) ? definition : objectFromShape(definition);
9
+ }
10
+ const NON_JSON_ZOD3_OUTPUTS = /* @__PURE__ */ new Set([
11
+ "ZodBigInt",
12
+ "ZodDate",
13
+ "ZodFunction",
14
+ "ZodMap",
15
+ "ZodNaN",
16
+ "ZodPromise",
17
+ "ZodSet",
18
+ "ZodSymbol",
19
+ "ZodUndefined",
20
+ "ZodVoid"
21
+ ]);
22
+ function unsupportedZod3Output(schema, seen = /* @__PURE__ */ new Set()) {
23
+ if (seen.has(schema)) return void 0;
24
+ seen.add(schema);
25
+ const definition = schema._def;
26
+ if (!definition) return void 0;
27
+ if (definition.effect?.type === "transform") return "Transforms cannot be represented in JSON Schema";
28
+ const typeName = definition.typeName;
29
+ if (typeof typeName === "string" && NON_JSON_ZOD3_OUTPUTS.has(typeName)) return `${typeName} does not produce a JSON value`;
30
+ const shape = definition.shape;
31
+ if (typeof shape === "function") {
32
+ const fields = shape();
33
+ for (const field of Object.values(fields)) {
34
+ const issue = unsupportedZod3Output(field, seen);
35
+ if (issue) return issue;
36
+ }
37
+ }
38
+ const getter = definition.getter;
39
+ if (typeof getter === "function") {
40
+ const issue = unsupportedZod3Output(getter(), seen);
41
+ if (issue) return issue;
42
+ }
43
+ for (const value of Object.values(definition)) if (Array.isArray(value)) for (const entry of value) {
44
+ if (!isZodSchema(entry)) continue;
45
+ const issue = unsupportedZod3Output(entry, seen);
46
+ if (issue) return issue;
47
+ }
48
+ else if (value && typeof value === "object" && isZodSchema(value)) {
49
+ const issue = unsupportedZod3Output(value, seen);
50
+ if (issue) return issue;
51
+ }
52
+ }
53
+ function jsonSchemaFromDefinition(definition, pipeStrategy) {
54
+ const schema = schemaFromDefinition(definition);
55
+ if (pipeStrategy === "output") {
56
+ const issue = unsupportedZod3Output(schema);
57
+ if (issue) throw new Error(issue);
58
+ }
59
+ return toJsonSchemaCompat(schema, {
60
+ target: "draft-2020-12",
61
+ pipeStrategy
62
+ });
63
+ }
64
+ //#endregion
65
+ export { schemaFromDefinition as n, jsonSchemaFromDefinition as t };
@@ -0,0 +1,76 @@
1
+ let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
2
+ let _modelcontextprotocol_sdk_server_zod_json_schema_compat_js = require("@modelcontextprotocol/sdk/server/zod-json-schema-compat.js");
3
+ //#region src/core/schema.ts
4
+ function isZodSchema(definition) {
5
+ return (typeof definition === "object" || typeof definition === "function") && definition !== null && typeof definition.safeParse === "function";
6
+ }
7
+ function schemaFromDefinition(definition) {
8
+ return isZodSchema(definition) ? definition : (0, _modelcontextprotocol_sdk_server_zod_compat_js.objectFromShape)(definition);
9
+ }
10
+ const NON_JSON_ZOD3_OUTPUTS = /* @__PURE__ */ new Set([
11
+ "ZodBigInt",
12
+ "ZodDate",
13
+ "ZodFunction",
14
+ "ZodMap",
15
+ "ZodNaN",
16
+ "ZodPromise",
17
+ "ZodSet",
18
+ "ZodSymbol",
19
+ "ZodUndefined",
20
+ "ZodVoid"
21
+ ]);
22
+ function unsupportedZod3Output(schema, seen = /* @__PURE__ */ new Set()) {
23
+ if (seen.has(schema)) return void 0;
24
+ seen.add(schema);
25
+ const definition = schema._def;
26
+ if (!definition) return void 0;
27
+ if (definition.effect?.type === "transform") return "Transforms cannot be represented in JSON Schema";
28
+ const typeName = definition.typeName;
29
+ if (typeof typeName === "string" && NON_JSON_ZOD3_OUTPUTS.has(typeName)) return `${typeName} does not produce a JSON value`;
30
+ const shape = definition.shape;
31
+ if (typeof shape === "function") {
32
+ const fields = shape();
33
+ for (const field of Object.values(fields)) {
34
+ const issue = unsupportedZod3Output(field, seen);
35
+ if (issue) return issue;
36
+ }
37
+ }
38
+ const getter = definition.getter;
39
+ if (typeof getter === "function") {
40
+ const issue = unsupportedZod3Output(getter(), seen);
41
+ if (issue) return issue;
42
+ }
43
+ for (const value of Object.values(definition)) if (Array.isArray(value)) for (const entry of value) {
44
+ if (!isZodSchema(entry)) continue;
45
+ const issue = unsupportedZod3Output(entry, seen);
46
+ if (issue) return issue;
47
+ }
48
+ else if (value && typeof value === "object" && isZodSchema(value)) {
49
+ const issue = unsupportedZod3Output(value, seen);
50
+ if (issue) return issue;
51
+ }
52
+ }
53
+ function jsonSchemaFromDefinition(definition, pipeStrategy) {
54
+ const schema = schemaFromDefinition(definition);
55
+ if (pipeStrategy === "output") {
56
+ const issue = unsupportedZod3Output(schema);
57
+ if (issue) throw new Error(issue);
58
+ }
59
+ return (0, _modelcontextprotocol_sdk_server_zod_json_schema_compat_js.toJsonSchemaCompat)(schema, {
60
+ target: "draft-2020-12",
61
+ pipeStrategy
62
+ });
63
+ }
64
+ //#endregion
65
+ Object.defineProperty(exports, "jsonSchemaFromDefinition", {
66
+ enumerable: true,
67
+ get: function() {
68
+ return jsonSchemaFromDefinition;
69
+ }
70
+ });
71
+ Object.defineProperty(exports, "schemaFromDefinition", {
72
+ enumerable: true,
73
+ get: function() {
74
+ return schemaFromDefinition;
75
+ }
76
+ });
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_logger = require("../../logger-CN1q-KNn.cjs");
3
- const require_authorize = require("../../authorize-ChY44o_1.cjs");
3
+ const require_cors = require("../../cors-CmKzDN7k.cjs");
4
4
  const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
5
- const require_mcp = require("../../mcp-CUGwXkxb.cjs");
5
+ const require_mcp = require("../../mcp-DQ1Vdv4v.cjs");
6
6
  const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
7
- const require_list_tools = require("../../list-tools-DCF6G4fn.cjs");
8
- const require_rest = require("../../rest-BE05MUNS.cjs");
9
- const require_forwarded = require("../../forwarded-Bhwcj22u.cjs");
7
+ const require_list_tools = require("../../list-tools-Dkyyje7j.cjs");
8
+ const require_rest = require("../../rest-P6XZWP42.cjs");
9
+ const require_forwarded = require("../../forwarded-BC_RHnn5.cjs");
10
10
  const require_paths = require("../../paths-OP318a6c.cjs");
11
11
  //#region src/stacks/supabase/handler.ts
12
12
  function deriveResourcePath(options) {
@@ -50,7 +50,7 @@ function dispatchFor(pathname) {
50
50
  */
51
51
  function createSupabaseHandler(mcp, options = {}) {
52
52
  const resourcePath = deriveResourcePath(options);
53
- if (resourcePath !== void 0) require_authorize.assertResourcePathShape(resourcePath);
53
+ if (resourcePath !== void 0) require_cors.assertResourcePathShape(resourcePath);
54
54
  const servesOwnPrm = !(mcp.auth?.type === "oauth" && mcp.auth.protectedResourceMetadataUrl !== void 0);
55
55
  const metadataPath = resourcePath === void 0 || !servesOwnPrm ? void 0 : `${require_logger.trimTrailingSlash(resourcePath)}${require_metadata_path.OAUTH_PROTECTED_RESOURCE_METADATA_PATH}`;
56
56
  const runtimeOptions = {
@@ -67,7 +67,7 @@ function createSupabaseHandler(mcp, options = {}) {
67
67
  const metadataHandler = require_protocols_oauth_metadata.createOAuthProtectedResourceMetadataHandler(mcp, runtimeOptions);
68
68
  return async (request) => {
69
69
  const req = require_forwarded.applyForwardedOrigin(request, runtimeOptions);
70
- const recorder = require_authorize.createRecorderForRuntime(mcp, { stack: "supabase" });
70
+ const recorder = require_cors.createRecorderForRuntime(mcp, { stack: "supabase" });
71
71
  const target = dispatchFor(new URL(req.url).pathname);
72
72
  switch (target.kind) {
73
73
  case "metadata": return metadataHandler(req);
@@ -1,4 +1,4 @@
1
- import { c as McpDefinition } from "../../types-C0Wgm9zp.cjs";
1
+ import { u as McpDefinition } from "../../types-D1cgsnPu.cjs";
2
2
  //#region src/stacks/supabase/handler.d.ts
3
3
  type SupabaseHandler = (request: Request) => Promise<Response>;
4
4
  interface SupabaseHandlerOptions {
@@ -1,4 +1,4 @@
1
- import { c as McpDefinition } from "../../types-C0Wgm9zp.js";
1
+ import { u as McpDefinition } from "../../types-D1cgsnPu.js";
2
2
  //#region src/stacks/supabase/handler.d.ts
3
3
  type SupabaseHandler = (request: Request) => Promise<Response>;
4
4
  interface SupabaseHandlerOptions {
@@ -1,11 +1,11 @@
1
1
  import { s as trimTrailingSlash } from "../../logger-Ctv5xUSD.js";
2
- import { a as assertResourcePathShape, s as createRecorderForRuntime } from "../../authorize--rUeMOGU.js";
2
+ import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-D4YbODs-.js";
3
3
  import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
4
- import { t as createMcpProtocolHandler } from "../../mcp-Czp-hHjN.js";
4
+ import { t as createMcpProtocolHandler } from "../../mcp-Cs4zfvSi.js";
5
5
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
6
- import { n as createListToolsHandler } from "../../list-tools-BLGr7mot.js";
7
- import { t as createInvokeToolHandler } from "../../rest-BS7bBOd9.js";
8
- import { t as applyForwardedOrigin } from "../../forwarded-BlLF3dfc.js";
6
+ import { n as createListToolsHandler } from "../../list-tools-ePP9tXND.js";
7
+ import { t as createInvokeToolHandler } from "../../rest-DSclWpIt.js";
8
+ import { t as applyForwardedOrigin } from "../../forwarded-B3EBjHnA.js";
9
9
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
10
10
  //#region src/stacks/supabase/handler.ts
11
11
  function deriveResourcePath(options) {
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_package = require("../../package-CGLPZwz-.cjs");
5
+ const require_package = require("../../package-C3YVYgxp.cjs");
6
6
  const require_fs_errors = require("../../fs-errors-CWNzOV75.cjs");
7
7
  const require_supabase_config = require("../../supabase-config-Dz7dnUv0.cjs");
8
8
  const require_paths = require("../../paths-OP318a6c.cjs");
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-VBHO8YH_.cjs";
1
+ import { t as McpPluginApi } from "../../io-BEwvgN8s.cjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/supabase/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-SMlD5WeX.js";
1
+ import { t as McpPluginApi } from "../../io-CvALf9NE.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/supabase/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { t as version } from "../../package-DgiA0xuY.js";
1
+ import { t as version } from "../../package-DzB_5Hur.js";
2
2
  import { t as isFileMissing } from "../../fs-errors-PA2t1TIp.js";
3
3
  import { t as readSupabaseProjectRef } from "../../supabase-config-CakTU8YF.js";
4
4
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_authorize = require("../../authorize-ChY44o_1.cjs");
3
- const require_mcp = require("../../mcp-CUGwXkxb.cjs");
2
+ const require_cors = require("../../cors-CmKzDN7k.cjs");
3
+ const require_mcp = require("../../mcp-DQ1Vdv4v.cjs");
4
4
  const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
5
- const require_list_tools = require("../../list-tools-DCF6G4fn.cjs");
6
- const require_rest = require("../../rest-BE05MUNS.cjs");
7
- const require_forwarded = require("../../forwarded-Bhwcj22u.cjs");
5
+ const require_list_tools = require("../../list-tools-Dkyyje7j.cjs");
6
+ const require_rest = require("../../rest-P6XZWP42.cjs");
7
+ const require_forwarded = require("../../forwarded-BC_RHnn5.cjs");
8
8
  //#region src/stacks/tanstack/handlers.ts
9
9
  const STACK = "tanstack";
10
10
  /**
@@ -13,7 +13,7 @@ const STACK = "tanstack";
13
13
  */
14
14
  function createTanStackMcpHandler(mcp, options = {}) {
15
15
  const handler = require_mcp.createMcpProtocolHandler(mcp, options);
16
- return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_authorize.createRecorderForRuntime(mcp, { stack: STACK }));
16
+ return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_cors.createRecorderForRuntime(mcp, { stack: STACK }));
17
17
  }
18
18
  /**
19
19
  * Build a TanStack Start handler for `GET /.mcp/list-tools`. Returns the
@@ -21,7 +21,7 @@ function createTanStackMcpHandler(mcp, options = {}) {
21
21
  */
22
22
  function createTanStackListToolsHandler(mcp, options = {}) {
23
23
  const handler = require_list_tools.createListToolsHandler(mcp, options);
24
- return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_authorize.createRecorderForRuntime(mcp, { stack: STACK }));
24
+ return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_cors.createRecorderForRuntime(mcp, { stack: STACK }));
25
25
  }
26
26
  /**
27
27
  * Build a TanStack Start handler for `POST /.mcp/invoke-tool/$tool`.
@@ -30,7 +30,7 @@ function createTanStackListToolsHandler(mcp, options = {}) {
30
30
  */
31
31
  function createTanStackInvokeToolHandler(mcp, options = {}) {
32
32
  const handler = require_rest.createInvokeToolHandler(mcp, options);
33
- return ({ request, params }) => handler(require_forwarded.applyForwardedOrigin(request, options), params.tool, require_authorize.createRecorderForRuntime(mcp, { stack: STACK }));
33
+ return ({ request, params }) => handler(require_forwarded.applyForwardedOrigin(request, options), params.tool, require_cors.createRecorderForRuntime(mcp, { stack: STACK }));
34
34
  }
35
35
  /**
36
36
  * Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
@@ -1,5 +1,5 @@
1
- import { c as McpDefinition } from "../../types-C0Wgm9zp.cjs";
2
- import { t as McpRuntimeOptions } from "../../authorize-BcNuNPtP.cjs";
1
+ import { u as McpDefinition } from "../../types-D1cgsnPu.cjs";
2
+ import { t as McpRuntimeOptions } from "../../authorize-BzZFS0zi.cjs";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRouteCtx {
5
5
  request: Request;
@@ -1,5 +1,5 @@
1
- import { c as McpDefinition } from "../../types-C0Wgm9zp.js";
2
- import { t as McpRuntimeOptions } from "../../authorize-Cs1yyLrq.js";
1
+ import { u as McpDefinition } from "../../types-D1cgsnPu.js";
2
+ import { t as McpRuntimeOptions } from "../../authorize-BjNE3LPr.js";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRouteCtx {
5
5
  request: Request;
@@ -1,9 +1,9 @@
1
- import { s as createRecorderForRuntime } from "../../authorize--rUeMOGU.js";
2
- import { t as createMcpProtocolHandler } from "../../mcp-Czp-hHjN.js";
1
+ import { c as createRecorderForRuntime } from "../../cors-D4YbODs-.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-Cs4zfvSi.js";
3
3
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
4
- import { n as createListToolsHandler } from "../../list-tools-BLGr7mot.js";
5
- import { t as createInvokeToolHandler } from "../../rest-BS7bBOd9.js";
6
- import { t as applyForwardedOrigin } from "../../forwarded-BlLF3dfc.js";
4
+ import { n as createListToolsHandler } from "../../list-tools-ePP9tXND.js";
5
+ import { t as createInvokeToolHandler } from "../../rest-DSclWpIt.js";
6
+ import { t as applyForwardedOrigin } from "../../forwarded-B3EBjHnA.js";
7
7
  //#region src/stacks/tanstack/handlers.ts
8
8
  const STACK = "tanstack";
9
9
  /**
@@ -79,14 +79,17 @@ function relativeImportSpecifier(routeFile, target) {
79
79
  const withoutExt = normalizePath((0, node_path.relative)((0, node_path.dirname)(routeFile), target)).replace(/\.ts$/, "");
80
80
  return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
81
81
  }
82
- function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, mcpEntry, projectRoot) {
82
+ function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
83
83
  const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
84
84
  const routeRel = normalizePath((0, node_path.relative)(projectRoot, route.file));
85
85
  const note = route.spaFallbackNote ? " // ANY: TanStack returns SPA HTML for methods not in `handlers`; the SDK 405s instead.\n" : "";
86
86
  const optionEntries = [`resourcePath: "${resourcePath}"`];
87
87
  if (metadataPath !== void 0) optionEntries.push(`metadataPath: "${metadataPath}"`);
88
- if (trustForwardedHost) if (route.attestsForwardedHost) optionEntries.push("// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.\n trustForwardedHost: true", "forwardedHostTrustedByPlatform: true");
89
- else optionEntries.push("trustForwardedHost: true");
88
+ if (trustForwardedHost) if (route.attestsForwardedHost) {
89
+ const trustNote = trustForwardedProto ? "// Trusting X-Forwarded-Host/-Proto is safe on Lovable hosting only (its\n // proxies overwrite both headers); remove these options behind other proxies." : "// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.";
90
+ optionEntries.push(`${trustNote}\n trustForwardedHost: true`, "forwardedHostTrustedByPlatform: true");
91
+ } else optionEntries.push("trustForwardedHost: true");
92
+ if (trustForwardedProto) optionEntries.push("trustForwardedProto: true");
90
93
  const optionsObject = `{\n${optionEntries.map((entry) => ` ${entry},`).join("\n")}\n }`;
91
94
  const inlineRouteOpen = `export const Route = createFileRoute("${route.routeLiteral}")({`;
92
95
  const routeOpen = inlineRouteOpen.length <= OXFMT_PRINT_WIDTH ? inlineRouteOpen : `export const Route = createFileRoute(\n "${route.routeLiteral}",\n)({`;
@@ -193,6 +196,7 @@ function mcpPlugin(options = {}) {
193
196
  const metadataUrlPath = canonicalUrlPath(options.metadataPath ?? "/.well-known/oauth-protected-resource");
194
197
  const injectedMetadataPath = emitProtectedResourceMetadataRoute ? metadataUrlPath : void 0;
195
198
  const trustForwardedHost = options.trustForwardedHost !== false;
199
+ const trustForwardedProto = options.trustForwardedProto !== false;
196
200
  let projectRoot = process.cwd();
197
201
  let mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
198
202
  let { routesDir, mcpRouteFile, metadataRouteFile, listToolsRouteFile, invokeToolRouteFile, listToolsLiteral, invokeToolLiteral } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, urlPath, metadataUrlPath);
@@ -230,7 +234,7 @@ function mcpPlugin(options = {}) {
230
234
  });
231
235
  for (const route of routes) {
232
236
  expected.add(route.file);
233
- writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, mcpEntry, projectRoot));
237
+ writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
234
238
  }
235
239
  }
236
240
  for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-VBHO8YH_.cjs";
1
+ import { t as McpPluginApi } from "../../io-BEwvgN8s.cjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -77,6 +77,16 @@ interface McpPluginOptions {
77
77
  * @default true
78
78
  */
79
79
  trustForwardedHost?: boolean;
80
+ /**
81
+ * Derive the public scheme of same-origin CORS checks and advertised OAuth
82
+ * URLs from `X-Forwarded-Proto`. Lovable's preview proxy terminates TLS and
83
+ * forwards plain http to the dev server while overwriting
84
+ * `X-Forwarded-Proto`, so the default is `true` to keep same-origin browser
85
+ * requests and advertised `https` URLs working in previews. Set `false` only
86
+ * when deploying behind a proxy that does not overwrite the header.
87
+ * @default true
88
+ */
89
+ trustForwardedProto?: boolean;
80
90
  }
81
91
  declare function assertUrlPathShape(urlPath: string): string;
82
92
  declare function deriveRouteFileName(urlPath: string): string;
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-SMlD5WeX.js";
1
+ import { t as McpPluginApi } from "../../io-CvALf9NE.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -77,6 +77,16 @@ interface McpPluginOptions {
77
77
  * @default true
78
78
  */
79
79
  trustForwardedHost?: boolean;
80
+ /**
81
+ * Derive the public scheme of same-origin CORS checks and advertised OAuth
82
+ * URLs from `X-Forwarded-Proto`. Lovable's preview proxy terminates TLS and
83
+ * forwards plain http to the dev server while overwriting
84
+ * `X-Forwarded-Proto`, so the default is `true` to keep same-origin browser
85
+ * requests and advertised `https` URLs working in previews. Set `false` only
86
+ * when deploying behind a proxy that does not overwrite the header.
87
+ * @default true
88
+ */
89
+ trustForwardedProto?: boolean;
80
90
  }
81
91
  declare function assertUrlPathShape(urlPath: string): string;
82
92
  declare function deriveRouteFileName(urlPath: string): string;
@@ -75,14 +75,17 @@ function relativeImportSpecifier(routeFile, target) {
75
75
  const withoutExt = normalizePath(relative(dirname(routeFile), target)).replace(/\.ts$/, "");
76
76
  return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
77
77
  }
78
- function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, mcpEntry, projectRoot) {
78
+ function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
79
79
  const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
80
80
  const routeRel = normalizePath(relative(projectRoot, route.file));
81
81
  const note = route.spaFallbackNote ? " // ANY: TanStack returns SPA HTML for methods not in `handlers`; the SDK 405s instead.\n" : "";
82
82
  const optionEntries = [`resourcePath: "${resourcePath}"`];
83
83
  if (metadataPath !== void 0) optionEntries.push(`metadataPath: "${metadataPath}"`);
84
- if (trustForwardedHost) if (route.attestsForwardedHost) optionEntries.push("// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.\n trustForwardedHost: true", "forwardedHostTrustedByPlatform: true");
85
- else optionEntries.push("trustForwardedHost: true");
84
+ if (trustForwardedHost) if (route.attestsForwardedHost) {
85
+ const trustNote = trustForwardedProto ? "// Trusting X-Forwarded-Host/-Proto is safe on Lovable hosting only (its\n // proxies overwrite both headers); remove these options behind other proxies." : "// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.";
86
+ optionEntries.push(`${trustNote}\n trustForwardedHost: true`, "forwardedHostTrustedByPlatform: true");
87
+ } else optionEntries.push("trustForwardedHost: true");
88
+ if (trustForwardedProto) optionEntries.push("trustForwardedProto: true");
86
89
  const optionsObject = `{\n${optionEntries.map((entry) => ` ${entry},`).join("\n")}\n }`;
87
90
  const inlineRouteOpen = `export const Route = createFileRoute("${route.routeLiteral}")({`;
88
91
  const routeOpen = inlineRouteOpen.length <= OXFMT_PRINT_WIDTH ? inlineRouteOpen : `export const Route = createFileRoute(\n "${route.routeLiteral}",\n)({`;
@@ -189,6 +192,7 @@ function mcpPlugin(options = {}) {
189
192
  const metadataUrlPath = canonicalUrlPath(options.metadataPath ?? "/.well-known/oauth-protected-resource");
190
193
  const injectedMetadataPath = emitProtectedResourceMetadataRoute ? metadataUrlPath : void 0;
191
194
  const trustForwardedHost = options.trustForwardedHost !== false;
195
+ const trustForwardedProto = options.trustForwardedProto !== false;
192
196
  let projectRoot = process.cwd();
193
197
  let mcpEntry = resolve(projectRoot, mcpEntryOption);
194
198
  let { routesDir, mcpRouteFile, metadataRouteFile, listToolsRouteFile, invokeToolRouteFile, listToolsLiteral, invokeToolLiteral } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, urlPath, metadataUrlPath);
@@ -226,7 +230,7 @@ function mcpPlugin(options = {}) {
226
230
  });
227
231
  for (const route of routes) {
228
232
  expected.add(route.file);
229
- writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, mcpEntry, projectRoot));
233
+ writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
230
234
  }
231
235
  }
232
236
  for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {