@lovable.dev/mcp-js 3.0.4 → 3.0.5

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
@@ -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-dULHdKny.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-NrWvjpmZ.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-D8nhrfTR.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-KAnnqE79.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,5 +1,5 @@
1
1
  import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
2
- import { t as version } from "./package-Ki9PQjkY.js";
2
+ import { t as version } from "./package-D8nhrfTR.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,5 +1,5 @@
1
1
  const require_schema = require("./schema-DNMsvJwE.cjs");
2
- const require_package = require("./package-B_Yt2-fx.cjs");
2
+ const require_package = require("./package-KAnnqE79.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,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-BGAtyAr_.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,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-COakIjqg.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,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "3.0.4";
2
+ var version = "3.0.5";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.0.4";
2
+ var version = "3.0.5";
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-Cjp6b4hW.cjs");
2
+ const require_mcp = require("../../mcp-DTAMXcRF.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-ChLv-MV0.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-COakIjqg.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-BGAtyAr_.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-COakIjqg.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-DTAMXcRF.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-BGAtyAr_.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-ChLv-MV0.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-B_Yt2-fx.cjs");
5
+ const require_package = require("../../package-KAnnqE79.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 version } from "../../package-Ki9PQjkY.js";
1
+ import { t as version } from "../../package-D8nhrfTR.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,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-COakIjqg.cjs");
3
+ const require_mcp = require("../../mcp-DTAMXcRF.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-BGAtyAr_.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-ChLv-MV0.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": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },