@lovable.dev/mcp-js 2.2.0-rc.0 → 2.2.1-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.
package/README.md CHANGED
@@ -410,7 +410,9 @@ import { mcpPlugin } from "@lovable.dev/mcp-js/stacks/supabase/vite";
410
410
  export default defineConfig({ plugins: [mcpPlugin()] });
411
411
  ```
412
412
 
413
- The plugin bundles `src/lib/mcp/index.ts` (and the tool files it imports) into `supabase/functions/mcp/index.ts` on `configResolved`, re-emits on `buildStart`, and watches the bundled source files for changes during `vite dev`. The emitted function calls `Deno.serve(createSupabaseHandler(mcp, { functionName: "mcp" }))`. The handler is one Web-Standard `Request → Response` that dispatches by URL suffix to the same protocol handlers the TanStack stack uses:
413
+ The plugin bundles `src/lib/mcp/index.ts` (and the tool files it imports) into `supabase/functions/mcp/index.ts` on `configResolved`, re-emits on `buildStart`, and watches the bundled source files for changes during `vite dev`. The bundle supports TypeScript, JavaScript, and JSON project imports plus Vite aliases and npm dependencies. It rejects frontend image imports (`.avif`, `.gif`, `.jpg`, `.jpeg`, `.png`, `.svg`, `.webp`, including query suffixes) with the local import chain. Supabase MCP tools should read assets from runtime storage or use external URLs instead; the emitter does not turn images into data URLs or add URL loaders.
414
+
415
+ The emitted function calls `Deno.serve(createSupabaseHandler(mcp, { functionName: "mcp" }))`. The handler is one Web-Standard `Request → Response` that dispatches by URL suffix to the same protocol handlers the TanStack stack uses:
414
416
 
415
417
  | URL suffix | Target |
416
418
  | --- | --- |
@@ -4,7 +4,7 @@ const projectRoot = process.argv[2] ?? process.cwd();
4
4
  import("zod/v3").catch((err) => {
5
5
  const message = err instanceof Error ? err.message : String(err);
6
6
  throw new Error(`@lovable.dev/mcp-js requires zod ^3.25 or ^4.0 to extract MCP schemas. Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
