@lovable.dev/mcp-js 3.0.4 → 3.0.6

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 (34) hide show
  1. package/README.md +4 -0
  2. package/dist/{base-Bohn3qri.d.ts → base-B7D0KqaY.d.ts} +1 -1
  3. package/dist/{base-CZiROmNS.d.cts → base-D3TT1Wup.d.cts} +1 -1
  4. package/dist/cli/extract-manifest.cjs +1 -1
  5. package/dist/cli/extract-manifest.js +1 -1
  6. package/dist/{cors-ZvCUb2VJ.js → cors-C3JU5DNM.js} +13 -1
  7. package/dist/{cors-DLtOeUWZ.cjs → cors-dZ1AWhSq.cjs} +13 -1
  8. package/dist/{io-B6bo6fCM.cjs → io-DV_Bkma8.cjs} +16 -5
  9. package/dist/{io-DjizMl4m.js → io-x7rcGbQj.js} +13 -2
  10. package/dist/{mcp-Cjp6b4hW.cjs → mcp-WUiGYfjS.cjs} +1 -1
  11. package/dist/{mcp-CF4Jk7ox.js → mcp-woEauhMi.js} +1 -1
  12. package/dist/{package-B_Yt2-fx.cjs → package-CoGnWS6Y.cjs} +1 -1
  13. package/dist/{package-Ki9PQjkY.js → package-DIh9b_dF.js} +1 -1
  14. package/dist/protocols/mcp/index.cjs +1 -1
  15. package/dist/protocols/mcp/index.d.cts +1 -1
  16. package/dist/protocols/mcp/index.d.ts +1 -1
  17. package/dist/protocols/mcp/index.js +1 -1
  18. package/dist/protocols/oauth-metadata.cjs +1 -1
  19. package/dist/protocols/oauth-metadata.d.cts +1 -1
  20. package/dist/protocols/oauth-metadata.d.ts +1 -1
  21. package/dist/protocols/oauth-metadata.js +1 -1
  22. package/dist/stacks/supabase/index.cjs +2 -2
  23. package/dist/stacks/supabase/index.js +2 -2
  24. package/dist/stacks/supabase/vite.cjs +7 -8
  25. package/dist/stacks/supabase/vite.js +2 -3
  26. package/dist/stacks/tanstack/index.cjs +2 -2
  27. package/dist/stacks/tanstack/index.js +2 -2
  28. package/dist/stacks/tanstack/vite.cjs +7 -8
  29. package/dist/stacks/tanstack/vite.js +1 -2
  30. package/dist/{supabase-config-CakTU8YF.js → supabase-config-DITfH_bn.js} +6 -2
  31. package/dist/{supabase-config-Dz7dnUv0.cjs → supabase-config-Dz13d9ze.cjs} +12 -2
  32. package/package.json +1 -1
  33. package/dist/fs-errors-CWNzOV75.cjs +0 -11
  34. package/dist/fs-errors-PA2t1TIp.js +0 -6
package/README.md CHANGED
@@ -358,6 +358,10 @@ A `500` on an OAuth-protected route is always one of three causes, logged at `er
358
358
 
359
359
  Each MCP server records per-invocation telemetry — tool name, JSON-RPC method, outcome, latency, request and response sizes when available, and the verified token `sub` for authenticated calls — as **OTLP/HTTP JSON logs**, one awaited POST per record, bounded by a 3-second timeout; a failed or slow POST is logged (`metrics.failed`) and swallowed, never failing the request. Outcomes cover tool results (`ok`, `tool_error`, `handler_error`, `transport_error`), `app_context_error` for a request failed by a throwing `createAppContext` or `enabled`, the authorization gate — `auth_challenge` for an unauthenticated request answered with the `401` challenge (so probe traffic produces records), and the `auth_*` discovery/JWKS failure outcomes — and `origin_rejected` for a request refused `403` by the origin policy. Tool-call records also carry the protocol era (`mcp.protocol`: `2026-07-28` or `legacy`); records emitted before protocol classification (auth challenges, transport errors, origin rejections) have no protocol attribute. The bearer token, full claims, tool arguments, and response payloads are never captured. Emission is **on by default** and self-disables at runtime when `LOVABLE_API_KEY` is absent: records are dropped and one `metrics.disabled_no_api_key` warning is logged per process, so a local `vite dev` stays quiet. With `metrics: false` the recorder never runs — on Deno and Cloudflare Workers that also means `LOVABLE_MCP_LOG_LEVEL` is never applied (use `setLogLevel()` instead).
360
360
 
361
+ Starting in SDK 3.0.5, rejected bearer tokens also emit `auth_token_expired`, `auth_token_invalid`, or `auth_insufficient_scope`. Unexpected verifier failures emit `auth_unexpected_error`; they are not evidence of an expired or invalid token. Each rejection emits one `mcp.gate.rejection` record with `mcp.method=authorize`, no tool or end-user identity, and no claims or error text. Successful authorization adds no event; missing bearers remain `auth_challenge`. Rejected-token telemetry uses the runtime's background scheduler when available, otherwise delivery is awaited.
362
+
363
+ To query these failures, filter `method = 'authorize'` and the outcomes above; use `method = 'tools/call'` for invocation counts. Coverage depends on apps adopting SDK 3.0.5 or later, so older SDKs' missing events do not mean zero rejections. These events increase the warehouse's operational `event_count`, which already includes authorization faults. They do not increase `tool_call_count` or the active-app signals derived from executed calls.
364
+
361
365
  Configure it on the MCP definition:
362
366
 
363
367
  ```ts
