@lovable.dev/mcp-js 3.0.5 → 4.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.internal.md +5 -3
  2. package/README.md +18 -1
  3. package/dist/{authorize-BS_In2AW.d.cts → authorize-Ba1deW5O.d.cts} +1 -1
  4. package/dist/{authorize-Dt7ll7Ur.d.ts → authorize-Chb9Sb1f.d.ts} +1 -1
  5. package/dist/{base-B7D0KqaY.d.ts → base-D-lvtqSA.d.ts} +1 -1
  6. package/dist/{base-D3TT1Wup.d.cts → base-D7ei8TjY.d.cts} +1 -1
  7. package/dist/cli/extract-manifest.cjs +3 -3
  8. package/dist/cli/extract-manifest.js +3 -3
  9. package/dist/{cors-COakIjqg.cjs → cors-BuPvEjxu.cjs} +1 -1
  10. package/dist/{cors-BGAtyAr_.js → cors-D9LajKfo.js} +1 -1
  11. package/dist/{errors-ZmYYVYKN.js → errors-BEl2IOnx.js} +1 -1
  12. package/dist/{errors-CWxgUZH3.cjs → errors-BlSu6Nrn.cjs} +1 -1
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.cts +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/{io-BvogiiQ1.d.ts → io-B72X5KDG.d.ts} +1 -1
  18. package/dist/{io-dULHdKny.cjs → io-BpxqVag8.cjs} +2 -2
  19. package/dist/{io-NrWvjpmZ.js → io-DFsll31O.js} +2 -2
  20. package/dist/{io-Bn0ErYbG.d.cts → io-foChTR9t.d.cts} +1 -1
  21. package/dist/{mcp-ChLv-MV0.js → mcp-B1wBn_X-.js} +5 -5
  22. package/dist/{mcp-DTAMXcRF.cjs → mcp-DMMqfwKm.cjs} +7 -7
  23. package/dist/{package-D8nhrfTR.js → package-BWLBCBmc.js} +1 -1
  24. package/dist/{package-KAnnqE79.cjs → package-Bt33FsvP.cjs} +1 -1
  25. package/dist/protocols/mcp/index.cjs +1 -1
  26. package/dist/protocols/mcp/index.d.cts +3 -3
  27. package/dist/protocols/mcp/index.d.ts +3 -3
  28. package/dist/protocols/mcp/index.js +1 -1
  29. package/dist/protocols/oauth-metadata.cjs +1 -1
  30. package/dist/protocols/oauth-metadata.d.cts +3 -3
  31. package/dist/protocols/oauth-metadata.d.ts +3 -3
  32. package/dist/protocols/oauth-metadata.js +1 -1
  33. package/dist/schema-CjFpqCEP.cjs +27 -0
  34. package/dist/schema-DBTR1XbM.js +16 -0
  35. package/dist/stacks/supabase/index.cjs +2 -2
  36. package/dist/stacks/supabase/index.d.cts +1 -1
  37. package/dist/stacks/supabase/index.d.ts +1 -1
  38. package/dist/stacks/supabase/index.js +2 -2
  39. package/dist/stacks/supabase/vite.cjs +1 -1
  40. package/dist/stacks/supabase/vite.d.cts +1 -1
  41. package/dist/stacks/supabase/vite.d.ts +1 -1
  42. package/dist/stacks/supabase/vite.js +1 -1
  43. package/dist/stacks/tanstack/index.cjs +2 -2
  44. package/dist/stacks/tanstack/index.d.cts +2 -2
  45. package/dist/stacks/tanstack/index.d.ts +2 -2
  46. package/dist/stacks/tanstack/index.js +2 -2
  47. package/dist/stacks/tanstack/vite.d.cts +1 -1
  48. package/dist/stacks/tanstack/vite.d.ts +1 -1
  49. package/dist/{types-BX8RawmT.d.cts → types-srTXYLoX.d.cts} +13 -18
  50. package/dist/{types-BX8RawmT.d.ts → types-srTXYLoX.d.ts} +13 -18
  51. package/package.json +3 -4
  52. package/dist/schema-DNMsvJwE.cjs +0 -111
  53. package/dist/schema-JK_1KkOa.js +0 -76
@@ -73,13 +73,15 @@ Two reasons:
73
73
  1. **`.d.ts` stability across SDK bumps.** The SDK's published type tree (`@modelcontextprotocol/sdk/types.js`) and its zod-compat shape generics have shipped breaking type-only changes between minor versions. Owning our own type re-declarations lets us bump the SDK's runtime without forcing every downstream consumer to re-type-check.
74
74
  2. **Optionality on the SDK itself.** If we ever swap or drop `@modelcontextprotocol/sdk` — different transport, in-house protocol implementation, a fork — consumers' code is the contract that matters, and it's typed against this package's surface, not the SDK's. The runtime hand-off can change without rippling through user code.
75
75
 
76
- The published `.d.ts` files import only from `zod` and `vite`. Three SDK concerns were re-implemented (or re-typed) locally:
76
+ The published `.d.ts` files import only from `zod/v4/core` and `vite`. Three SDK concerns were re-implemented (or re-typed) locally:
77
77
 
78
78
  - **Content blocks and `ToolAnnotations`** — re-declared in `core/types.ts` to match the MCP wire format without depending on `@modelcontextprotocol/sdk/types.js`. The runtime still serializes via the SDK; only the type tree is owned.
79
- - **`ZodRawShape`, `ZodType`, `infer`** — sourced directly from `zod` (a peer dep). zod v3 and v4 both export all three at the top level; `ZodType` is non-deprecated in both versions with safe generic defaults. We re-export them from `core/types.ts` as `ZodRawShape` / `ZodSchema` / `ShapeOutput` (`ZodSchema` is a no-generic alias for `ZodType`). No dependency on `@modelcontextprotocol/sdk/server/zod-compat.js` types.
79
+ - **Schema types** — `ZodSchema` aliases `$ZodType` from `zod/v4/core`; `ZodRawShape` maps names to those schemas and `ShapeOutput` infers their parsed output. Both Classic and Mini are supported, including the v4 bundled in Zod 3.25.76. Root-v3 schemas are not accepted.
80
80
  - **`ContentBlock` union** — `TextContent | ImageContent | AudioContent | EmbeddedResource | ResourceLink`, structurally matching MCP's wire format. Consumers can type custom content (`return { content: [<ImageContent>, <TextContent>] }`) without referencing the SDK.
81
81
 
