@lovable.dev/mcp-js 0.28.0 → 0.29.0-rc.1

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-C8osWdMU.d.cts} +3 -0
  5. package/dist/{base-CUkmyaXJ.d.ts → base-C8osWdMU.d.ts} +3 -0
  6. package/dist/cli/extract-manifest.cjs +2 -2
  7. package/dist/cli/extract-manifest.js +2 -2
  8. package/dist/{authorize--rUeMOGU.js → cors-BDTQQJE2.js} +68 -24
  9. package/dist/{authorize-ChY44o_1.cjs → cors-BRv5KXKQ.cjs} +73 -29
  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-CAJSRt_t.cjs} +6 -4
  13. package/dist/{gate-BiM6EBeA.js → gate-uCVrbDBb.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-SMlD5WeX.d.ts → io-BYUyNFdn.d.ts} +1 -1
  19. package/dist/{io-VBHO8YH_.d.cts → io-B_YLNWDL.d.cts} +1 -1
  20. package/dist/{list-tools-BLGr7mot.js → list-tools-C1OiTDR9.js} +9 -13
  21. package/dist/{list-tools-BN97L2Yv.d.cts → list-tools-C3AoI2Zw.d.cts} +3 -3
  22. package/dist/list-tools-DES10avA.cjs +48 -0
  23. package/dist/{list-tools-BAqQVIHk.d.ts → list-tools-DXqSPvNY.d.ts} +3 -3
  24. package/dist/mcp-C9B7o75m.cjs +345 -0
  25. package/dist/mcp-HDkUr85V.js +340 -0
  26. package/dist/{package-DgiA0xuY.js → package-BI5r4uGM.js} +1 -1
  27. package/dist/{package-CGLPZwz-.cjs → package-ClCIqol1.cjs} +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-BE05MUNS.cjs → rest-BBdfHMGh.cjs} +28 -27
  41. package/dist/{rest-BS7bBOd9.js → rest-Cr7NhxL3.js} +13 -12
  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 +7 -1
  58. package/dist/stacks/tanstack/vite.d.ts +7 -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
  import { i as ToolContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-DSe96Ffd.js";
2
- import { f as methodNotAllowed, l as nowMs, n as createRequestAuthorizer, t as assertRestResourceBinding, u as JSON_HEADERS } from "./authorize--rUeMOGU.js";
3
- import { t as extractTextContent } from "./content-D5LJAHyM.js";
4
- import { t as createGatedHandler } from "./gate-BiM6EBeA.js";
5
- import "./list-tools-BLGr7mot.js";
2
+ import { d as JSON_HEADERS, n as assertRestResourceBinding, p as methodNotAllowed, r as createRequestAuthorizer, u as nowMs } from "./cors-BDTQQJE2.js";
3
+ import { n as extractTextContent, t as finalizeToolResult } from "./tool-result-DfCk445b.js";
4
+ import { t as createGatedHandler } from "./gate-uCVrbDBb.js";
5
+ import "./list-tools-C1OiTDR9.js";
6
6
  import { getParseErrorMessage, objectFromShape, safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
7
7
  //#region src/protocols/rest/invoke-tool.ts
8
8
  const MAX_REFLECTED_TOOL_NAME = 256;
@@ -71,7 +71,8 @@ function createInvokeToolHandler(mcp, options = {}) {
71
71
  outcome: "handler_error",
72
72
  durationMs: nowMs() - start,
73
73
  errorText: errorSummary(err),
74
- endUserId
74
+ endUserId,
75
+ protocol: "rest"
75
76
  });
76
77
  return new Response(JSON.stringify({
77
78
  error: "handler threw",
@@ -95,29 +96,29 @@ function createInvokeToolHandler(mcp, options = {}) {
95
96
  method: "tools/call",
96
97
  outcome: "handler_error",
97
98
  durationMs: nowMs() - start,
98
- endUserId
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
104
  headers: JSON_HEADERS
103
105
  });
104
106
  }
107
+ result = await 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
112
  durationMs: nowMs() - start,
110
113
  errorText: result.isError ? extractTextContent(result.content) : void 0,
111
- endUserId
112
- });
113
- return Response.json({
114
- content: result.content ?? [],
115
- structuredContent: result.structuredContent,
116
- isError: result.isError
114
+ endUserId,
115
+ protocol: "rest"
117
116
  });
117
+ return Response.json(result);
118
118
  };