@@ -1,6 +1,6 @@
1
1
  import { j as McpProtocolEra } from "./types-BX8RawmT.js";
2
2
  //#region src/metrics/impl/base.d.ts
3
- type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
3
+ type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "auth_token_expired" | "auth_token_invalid" | "auth_insufficient_scope" | "auth_unexpected_error" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
4
4
  /** One recorded MCP call. Carries no arguments or response payloads — only the
5
5
  * tool name, the JSON-RPC method, the result class, timing, and byte sizes.
6
6
  * `errorText` is the sole exception: it is logged locally for debugging and
@@ -1,6 +1,6 @@
1
1
  import { j as McpProtocolEra } from "./types-BX8RawmT.cjs";
2
2
  //#region src/metrics/impl/base.d.ts
3
- type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
3
+ type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "auth_token_expired" | "auth_token_invalid" | "auth_insufficient_scope" | "auth_unexpected_error" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
4
4
  /** One recorded MCP call. Carries no arguments or response payloads — only the
5
5
  * tool name, the JSON-RPC method, the result class, timing, and byte sizes.
6
6
  * `errorText` is the sole exception: it is logged locally for debugging and
@@ -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-B6bo6fCM.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
7
+ }).then(() => Promise.resolve().then(() => require("../io-DV_Bkma8.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-DjizMl4m.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
7
+ }).then(() => import("../io-x7rcGbQj.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-Ki9PQjkY.js";
2
+ import { t as version } from "./package-DIh9b_dF.js";
3
3
  import "./metadata-path-CAkNcfyY.js";
4
4
  import { createLocalJWKSet, decodeProtectedHeader, errors, jwtVerify } from "jose";
5
5
  //#region src/core/http.ts
@@ -847,6 +847,12 @@ function missingRequiredScopes(auth, scopes) {
847
847
  function assertRequiredScopes(auth, context) {
848
848
  if (missingRequiredScopes(auth, context.principal.scopes).length > 0) throw new OAuthTokenError(403, "insufficient_scope", "Additional OAuth scope is required");
849
849
  }
850
+ function tokenRejectionOutcome(err) {
851
+ if (err instanceof OAuthTokenError) return err.oauthError === "insufficient_scope" ? "auth_insufficient_scope" : "auth_token_invalid";
852
+ if (err instanceof errors.JWTExpired) return "auth_token_expired";
853
+ if (err instanceof errors.JWTClaimValidationFailed || err instanceof errors.JWTInvalid || err instanceof errors.JWSInvalid || err instanceof errors.JWSSignatureVerificationFailed || err instanceof errors.JOSEAlgNotAllowed || err instanceof errors.JWKSNoMatchingKey) return "auth_token_invalid";
854
+ return "auth_unexpected_error";
855
+ }
850
856
  function createRequestAuthorizer(mcp, options = {}) {
851
857
  const runtime = getOAuthRuntime(mcp, options);
852
858
  return { async authorize(request, recorder, scheduleBackground) {
@@ -913,6 +919,12 @@ function createRequestAuthorizer(mcp, options = {}) {
913
919
  response: oauthConfigurationErrorResponse()
914
920
  };
915
921
  }
922
+ if (recorder) await emitBeforeResponse(recorder, {
923
+ tool: null,
924
+ method: "authorize",
925
+ outcome: tokenRejectionOutcome(err),
926
+ durationMs: nowMs() - startedAt
927
+ }, scheduleBackground);
916
928
  if (err instanceof OAuthTokenError) {
917
929
  log.info("auth.token_rejected", {
918
930
  status: err.status,
@@ -1,5 +1,5 @@
1
1
  const require_logger = require("./logger-C-Hdu57K.cjs");
2
- const require_package = require("./package-B_Yt2-fx.cjs");
2
+ const require_package = require("./package-CoGnWS6Y.cjs");
3
3
  require("./metadata-path-zd7NSNoa.cjs");
4
4
  let jose = require("jose");
5
5
  //#region src/core/http.ts
@@ -847,6 +847,12 @@ function missingRequiredScopes(auth, scopes) {
847
847
  function assertRequiredScopes(auth, context) {
848
848
  if (missingRequiredScopes(auth, context.principal.scopes).length > 0) throw new OAuthTokenError(403, "insufficient_scope", "Additional OAuth scope is required");
849
849
  }
850
+ function tokenRejectionOutcome(err) {
851
+ if (err instanceof OAuthTokenError) return err.oauthError === "insufficient_scope" ? "auth_insufficient_scope" : "auth_token_invalid";
852
+ if (err instanceof jose.errors.JWTExpired) return "auth_token_expired";
853
+ if (err instanceof jose.errors.JWTClaimValidationFailed || err instanceof jose.errors.JWTInvalid || err instanceof jose.errors.JWSInvalid || err instanceof jose.errors.JWSSignatureVerificationFailed || err instanceof jose.errors.JOSEAlgNotAllowed || err instanceof jose.errors.JWKSNoMatchingKey) return "auth_token_invalid";
854
+ return "auth_unexpected_error";
855
+ }
850
856
  function createRequestAuthorizer(mcp, options = {}) {
851
857
  const runtime = getOAuthRuntime(mcp, options);
852
858
  return { async authorize(request, recorder, scheduleBackground) {
@@ -913,6 +919,12 @@ function createRequestAuthorizer(mcp, options = {}) {
913
919
  response: oauthConfigurationErrorResponse()
914
920
  };
915
921
  }
922
+ if (recorder) await emitBeforeResponse(recorder, {
923
+ tool: null,
924
+ method: "authorize",
925
+ outcome: tokenRejectionOutcome(err),
926
+ durationMs: nowMs() - startedAt
927
+ }, scheduleBackground);
916
928
  if (err instanceof OAuthTokenError) {
917
929
  require_logger.log.info("auth.token_rejected", {
918
930
  status: err.status,
@@ -1,6 +1,6 @@
1
1
  const require_schema = require("./schema-DNMsvJwE.cjs");
2
- const require_package = require("./package-B_Yt2-fx.cjs");
3
- const require_fs_errors = require("./fs-errors-CWNzOV75.cjs");
2
+ const require_package = require("./package-CoGnWS6Y.cjs");
3
+ const require_supabase_config = require("./supabase-config-Dz13d9ze.cjs");
4
4
  let node_fs = require("node:fs");
5
5
  let node_path = require("node:path");
6
6
  let vite = require("vite");
@@ -59,9 +59,16 @@ function isAuthShape(auth) {
59
59
  const a = auth;
60
60
  return a.type === "oauth" && typeof a.issuer === "string" && a.issuer.length > 0;
61
61
  }
62
+ function hasBlankIssuerHost(issuer) {
63
+ if (!URL.canParse(issuer)) return false;
64
+ const { hostname } = new URL(issuer);
65
+ return hostname === "" || hostname.startsWith(".");
66
+ }
62
67
  function manifestFromDefinition(definition, urlPath, source = "the MCP entry") {
63
68
  const def = definition;
64
69
  if (!(!!def && typeof def === "object" && typeof def.name === "string" && typeof def.title === "string" && typeof def.version === "string" && Array.isArray(def.tools) && def.tools.every(isToolShape) && isAuthShape(def.auth))) throw new Error(`@lovable.dev/mcp-js: ${source} must \`export default defineMcp(...)\` (got ${definition == null ? "no default export" : typeof definition}).`);
70
+ const issuer = def.auth?.issuer;
71
+ if (issuer !== void 0 && hasBlankIssuerHost(issuer)) throw new Error(`@lovable.dev/mcp-js: ${source} resolves its OAuth issuer to "${issuer}", which has no project host. Set VITE_SUPABASE_PROJECT_ID or the top-level project_id in supabase/config.toml, then extract the manifest again.`);
65
72
  return {
66
73
  version: 1,
67
74
  sdk_version: require_package.version,
@@ -95,6 +102,7 @@ async function produceViaSsr(projectRoot, alias, ssr, entryAbs, urlPath) {
95
102
  //#endregion
96
103
  //#region src/manifest/io.ts
97
104
  const MAX_MANIFEST_TOOLS = 512;
105
+ const SUPABASE_PROJECT_REF_ENV = "VITE_SUPABASE_PROJECT_ID";
98
106
  const MCP_PLUGIN_NAME_PREFIX = "@lovable.dev/mcp-js";
99
107
  const DEFAULT_MCP_ENTRY = "src/lib/mcp/index.ts";
100
108
  const DEFAULT_MCP_PATH = "/mcp";
@@ -104,7 +112,7 @@ function writeManifestIfChanged(file, manifest) {
104
112
  try {
105
113
  existing = (0, node_fs.readFileSync)(file, "utf8");
106
114
  } catch (err) {
107
- if (!require_fs_errors.isFileMissing(err)) throw err;
115
+ if (!require_supabase_config.isFileMissing(err)) throw err;
108
116
  }
109
117
  if (existing === content) return;
110
118
  (0, node_fs.mkdirSync)((0, node_path.dirname)(file), { recursive: true });
@@ -123,7 +131,7 @@ function removeManifest(file) {
123
131
  try {
124
132
  (0, node_fs.unlinkSync)(file);
125
133
  } catch (err) {
126
- if (!require_fs_errors.isFileMissing(err)) throw err;
134
+ if (!require_supabase_config.isFileMissing(err)) throw err;
127
135
  }
128
136
  }
129
137
  async function syncManifest(manifestFile, entryAbs, urlPath, produce) {
@@ -131,7 +139,7 @@ async function syncManifest(manifestFile, entryAbs, urlPath, produce) {
131
139
  try {
132
140
  (0, node_fs.lstatSync)(entryAbs);
133
141
  } catch (err) {
134
- if (!require_fs_errors.isFileMissing(err)) throw err;
142
+ if (!require_supabase_config.isFileMissing(err)) throw err;
135
143
  entryExists = false;
136
144
  }
137
145
  if (!entryExists) {
@@ -143,10 +151,13 @@ async function syncManifest(manifestFile, entryAbs, urlPath, produce) {
143
151
  if (manifest.mcp.tools.length > MAX_MANIFEST_TOOLS) throw new Error(`@lovable.dev/mcp-js: ${entryAbs} declares ${manifest.mcp.tools.length} tools, exceeding the App MCP manifest limit of ${MAX_MANIFEST_TOOLS}. Reduce defineMcp({ tools }) to ${MAX_MANIFEST_TOOLS} tools or fewer and extract the manifest again.`);
144
152
  }
145
153
  async function runExtract(projectRoot) {
154
+ if (process.env[SUPABASE_PROJECT_REF_ENV] === "") delete process.env[SUPABASE_PROJECT_REF_ENV];
146
155
  const resolved = await (0, vite.resolveConfig)({
147
156
  root: projectRoot,
148
157
  logLevel: "silent"
149
158
  }, "serve");
159
+ const ref = resolved.env[SUPABASE_PROJECT_REF_ENV] || require_supabase_config.readSupabaseProjectRef(projectRoot);
160
+ if (ref) process.env[SUPABASE_PROJECT_REF_ENV] = ref;
150
161
  const alias = resolved.resolve?.alias ?? [];
151
162
  const ssr = {
152
163
  external: resolved.ssr.external,
@@ -1,6 +1,6 @@
1
1
  import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
2
- import { t as version } from "./package-Ki9PQjkY.js";
3
- import { t as isFileMissing } from "./fs-errors-PA2t1TIp.js";
2
+ import { t as version } from "./package-DIh9b_dF.js";
3
+ import { n as isFileMissing, t as readSupabaseProjectRef } from "./supabase-config-DITfH_bn.js";
4
4
  import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { dirname, resolve } from "node:path";
6
6
  import { createServer, resolveConfig } from "vite";
@@ -59,9 +59,16 @@ function isAuthShape(auth) {
59
59
  const a = auth;
60
60
  return a.type === "oauth" && typeof a.issuer === "string" && a.issuer.length > 0;
61
61
  }
62
+ function hasBlankIssuerHost(issuer) {
63
+ if (!URL.canParse(issuer)) return false;
64
+ const { hostname } = new URL(issuer);
65
+ return hostname === "" || hostname.startsWith(".");
66
+ }
62
67
  function manifestFromDefinition(definition, urlPath, source = "the MCP entry") {
63
68
  const def = definition;
64
69
  if (!(!!def && typeof def === "object" && typeof def.name === "string" && typeof def.title === "string" && typeof def.version === "string" && Array.isArray(def.tools) && def.tools.every(isToolShape) && isAuthShape(def.auth))) throw new Error(`@lovable.dev/mcp-js: ${source} must \`export default defineMcp(...)\` (got ${definition == null ? "no default export" : typeof definition}).`);
70
+ const issuer = def.auth?.issuer;
71
+ if (issuer !== void 0 && hasBlankIssuerHost(issuer)) throw new Error(`@lovable.dev/mcp-js: ${source} resolves its OAuth issuer to "${issuer}", which has no project host. Set VITE_SUPABASE_PROJECT_ID or the top-level project_id in supabase/config.toml, then extract the manifest again.`);
65
72
  return {
66
73
  version: 1,
67
74
  sdk_version: version,
@@ -95,6 +102,7 @@ async function produceViaSsr(projectRoot, alias, ssr, entryAbs, urlPath) {
95
102
  //#endregion
96
103
  //#region src/manifest/io.ts
97
104
  const MAX_MANIFEST_TOOLS = 512;
105
+ const SUPABASE_PROJECT_REF_ENV = "VITE_SUPABASE_PROJECT_ID";
98
106
  const MCP_PLUGIN_NAME_PREFIX = "@lovable.dev/mcp-js";
99
107
  const DEFAULT_MCP_ENTRY = "src/lib/mcp/index.ts";
100
108
  const DEFAULT_MCP_PATH = "/mcp";
@@ -143,10 +151,13 @@ async function syncManifest(manifestFile, entryAbs, urlPath, produce) {
143
151
  if (manifest.mcp.tools.length > MAX_MANIFEST_TOOLS) throw new Error(`@lovable.dev/mcp-js: ${entryAbs} declares ${manifest.mcp.tools.length} tools, exceeding the App MCP manifest limit of ${MAX_MANIFEST_TOOLS}. Reduce defineMcp({ tools }) to ${MAX_MANIFEST_TOOLS} tools or fewer and extract the manifest again.`);
144
152
  }
145
153
  async function runExtract(projectRoot) {
154
+ if (process.env[SUPABASE_PROJECT_REF_ENV] === "") delete process.env[SUPABASE_PROJECT_REF_ENV];
146
155
  const resolved = await resolveConfig({
147
156
  root: projectRoot,
148
157
  logLevel: "silent"
149
158
  }, "serve");
159
+ const ref = resolved.env[SUPABASE_PROJECT_REF_ENV] || readSupabaseProjectRef(projectRoot);
160
+ if (ref) process.env[SUPABASE_PROJECT_REF_ENV] = ref;
150
161
  const alias = resolved.resolve?.alias ?? [];
151
162
  const ssr = {
152
163
  external: resolved.ssr.external,
@@ -1,7 +1,7 @@
1
1
  const require_schema = require("./schema-DNMsvJwE.cjs");
2
2
  const require_logger = require("./logger-C-Hdu57K.cjs");
3
3
  const require_errors = require("./errors-CWxgUZH3.cjs");
4
- const require_cors = require("./cors-DLtOeUWZ.cjs");
4
+ const require_cors = require("./cors-dZ1AWhSq.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-JK_1KkOa.js";
3
3
  import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-ZmYYVYKN.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-ZvCUb2VJ.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-C3JU5DNM.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,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.0.4";
2
+ var version = "3.0.6";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "3.0.4";
2
+ var version = "3.0.6";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mcp = require("../../mcp-Cjp6b4hW.cjs");
2
+ const require_mcp = require("../../mcp-WUiGYfjS.cjs");
3
3
  exports.createMcpProtocolHandler = require_mcp.createMcpProtocolHandler;
@@ -1,5 +1,5 @@
1
1
  import { m as McpDefinition } from "../../types-BX8RawmT.cjs";
2
- import { t as MetricsRecorder } from "../../base-CZiROmNS.cjs";
2
+ import { t as MetricsRecorder } from "../../base-D3TT1Wup.cjs";
3
3
  import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-BS_In2AW.cjs";
4
4
  //#region src/protocols/mcp/protocol.d.ts
5
5
  type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
@@ -1,5 +1,5 @@
1
1
  import { m as McpDefinition } from "../../types-BX8RawmT.js";
2
- import { t as MetricsRecorder } from "../../base-Bohn3qri.js";
2
+ import { t as MetricsRecorder } from "../../base-B7D0KqaY.js";
3
3
  import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Dt7ll7Ur.js";
4
4
  //#region src/protocols/mcp/protocol.d.ts
5
5
  type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
@@ -1,2 +1,2 @@
1
- import { t as createMcpProtocolHandler } from "../../mcp-CF4Jk7ox.js";
1
+ import { t as createMcpProtocolHandler } from "../../mcp-woEauhMi.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-DLtOeUWZ.cjs");
3
+ const require_cors = require("../cors-dZ1AWhSq.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 { m as McpDefinition } from "../types-BX8RawmT.cjs";
2
- import { t as MetricsRecorder } from "../base-CZiROmNS.cjs";
2
+ import { t as MetricsRecorder } from "../base-D3TT1Wup.cjs";
3
3
  import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-BS_In2AW.cjs";
4
4
  //#region src/protocols/oauth-metadata.d.ts
5
5
  type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
@@ -1,5 +1,5 @@
1
1
  import { m as McpDefinition } from "../types-BX8RawmT.js";
2
- import { t as MetricsRecorder } from "../base-Bohn3qri.js";
2
+ import { t as MetricsRecorder } from "../base-B7D0KqaY.js";
3
3
  import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-Dt7ll7Ur.js";
4
4
  //#region src/protocols/oauth-metadata.d.ts
5
5
  type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
@@ -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-ZvCUb2VJ.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-C3JU5DNM.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-DLtOeUWZ.cjs");
3
+ const require_cors = require("../../cors-dZ1AWhSq.cjs");
4
4
  const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
5
- const require_mcp = require("../../mcp-Cjp6b4hW.cjs");
5
+ const require_mcp = require("../../mcp-WUiGYfjS.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-ZvCUb2VJ.js";
2
+ import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-C3JU5DNM.js";
3
3
  import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
4
- import { t as createMcpProtocolHandler } from "../../mcp-CF4Jk7ox.js";
4
+ import { t as createMcpProtocolHandler } from "../../mcp-woEauhMi.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,9 +2,8 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_package = require("../../package-B_Yt2-fx.cjs");
6
- const require_fs_errors = require("../../fs-errors-CWNzOV75.cjs");
7
- const require_supabase_config = require("../../supabase-config-Dz7dnUv0.cjs");
5
+ const require_package = require("../../package-CoGnWS6Y.cjs");
6
+ const require_supabase_config = require("../../supabase-config-Dz13d9ze.cjs");
8
7
  const require_paths = require("../../paths-OP318a6c.cjs");
9
8
  let node_fs = require("node:fs");
10
9
  let node_path = require("node:path");
@@ -17,7 +16,7 @@ function fileExists(path) {
17
16
  (0, node_fs.lstatSync)(path);
18
17
  return true;
19
18
  } catch (err) {
20
- if (require_fs_errors.isFileMissing(err)) return false;
19
+ if (require_supabase_config.isFileMissing(err)) return false;
21
20
  throw err;
22
21
  }
23
22
  }
@@ -37,7 +36,7 @@ function writeIfChanged(file, content, ownershipCheck) {
37
36
  try {
38
37
  existing = (0, node_fs.readFileSync)(file, "utf8");
39
38
  } catch (err) {
40
- if (!require_fs_errors.isFileMissing(err)) throw err;
39
+ if (!require_supabase_config.isFileMissing(err)) throw err;
41
40
  }
42
41
  if (existing !== void 0) {
43
42
  if (!ownershipCheck(existing)) throw new Error(`@lovable.dev/mcp-js: refusing to overwrite user-authored file at ${file}. Delete it or move it first.`);
@@ -227,7 +226,7 @@ function cleanupOrphans(functionDir, expected, removed) {
227
226
  try {
228
227
  entries = (0, node_fs.readdirSync)(functionDir);
229
228
  } catch (err) {
230
- if (require_fs_errors.isFileMissing(err)) return;
229
+ if (require_supabase_config.isFileMissing(err)) return;
231
230
  throw err;
232
231
  }
233
232
  for (const entry of entries) {
@@ -237,14 +236,14 @@ function cleanupOrphans(functionDir, expected, removed) {
237
236
  try {
238
237
  content = (0, node_fs.readFileSync)(full, "utf8");
239
238
  } catch (err) {
240
- if (require_fs_errors.isFileMissing(err) || err.code === "EISDIR") continue;
239
+ if (require_supabase_config.isFileMissing(err) || err.code === "EISDIR") continue;
241
240
  throw err;
242
241
  }
243
242
  if (hasGeneratedBanner(content) || hasGeneratedJsonMarker(content)) try {
244
243
  (0, node_fs.unlinkSync)(full);
245
244
  removed.push(full);
246
245
  } catch (err) {
247
- if (!require_fs_errors.isFileMissing(err)) throw err;
246
+ if (!require_supabase_config.isFileMissing(err)) throw err;
248
247
  }
249
248
  }
250
249
  }
@@ -1,6 +1,5 @@
1
- import { t as version } from "../../package-Ki9PQjkY.js";
2
- import { t as isFileMissing } from "../../fs-errors-PA2t1TIp.js";
3
- import { t as readSupabaseProjectRef } from "../../supabase-config-CakTU8YF.js";
1
+ import { t as version } from "../../package-DIh9b_dF.js";
2
+ import { n as isFileMissing, t as readSupabaseProjectRef } from "../../supabase-config-DITfH_bn.js";
4
3
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
5
4
  import { lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
6
5
  import { dirname, join, relative, resolve, sep } from "node:path";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cors = require("../../cors-DLtOeUWZ.cjs");
3
- const require_mcp = require("../../mcp-Cjp6b4hW.cjs");
2
+ const require_cors = require("../../cors-dZ1AWhSq.cjs");
3
+ const require_mcp = require("../../mcp-WUiGYfjS.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-ZvCUb2VJ.js";
2
- import { t as createMcpProtocolHandler } from "../../mcp-CF4Jk7ox.js";
1
+ import { c as createRecorderForRuntime } from "../../cors-C3JU5DNM.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-woEauhMi.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
@@ -3,8 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../metadata-path-zd7NSNoa.cjs");
6
- const require_fs_errors = require("../../fs-errors-CWNzOV75.cjs");
7
- const require_supabase_config = require("../../supabase-config-Dz7dnUv0.cjs");
6
+ const require_supabase_config = require("../../supabase-config-Dz13d9ze.cjs");
8
7
  let node_fs = require("node:fs");
9
8
  let node_path = require("node:path");
10
9
  let vite = require("vite");
@@ -108,7 +107,7 @@ function writeIfChanged(file, content) {
108
107
  try {
109
108
  existing = (0, node_fs.readFileSync)(file, "utf8");
110
109
  } catch (err) {
111
- if (!require_fs_errors.isFileMissing(err)) throw err;
110
+ if (!require_supabase_config.isFileMissing(err)) throw err;
112
111
  }
113
112
  if (existing !== void 0) {
114
113
  if (!hasGeneratedBanner(existing)) throw new Error(`@lovable.dev/mcp-js: refusing to overwrite user-authored route at ${file}. Delete it or move it first.`);
@@ -122,7 +121,7 @@ function fileStartsWithBanner(file) {
122
121
  try {
123
122
  return hasGeneratedBanner((0, node_fs.readFileSync)(file, "utf8"));
124
123
  } catch (err) {
125
- if (require_fs_errors.isFileMissing(err)) return false;
124
+ if (require_supabase_config.isFileMissing(err)) return false;
126
125
  throw err;
127
126
  }
128
127
  }
@@ -133,7 +132,7 @@ function findAdoptedFiles(routesDir) {
133
132
  try {
134
133
  entries = (0, node_fs.readdirSync)(dir);
135
134
  } catch (err) {
136
- if (require_fs_errors.isFileMissing(err)) return;
135
+ if (require_supabase_config.isFileMissing(err)) return;
137
136
  throw err;
138
137
  }
139
138
  for (const entry of entries) {
@@ -142,7 +141,7 @@ function findAdoptedFiles(routesDir) {
142
141
  try {
143
142
  stat = (0, node_fs.lstatSync)(full);
144
143
  } catch (err) {
145
- if (require_fs_errors.isFileMissing(err)) continue;
144
+ if (require_supabase_config.isFileMissing(err)) continue;
146
145
  throw err;
147
146
  }
148
147
  if (stat.isDirectory()) visit(full);
@@ -188,7 +187,7 @@ function mcpPlugin(options = {}) {
188
187
  try {
189
188
  (0, node_fs.lstatSync)(mcpEntry);
190
189
  } catch (err) {
191
- if (!require_fs_errors.isFileMissing(err)) throw err;
190
+ if (!require_supabase_config.isFileMissing(err)) throw err;
192
191
  mcpEntryExists = false;
193
192
  }
194
193
  const expected = /* @__PURE__ */ new Set();
