@lovable.dev/mcp-js 3.0.6 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -1
- package/dist/cli/check-server.cjs +61 -0
- package/dist/cli/check-server.d.cts +1 -0
- package/dist/cli/check-server.d.ts +1 -0
- package/dist/cli/check-server.js +62 -0
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-C3JU5DNM.js → cors-Df2tqbzV.js} +1 -1
- package/dist/{cors-dZ1AWhSq.cjs → cors-YjwGFsid.cjs} +1 -1
- package/dist/diagnostic-ClI2_5MW.js +11 -0
- package/dist/diagnostic-DRKjgCsW.d.cts +12 -0
- package/dist/diagnostic-DRKjgCsW.d.ts +12 -0
- package/dist/diagnostic-ol9IE9Dl.cjs +16 -0
- package/dist/{io-x7rcGbQj.js → io-BoS6dhC0.js} +1 -1
- package/dist/{io-DV_Bkma8.cjs → io-D_DKGquD.cjs} +1 -1
- package/dist/{mcp-woEauhMi.js → mcp-Bm89K_uU.js} +3 -69
- package/dist/{mcp-WUiGYfjS.cjs → mcp-aNWgpVIF.cjs} +5 -71
- package/dist/{package-DIh9b_dF.js → package-C6IcwY5Z.js} +1 -1
- package/dist/{package-CoGnWS6Y.cjs → package-Cl7NhnV4.cjs} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/stacks/supabase/index.cjs +2 -2
- package/dist/stacks/supabase/index.js +2 -2
- package/dist/stacks/supabase/vite.cjs +1 -1
- package/dist/stacks/supabase/vite.js +1 -1
- package/dist/stacks/tanstack/index.cjs +2 -2
- package/dist/stacks/tanstack/index.js +2 -2
- package/dist/testing/index.cjs +46 -0
- package/dist/testing/index.d.cts +10 -0
- package/dist/testing/index.d.ts +10 -0
- package/dist/testing/index.js +44 -0
- package/dist/testing/server.cjs +197 -0
- package/dist/testing/server.d.cts +31 -0
- package/dist/testing/server.d.ts +31 -0
- package/dist/testing/server.js +195 -0
- package/dist/tool-result-DcNioyiI.js +70 -0
- package/dist/tool-result-rU-PpNNi.cjs +87 -0
- package/package.json +26 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const require_schema = require("./schema-DNMsvJwE.cjs");
|
|
2
|
+
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
3
|
+
//#region src/core/tool-result.ts
|
|
4
|
+
function normalizeResourceLinkIcon(icon) {
|
|
5
|
+
if (typeof icon.sizes !== "string") return icon;
|
|
6
|
+
const { sizes, ...rest } = icon;
|
|
7
|
+
const normalized = sizes.trim();
|
|
8
|
+
return normalized === "" ? rest : {
|
|
9
|
+
...rest,
|
|
10
|
+
sizes: normalized.split(/\s+/)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function normalizeToolContent(content) {
|
|
14
|
+
return (content ?? []).map((block) => {
|
|
15
|
+
if (block.type !== "resource_link" || block.icons === void 0) return block;
|
|
16
|
+
return {
|
|
17
|
+
...block,
|
|
18
|
+
icons: block.icons.map(normalizeResourceLinkIcon)
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function outputValidationError(text) {
|
|
23
|
+
return {
|
|
24
|
+
content: [{
|
|
25
|
+
type: "text",
|
|
26
|
+
text
|
|
27
|
+
}],
|
|
28
|
+
isError: true
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function isJsonValue(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
32
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return true;
|
|
33
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
34
|
+
if (typeof value !== "object" || ancestors.has(value)) return false;
|
|
35
|
+
const prototype = Object.getPrototypeOf(value);
|
|
36
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) return false;
|
|
37
|
+
ancestors.add(value);
|
|
38
|
+
const valid = (Array.isArray(value) ? value : Object.values(value).filter((entry) => entry !== void 0)).every((entry) => isJsonValue(entry, ancestors));
|
|
39
|
+
ancestors.delete(value);
|
|
40
|
+
return valid;
|
|
41
|
+
}
|
|
42
|
+
async function finalizeToolResult(tool, result) {
|
|
43
|
+
const content = normalizeToolContent(result.content);
|
|
44
|
+
let structuredContent = result.structuredContent;
|
|
45
|
+
if (tool.outputSchema && !result.isError) {
|
|
46
|
+
if (structuredContent === void 0) return outputValidationError(`Output validation error: Tool ${tool.name} has an output schema but no structured content was provided`);
|
|
47
|
+
try {
|
|
48
|
+
const parsed = await (0, _modelcontextprotocol_sdk_server_zod_compat_js.safeParseAsync)(require_schema.schemaFromDefinition(tool.outputSchema, false), structuredContent);
|
|
49
|
+
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)}`);
|
|
50
|
+
structuredContent = parsed.data;
|
|
51
|
+
} catch {
|
|
52
|
+
return outputValidationError(`Output validation error: Could not validate structured content for tool ${tool.name}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (structuredContent !== void 0 && !isJsonValue(structuredContent)) {
|
|
56
|
+
if (!result.isError) return outputValidationError(`Output validation error: Tool ${tool.name} returned a non-JSON structured value`);
|
|
57
|
+
structuredContent = void 0;
|
|
58
|
+
}
|
|
59
|
+
if (structuredContent !== void 0 && (structuredContent === null || typeof structuredContent !== "object" || Array.isArray(structuredContent)) && !content.some((block) => block.type === "text")) content.push({
|
|
60
|
+
type: "text",
|
|
61
|
+
text: JSON.stringify(structuredContent)
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
content,
|
|
65
|
+
structuredContent,
|
|
66
|
+
isError: result.isError
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
Object.defineProperty(exports, "finalizeToolResult", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function() {
|
|
73
|
+
return finalizeToolResult;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "isJsonValue", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function() {
|
|
79
|
+
return isJsonValue;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(exports, "normalizeToolContent", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function() {
|
|
85
|
+
return normalizeToolContent;
|
|
86
|
+
}
|
|
87
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/mcp-js",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20"
|
|
6
6
|
},
|
|
@@ -82,6 +82,26 @@
|
|
|
82
82
|
"default": "./dist/stacks/supabase/index.cjs"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
+
"./testing": {
|
|
86
|
+
"import": {
|
|
87
|
+
"types": "./dist/testing/index.d.ts",
|
|
88
|
+
"default": "./dist/testing/index.js"
|
|
89
|
+
},
|
|
90
|
+
"require": {
|
|
91
|
+
"types": "./dist/testing/index.d.cts",
|
|
92
|
+
"default": "./dist/testing/index.cjs"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"./testing/server": {
|
|
96
|
+
"import": {
|
|
97
|
+
"types": "./dist/testing/server.d.ts",
|
|
98
|
+
"default": "./dist/testing/server.js"
|
|
99
|
+
},
|
|
100
|
+
"require": {
|
|
101
|
+
"types": "./dist/testing/server.d.cts",
|
|
102
|
+
"default": "./dist/testing/server.cjs"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
85
105
|
"./stacks/supabase/vite": {
|
|
86
106
|
"import": {
|
|
87
107
|
"types": "./dist/stacks/supabase/vite.d.ts",
|
|
@@ -94,6 +114,7 @@
|
|
|
94
114
|
}
|
|
95
115
|
},
|
|
96
116
|
"bin": {
|
|
117
|
+
"lovable-mcp-check": "./dist/cli/check-server.cjs",
|
|
97
118
|
"lovable-mcp-extract-manifest": "./dist/cli/extract-manifest.cjs"
|
|
98
119
|
},
|
|
99
120
|
"files": [
|
|
@@ -108,6 +129,8 @@
|
|
|
108
129
|
],
|
|
109
130
|
"license": "MIT",
|
|
110
131
|
"dependencies": {
|
|
132
|
+
"@modelcontextprotocol/client": "2.3.0",
|
|
133
|
+
"@modelcontextprotocol/core": "2.3.0",
|
|
111
134
|
"@modelcontextprotocol/server": "2.0.0",
|
|
112
135
|
"@modelcontextprotocol/sdk": "1.28.0",
|
|
113
136
|
"esbuild": "^0.27.0",
|
|
@@ -135,7 +158,8 @@
|
|
|
135
158
|
"format:check": "oxfmt --check src/ tests/",
|
|
136
159
|
"lint": "oxfmt --check src/ tests/ && oxlint -c ../../oxlint.config.ts src/ tests/",
|
|
137
160
|
"lint:fix": "oxfmt --write src/ tests/ && oxlint -c ../../oxlint.config.ts --fix src/ tests/",
|
|
138
|
-
"test": "vitest run --project unit && npm run test:package:zod",
|
|
161
|
+
"test": "vitest run --project unit && npm run test:package:zod && node tests/package/testing-kit.mjs",
|
|
162
|
+
"test:package:testing": "npm run build && node tests/package/testing-kit.mjs",
|
|
139
163
|
"test:package:zod": "npm run build && node tests/package/zod-compat.mjs",
|
|
140
164
|
"test:watch": "vitest --project unit",
|
|
141
165
|
"example:tanstack:install": "bun link && cd example/tanstack && bun install && bun link @lovable.dev/mcp-js",
|