119
119
  const gated = createGatedHandler({
120
120
  authorizer: createRequestAuthorizer(mcp, options),
121
+ allowedOrigins: mcp.allowedOrigins,
121
122
  methods: ["POST"],
122
123
  methodNotAllowed,
123
124
  handle
@@ -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-BRv5KXKQ.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-C9B7o75m.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-DES10avA.cjs");
8
+ const require_rest = require("../../rest-BBdfHMGh.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-BDTQQJE2.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-HDkUr85V.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-C1OiTDR9.js";
7
+ import { t as createInvokeToolHandler } from "../../rest-Cr7NhxL3.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-ClCIqol1.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-B_YLNWDL.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-BYUyNFdn.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-BI5r4uGM.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-BRv5KXKQ.cjs");
3
+ const require_mcp = require("../../mcp-C9B7o75m.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-DES10avA.cjs");
6
+ const require_rest = require("../../rest-BBdfHMGh.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-BDTQQJE2.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-HDkUr85V.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-C1OiTDR9.js";
5
+ import { t as createInvokeToolHandler } from "../../rest-Cr7NhxL3.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-B_YLNWDL.cjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -77,6 +77,12 @@ interface McpPluginOptions {
77
77
  * @default true
78
78
  */
79
79
  trustForwardedHost?: boolean;
80
+ /**
81
+ * Derive the public scheme for same-origin checks and advertised OAuth URLs
82
+ * from `X-Forwarded-Proto`. Safe only behind an overwriting proxy.
83
+ * @default true
84
+ */
85
+ trustForwardedProto?: boolean;
80
86
  }
81
87
  declare function assertUrlPathShape(urlPath: string): string;
82
88
  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-BYUyNFdn.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -77,6 +77,12 @@ interface McpPluginOptions {
77
77
  * @default true
78
78
  */
79
79
  trustForwardedHost?: boolean;
80
+ /**
81
+ * Derive the public scheme for same-origin checks and advertised OAuth URLs
82
+ * from `X-Forwarded-Proto`. Safe only behind an overwriting proxy.
83
+ * @default true
84
+ */
85
+ trustForwardedProto?: boolean;
80
86
  }
81
87
  declare function assertUrlPathShape(urlPath: string): string;
82
88
  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 {
@@ -0,0 +1,89 @@
1
+ const require_schema = require("./schema-D3vClxb7.cjs");
2
+ let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
3
+ //#region src/core/content.ts
4
+ /** Join the text of a result's `type: "text"` blocks into one string, dropping
5
+ * binary/resource blocks. Used to surface a `tool_error` message in the local
6
+ * log; never sent over the telemetry wire. Returns undefined when there is no
7
+ * text to show. */
8
+ function extractTextContent(content) {
9
+ if (!content) return void 0;
10
+ const text = content.filter((block) => block.type === "text").map((block) => block.text).join("\n").trim();
11
+ return text.length > 0 ? text : void 0;
12
+ }
13
+ //#endregion
14
+ //#region src/core/tool-result.ts
15
+ function normalizeResourceLinkIcon(icon) {
16
+ if (typeof icon.sizes !== "string") return icon;
17
+ const { sizes, ...rest } = icon;
18
+ const normalized = sizes.trim();
19
+ return normalized === "" ? rest : {
20
+ ...rest,
21
+ sizes: normalized.split(/\s+/)
22
+ };
23
+ }
24
+ function normalizeToolContent(content) {
25
+ return (content ?? []).map((block) => {
26
+ if (block.type !== "resource_link" || block.icons === void 0) return block;
27
+ return {
28
+ ...block,
29
+ icons: block.icons.map(normalizeResourceLinkIcon)
30
+ };
31
+ });
32
+ }
33
+ function outputValidationError(text) {
34
+ return {
35
+ content: [{
36
+ type: "text",
37
+ text
38
+ }],
39
+ isError: true
40
+ };
41
+ }
42
+ function isJsonValue(value, ancestors = /* @__PURE__ */ new Set()) {
43
+ if (value === null || typeof value === "boolean" || typeof value === "string") return true;
44
+ if (typeof value === "number") return Number.isFinite(value);
45
+ if (typeof value !== "object" || ancestors.has(value)) return false;
46
+ const prototype = Object.getPrototypeOf(value);
47
+ if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return false;
48
+ ancestors.add(value);
49
+ const valid = Object.values(value).every((entry) => isJsonValue(entry, ancestors));
50
+ ancestors.delete(value);
51
+ return valid;
52
+ }
53
+ async function finalizeToolResult(tool, result) {
54
+ const content = normalizeToolContent(result.content);
55
+ let structuredContent = result.structuredContent;
56
+ if (tool.outputSchema && !result.isError) {
57
+ if (structuredContent === void 0) return outputValidationError(`Output validation error: Tool ${tool.name} has an output schema but no structured content was provided`);
58
+ try {
59
+ const parsed = await (0, _modelcontextprotocol_sdk_server_zod_compat_js.safeParseAsync)(require_schema.schemaFromDefinition(tool.outputSchema), structuredContent);
60
+ if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${(0, _modelcontextprotocol_sdk_server_zod_compat_js.getParseErrorMessage)(parsed.error)}`);
61
+ structuredContent = parsed.data;
62
+ } catch {
63
+ return outputValidationError(`Output validation error: Could not validate structured content for tool ${tool.name}`);
64
+ }
65
+ }
66
+ if (structuredContent !== void 0 && !isJsonValue(structuredContent)) return outputValidationError(`Output validation error: Tool ${tool.name} returned a non-JSON structured value`);
67
+ if (structuredContent !== void 0 && (structuredContent === null || typeof structuredContent !== "object" || Array.isArray(structuredContent)) && !content.some((block) => block.type === "text")) content.push({
68
+ type: "text",
69
+ text: JSON.stringify(structuredContent)
70
+ });
71
+ return {
72
+ content,
73
+ structuredContent,
74
+ isError: result.isError
75
+ };
76
+ }
77
+ //#endregion
78
+ Object.defineProperty(exports, "extractTextContent", {
79
+ enumerable: true,
80
+ get: function() {
81
+ return extractTextContent;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "finalizeToolResult", {
85
+ enumerable: true,
86
+ get: function() {
87
+ return finalizeToolResult;
88
+ }
89
+ });