@@ -212,7 +211,7 @@ function mcpPlugin(options = {}) {
212
211
  for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {
213
212
  (0, node_fs.unlinkSync)(file);
214
213
  } catch (err) {
215
- if (!require_fs_errors.isFileMissing(err)) throw err;
214
+ if (!require_supabase_config.isFileMissing(err)) throw err;
216
215
  }
217
216
  };
218
217
  return {
@@ -1,6 +1,5 @@
1
1
  import "../../metadata-path-CAkNcfyY.js";
2
- import { t as isFileMissing } from "../../fs-errors-PA2t1TIp.js";
3
- import { t as readSupabaseProjectRef } from "../../supabase-config-CakTU8YF.js";
2
+ import { n as isFileMissing, t as readSupabaseProjectRef } from "../../supabase-config-DITfH_bn.js";
4
3
  import { lstatSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
5
4
  import { dirname, join, relative, resolve, sep } from "node:path";
6
5
  import { loadEnv } from "vite";
@@ -1,6 +1,10 @@
1
- import { t as isFileMissing } from "./fs-errors-PA2t1TIp.js";
2
1
  import { readFileSync } from "node:fs";
3
2
  import { join } from "node:path";
3
+ //#region src/core/fs-errors.ts
4
+ function isFileMissing(err) {
5
+ return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
6
+ }
7
+ //#endregion
4
8
  //#region src/core/supabase-config.ts
5
9
  const SUPABASE_CONFIG_RELATIVE_PATH = "supabase/config.toml";
6
10
  function readSupabaseProjectRef(projectRoot) {
@@ -23,4 +27,4 @@ function readSupabaseProjectRef(projectRoot) {
23
27
  }
24
28
  }
25
29
  //#endregion
26
- export { readSupabaseProjectRef as t };
30
+ export { isFileMissing as n, readSupabaseProjectRef as t };
@@ -1,6 +1,10 @@
1
- const require_fs_errors = require("./fs-errors-CWNzOV75.cjs");
2
1
  let node_fs = require("node:fs");
3
2
  let node_path = require("node:path");
3
+ //#region src/core/fs-errors.ts
4
+ function isFileMissing(err) {
5
+ return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
6
+ }
7
+ //#endregion
4
8
  //#region src/core/supabase-config.ts
5
9
  const SUPABASE_CONFIG_RELATIVE_PATH = "supabase/config.toml";
6
10
  function readSupabaseProjectRef(projectRoot) {
@@ -8,7 +12,7 @@ function readSupabaseProjectRef(projectRoot) {
8
12
  try {
9
13
  content = (0, node_fs.readFileSync)((0, node_path.join)(projectRoot, SUPABASE_CONFIG_RELATIVE_PATH), "utf8");
10
14
  } catch (err) {
11
- if (require_fs_errors.isFileMissing(err)) return void 0;
15
+ if (isFileMissing(err)) return void 0;
12
16
  throw err;
13
17
  }
14
18
  for (const raw of content.split(/\r?\n/)) {
@@ -23,6 +27,12 @@ function readSupabaseProjectRef(projectRoot) {
23
27
  }
24
28
  }
25
29
  //#endregion
30
+ Object.defineProperty(exports, "isFileMissing", {
31
+ enumerable: true,
32
+ get: function() {
33
+ return isFileMissing;
34
+ }
35
+ });
26
36
  Object.defineProperty(exports, "readSupabaseProjectRef", {
27
37
  enumerable: true,
28
38
  get: function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/mcp-js",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -1,11 +0,0 @@
1
- //#region src/core/fs-errors.ts
2
- function isFileMissing(err) {
3
- return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
4
- }
5
- //#endregion
6
- Object.defineProperty(exports, "isFileMissing", {
7
- enumerable: true,
8
- get: function() {
9
- return isFileMissing;
10
- }
11
- });
@@ -1,6 +0,0 @@
1
- //#region src/core/fs-errors.ts
2
- function isFileMissing(err) {
3
- return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
4
- }
5
- //#endregion
6
- export { isFileMissing as t };