7
- }).then(() => Promise.resolve().then(() => require("../io-DaqblVaG.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
7
+ }).then(() => Promise.resolve().then(() => require("../io-B5YhIOox.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
8
8
  console.error(err instanceof Error ? err.message : String(err));
9
9
  process.exit(1);
10
10
  });
@@ -4,7 +4,7 @@ const projectRoot = process.argv[2] ?? process.cwd();
4
4
  import("zod/v3").catch((err) => {
5
5
  const message = err instanceof Error ? err.message : String(err);
6
6
  throw new Error(`@lovable.dev/mcp-js requires zod ^3.25 or ^4.0 to extract MCP schemas. Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
7
- }).then(() => import("../io-DD8wjGjd.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
7
+ }).then(() => import("../io-vSrrd3JY.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
8
8
  console.error(err instanceof Error ? err.message : String(err));
9
9
  process.exit(1);
10
10
  });
@@ -1,5 +1,5 @@
1
1
  import { i as log, n as applyLogLevelFromEnv, o as parseSafeUrl, r as describeError, s as trimTrailingSlash, t as LOG_LEVEL_ENV_VAR, u as resolveMetricsConfig } from "./logger-CpLgYbCG.js";
2
- import { t as version } from "./package-cPx-zYIb.js";
2
+ import { t as version } from "./package-CVKelx7_.js";
3
3
  import "./metadata-path-CAkNcfyY.js";
4
4
  import { createLocalJWKSet, decodeProtectedHeader, errors, jwtVerify } from "jose";
5
5
  //#region src/core/http.ts
@@ -1,5 +1,5 @@
1
1
  const require_logger = require("./logger-C-Hdu57K.cjs");
2
- const require_package = require("./package-hWM0Ru0w.cjs");
2
+ const require_package = require("./package-DScvhJWH.cjs");
3
3
  require("./metadata-path-zd7NSNoa.cjs");
4
4
  let jose = require("jose");
5
5
  //#region src/core/http.ts
@@ -1,5 +1,5 @@
1
1
  const require_schema = require("./schema-D3vClxb7.cjs");
2
- const require_package = require("./package-hWM0Ru0w.cjs");
2
+ const require_package = require("./package-DScvhJWH.cjs");
3
3
  const require_fs_errors = require("./fs-errors-CWNzOV75.cjs");
4
4
  let node_fs = require("node:fs");
5
5
  let node_path = require("node:path");
@@ -1,5 +1,5 @@
1
1
  import { t as jsonSchemaFromDefinition } from "./schema-CW1jKvio.js";
2
- import { t as version } from "./package-cPx-zYIb.js";
2
+ import { t as version } from "./package-CVKelx7_.js";
3
3
  import { t as isFileMissing } from "./fs-errors-PA2t1TIp.js";
4
4
  import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { dirname, resolve } from "node:path";
@@ -1,7 +1,7 @@
1
1
  const require_logger = require("./logger-C-Hdu57K.cjs");
2
2
  const require_schema = require("./schema-D3vClxb7.cjs");
3
3
  const require_errors = require("./errors-CpTdzogX.cjs");
4
- const require_cors = require("./cors-Dm9Yn8E5.cjs");
4
+ const require_cors = require("./cors-DZssEvoX.cjs");
5
5
  let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
6
6
  let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
7
7
  //#region src/core/content.ts
@@ -1,7 +1,7 @@
1
1
  import { i as log, r as describeError } from "./logger-CpLgYbCG.js";
2
2
  import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-CW1jKvio.js";
3
3
  import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-DGcJ8jPK.js";
4
- import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-BfacizN-.js";
4
+ import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-BJBsfjIx.js";
5
5
  import { getParseErrorMessage, safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
6
6
  import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, createMcpHandler } from "@modelcontextprotocol/server";
7
7
  //#region src/core/content.ts
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "2.2.0-rc.0";
2
+ var version = "2.2.1-rc.0";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2.2.0-rc.0";
2
+ var version = "2.2.1-rc.0";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mcp = require("../../mcp-BGsPYWs1.cjs");
2
+ const require_mcp = require("../../mcp-CGRqYHDG.cjs");
3
3
  exports.createMcpProtocolHandler = require_mcp.createMcpProtocolHandler;
@@ -1,2 +1,2 @@
1
- import { t as createMcpProtocolHandler } from "../../mcp-DdJJjYYZ.js";
1
+ import { t as createMcpProtocolHandler } from "../../mcp-D865ferJ.js";
2
2
  export { createMcpProtocolHandler };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_logger = require("../logger-C-Hdu57K.cjs");
3
- const require_cors = require("../cors-Dm9Yn8E5.cjs");
3
+ const require_cors = require("../cors-DZssEvoX.cjs");
4
4
  //#region src/protocols/oauth-metadata.ts
5
5
  function notFound() {
6
6
  return new Response(JSON.stringify({ error: "not found" }), {
@@ -1,5 +1,5 @@
1
1
  import { i as log, r as describeError } from "../logger-CpLgYbCG.js";
2
- import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-BfacizN-.js";
2
+ import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-BJBsfjIx.js";
3
3
  //#region src/protocols/oauth-metadata.ts
4
4
  function notFound() {
5
5
  return new Response(JSON.stringify({ error: "not found" }), {
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_logger = require("../../logger-C-Hdu57K.cjs");
3
- const require_cors = require("../../cors-Dm9Yn8E5.cjs");
3
+ const require_cors = require("../../cors-DZssEvoX.cjs");
4
4
  const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
5
- const require_mcp = require("../../mcp-BGsPYWs1.cjs");
5
+ const require_mcp = require("../../mcp-CGRqYHDG.cjs");
6
6
  const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
7
7
  const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
8
8
  const require_paths = require("../../paths-OP318a6c.cjs");
@@ -1,7 +1,7 @@
1
1
  import { s as trimTrailingSlash } from "../../logger-CpLgYbCG.js";
2
- import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-BfacizN-.js";
2
+ import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-BJBsfjIx.js";
3
3
  import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
4
- import { t as createMcpProtocolHandler } from "../../mcp-DdJJjYYZ.js";
4
+ import { t as createMcpProtocolHandler } from "../../mcp-D865ferJ.js";
5
5
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
6
6
  import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
7
7
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
@@ -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-hWM0Ru0w.cjs");
5
+ const require_package = require("../../package-DScvhJWH.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");
@@ -78,6 +78,7 @@ function externalizeBareAsNpm(versions) {
78
78
  path: p,
79
79
  external: true
80
80
  };
81
+ if (p === "@" || p.startsWith("@/")) throw new Error(`@lovable.dev/mcp-js: unresolved project alias ${JSON.stringify(p)} while emitting Supabase MCP`);
81
82
  return {
82
83
  path: npmSpecifierFor(p, versions),
83
84
  external: true
@@ -86,6 +87,35 @@ function externalizeBareAsNpm(versions) {
86
87
  }
87
88
  };
88
89
  }
90
+ const FRONTEND_IMAGE_RE = /\.(?:avif|gif|jpe?g|png|svg|webp)(?:[?#].*)?$/i;
91
+ function rejectFrontendImages(projectRoot) {
92
+ const displayRoot = (0, node_fs.realpathSync)(projectRoot);
93
+ const parentByInput = /* @__PURE__ */ new Map();
94
+ return {
95
+ name: "lovable-mcp-reject-frontend-images",
96
+ setup(pluginBuild) {
97
+ pluginBuild.onResolve({ filter: /.*/ }, async (args) => {
98
+ if (args.pluginData?.assetGraphResolved) return null;
99
+ if (!args.importer || /^(npm|node|jsr|https?|data):/.test(args.path)) return null;
100
+ const resolved = await pluginBuild.resolve(args.path.replace(/[?#].*$/, ""), {
101
+ kind: args.kind,
102
+ importer: args.importer,
103
+ resolveDir: args.resolveDir,
104
+ pluginData: { assetGraphResolved: true }
105
+ });
106
+ if (resolved.errors.length > 0 || resolved.external) return null;
107
+ const importer = (0, node_path.resolve)(args.importer);
108
+ const input = (0, node_path.resolve)(resolved.path);
109
+ if (!parentByInput.has(input)) parentByInput.set(input, importer);
110
+ if (!FRONTEND_IMAGE_RE.test(args.path)) return null;
111
+ const chain = [input];
112
+ for (let current = importer; current && !chain.includes(current); current = parentByInput.get(current) ?? "") chain.unshift(current);
113
+ const display = chain.filter((path) => !path.endsWith("lovable-mcp-supabase-entry.ts")).map((path) => (0, node_path.relative)(displayRoot, path).split(node_path.sep).join("/")).join(" → ");
114
+ throw new Error(`@lovable.dev/mcp-js: Supabase MCP tools cannot import frontend image assets. Import chain: ${display}. Move the asset lookup to runtime storage or return an external URL instead.`);
115
+ });
116
+ }
117
+ };
118
+ }
89
119
  function applyViteAliases(importee, aliases) {
90
120
  for (const { find, replacement } of aliases) if (find instanceof RegExp) {
91
121
  if (find.test(importee)) return importee.replace(find, replacement);
@@ -134,7 +164,11 @@ async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName, inlin
134
164
  absWorkingDir: projectRoot,
135
165
  logLevel: "silent",
136
166
  define: importMetaEnvDefines(inlineEnv),
137
- plugins: [...aliases.length > 0 ? [resolveViteAliases(aliases)] : [], externalizeBareAsNpm(versions)]
167
+ plugins: [
168
+ ...aliases.length > 0 ? [resolveViteAliases(aliases)] : [],
169
+ rejectFrontendImages(projectRoot),
170
+ externalizeBareAsNpm(versions)
171
+ ]
138
172
  });
139
173
  const out = result.outputFiles[0]?.text ?? "";
140
174
  const inputs = Object.keys(result.metafile?.inputs ?? {}).filter((p) => !p.startsWith("<") && !p.startsWith("npm:")).map((p) => (0, node_path.resolve)(projectRoot, p));
@@ -1,8 +1,8 @@
1
- import { t as version } from "../../package-cPx-zYIb.js";
1
+ import { t as version } from "../../package-CVKelx7_.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";
5
- import { lstatSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
5
+ import { lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join, relative, resolve, sep } from "node:path";
7
7
  import { loadEnv } from "vite";
8
8
  import { build } from "esbuild";
@@ -74,6 +74,7 @@ function externalizeBareAsNpm(versions) {
74
74
  path: p,
75
75
  external: true
76
76
  };
77
+ if (p === "@" || p.startsWith("@/")) throw new Error(`@lovable.dev/mcp-js: unresolved project alias ${JSON.stringify(p)} while emitting Supabase MCP`);
77
78
  return {
78
79
  path: npmSpecifierFor(p, versions),
79
80
  external: true
@@ -82,6 +83,35 @@ function externalizeBareAsNpm(versions) {
82
83
  }
83
84
  };
84
85
  }
86
+ const FRONTEND_IMAGE_RE = /\.(?:avif|gif|jpe?g|png|svg|webp)(?:[?#].*)?$/i;
87
+ function rejectFrontendImages(projectRoot) {
88
+ const displayRoot = realpathSync(projectRoot);
89
+ const parentByInput = /* @__PURE__ */ new Map();
90
+ return {
91
+ name: "lovable-mcp-reject-frontend-images",
92
+ setup(pluginBuild) {
93
+ pluginBuild.onResolve({ filter: /.*/ }, async (args) => {
94
+ if (args.pluginData?.assetGraphResolved) return null;
95
+ if (!args.importer || /^(npm|node|jsr|https?|data):/.test(args.path)) return null;
96
+ const resolved = await pluginBuild.resolve(args.path.replace(/[?#].*$/, ""), {
97
+ kind: args.kind,
98
+ importer: args.importer,
99
+ resolveDir: args.resolveDir,
100
+ pluginData: { assetGraphResolved: true }
101
+ });
102
+ if (resolved.errors.length > 0 || resolved.external) return null;
103
+ const importer = resolve(args.importer);
104
+ const input = resolve(resolved.path);
105
+ if (!parentByInput.has(input)) parentByInput.set(input, importer);
106
+ if (!FRONTEND_IMAGE_RE.test(args.path)) return null;
107
+ const chain = [input];
108
+ for (let current = importer; current && !chain.includes(current); current = parentByInput.get(current) ?? "") chain.unshift(current);
109
+ const display = chain.filter((path) => !path.endsWith("lovable-mcp-supabase-entry.ts")).map((path) => relative(displayRoot, path).split(sep).join("/")).join(" → ");
110
+ throw new Error(`@lovable.dev/mcp-js: Supabase MCP tools cannot import frontend image assets. Import chain: ${display}. Move the asset lookup to runtime storage or return an external URL instead.`);
111
+ });
112
+ }
113
+ };
114
+ }
85
115
  function applyViteAliases(importee, aliases) {
86
116
  for (const { find, replacement } of aliases) if (find instanceof RegExp) {
87
117
  if (find.test(importee)) return importee.replace(find, replacement);
@@ -130,7 +160,11 @@ async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName, inlin
130
160
  absWorkingDir: projectRoot,
131
161
  logLevel: "silent",
132
162
  define: importMetaEnvDefines(inlineEnv),
133
- plugins: [...aliases.length > 0 ? [resolveViteAliases(aliases)] : [], externalizeBareAsNpm(versions)]
163
+ plugins: [
164
+ ...aliases.length > 0 ? [resolveViteAliases(aliases)] : [],
165
+ rejectFrontendImages(projectRoot),
166
+ externalizeBareAsNpm(versions)
167
+ ]
134
168
  });
135
169
  const out = result.outputFiles[0]?.text ?? "";
136
170
  const inputs = Object.keys(result.metafile?.inputs ?? {}).filter((p) => !p.startsWith("<") && !p.startsWith("npm:")).map((p) => resolve(projectRoot, p));
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cors = require("../../cors-Dm9Yn8E5.cjs");
3
- const require_mcp = require("../../mcp-BGsPYWs1.cjs");
2
+ const require_cors = require("../../cors-DZssEvoX.cjs");
3
+ const require_mcp = require("../../mcp-CGRqYHDG.cjs");
4
4
  const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
5
5
  const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
6
6
  //#region src/stacks/tanstack/handlers.ts
@@ -1,5 +1,5 @@
1
- import { c as createRecorderForRuntime } from "../../cors-BfacizN-.js";
2
- import { t as createMcpProtocolHandler } from "../../mcp-DdJJjYYZ.js";
1
+ import { c as createRecorderForRuntime } from "../../cors-BJBsfjIx.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-D865ferJ.js";
3
3
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
4
4
  import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
5
5
  //#region src/stacks/tanstack/handlers.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/mcp-js",
3
- "version": "2.2.0-rc.0",
3
+ "version": "2.2.1-rc.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },