@lovable.dev/mcp-js 3.2.1 → 4.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.internal.md +5 -3
- package/README.md +18 -1
- package/dist/{authorize-DUEaDXjU.d.ts → authorize-8crkySbp.d.ts} +1 -1
- package/dist/{authorize-bDiUiJco.d.cts → authorize-BZdUmD37.d.cts} +1 -1
- package/dist/{base-D2d7lJY5.d.cts → base-CChLZaEN.d.cts} +1 -1
- package/dist/{base-CLO7XsxC.d.ts → base-DQPu0cno.d.ts} +1 -1
- package/dist/cli/extract-manifest.cjs +3 -3
- package/dist/cli/extract-manifest.js +3 -3
- package/dist/{cors-CAjdoGLn.cjs → cors-Ct-kdMcl.cjs} +1 -1
- package/dist/{cors-DqGRvw0A.js → cors-Ct8SFh-_.js} +1 -1
- package/dist/{errors-CljrUVby.js → errors-Cul5Uyfw.js} +1 -1
- package/dist/{errors-CLfxIB-l.cjs → errors-ebgNFNvm.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{io-CFyHLyvs.d.ts → io-4N9Hcw0w.d.ts} +1 -1
- package/dist/{io-DfUvQ-SV.d.cts → io-Be8y8E2V.d.cts} +1 -1
- package/dist/{io-C-KJpQde.cjs → io-Bf4Narx6.cjs} +2 -2
- package/dist/{io-DewJxgO4.js → io-VMIaguRH.js} +2 -2
- package/dist/{mcp-FRaH2mQW.cjs → mcp-By6C2M4i.cjs} +6 -6
- package/dist/{mcp-ClL3tmtt.js → mcp-DWxIy07i.js} +5 -5
- package/dist/{package-B0CFKfHW.cjs → package-CBMX__7C.cjs} +1 -1
- package/dist/{package-tjBEL0hN.js → package-Ci4yKJUI.js} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +3 -3
- package/dist/protocols/mcp/index.d.ts +3 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/schema-CjFpqCEP.cjs +27 -0
- package/dist/schema-DBTR1XbM.js +16 -0
- package/dist/stacks/supabase/index.cjs +2 -2
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +2 -2
- package/dist/stacks/supabase/vite.cjs +1 -1
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +1 -1
- package/dist/stacks/tanstack/index.cjs +2 -2
- package/dist/stacks/tanstack/index.d.cts +2 -2
- package/dist/stacks/tanstack/index.d.ts +2 -2
- package/dist/stacks/tanstack/index.js +2 -2
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/testing/index.cjs +4 -4
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +3 -3
- package/dist/{tool-result-DcNioyiI.js → tool-result-teeTDoM1.js} +3 -3
- package/dist/{tool-result-rU-PpNNi.cjs → tool-result-yqOfZUOP.cjs} +4 -4
- package/dist/{types-CAFCH0yK.d.ts → types-CyDJi9Jb.d.cts} +13 -18
- package/dist/{types-CAFCH0yK.d.cts → types-CyDJi9Jb.d.ts} +13 -18
- package/package.json +5 -6
- package/dist/schema-DNMsvJwE.cjs +0 -111
- package/dist/schema-JK_1KkOa.js +0 -76
package/README.internal.md
CHANGED
|
@@ -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
|
-
-
|
|
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
|
|
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",
|
|
@@ -86,6 +86,23 @@ The server advertises the [Skills extension](https://modelcontextprotocol.io/ext
|
|
|
86
86
|
|
|
87
87
|
Fallback is reference text, not installation, execution or a permission grant. It preserves source text rather than summarizing it or rewriting links. A capable client that omits the declaration can receive both representations, even if its native skill loader is disabled. Host context limits still apply: the SDK does not truncate instructions or guarantee that a host will retain them. Build output lists published file sizes; the standard recommends at most 512 files and 16 MiB per skill, and fallback instructions should be substantially smaller for practical model context. Omit `skills` to retain existing tools-only behavior.
|
|
88
88
|
|
|
89
|
+
## Upgrade to 4.x without migrating app forms
|
|
90
|
+
|
|
91
|
+
MCP schemas must use Zod 4 Classic (`zod/v4`) or Mini (`zod/v4-mini`). The peer
|
|
92
|
+
range is `^3.25.76 || ^4.0.0`; TypeScript consumers need 5.5 or newer. Zod
|
|
93
|
+
3.25.76 includes v4 at `zod/v4` while its root `zod` export remains v3.
|
|
94
|
+
|
|
95
|
+
For an app on Zod 3, upgrade within that major to `^3.25.76`, then change only
|
|
96
|
+
MCP schema imports to `zod/v4`. Leave form schemas, resolvers, and their root
|
|
97
|
+
imports unchanged. Shared v3 schemas cannot be passed to MCP tools: define a
|
|
98
|
+
v4 MCP schema or migrate the shared schema and its consumers deliberately.
|
|
99
|
+
Zod 4 apps can keep their root imports, though `zod/v4` makes the contract
|
|
100
|
+
explicit. Rebuild and run `lovable-mcp-extract-manifest` after upgrading.
|
|
101
|
+
|
|
102
|
+
Schema APIs can differ between v3 and v4; fix MCP schema errors rather than
|
|
103
|
+
casting them away. V3 MCP schemas are rejected during `defineMcp`. The MCP
|
|
104
|
+
transport, stateless legacy support, and OAuth configuration are unchanged.
|
|
105
|
+
|
|
89
106
|
## What the plugin emits
|
|
90
107
|
|
|
91
108
|
| URL | File | Purpose |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as McpProtocolEra } from "./types-
|
|
1
|
+
import { M as McpProtocolEra } from "./types-CyDJi9Jb.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,4 +1,4 @@
|
|
|
1
|
-
import { M as McpProtocolEra } from "./types-
|
|
1
|
+
import { M as McpProtocolEra } from "./types-CyDJi9Jb.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,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/
|
|
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-
|
|
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-Bf4Narx6.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/
|
|
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-
|
|
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-VMIaguRH.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-
|
|
2
|
+
const require_package = require("./package-CBMX__7C.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-
|
|
2
|
+
import { t as version } from "./package-Ci4yKJUI.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,6 +1,6 @@
|
|
|
1
1
|
import { o as parseSafeUrl, s as trimTrailingSlash, u as resolveMetricsConfig } from "./logger-CpLgYbCG.js";
|
|
2
2
|
import { n as validateSkills } from "./format-DKEuO8Tn.js";
|
|
3
|
-
import { t as jsonSchemaFromDefinition } from "./schema-
|
|
3
|
+
import { t as jsonSchemaFromDefinition } from "./schema-DBTR1XbM.js";
|
|
4
4
|
//#region src/core/define.ts
|
|
5
5
|
function toolRequiresAppContext(tool) {
|
|
6
6
|
return "requiresAppContext" in tool && tool.requiresAppContext === true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_schema = require("./schema-DNMsvJwE.cjs");
|
|
2
1
|
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
3
2
|
const require_format = require("./format-DDzvc92Z.cjs");
|
|
3
|
+
const require_schema = require("./schema-CjFpqCEP.cjs");
|
|
4
4
|
//#region src/core/define.ts
|
|
5
5
|
function toolRequiresAppContext(tool) {
|
|
6
6
|
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-
|
|
3
|
+
const require_errors = require("./errors-ebgNFNvm.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 AuthContext, C as ToolVisibilityContext, D as Skill, E as ZodSchema, F as JwtClaims, I as McpAuthConfig, M as McpProtocolEra, N as ProgressUpdate, O as MetricsConfig, P as ToolContext, 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 McpClientInfo, k as MetricsOptions, 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-
|
|
1
|
+
import { A as AuthContext, C as ToolVisibilityContext, D as Skill, E as ZodSchema, F as JwtClaims, I as McpAuthConfig, M as McpProtocolEra, N as ProgressUpdate, O as MetricsConfig, P as ToolContext, 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 McpClientInfo, k as MetricsOptions, 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-CyDJi9Jb.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 AuthContext, C as ToolVisibilityContext, D as Skill, E as ZodSchema, F as JwtClaims, I as McpAuthConfig, M as McpProtocolEra, N as ProgressUpdate, O as MetricsConfig, P as ToolContext, 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 McpClientInfo, k as MetricsOptions, 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-
|
|
1
|
+
import { A as AuthContext, C as ToolVisibilityContext, D as Skill, E as ZodSchema, F as JwtClaims, I as McpAuthConfig, M as McpProtocolEra, N as ProgressUpdate, O as MetricsConfig, P as ToolContext, 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 McpClientInfo, k as MetricsOptions, 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-CyDJi9Jb.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-
|
|
2
|
+
import { a as ToolContext, i as AuthContext, o as defineMcp, s as defineTool, t as ToolError } from "./errors-Cul5Uyfw.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,5 +1,5 @@
|
|
|
1
|
-
const require_schema = require("./schema-
|
|
2
|
-
const require_package = require("./package-
|
|
1
|
+
const require_schema = require("./schema-CjFpqCEP.cjs");
|
|
2
|
+
const require_package = require("./package-CBMX__7C.cjs");
|
|
3
3
|
const require_hooks = require("./hooks-xQl3EkDa.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-
|
|
2
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as jsonSchemaFromDefinition } from "./schema-DBTR1XbM.js";
|
|
2
|
+
import { t as version } from "./package-Ci4yKJUI.js";
|
|
3
3
|
import { a as isFileMissing, i as readSupabaseProjectRef, r as skillImportVitePlugin } from "./hooks-BOdDe251.js";
|
|
4
4
|
import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, resolve } from "node:path";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_schema = require("./schema-DNMsvJwE.cjs");
|
|
2
1
|
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
2
|
+
const require_schema = require("./schema-CjFpqCEP.cjs");
|
|
3
|
+
const require_errors = require("./errors-ebgNFNvm.cjs");
|
|
4
|
+
const require_cors = require("./cors-Ct-kdMcl.cjs");
|
|
5
|
+
const require_tool_result = require("./tool-result-yqOfZUOP.cjs");
|
|
6
|
+
let zod_v4_core = require("zod/v4/core");
|
|
7
7
|
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
8
8
|
//#region src/core/content.ts
|
|
9
9
|
/** Join the text of a result's `type: "text"` blocks into one string, dropping
|
|
@@ -190,7 +190,7 @@ function standardSchemaFromDefinition(definition, strict) {
|
|
|
190
190
|
version: 1,
|
|
191
191
|
vendor: "zod",
|
|
192
192
|
validate: async (value) => {
|
|
193
|
-
const parsed = await (0,
|
|
193
|
+
const parsed = await (0, zod_v4_core.safeParseAsync)(schema, value);
|
|
194
194
|
return parsed.success ? { value: parsed.data } : { issues: zodIssues(parsed.error) };
|
|
195
195
|
},
|
|
196
196
|
jsonSchema: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { i as log, r as describeError } from "./logger-CpLgYbCG.js";
|
|
2
|
-
import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-
|
|
3
|
-
import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-
|
|
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-
|
|
5
|
-
import { t as finalizeToolResult } from "./tool-result-
|
|
6
|
-
import { safeParseAsync } from "
|
|
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-Cul5Uyfw.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-Ct8SFh-_.js";
|
|
5
|
+
import { t as finalizeToolResult } from "./tool-result-teeTDoM1.js";
|
|
6
|
+
import { safeParseAsync } from "zod/v4/core";
|
|
7
7
|
import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler } from "@modelcontextprotocol/server";
|
|
8
8
|
//#region src/core/content.ts
|
|
9
9
|
/** Join the text of a result's `type: "text"` blocks into one string, dropping
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CyDJi9Jb.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-CChLZaEN.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-BZdUmD37.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-
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CyDJi9Jb.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-DQPu0cno.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-8crkySbp.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-
|
|
1
|
+
import { t as createMcpProtocolHandler } from "../../mcp-DWxIy07i.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-
|
|
3
|
+
const require_cors = require("../cors-Ct-kdMcl.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-
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../types-CyDJi9Jb.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-CChLZaEN.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-BZdUmD37.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-
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../types-CyDJi9Jb.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-DQPu0cno.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-8crkySbp.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-
|
|
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-Ct8SFh-_.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-
|
|
3
|
+
const require_cors = require("../../cors-Ct-kdMcl.cjs");
|
|
4
4
|
const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
|
|
5
|
-
const require_mcp = require("../../mcp-
|
|
5
|
+
const require_mcp = require("../../mcp-By6C2M4i.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-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CyDJi9Jb.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-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CyDJi9Jb.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-
|
|
2
|
+
import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-Ct8SFh-_.js";
|
|
3
3
|
import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
|
|
4
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
4
|
+
import { t as createMcpProtocolHandler } from "../../mcp-DWxIy07i.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-
|
|
5
|
+
const require_package = require("../../package-CBMX__7C.cjs");
|
|
6
6
|
const require_hooks = require("../../hooks-xQl3EkDa.cjs");
|
|
7
7
|
const require_paths = require("../../paths-OP318a6c.cjs");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../../package-
|
|
1
|
+
import { t as version } from "../../package-Ci4yKJUI.js";
|
|
2
2
|
import { a as isFileMissing, i as readSupabaseProjectRef, n as skillImportEsbuildPlugin, t as isSkillImportInput } from "../../hooks-BOdDe251.js";
|
|
3
3
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|
|
4
4
|
import { lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cors = require("../../cors-
|
|
3
|
-
const require_mcp = require("../../mcp-
|
|
2
|
+
const require_cors = require("../../cors-Ct-kdMcl.cjs");
|
|
3
|
+
const require_mcp = require("../../mcp-By6C2M4i.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-
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CyDJi9Jb.cjs";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-BZdUmD37.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-
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CyDJi9Jb.js";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-8crkySbp.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-
|
|
2
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { c as createRecorderForRuntime } from "../../cors-Ct8SFh-_.js";
|
|
2
|
+
import { t as createMcpProtocolHandler } from "../../mcp-DWxIy07i.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/dist/testing/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_schema = require("../schema-
|
|
3
|
-
const require_tool_result = require("../tool-result-
|
|
2
|
+
const require_schema = require("../schema-CjFpqCEP.cjs");
|
|
3
|
+
const require_tool_result = require("../tool-result-yqOfZUOP.cjs");
|
|
4
4
|
const require_diagnostic = require("../diagnostic-ol9IE9Dl.cjs");
|
|
5
|
-
let
|
|
5
|
+
let zod_v4_core = require("zod/v4/core");
|
|
6
6
|
let _modelcontextprotocol_core = require("@modelcontextprotocol/core");
|
|
7
7
|
//#region src/testing/result.ts
|
|
8
8
|
async function assertToolResult(result, expected = {}) {
|
|
@@ -36,7 +36,7 @@ async function assertToolResult(result, expected = {}) {
|
|
|
36
36
|
if (expected.outputSchema && !value.isError) {
|
|
37
37
|
let valid = false;
|
|
38
38
|
try {
|
|
39
|
-
valid = value.structuredContent !== void 0 && (await (0,
|
|
39
|
+
valid = value.structuredContent !== void 0 && (await (0, zod_v4_core.safeParseAsync)(require_schema.schemaFromDefinition(expected.outputSchema, false), value.structuredContent)).success;
|
|
40
40
|
} catch {}
|
|
41
41
|
if (!valid) fail("result.output-schema", "Successful structuredContent must be present and match the declared outputSchema.");
|
|
42
42
|
}
|
package/dist/testing/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as ZodOutputSchema } from "../types-
|
|
1
|
+
import { w as ZodOutputSchema } from "../types-CyDJi9Jb.cjs";
|
|
2
2
|
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.cjs";
|
|
3
3
|
//#region src/testing/result.d.ts
|
|
4
4
|
interface ToolResultExpectation {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as ZodOutputSchema } from "../types-
|
|
1
|
+
import { w as ZodOutputSchema } from "../types-CyDJi9Jb.js";
|
|
2
2
|
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.js";
|
|
3
3
|
//#region src/testing/result.d.ts
|
|
4
4
|
interface ToolResultExpectation {
|
package/dist/testing/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as schemaFromDefinition } from "../schema-
|
|
2
|
-
import { n as isJsonValue, r as normalizeToolContent } from "../tool-result-
|
|
1
|
+
import { n as schemaFromDefinition } from "../schema-DBTR1XbM.js";
|
|
2
|
+
import { n as isJsonValue, r as normalizeToolContent } from "../tool-result-teeTDoM1.js";
|
|
3
3
|
import { t as McpCheckError } from "../diagnostic-ClI2_5MW.js";
|
|
4
|
-
import { safeParseAsync } from "
|
|
4
|
+
import { safeParseAsync } from "zod/v4/core";
|
|
5
5
|
import { CallToolResultSchema } from "@modelcontextprotocol/core";
|
|
6
6
|
//#region src/testing/result.ts
|
|
7
7
|
async function assertToolResult(result, expected = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as schemaFromDefinition } from "./schema-
|
|
2
|
-
import {
|
|
1
|
+
import { n as schemaFromDefinition } from "./schema-DBTR1XbM.js";
|
|
2
|
+
import { safeParseAsync } from "zod/v4/core";
|
|
3
3
|
//#region src/core/tool-result.ts
|
|
4
4
|
function normalizeResourceLinkIcon(icon) {
|
|
5
5
|
if (typeof icon.sizes !== "string") return icon;
|
|
@@ -46,7 +46,7 @@ async function finalizeToolResult(tool, result) {
|
|
|
46
46
|
if (structuredContent === void 0) return outputValidationError(`Output validation error: Tool ${tool.name} has an output schema but no structured content was provided`);
|
|
47
47
|
try {
|
|
48
48
|
const parsed = await safeParseAsync(schemaFromDefinition(tool.outputSchema, false), structuredContent);
|
|
49
|
-
if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${
|
|
49
|
+
if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${parsed.error.message}`);
|
|
50
50
|
structuredContent = parsed.data;
|
|
51
51
|
} catch {
|
|
52
52
|
return outputValidationError(`Output validation error: Could not validate structured content for tool ${tool.name}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_schema = require("./schema-
|
|
2
|
-
let
|
|
1
|
+
const require_schema = require("./schema-CjFpqCEP.cjs");
|
|
2
|
+
let zod_v4_core = require("zod/v4/core");
|
|
3
3
|
//#region src/core/tool-result.ts
|
|
4
4
|
function normalizeResourceLinkIcon(icon) {
|
|
5
5
|
if (typeof icon.sizes !== "string") return icon;
|
|
@@ -45,8 +45,8 @@ async function finalizeToolResult(tool, result) {
|
|
|
45
45
|
if (tool.outputSchema && !result.isError) {
|
|
46
46
|
if (structuredContent === void 0) return outputValidationError(`Output validation error: Tool ${tool.name} has an output schema but no structured content was provided`);
|
|
47
47
|
try {
|
|
48
|
-
const parsed = await (0,
|
|
49
|
-
if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${
|
|
48
|
+
const parsed = await (0, zod_v4_core.safeParseAsync)(require_schema.schemaFromDefinition(tool.outputSchema, false), structuredContent);
|
|
49
|
+
if (!parsed.success) return outputValidationError(`Output validation error: Invalid structured content for tool ${tool.name}: ${parsed.error.message}`);
|
|
50
50
|
structuredContent = parsed.data;
|
|
51
51
|
} catch {
|
|
52
52
|
return outputValidationError(`Output validation error: Could not validate structured content for tool ${tool.name}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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;
|
|
@@ -186,22 +186,17 @@ interface Skill {
|
|
|
186
186
|
}
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region src/core/types.d.ts
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
* in both v3 and v4. Use this when you need to type an individual schema;
|
|
192
|
-
* for the `{ text: z.string() }` shape passed to `defineTool`'s
|
|
193
|
-
* `inputSchema`, use `ZodRawShape`.
|
|
194
|
-
*/
|
|
195
|
-
type ZodSchema = ZodType;
|
|
189
|
+
/** A Zod 4 schema, from Classic or Mini. */
|
|
190
|
+
type ZodSchema = $ZodType;
|
|
196
191
|
/** A raw zod shape (`{ text: z.string() }`) — the format `defineTool`'s
|
|
197
192
|
* `inputSchema` expects and the object shorthand accepted by `outputSchema`. */
|
|
198
|
-
type ZodRawShape
|
|
199
|
-
type ZodOutputSchema = ZodSchema | ZodRawShape
|
|
193
|
+
type ZodRawShape = Record<string, ZodSchema>;
|
|
194
|
+
type ZodOutputSchema = ZodSchema | ZodRawShape;
|
|
200
195
|
/**
|
|
201
196
|
* Infer the parsed-output type of a zod raw shape — given
|
|
202
197
|
* `{ text: ZodString, n: ZodNumber }`, produces `{ text: string, n: number }`.
|
|
203
198
|
*/
|
|
204
|
-
type ShapeOutput<Shape extends ZodRawShape
|
|
199
|
+
type ShapeOutput<Shape extends ZodRawShape> = { [K in keyof Shape]: output<Shape[K]>; };
|
|
205
200
|
/**
|
|
206
201
|
* Per-content-block metadata. Distinct from `ToolAnnotations`, which
|
|
207
202
|
* decorates the tool as a whole — these decorate a single piece of
|
|
@@ -328,7 +323,7 @@ interface CreateAppContextInput {
|
|
|
328
323
|
interface ToolVisibilityContext<TAppContext> {
|
|
329
324
|
readonly appContext: TAppContext;
|
|
330
325
|
}
|
|
331
|
-
interface ToolDefinitionBase<TInput extends ZodRawShape
|
|
326
|
+
interface ToolDefinitionBase<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
|
|
332
327
|
readonly name: string;
|
|
333
328
|
/** Human-readable display name shown to the user in MCP clients. Required. */
|
|
334
329
|
readonly title: string;
|
|
@@ -340,18 +335,18 @@ interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawSh
|
|
|
340
335
|
readonly outputSchema?: TOutput;
|
|
341
336
|
readonly annotations?: ToolAnnotations;
|
|
342
337
|
}
|
|
343
|
-
type ToolHandler<TInput extends ZodRawShape
|
|
338
|
+
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>;
|
|
344
339
|
/** A tool that exists for every caller. Its handler receives the plain `ToolContext`. */
|
|
345
|
-
interface ToolDefinition<TInput extends ZodRawShape
|
|
340
|
+
interface ToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
|
|
346
341
|
readonly handler: ToolHandler<TInput, undefined>;
|
|
347
342
|
}
|
|
348
343
|
/** Input to `defineTool.withAppContext<TAppContext>()`. */
|
|
349
|
-
interface AppContextToolDefinitionInput<TInput extends ZodRawShape
|
|
344
|
+
interface AppContextToolDefinitionInput<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
|
|
350
345
|
/** Synchronously decide whether this tool exists for the current caller. */
|
|
351
346
|
readonly enabled?: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
|
|
352
347
|
readonly handler: ToolHandler<TInput, TAppContext>;
|
|
353
348
|
}
|
|
354
|
-
interface AppContextToolDefinition<TInput extends ZodRawShape
|
|
349
|
+
interface AppContextToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
|
|
355
350
|
readonly requiresAppContext: true;
|
|
356
351
|
}
|
|
357
352
|
/** Type-erased element of `McpDefinition.tools`; per-tool generic typing
|
|
@@ -360,7 +355,7 @@ interface AnyToolDefinition<TAppContext = never> {
|
|
|
360
355
|
readonly name: string;
|
|
361
356
|
readonly title: string;
|
|
362
357
|
readonly description: string;
|
|
363
|
-
readonly inputSchema?: ZodRawShape
|
|
358
|
+
readonly inputSchema?: ZodRawShape | undefined;
|
|
364
359
|
readonly strict?: boolean;
|
|
365
360
|
readonly outputSchema?: ZodOutputSchema | undefined;
|
|
366
361
|
readonly annotations?: ToolAnnotations;
|
|
@@ -416,4 +411,4 @@ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>
|
|
|
416
411
|
readonly [McpDefinitionBrand]: never;
|
|
417
412
|
};
|
|
418
413
|
//#endregion
|
|
419
|
-
export { AuthContext as A, ToolVisibilityContext as C, Skill as D, ZodSchema as E, JwtClaims as F, McpAuthConfig as I, McpProtocolEra as M, ProgressUpdate as N, MetricsConfig as O, ToolContext as P, ToolHandlerResult as S, ZodRawShape
|
|
414
|
+
export { AuthContext as A, ToolVisibilityContext as C, Skill as D, ZodSchema as E, JwtClaims as F, McpAuthConfig as I, McpProtocolEra as M, ProgressUpdate as N, MetricsConfig as O, ToolContext 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, McpClientInfo as j, MetricsOptions 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 {
|
|
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;
|
|
@@ -186,22 +186,17 @@ interface Skill {
|
|
|
186
186
|
}
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region src/core/types.d.ts
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
* in both v3 and v4. Use this when you need to type an individual schema;
|
|
192
|
-
* for the `{ text: z.string() }` shape passed to `defineTool`'s
|
|
193
|
-
* `inputSchema`, use `ZodRawShape`.
|
|
194
|
-
*/
|
|
195
|
-
type ZodSchema = ZodType;
|
|
189
|
+
/** A Zod 4 schema, from Classic or Mini. */
|
|
190
|
+
type ZodSchema = $ZodType;
|
|
196
191
|
/** A raw zod shape (`{ text: z.string() }`) — the format `defineTool`'s
|
|
197
192
|
* `inputSchema` expects and the object shorthand accepted by `outputSchema`. */
|
|
198
|
-
type ZodRawShape
|
|
199
|
-
type ZodOutputSchema = ZodSchema | ZodRawShape
|
|
193
|
+
type ZodRawShape = Record<string, ZodSchema>;
|
|
194
|
+
type ZodOutputSchema = ZodSchema | ZodRawShape;
|
|
200
195
|
/**
|
|
201
196
|
* Infer the parsed-output type of a zod raw shape — given
|
|
202
197
|
* `{ text: ZodString, n: ZodNumber }`, produces `{ text: string, n: number }`.
|
|
203
198
|
*/
|
|
204
|
-
type ShapeOutput<Shape extends ZodRawShape
|
|
199
|
+
type ShapeOutput<Shape extends ZodRawShape> = { [K in keyof Shape]: output<Shape[K]>; };
|
|
205
200
|
/**
|
|
206
201
|
* Per-content-block metadata. Distinct from `ToolAnnotations`, which
|
|
207
202
|
* decorates the tool as a whole — these decorate a single piece of
|
|
@@ -328,7 +323,7 @@ interface CreateAppContextInput {
|
|
|
328
323
|
interface ToolVisibilityContext<TAppContext> {
|
|
329
324
|
readonly appContext: TAppContext;
|
|
330
325
|
}
|
|
331
|
-
interface ToolDefinitionBase<TInput extends ZodRawShape
|
|
326
|
+
interface ToolDefinitionBase<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
|
|
332
327
|
readonly name: string;
|
|
333
328
|
/** Human-readable display name shown to the user in MCP clients. Required. */
|
|
334
329
|
readonly title: string;
|
|
@@ -340,18 +335,18 @@ interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawSh
|
|
|
340
335
|
readonly outputSchema?: TOutput;
|
|
341
336
|
readonly annotations?: ToolAnnotations;
|
|
342
337
|
}
|
|
343
|
-
type ToolHandler<TInput extends ZodRawShape
|
|
338
|
+
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>;
|
|
344
339
|
/** A tool that exists for every caller. Its handler receives the plain `ToolContext`. */
|
|
345
|
-
interface ToolDefinition<TInput extends ZodRawShape
|
|
340
|
+
interface ToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
|
|
346
341
|
readonly handler: ToolHandler<TInput, undefined>;
|
|
347
342
|
}
|
|
348
343
|
/** Input to `defineTool.withAppContext<TAppContext>()`. */
|
|
349
|
-
interface AppContextToolDefinitionInput<TInput extends ZodRawShape
|
|
344
|
+
interface AppContextToolDefinitionInput<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
|
|
350
345
|
/** Synchronously decide whether this tool exists for the current caller. */
|
|
351
346
|
readonly enabled?: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
|
|
352
347
|
readonly handler: ToolHandler<TInput, TAppContext>;
|
|
353
348
|
}
|
|
354
|
-
interface AppContextToolDefinition<TInput extends ZodRawShape
|
|
349
|
+
interface AppContextToolDefinition<TInput extends ZodRawShape | undefined = ZodRawShape | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
|
|
355
350
|
readonly requiresAppContext: true;
|
|
356
351
|
}
|
|
357
352
|
/** Type-erased element of `McpDefinition.tools`; per-tool generic typing
|
|
@@ -360,7 +355,7 @@ interface AnyToolDefinition<TAppContext = never> {
|
|
|
360
355
|
readonly name: string;
|
|
361
356
|
readonly title: string;
|
|
362
357
|
readonly description: string;
|
|
363
|
-
readonly inputSchema?: ZodRawShape
|
|
358
|
+
readonly inputSchema?: ZodRawShape | undefined;
|
|
364
359
|
readonly strict?: boolean;
|
|
365
360
|
readonly outputSchema?: ZodOutputSchema | undefined;
|
|
366
361
|
readonly annotations?: ToolAnnotations;
|
|
@@ -416,4 +411,4 @@ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>
|
|
|
416
411
|
readonly [McpDefinitionBrand]: never;
|
|
417
412
|
};
|
|
418
413
|
//#endregion
|
|
419
|
-
export { AuthContext as A, ToolVisibilityContext as C, Skill as D, ZodSchema as E, JwtClaims as F, McpAuthConfig as I, McpProtocolEra as M, ProgressUpdate as N, MetricsConfig as O, ToolContext as P, ToolHandlerResult as S, ZodRawShape
|
|
414
|
+
export { AuthContext as A, ToolVisibilityContext as C, Skill as D, ZodSchema as E, JwtClaims as F, McpAuthConfig as I, McpProtocolEra as M, ProgressUpdate as N, MetricsConfig as O, ToolContext 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, McpClientInfo as j, MetricsOptions 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
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20"
|
|
6
6
|
},
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
},
|
|
124
124
|
"bin": {
|
|
125
125
|
"lovable-mcp-check": "./dist/cli/check-server.cjs",
|
|
126
|
-
"lovable-mcp-extract-manifest": "./dist/cli/extract-manifest.
|
|
126
|
+
"lovable-mcp-extract-manifest": "./dist/cli/extract-manifest.js"
|
|
127
127
|
},
|
|
128
128
|
"files": [
|
|
129
129
|
"dist",
|
|
@@ -142,24 +142,23 @@
|
|
|
142
142
|
"@modelcontextprotocol/client": "2.3.0",
|
|
143
143
|
"@modelcontextprotocol/core": "2.3.0",
|
|
144
144
|
"@modelcontextprotocol/server": "2.0.0",
|
|
145
|
-
"@modelcontextprotocol/sdk": "1.28.0",
|
|
146
145
|
"esbuild": "^0.27.0",
|
|
147
146
|
"jose": "^6.2.2",
|
|
148
147
|
"js-yaml": "^4.3.2"
|
|
149
148
|
},
|
|
150
149
|
"peerDependencies": {
|
|
151
150
|
"vite": ">=5.0.0 <9.0.0",
|
|
152
|
-
"zod": "^3.25 || ^4.0"
|
|
151
|
+
"zod": "^3.25.76 || ^4.0.0"
|
|
153
152
|
},
|
|
154
153
|
"devDependencies": {
|
|
154
|
+
"@types/js-yaml": "^4.0.9",
|
|
155
155
|
"@types/node": "22.13.13",
|
|
156
156
|
"rimraf": "^5.0.0",
|
|
157
157
|
"tsdown": "^0.22.5",
|
|
158
158
|
"typescript": "7.0.2",
|
|
159
159
|
"vite": "^7.3.1",
|
|
160
160
|
"vitest": "^4.1.5",
|
|
161
|
-
"zod": "^4.1.13"
|
|
162
|
-
"@types/js-yaml": "^4.0.9"
|
|
161
|
+
"zod": "^4.1.13"
|
|
163
162
|
},
|
|
164
163
|
"scripts": {
|
|
165
164
|
"build": "tsdown",
|
package/dist/schema-DNMsvJwE.cjs
DELETED
|
@@ -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
|
-
});
|
package/dist/schema-JK_1KkOa.js
DELETED
|
@@ -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 };
|