82
- The **runtime** still hands off to the MCP SDKs — `createMcpHandler` + `McpServer` come from `@modelcontextprotocol/server` (v2), and `safeParseAsync` + `toJsonSchemaCompat` come from `@modelcontextprotocol/sdk`'s zod-compat modules for input validation and JSON-Schema serialization. Those are runtime dependencies, not type-surface dependencies. Input shapes are wrapped by our own `strictObjectFromShape` (`src/core/schema.ts`), a strict twin of the SDK's `objectFromShape`, because the SDK only offers strip-mode objects; `strict: false` tools and output schemas still use the SDK's wrapper.
82
+ The runtime uses `createMcpHandler` and `McpServer` from `@modelcontextprotocol/server` (v2). Parsing and JSON Schema conversion use `zod/v4/core` directly, with Mini's object constructors for raw shapes. There is no v1 MCP SDK or v3 schema converter dependency.
83
+
84
+ The manifest CLI runs as ESM to share Zod's metadata registry with Vite SSR's ESM-loaded app schemas. Embedded v4 in Zod 3.25.76 and early Zod 4 versions keep separate ESM/CJS registries; crossing them loses descriptions even when parsing succeeds. Packed-consumer tests exercise descriptions, both module formats, and the supported version floors.
83
85
 
84
86
  ### 8. Stale-route cleanup on every regen
85
87
 
package/README.md CHANGED
@@ -5,7 +5,7 @@ Author MCP servers for Lovable apps. Declare tools with `defineTool`, register t
5
5
  ```ts
6
6
  // src/lib/mcp/tools/echo.ts
7
7
  import { defineTool } from "@lovable.dev/mcp-js";
8
- import { z } from "zod";
8
+ import { z } from "zod/v4";
9
9
 
10
10
  export default defineTool({
11
11
  name: "echo",
@@ -44,6 +44,23 @@ Manifest extraction allows **512 tools** in the evaluated `defineMcp({ tools })`
44
44
 
45
45
  `inputSchema` is closed: a `tools/call` carrying an argument key the schema does not declare fails in-band (`isError: true`, naming the key) instead of silently dropping it, and `tools/list` advertises `additionalProperties: false`. Set `strict: false` on a tool to accept and drop unknown keys instead.
46
46
 
47
+ ## Upgrade to 4.x without migrating app forms
48
+
49
+ MCP schemas must use Zod 4 Classic (`zod/v4`) or Mini (`zod/v4-mini`). The peer
50
+ range is `^3.25.76 || ^4.0.0`; TypeScript consumers need 5.5 or newer. Zod
51
+ 3.25.76 includes v4 at `zod/v4` while its root `zod` export remains v3.
52
+
53
+ For an app on Zod 3, upgrade within that major to `^3.25.76`, then change only
54
+ MCP schema imports to `zod/v4`. Leave form schemas, resolvers, and their root
55
+ imports unchanged. Shared v3 schemas cannot be passed to MCP tools: define a
56
+ v4 MCP schema or migrate the shared schema and its consumers deliberately.
57
+ Zod 4 apps can keep their root imports, though `zod/v4` makes the contract
58
+ explicit. Rebuild and run `lovable-mcp-extract-manifest` after upgrading.
59
+
60
+ Schema APIs can differ between v3 and v4; fix MCP schema errors rather than
61
+ casting them away. V3 MCP schemas are rejected during `defineMcp`. The MCP
62
+ transport, stateless legacy support, and OAuth configuration are unchanged.
63
+
47
64
  ## What the plugin emits
48
65
 
49
66
  | URL | File | Purpose |
@@ -1,4 +1,4 @@
1
- import "./types-BX8RawmT.cjs";
1
+ import "./types-srTXYLoX.cjs";
2
2
  //#region src/metrics/recorder.d.ts
3
3
  type ScheduleBackground = (task: Promise<unknown>) => void;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import "./types-BX8RawmT.js";
1
+ import "./types-srTXYLoX.js";
2
2
  //#region src/metrics/recorder.d.ts
3
3
  type ScheduleBackground = (task: Promise<unknown>) => void;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { j as McpProtocolEra } from "./types-BX8RawmT.js";
1
+ import { j as McpProtocolEra } from "./types-srTXYLoX.js";
2
2
  //#region src/metrics/impl/base.d.ts
3
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
@@ -1,4 +1,4 @@
1
- import { j as McpProtocolEra } from "./types-BX8RawmT.cjs";
1
+ import { j as McpProtocolEra } from "./types-srTXYLoX.cjs";
2
2
  //#region src/metrics/impl/base.d.ts
3
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
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  //#region src/cli/extract-manifest.ts
3
3
  const projectRoot = process.argv[2] ?? process.cwd();
4
- import("zod/v3").catch((err) => {
4
+ import("zod/v4/core").catch((err) => {
5
5
  const message = err instanceof Error ? err.message : String(err);
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-dULHdKny.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
6
+ throw new Error(`@lovable.dev/mcp-js requires zod ^3.25.76 or ^4.0.0 to extract MCP schemas. Import MCP schemas from "zod/v4"; existing app forms can keep importing from "zod". Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
7
+ }).then(() => Promise.resolve().then(() => require("../io-BpxqVag8.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
  });
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  //#region src/cli/extract-manifest.ts
3
3
  const projectRoot = process.argv[2] ?? process.cwd();
4
- import("zod/v3").catch((err) => {
4
+ import("zod/v4/core").catch((err) => {
5
5
  const message = err instanceof Error ? err.message : String(err);
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-NrWvjpmZ.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
6
+ throw new Error(`@lovable.dev/mcp-js requires zod ^3.25.76 or ^4.0.0 to extract MCP schemas. Import MCP schemas from "zod/v4"; existing app forms can keep importing from "zod". Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
7
+ }).then(() => import("../io-DFsll31O.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
  const require_logger = require("./logger-C-Hdu57K.cjs");
2
- const require_package = require("./package-KAnnqE79.cjs");
2
+ const require_package = require("./package-Bt33FsvP.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
  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-D8nhrfTR.js";
2
+ import { t as version } from "./package-BWLBCBmc.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
  import { o as parseSafeUrl, s as trimTrailingSlash, u as resolveMetricsConfig } from "./logger-CpLgYbCG.js";
2
- import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
2
+ import { t as jsonSchemaFromDefinition } from "./schema-DBTR1XbM.js";
3
3
  //#region src/core/define.ts
4
4
  function toolRequiresAppContext(tool) {
5
5
  return "requiresAppContext" in tool && tool.requiresAppContext === true;
@@ -1,5 +1,5 @@
1
- const require_schema = require("./schema-DNMsvJwE.cjs");
2
1
  const require_logger = require("./logger-C-Hdu57K.cjs");
2
+ const require_schema = require("./schema-CjFpqCEP.cjs");
3
3
  //#region src/core/define.ts
4
4
  function toolRequiresAppContext(tool) {
5
5
  return "requiresAppContext" in tool && tool.requiresAppContext === true;
package/dist/index.cjs CHANGED
@@ -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_errors = require("./errors-CWxgUZH3.cjs");
3
+ const require_errors = require("./errors-BlSu6Nrn.cjs");
4
4
  //#region src/auth/config.ts
5
5
  function frozenArray(value) {
6
6
  return value === void 0 ? void 0 : Object.freeze([...value]);
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as McpClientInfo, C as ToolVisibilityContext, D as MetricsConfig, E as ZodSchema, F as McpAuthConfig, M as ProgressUpdate, N as ToolContext, O as MetricsOptions, P as JwtClaims, S as ToolHandlerResult, T as ZodRawShape, _ as ResourceLinkIcon, a as ContentBlock, b as ToolContent, c as EmbeddedResource, d as JsonValue, f as JsonValueInput, g as ResourceLink, h as McpDefinitionInput, i as ContentAnnotations, j as McpProtocolEra, k as AuthContext, l as EmbeddedTextResource, m as McpDefinition, n as AppContextToolDefinitionInput, o as CreateAppContextInput, p as McpAllowedOrigins, r as AudioContent, s as EmbeddedBlobResource, t as AppContextToolDefinition, u as ImageContent, v as TextContent, w as ZodOutputSchema, x as ToolDefinition, y as ToolAnnotations } from "./types-BX8RawmT.cjs";
1
+ import { A as McpClientInfo, C as ToolVisibilityContext, D as MetricsConfig, E as ZodSchema, F as McpAuthConfig, M as ProgressUpdate, N as ToolContext, O as MetricsOptions, P as JwtClaims, S as ToolHandlerResult, T as ZodRawShape, _ as ResourceLinkIcon, a as ContentBlock, b as ToolContent, c as EmbeddedResource, d as JsonValue, f as JsonValueInput, g as ResourceLink, h as McpDefinitionInput, i as ContentAnnotations, j as McpProtocolEra, k as AuthContext, l as EmbeddedTextResource, m as McpDefinition, n as AppContextToolDefinitionInput, o as CreateAppContextInput, p as McpAllowedOrigins, r as AudioContent, s as EmbeddedBlobResource, t as AppContextToolDefinition, u as ImageContent, v as TextContent, w as ZodOutputSchema, x as ToolDefinition, y as ToolAnnotations } from "./types-srTXYLoX.cjs";
2
2
  //#region src/core/define.d.ts
3
3
  /**
4
4
  * Declare a single MCP tool. Import the result into your MCP definition's
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as McpClientInfo, C as ToolVisibilityContext, D as MetricsConfig, E as ZodSchema, F as McpAuthConfig, M as ProgressUpdate, N as ToolContext, O as MetricsOptions, P as JwtClaims, S as ToolHandlerResult, T as ZodRawShape, _ as ResourceLinkIcon, a as ContentBlock, b as ToolContent, c as EmbeddedResource, d as JsonValue, f as JsonValueInput, g as ResourceLink, h as McpDefinitionInput, i as ContentAnnotations, j as McpProtocolEra, k as AuthContext, l as EmbeddedTextResource, m as McpDefinition, n as AppContextToolDefinitionInput, o as CreateAppContextInput, p as McpAllowedOrigins, r as AudioContent, s as EmbeddedBlobResource, t as AppContextToolDefinition, u as ImageContent, v as TextContent, w as ZodOutputSchema, x as ToolDefinition, y as ToolAnnotations } from "./types-BX8RawmT.js";
1
+ import { A as McpClientInfo, C as ToolVisibilityContext, D as MetricsConfig, E as ZodSchema, F as McpAuthConfig, M as ProgressUpdate, N as ToolContext, O as MetricsOptions, P as JwtClaims, S as ToolHandlerResult, T as ZodRawShape, _ as ResourceLinkIcon, a as ContentBlock, b as ToolContent, c as EmbeddedResource, d as JsonValue, f as JsonValueInput, g as ResourceLink, h as McpDefinitionInput, i as ContentAnnotations, j as McpProtocolEra, k as AuthContext, l as EmbeddedTextResource, m as McpDefinition, n as AppContextToolDefinitionInput, o as CreateAppContextInput, p as McpAllowedOrigins, r as AudioContent, s as EmbeddedBlobResource, t as AppContextToolDefinition, u as ImageContent, v as TextContent, w as ZodOutputSchema, x as ToolDefinition, y as ToolAnnotations } from "./types-srTXYLoX.js";
2
2
  //#region src/core/define.d.ts
3
3
  /**
4
4
  * Declare a single MCP tool. Import the result into your MCP definition's
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as setLogLevel } from "./logger-CpLgYbCG.js";
2
- import { a as ToolContext, i as AuthContext, o as defineMcp, s as defineTool, t as ToolError } from "./errors-ZmYYVYKN.js";
2
+ import { a as ToolContext, i as AuthContext, o as defineMcp, s as defineTool, t as ToolError } from "./errors-BEl2IOnx.js";
3
3
  //#region src/auth/config.ts
4
4
  function frozenArray(value) {
5
5
  return value === void 0 ? void 0 : Object.freeze([...value]);
@@ -1,4 +1,4 @@
1
- import "./types-BX8RawmT.js";
1
+ import "./types-srTXYLoX.js";
2
2
  //#region src/manifest/io.d.ts
3
3
  /**
4
4
  * Shape every MCP Vite plugin exposes on its `api` so `runExtract` can read
@@ -1,5 +1,5 @@
1
- const require_schema = require("./schema-DNMsvJwE.cjs");
2
- const require_package = require("./package-KAnnqE79.cjs");
1
+ const require_schema = require("./schema-CjFpqCEP.cjs");
2
+ const require_package = require("./package-Bt33FsvP.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
- import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
2
- import { t as version } from "./package-D8nhrfTR.js";
1
+ import { t as jsonSchemaFromDefinition } from "./schema-DBTR1XbM.js";
2
+ import { t as version } from "./package-BWLBCBmc.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,4 +1,4 @@
1
- import "./types-BX8RawmT.cjs";
1
+ import "./types-srTXYLoX.cjs";
2
2
  //#region src/manifest/io.d.ts
3
3
  /**
4
4
  * Shape every MCP Vite plugin exposes on its `api` so `runExtract` can read
@@ -1,8 +1,8 @@
1
1
  import { i as log, r as describeError } from "./logger-CpLgYbCG.js";
2
- import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
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-BGAtyAr_.js";
5
- import { getParseErrorMessage, safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
2
+ import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-DBTR1XbM.js";
3
+ import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-BEl2IOnx.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-D9LajKfo.js";
5
+ import { safeParseAsync } from "zod/v4/core";
6
6
  import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, createMcpHandler } from "@modelcontextprotocol/server";
7
7
  //#region src/core/content.ts
8
8
  /** Join the text of a result's `type: "text"` blocks into one string, dropping
@@ -61,7 +61,7 @@ async function finalizeToolResult(tool, result) {
61
61
  if (structuredContent === void 0) return outputValidationError(`Output validation error: Tool ${tool.name} has an output schema but no structured content was provided`);
62
62
  try {
63
63
  const parsed = await safeParseAsync(schemaFromDefinition(tool.outputSchema, false), structuredContent);
64
- if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${getParseErrorMessage(parsed.error)}`);
64
+ if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${parsed.error.message}`);
65
65
  structuredContent = parsed.data;
66
66
  } catch {
67
67
  return outputValidationError(`Output validation error: Could not validate structured content for tool ${tool.name}`);
@@ -1,8 +1,8 @@
1
- const require_schema = require("./schema-DNMsvJwE.cjs");
2
1
  const require_logger = require("./logger-C-Hdu57K.cjs");
3
- const require_errors = require("./errors-CWxgUZH3.cjs");
4
- const require_cors = require("./cors-COakIjqg.cjs");
5
- let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
2
+ const require_schema = require("./schema-CjFpqCEP.cjs");
3
+ const require_errors = require("./errors-BlSu6Nrn.cjs");
4
+ const require_cors = require("./cors-BuPvEjxu.cjs");
5
+ let zod_v4_core = require("zod/v4/core");
6
6
  let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
7
7
  //#region src/core/content.ts
8
8
  /** Join the text of a result's `type: "text"` blocks into one string, dropping
@@ -60,8 +60,8 @@ async function finalizeToolResult(tool, result) {
60
60
  if (tool.outputSchema && !result.isError) {
61
61
  if (structuredContent === void 0) return outputValidationError(`Output validation error: Tool ${tool.name} has an output schema but no structured content was provided`);
62
62
  try {
63
- const parsed = await (0, _modelcontextprotocol_sdk_server_zod_compat_js.safeParseAsync)(require_schema.schemaFromDefinition(tool.outputSchema, false), structuredContent);
64
- 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)}`);
63
+ const parsed = await (0, zod_v4_core.safeParseAsync)(require_schema.schemaFromDefinition(tool.outputSchema, false), structuredContent);
64
+ if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${parsed.error.message}`);
65
65
  structuredContent = parsed.data;
66
66
  } catch {
67
67
  return outputValidationError(`Output validation error: Could not validate structured content for tool ${tool.name}`);
@@ -194,7 +194,7 @@ function standardSchemaFromDefinition(definition, strict) {
194
194
  version: 1,
195
195
  vendor: "zod",
196
196
  validate: async (value) => {
197
- const parsed = await (0, _modelcontextprotocol_sdk_server_zod_compat_js.safeParseAsync)(schema, value);
197
+ const parsed = await (0, zod_v4_core.safeParseAsync)(schema, value);
198
198
  return parsed.success ? { value: parsed.data } : { issues: zodIssues(parsed.error) };
199
199
  },
200
200
  jsonSchema: {
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "3.0.5";
2
+ var version = "4.0.0-rc.0";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.0.5";
2
+ var version = "4.0.0-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-DTAMXcRF.cjs");
2
+ const require_mcp = require("../../mcp-DMMqfwKm.cjs");
3
3
  exports.createMcpProtocolHandler = require_mcp.createMcpProtocolHandler;
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../../types-BX8RawmT.cjs";
2
- import { t as MetricsRecorder } from "../../base-D3TT1Wup.cjs";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-BS_In2AW.cjs";
1
+ import { m as McpDefinition } from "../../types-srTXYLoX.cjs";
2
+ import { t as MetricsRecorder } from "../../base-D7ei8TjY.cjs";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Ba1deW5O.cjs";
4
4
  //#region src/protocols/mcp/protocol.d.ts
5
5
  type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../../types-BX8RawmT.js";
2
- import { t as MetricsRecorder } from "../../base-B7D0KqaY.js";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Dt7ll7Ur.js";
1
+ import { m as McpDefinition } from "../../types-srTXYLoX.js";
2
+ import { t as MetricsRecorder } from "../../base-D-lvtqSA.js";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Chb9Sb1f.js";
4
4
  //#region src/protocols/mcp/protocol.d.ts
5
5
  type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  /**
@@ -1,2 +1,2 @@
1
- import { t as createMcpProtocolHandler } from "../../mcp-ChLv-MV0.js";
1
+ import { t as createMcpProtocolHandler } from "../../mcp-B1wBn_X-.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-COakIjqg.cjs");
3
+ const require_cors = require("../cors-BuPvEjxu.cjs");
4
4
  //#region src/protocols/oauth-metadata.ts
5
5
  function notFound() {
6
6
  return new Response(JSON.stringify({ error: "not found" }), {
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../types-BX8RawmT.cjs";
2
- import { t as MetricsRecorder } from "../base-D3TT1Wup.cjs";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-BS_In2AW.cjs";
1
+ import { m as McpDefinition } from "../types-srTXYLoX.cjs";
2
+ import { t as MetricsRecorder } from "../base-D7ei8TjY.cjs";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-Ba1deW5O.cjs";
4
4
  //#region src/protocols/oauth-metadata.d.ts
5
5
  type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../types-BX8RawmT.js";
2
- import { t as MetricsRecorder } from "../base-B7D0KqaY.js";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-Dt7ll7Ur.js";
1
+ import { m as McpDefinition } from "../types-srTXYLoX.js";
2
+ import { t as MetricsRecorder } from "../base-D-lvtqSA.js";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-Chb9Sb1f.js";
4
4
  //#region src/protocols/oauth-metadata.d.ts
5
5
  type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
@@ -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-BGAtyAr_.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-D9LajKfo.js";
3
3
  //#region src/protocols/oauth-metadata.ts
4
4
  function notFound() {
5
5
  return new Response(JSON.stringify({ error: "not found" }), {
@@ -0,0 +1,27 @@
1
+ let zod_v4_mini = require("zod/v4-mini");
2
+ let zod_v4_core = require("zod/v4/core");
3
+ //#region src/core/schema.ts
4
+ function schemaFromDefinition(definition, strict) {
5
+ if (definition instanceof zod_v4_core.$ZodType) return definition;
6
+ for (const field of Object.values(definition)) if (!(field instanceof zod_v4_core.$ZodType)) throw new Error("@lovable.dev/mcp-js requires Zod 4 schemas. Install zod ^3.25.76 or ^4.0.0 and import MCP schemas from \"zod/v4\". Existing app forms can keep importing from \"zod\".");
7
+ return strict ? (0, zod_v4_mini.strictObject)(definition) : (0, zod_v4_mini.object)(definition);
8
+ }
9
+ function jsonSchemaFromDefinition(definition, pipeStrategy, strict) {
10
+ return (0, zod_v4_core.toJSONSchema)(schemaFromDefinition(definition, strict), {
11
+ target: "draft-2020-12",
12
+ io: pipeStrategy
13
+ });
14
+ }
15
+ //#endregion
16
+ Object.defineProperty(exports, "jsonSchemaFromDefinition", {
17
+ enumerable: true,
18
+ get: function() {
19
+ return jsonSchemaFromDefinition;
20
+ }
21
+ });
22
+ Object.defineProperty(exports, "schemaFromDefinition", {
23
+ enumerable: true,
24
+ get: function() {
25
+ return schemaFromDefinition;
26
+ }
27
+ });
@@ -0,0 +1,16 @@
1
+ import { object, strictObject } from "zod/v4-mini";
2
+ import { $ZodType, toJSONSchema } from "zod/v4/core";
3
+ //#region src/core/schema.ts
4
+ function schemaFromDefinition(definition, strict) {
5
+ if (definition instanceof $ZodType) return definition;
6
+ for (const field of Object.values(definition)) if (!(field instanceof $ZodType)) throw new Error("@lovable.dev/mcp-js requires Zod 4 schemas. Install zod ^3.25.76 or ^4.0.0 and import MCP schemas from \"zod/v4\". Existing app forms can keep importing from \"zod\".");
7
+ return strict ? strictObject(definition) : object(definition);
8
+ }
9
+ function jsonSchemaFromDefinition(definition, pipeStrategy, strict) {
10
+ return toJSONSchema(schemaFromDefinition(definition, strict), {
11
+ target: "draft-2020-12",
12
+ io: pipeStrategy
13
+ });
14
+ }
15
+ //#endregion
16
+ export { schemaFromDefinition as n, jsonSchemaFromDefinition as t };
@@ -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-COakIjqg.cjs");
3
+ const require_cors = require("../../cors-BuPvEjxu.cjs");
4
4
  const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
5
- const require_mcp = require("../../mcp-DTAMXcRF.cjs");
5
+ const require_mcp = require("../../mcp-DMMqfwKm.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,4 +1,4 @@
1
- import { m as McpDefinition } from "../../types-BX8RawmT.cjs";
1
+ import { m as McpDefinition } from "../../types-srTXYLoX.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 { m as McpDefinition } from "../../types-BX8RawmT.js";
1
+ import { m as McpDefinition } from "../../types-srTXYLoX.js";
2
2
  //#region src/stacks/supabase/handler.d.ts
3
3
  type SupabaseHandler = (request: Request) => Promise<Response>;
4
4
  interface SupabaseHandlerOptions {
@@ -1,7 +1,7 @@
1
1
  import { s as trimTrailingSlash } from "../../logger-CpLgYbCG.js";
2
- import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-BGAtyAr_.js";
2
+ import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-D9LajKfo.js";
3
3
  import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
4
- import { t as createMcpProtocolHandler } from "../../mcp-ChLv-MV0.js";
4
+ import { t as createMcpProtocolHandler } from "../../mcp-B1wBn_X-.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-KAnnqE79.cjs");
5
+ const require_package = require("../../package-Bt33FsvP.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-Bn0ErYbG.cjs";
1
+ import { t as McpPluginApi } from "../../io-foChTR9t.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-BvogiiQ1.js";
1
+ import { t as McpPluginApi } from "../../io-B72X5KDG.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-D8nhrfTR.js";
1
+ import { t as version } from "../../package-BWLBCBmc.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-COakIjqg.cjs");
3
- const require_mcp = require("../../mcp-DTAMXcRF.cjs");
2
+ const require_cors = require("../../cors-BuPvEjxu.cjs");
3
+ const require_mcp = require("../../mcp-DMMqfwKm.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 { m as McpDefinition } from "../../types-BX8RawmT.cjs";
2
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-BS_In2AW.cjs";
1
+ import { m as McpDefinition } from "../../types-srTXYLoX.cjs";
2
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Ba1deW5O.cjs";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRequest extends Request {
5
5
  waitUntil?: ScheduleBackground;
@@ -1,5 +1,5 @@
1
- import { m as McpDefinition } from "../../types-BX8RawmT.js";
2
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Dt7ll7Ur.js";
1
+ import { m as McpDefinition } from "../../types-srTXYLoX.js";
2
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Chb9Sb1f.js";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRequest extends Request {
5
5
  waitUntil?: ScheduleBackground;
@@ -1,5 +1,5 @@
1
- import { c as createRecorderForRuntime } from "../../cors-BGAtyAr_.js";
2
- import { t as createMcpProtocolHandler } from "../../mcp-ChLv-MV0.js";
1
+ import { c as createRecorderForRuntime } from "../../cors-D9LajKfo.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-B1wBn_X-.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
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-Bn0ErYbG.cjs";
1
+ import { t as McpPluginApi } from "../../io-foChTR9t.cjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-BvogiiQ1.js";
1
+ import { t as McpPluginApi } from "../../io-B72X5KDG.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { TypeOf, ZodRawShape, ZodType } from "zod";
1
+ import { $ZodType, output } from "zod/v4/core";
2
2
  //#region src/auth/types.d.ts
3
3
  type JwtClaims = Record<string, unknown> & {
4
4
  iss?: string;
@@ -181,22 +181,17 @@ interface MetricsOptions {
181
181
  type MetricsConfig = boolean | MetricsOptions;
182
182
  //#endregion
183
183
  //#region src/core/types.d.ts
184
- /**
185
- * Any zod schema. Aliased to zod's `ZodType` (no generics) — non-deprecated
186
- * in both v3 and v4. Use this when you need to type an individual schema;
187
- * for the `{ text: z.string() }` shape passed to `defineTool`'s
188
- * `inputSchema`, use `ZodRawShape`.
189
- */
190
- type ZodSchema = ZodType;
184
+ /** A Zod 4 schema, from Classic or Mini. */
185
+ type ZodSchema = $ZodType;
191
186
  /** A raw zod shape (`{ text: z.string() }`) — the format `defineTool`'s
192
187
  * `inputSchema` expects and the object shorthand accepted by `outputSchema`. */
193
- type ZodRawShape$1 = ZodRawShape;
194
- type ZodOutputSchema = ZodSchema | ZodRawShape$1;
188
+ type ZodRawShape = Record<string, ZodSchema>;
189
+ type ZodOutputSchema = ZodSchema | ZodRawShape;
195
190
  /**
196
191
  * Infer the parsed-output type of a zod raw shape — given
197
192
  * `{ text: ZodString, n: ZodNumber }`, produces `{ text: string, n: number }`.
198
193
  */
199
- type ShapeOutput<Shape extends ZodRawShape$1> = { [K in keyof Shape]: Shape[K] extends ZodType ? TypeOf<Shape[K]> : unknown; };
194
+ type ShapeOutput<Shape extends ZodRawShape> = { [K in keyof Shape]: output<Shape[K]>; };
200
195
  /**
201
196
  * Per-content-block metadata. Distinct from `ToolAnnotations`, which
202
197
  * decorates the tool as a whole — these decorate a single piece of
@@ -323,7 +318,7 @@ interface CreateAppContextInput {
323
318
  interface ToolVisibilityContext<TAppContext> {
324
319
  readonly appContext: TAppContext;
325
320
  }
326
- interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
321
+ interface ToolDefinitionBase<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
327
322
  readonly name: string;
328
323
  /** Human-readable display name shown to the user in MCP clients. Required. */
329
324
  readonly title: string;
@@ -335,18 +330,18 @@ interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawSh
335
330
  readonly outputSchema?: TOutput;
336
331
  readonly annotations?: ToolAnnotations;
337
332
  }
338
- type ToolHandler<TInput extends ZodRawShape$1 | undefined, TAppContext> = TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult>;
333
+ type ToolHandler<TInput extends ZodRawShape | undefined, TAppContext> = TInput extends ZodRawShape ? (args: ShapeOutput<TInput>, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult>;
339
334
  /** A tool that exists for every caller. Its handler receives the plain `ToolContext`. */
340
- interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
335
+ interface ToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
341
336
  readonly handler: ToolHandler<TInput, undefined>;
342
337
  }
343
338
  /** Input to `defineTool.withAppContext<TAppContext>()`. */
344
- interface AppContextToolDefinitionInput<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
339
+ interface AppContextToolDefinitionInput<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
345
340
  /** Synchronously decide whether this tool exists for the current caller. */
346
341
  readonly enabled?: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
347
342
  readonly handler: ToolHandler<TInput, TAppContext>;
348
343
  }
349
- interface AppContextToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
344
+ interface AppContextToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
350
345
  readonly requiresAppContext: true;
351
346
  }
352
347
  /** Type-erased element of `McpDefinition.tools`; per-tool generic typing
@@ -355,7 +350,7 @@ interface AnyToolDefinition<TAppContext = never> {
355
350
  readonly name: string;
356
351
  readonly title: string;
357
352
  readonly description: string;
358
- readonly inputSchema?: ZodRawShape$1 | undefined;
353
+ readonly inputSchema?: ZodRawShape | undefined;
359
354
  readonly strict?: boolean;
360
355
  readonly outputSchema?: ZodOutputSchema | undefined;
361
356
  readonly annotations?: ToolAnnotations;
@@ -410,4 +405,4 @@ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>
410
405
  readonly [McpDefinitionBrand]: never;
411
406
  };
412
407
  //#endregion
413
- export { McpClientInfo as A, ToolVisibilityContext as C, MetricsConfig as D, ZodSchema as E, McpAuthConfig as F, ProgressUpdate as M, ToolContext as N, MetricsOptions as O, JwtClaims as P, ToolHandlerResult as S, ZodRawShape$1 as T, ResourceLinkIcon as _, ContentBlock as a, ToolContent as b, EmbeddedResource as c, JsonValue as d, JsonValueInput as f, ResourceLink as g, McpDefinitionInput as h, ContentAnnotations as i, McpProtocolEra as j, AuthContext as k, EmbeddedTextResource as l, McpDefinition as m, AppContextToolDefinitionInput as n, CreateAppContextInput as o, McpAllowedOrigins as p, AudioContent as r, EmbeddedBlobResource as s, AppContextToolDefinition as t, ImageContent as u, TextContent as v, ZodOutputSchema as w, ToolDefinition as x, ToolAnnotations as y };
408
+ export { McpClientInfo as A, ToolVisibilityContext as C, MetricsConfig as D, ZodSchema as E, McpAuthConfig as F, ProgressUpdate as M, ToolContext as N, MetricsOptions as O, JwtClaims as P, ToolHandlerResult as S, ZodRawShape as T, ResourceLinkIcon as _, ContentBlock as a, ToolContent as b, EmbeddedResource as c, JsonValue as d, JsonValueInput as f, ResourceLink as g, McpDefinitionInput as h, ContentAnnotations as i, McpProtocolEra as j, AuthContext as k, EmbeddedTextResource as l, McpDefinition as m, AppContextToolDefinitionInput as n, CreateAppContextInput as o, McpAllowedOrigins as p, AudioContent as r, EmbeddedBlobResource as s, AppContextToolDefinition as t, ImageContent as u, TextContent as v, ZodOutputSchema as w, ToolDefinition as x, ToolAnnotations as y };
@@ -1,4 +1,4 @@
1
- import { TypeOf, ZodRawShape, ZodType } from "zod";
1
+ import { $ZodType, output } from "zod/v4/core";
2
2
  //#region src/auth/types.d.ts
3
3
  type JwtClaims = Record<string, unknown> & {
4
4
  iss?: string;
@@ -181,22 +181,17 @@ interface MetricsOptions {
181
181
  type MetricsConfig = boolean | MetricsOptions;
182
182
  //#endregion
183
183
  //#region src/core/types.d.ts
184
- /**
185
- * Any zod schema. Aliased to zod's `ZodType` (no generics) — non-deprecated
186
- * in both v3 and v4. Use this when you need to type an individual schema;
187
- * for the `{ text: z.string() }` shape passed to `defineTool`'s
188
- * `inputSchema`, use `ZodRawShape`.
189
- */
190
- type ZodSchema = ZodType;
184
+ /** A Zod 4 schema, from Classic or Mini. */
185
+ type ZodSchema = $ZodType;
191
186
  /** A raw zod shape (`{ text: z.string() }`) — the format `defineTool`'s
192
187
  * `inputSchema` expects and the object shorthand accepted by `outputSchema`. */
193
- type ZodRawShape$1 = ZodRawShape;
194
- type ZodOutputSchema = ZodSchema | ZodRawShape$1;
188
+ type ZodRawShape = Record<string, ZodSchema>;
189
+ type ZodOutputSchema = ZodSchema | ZodRawShape;
195
190
  /**
196
191
  * Infer the parsed-output type of a zod raw shape — given
197
192
  * `{ text: ZodString, n: ZodNumber }`, produces `{ text: string, n: number }`.
198
193
  */
199
- type ShapeOutput<Shape extends ZodRawShape$1> = { [K in keyof Shape]: Shape[K] extends ZodType ? TypeOf<Shape[K]> : unknown; };
194
+ type ShapeOutput<Shape extends ZodRawShape> = { [K in keyof Shape]: output<Shape[K]>; };
200
195
  /**
201
196
  * Per-content-block metadata. Distinct from `ToolAnnotations`, which
202
197
  * decorates the tool as a whole — these decorate a single piece of
@@ -323,7 +318,7 @@ interface CreateAppContextInput {
323
318
  interface ToolVisibilityContext<TAppContext> {
324
319
  readonly appContext: TAppContext;
325
320
  }
326
- interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
321
+ interface ToolDefinitionBase<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
327
322
  readonly name: string;
328
323
  /** Human-readable display name shown to the user in MCP clients. Required. */
329
324
  readonly title: string;
@@ -335,18 +330,18 @@ interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawSh
335
330
  readonly outputSchema?: TOutput;
336
331
  readonly annotations?: ToolAnnotations;
337
332
  }
338
- type ToolHandler<TInput extends ZodRawShape$1 | undefined, TAppContext> = TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult>;
333
+ type ToolHandler<TInput extends ZodRawShape | undefined, TAppContext> = TInput extends ZodRawShape ? (args: ShapeOutput<TInput>, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult>;
339
334
  /** A tool that exists for every caller. Its handler receives the plain `ToolContext`. */
340
- interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
335
+ interface ToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
341
336
  readonly handler: ToolHandler<TInput, undefined>;
342
337
  }
343
338
  /** Input to `defineTool.withAppContext<TAppContext>()`. */
344
- interface AppContextToolDefinitionInput<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
339
+ interface AppContextToolDefinitionInput<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
345
340
  /** Synchronously decide whether this tool exists for the current caller. */
346
341
  readonly enabled?: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
347
342
  readonly handler: ToolHandler<TInput, TAppContext>;
348
343
  }
349
- interface AppContextToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
344
+ interface AppContextToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
350
345
  readonly requiresAppContext: true;
351
346
  }
352
347
  /** Type-erased element of `McpDefinition.tools`; per-tool generic typing
@@ -355,7 +350,7 @@ interface AnyToolDefinition<TAppContext = never> {
355
350
  readonly name: string;
356
351
  readonly title: string;
357
352
  readonly description: string;
358
- readonly inputSchema?: ZodRawShape$1 | undefined;
353
+ readonly inputSchema?: ZodRawShape | undefined;
359
354
  readonly strict?: boolean;
360
355
  readonly outputSchema?: ZodOutputSchema | undefined;
361
356
  readonly annotations?: ToolAnnotations;
@@ -410,4 +405,4 @@ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>
410
405
  readonly [McpDefinitionBrand]: never;
411
406
  };
412
407
  //#endregion
413
- export { McpClientInfo as A, ToolVisibilityContext as C, MetricsConfig as D, ZodSchema as E, McpAuthConfig as F, ProgressUpdate as M, ToolContext as N, MetricsOptions as O, JwtClaims as P, ToolHandlerResult as S, ZodRawShape$1 as T, ResourceLinkIcon as _, ContentBlock as a, ToolContent as b, EmbeddedResource as c, JsonValue as d, JsonValueInput as f, ResourceLink as g, McpDefinitionInput as h, ContentAnnotations as i, McpProtocolEra as j, AuthContext as k, EmbeddedTextResource as l, McpDefinition as m, AppContextToolDefinitionInput as n, CreateAppContextInput as o, McpAllowedOrigins as p, AudioContent as r, EmbeddedBlobResource as s, AppContextToolDefinition as t, ImageContent as u, TextContent as v, ZodOutputSchema as w, ToolDefinition as x, ToolAnnotations as y };
408
+ export { McpClientInfo as A, ToolVisibilityContext as C, MetricsConfig as D, ZodSchema as E, McpAuthConfig as F, ProgressUpdate as M, ToolContext as N, MetricsOptions as O, JwtClaims as P, ToolHandlerResult as S, ZodRawShape as T, ResourceLinkIcon as _, ContentBlock as a, ToolContent as b, EmbeddedResource as c, JsonValue as d, JsonValueInput as f, ResourceLink as g, McpDefinitionInput as h, ContentAnnotations as i, McpProtocolEra as j, AuthContext as k, EmbeddedTextResource as l, McpDefinition as m, AppContextToolDefinitionInput as n, CreateAppContextInput as o, McpAllowedOrigins as p, AudioContent as r, EmbeddedBlobResource as s, AppContextToolDefinition as t, ImageContent as u, TextContent as v, ZodOutputSchema as w, ToolDefinition as x, ToolAnnotations as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/mcp-js",
3
- "version": "3.0.5",
3
+ "version": "4.0.0-rc.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -94,7 +94,7 @@
94
94
  }
95
95
  },
96
96
  "bin": {
97
- "lovable-mcp-extract-manifest": "./dist/cli/extract-manifest.cjs"
97
+ "lovable-mcp-extract-manifest": "./dist/cli/extract-manifest.js"
98
98
  },
99
99
  "files": [
100
100
  "dist"
@@ -109,13 +109,12 @@
109
109
  "license": "MIT",
110
110
  "dependencies": {
111
111
  "@modelcontextprotocol/server": "2.0.0",
112
- "@modelcontextprotocol/sdk": "1.28.0",
113
112
  "esbuild": "^0.27.0",
114
113
  "jose": "^6.2.2"
115
114
  },
116
115
  "peerDependencies": {
117
116
  "vite": ">=5.0.0 <9.0.0",
118
- "zod": "^3.25 || ^4.0"
117
+ "zod": "^3.25.76 || ^4.0.0"
119
118
  },
120
119
  "devDependencies": {
121
120
  "@types/node": "22.13.13",
@@ -1,111 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
24
- let _modelcontextprotocol_sdk_server_zod_json_schema_compat_js = require("@modelcontextprotocol/sdk/server/zod-json-schema-compat.js");
25
- let zod_v3 = require("zod/v3");
26
- zod_v3 = __toESM(zod_v3, 1);
27
- let zod_v4_mini = require("zod/v4-mini");
28
- zod_v4_mini = __toESM(zod_v4_mini, 1);
29
- //#region src/core/schema.ts
30
- function isZodSchema(definition) {
31
- return (typeof definition === "object" || typeof definition === "function") && definition !== null && typeof definition.safeParse === "function";
32
- }
33
- function strictObjectFromShape(shape) {
34
- const values = Object.values(shape);
35
- if (values.length === 0) return zod_v4_mini.strictObject({});
36
- const v4Count = values.filter((value) => (0, _modelcontextprotocol_sdk_server_zod_compat_js.isZ4Schema)(value)).length;
37
- if (v4Count === values.length) return zod_v4_mini.strictObject(shape);
38
- if (v4Count === 0) return zod_v3.object(shape).strict();
39
- throw new Error("Mixed Zod versions detected in object shape.");
40
- }
41
- function schemaFromDefinition(definition, strict) {
42
- if (isZodSchema(definition)) return definition;
43
- return strict ? strictObjectFromShape(definition) : (0, _modelcontextprotocol_sdk_server_zod_compat_js.objectFromShape)(definition);
44
- }
45
- const NON_JSON_ZOD3_OUTPUTS = /* @__PURE__ */ new Set([
46
- "ZodBigInt",
47
- "ZodDate",
48
- "ZodFunction",
49
- "ZodMap",
50
- "ZodNaN",
51
- "ZodPromise",
52
- "ZodSet",
53
- "ZodSymbol",
54
- "ZodUndefined",
55
- "ZodVoid"
56
- ]);
57
- function unsupportedZod3Output(schema, seen = /* @__PURE__ */ new Set()) {
58
- if (seen.has(schema)) return void 0;
59
- seen.add(schema);
60
- const definition = schema._def;
61
- if (!definition) return void 0;
62
- if (definition.effect?.type === "transform") return "Transforms cannot be represented in JSON Schema";
63
- const typeName = definition.typeName;
64
- if (typeof typeName === "string" && NON_JSON_ZOD3_OUTPUTS.has(typeName)) return `${typeName} does not produce a JSON value`;
65
- const shape = definition.shape;
66
- if (typeof shape === "function") {
67
- const fields = shape();
68
- for (const field of Object.values(fields)) {
69
- const issue = unsupportedZod3Output(field, seen);
70
- if (issue) return issue;
71
- }
72
- }
73
- const getter = definition.getter;
74
- if (typeof getter === "function") {
75
- const issue = unsupportedZod3Output(getter(), seen);
76
- if (issue) return issue;
77
- }
78
- for (const value of Object.values(definition)) if (Array.isArray(value)) for (const entry of value) {
79
- if (!isZodSchema(entry)) continue;
80
- const issue = unsupportedZod3Output(entry, seen);
81
- if (issue) return issue;
82
- }
83
- else if (value && typeof value === "object" && isZodSchema(value)) {
84
- const issue = unsupportedZod3Output(value, seen);
85
- if (issue) return issue;
86
- }
87
- }
88
- function jsonSchemaFromDefinition(definition, pipeStrategy, strict) {
89
- const schema = schemaFromDefinition(definition, strict);
90
- if (pipeStrategy === "output") {
91
- const issue = unsupportedZod3Output(schema);
92
- if (issue) throw new Error(issue);
93
- }
94
- return (0, _modelcontextprotocol_sdk_server_zod_json_schema_compat_js.toJsonSchemaCompat)(schema, {
95
- target: "draft-2020-12",
96
- pipeStrategy
97
- });
98
- }
99
- //#endregion
100
- Object.defineProperty(exports, "jsonSchemaFromDefinition", {
101
- enumerable: true,
102
- get: function() {
103
- return jsonSchemaFromDefinition;
104
- }
105
- });
106
- Object.defineProperty(exports, "schemaFromDefinition", {
107
- enumerable: true,
108
- get: function() {
109
- return schemaFromDefinition;
110
- }
111
- });
@@ -1,76 +0,0 @@
1
- import { isZ4Schema, objectFromShape } from "@modelcontextprotocol/sdk/server/zod-compat.js";
2
- import { toJsonSchemaCompat } from "@modelcontextprotocol/sdk/server/zod-json-schema-compat.js";
3
- import * as z3 from "zod/v3";
4
- import * as z4mini from "zod/v4-mini";
5
- //#region src/core/schema.ts
6
- function isZodSchema(definition) {
7
- return (typeof definition === "object" || typeof definition === "function") && definition !== null && typeof definition.safeParse === "function";
8
- }
9
- function strictObjectFromShape(shape) {
10
- const values = Object.values(shape);
11
- if (values.length === 0) return z4mini.strictObject({});
12
- const v4Count = values.filter((value) => isZ4Schema(value)).length;
13
- if (v4Count === values.length) return z4mini.strictObject(shape);
14
- if (v4Count === 0) return z3.object(shape).strict();
15
- throw new Error("Mixed Zod versions detected in object shape.");
16
- }
17
- function schemaFromDefinition(definition, strict) {
18
- if (isZodSchema(definition)) return definition;
19
- return strict ? strictObjectFromShape(definition) : objectFromShape(definition);
20
- }
21
- const NON_JSON_ZOD3_OUTPUTS = /* @__PURE__ */ new Set([
22
- "ZodBigInt",
23
- "ZodDate",
24
- "ZodFunction",
25
- "ZodMap",
26
- "ZodNaN",
27
- "ZodPromise",
28
- "ZodSet",
29
- "ZodSymbol",
30
- "ZodUndefined",
31
- "ZodVoid"
32
- ]);
33
- function unsupportedZod3Output(schema, seen = /* @__PURE__ */ new Set()) {
34
- if (seen.has(schema)) return void 0;
35
- seen.add(schema);
36
- const definition = schema._def;
37
- if (!definition) return void 0;
38
- if (definition.effect?.type === "transform") return "Transforms cannot be represented in JSON Schema";
39
- const typeName = definition.typeName;
40
- if (typeof typeName === "string" && NON_JSON_ZOD3_OUTPUTS.has(typeName)) return `${typeName} does not produce a JSON value`;
41
- const shape = definition.shape;
42
- if (typeof shape === "function") {
43
- const fields = shape();
44
- for (const field of Object.values(fields)) {
45
- const issue = unsupportedZod3Output(field, seen);
46
- if (issue) return issue;
47
- }
48
- }
49
- const getter = definition.getter;
50
- if (typeof getter === "function") {
51
- const issue = unsupportedZod3Output(getter(), seen);
52
- if (issue) return issue;
53
- }
54
- for (const value of Object.values(definition)) if (Array.isArray(value)) for (const entry of value) {
55
- if (!isZodSchema(entry)) continue;
56
- const issue = unsupportedZod3Output(entry, seen);
57
- if (issue) return issue;
58
- }
59
- else if (value && typeof value === "object" && isZodSchema(value)) {
60
- const issue = unsupportedZod3Output(value, seen);
61
- if (issue) return issue;
62
- }
63
- }
64
- function jsonSchemaFromDefinition(definition, pipeStrategy, strict) {
65
- const schema = schemaFromDefinition(definition, strict);
66
- if (pipeStrategy === "output") {
67
- const issue = unsupportedZod3Output(schema);
68
- if (issue) throw new Error(issue);
69
- }
70
- return toJsonSchemaCompat(schema, {
71
- target: "draft-2020-12",
72
- pipeStrategy
73
- });
74
- }
75
- //#endregion
76
- export { schemaFromDefinition as n, jsonSchemaFromDefinition as t };