@lovable.dev/mcp-js 0.21.1-rc.1 → 0.22.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/dist/authorize-BMeXd_Sh.d.ts +25 -0
- package/dist/base-CM-KCpp6.d.ts +28 -0
- package/dist/chunk-4EHZUUS5.js +141 -0
- package/dist/chunk-6DXGZZA4.js +6 -0
- package/dist/chunk-6KNM7RGD.js +79 -0
- package/dist/chunk-6QFZYYUV.js +11 -0
- package/dist/chunk-EOFPMSND.js +6 -0
- package/dist/chunk-H37EB22A.js +125 -0
- package/dist/chunk-MA5H6PSF.js +46 -0
- package/dist/chunk-P43FIUMZ.js +114 -0
- package/dist/chunk-RK62EMPY.js +741 -0
- package/dist/chunk-RLE4UE63.js +58 -0
- package/dist/chunk-UQK5UO6C.js +26 -0
- package/dist/chunk-XQWJN6DC.js +14 -0
- package/dist/chunk-Y3ZFPEQH.js +8 -0
- package/dist/cli/extract-manifest.cjs +201 -116
- package/dist/cli/extract-manifest.d.cts +1 -1
- package/dist/cli/extract-manifest.d.ts +1 -1
- package/dist/cli/extract-manifest.js +156 -117
- package/dist/index.cjs +329 -129
- package/dist/index.d.cts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/index.js +177 -118
- package/dist/{io-CS4UL6_A.d.ts → io-D4srzRKc.d.ts} +4 -6
- package/dist/protocols/mcp/index.cjs +750 -3
- package/dist/protocols/mcp/index.d.cts +7 -6
- package/dist/protocols/mcp/index.d.ts +7 -6
- package/dist/protocols/mcp/index.js +12 -2
- package/dist/protocols/oauth-metadata.cjs +539 -48
- package/dist/protocols/oauth-metadata.d.cts +6 -5
- package/dist/protocols/oauth-metadata.d.ts +6 -5
- package/dist/protocols/oauth-metadata.js +10 -52
- package/dist/protocols/rest/index.cjs +843 -5
- package/dist/protocols/rest/index.d.cts +10 -7
- package/dist/protocols/rest/index.d.ts +10 -7
- package/dist/protocols/rest/index.js +16 -3
- package/dist/stacks/supabase/index.cjs +1318 -76
- package/dist/stacks/supabase/index.d.cts +30 -29
- package/dist/stacks/supabase/index.d.ts +30 -29
- package/dist/stacks/supabase/index.js +89 -73
- package/dist/stacks/supabase/vite.cjs +287 -258
- package/dist/stacks/supabase/vite.d.cts +24 -24
- package/dist/stacks/supabase/vite.d.ts +24 -24
- package/dist/stacks/supabase/vite.js +252 -252
- package/dist/stacks/tanstack/index.cjs +1272 -42
- package/dist/stacks/tanstack/index.d.cts +9 -8
- package/dist/stacks/tanstack/index.d.ts +9 -8
- package/dist/stacks/tanstack/index.js +41 -36
- package/dist/stacks/tanstack/vite.cjs +312 -223
- package/dist/stacks/tanstack/vite.d.cts +81 -80
- package/dist/stacks/tanstack/vite.d.ts +81 -80
- package/dist/stacks/tanstack/vite.js +282 -216
- package/dist/types-qqrmJ736.d.ts +321 -0
- package/package.json +28 -71
- package/dist/authorize-CumVyk7p.d.cts +0 -27
- package/dist/authorize-D6p4-9_D.d.ts +0 -27
- package/dist/base-CoIFvAmS.d.cts +0 -26
- package/dist/base-CoIFvAmS.d.ts +0 -26
- package/dist/content-D5LJAHyM.js +0 -12
- package/dist/content-NCYIGgOb.cjs +0 -17
- package/dist/context-BweeEcoA.cjs +0 -56
- package/dist/context-CIpPzN7P.js +0 -51
- package/dist/cors-B7CTXIHD.js +0 -829
- package/dist/cors-BebjKPrc.cjs +0 -912
- package/dist/forwarded--h4efJy-.js +0 -43
- package/dist/forwarded-Pi8Hs5Ps.cjs +0 -48
- package/dist/fs-errors-CWNzOV75.cjs +0 -11
- package/dist/fs-errors-PA2t1TIp.js +0 -6
- package/dist/io-CbbUbPY3.d.cts +0 -15
- package/dist/list-tools-CBCuS1Tv.cjs +0 -57
- package/dist/list-tools-CsWgiRy1.d.ts +0 -8
- package/dist/list-tools-CtZHOuPv.d.cts +0 -8
- package/dist/list-tools-D75RGtgs.js +0 -46
- package/dist/logger-2OXtfiIW.js +0 -141
- package/dist/logger-BqPOa_E1.cjs +0 -194
- package/dist/mcp-Cdj0AYst.cjs +0 -123
- package/dist/mcp-GngXbcqN.js +0 -118
- package/dist/metadata-path-CAkNcfyY.js +0 -12
- package/dist/metadata-path-zd7NSNoa.cjs +0 -17
- package/dist/package-7EUptuSJ.js +0 -4
- package/dist/package-BwCGVRcB.cjs +0 -9
- package/dist/paths-IS65L6TA.js +0 -7
- package/dist/paths-OP318a6c.cjs +0 -18
- package/dist/rest-CXH6-zv9.js +0 -113
- package/dist/rest-CyV8LHeB.cjs +0 -118
- package/dist/types-BYdYYTjk.d.cts +0 -321
- package/dist/types-BYdYYTjk.d.ts +0 -321
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertRestResourceBinding,
|
|
3
|
+
corsPreflightResponse,
|
|
4
|
+
createNoopRecorder,
|
|
5
|
+
createRequestAuthorizer,
|
|
6
|
+
headResponse,
|
|
7
|
+
methodNotAllowed,
|
|
8
|
+
withCors
|
|
9
|
+
} from "./chunk-RK62EMPY.js";
|
|
10
|
+
|
|
11
|
+
// src/protocols/rest/list-tools.ts
|
|
12
|
+
import { objectFromShape } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
13
|
+
import { toJsonSchemaCompat } from "@modelcontextprotocol/sdk/server/zod-json-schema-compat.js";
|
|
14
|
+
function shapeToJsonSchema(shape) {
|
|
15
|
+
if (!shape)
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
return toJsonSchemaCompat(objectFromShape(shape));
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function buildMcpListing(mcp) {
|
|
24
|
+
return {
|
|
25
|
+
server: { name: mcp.name, version: mcp.version, title: mcp.title },
|
|
26
|
+
tools: mcp.tools.map((tool) => ({
|
|
27
|
+
name: tool.name,
|
|
28
|
+
title: tool.title,
|
|
29
|
+
description: tool.description,
|
|
30
|
+
annotations: tool.annotations,
|
|
31
|
+
inputSchema: shapeToJsonSchema(tool.inputSchema),
|
|
32
|
+
outputSchema: shapeToJsonSchema(tool.outputSchema)
|
|
33
|
+
}))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function createListToolsHandler(mcp, options = {}) {
|
|
37
|
+
assertRestResourceBinding(mcp, options);
|
|
38
|
+
const authorizer = createRequestAuthorizer(mcp, options);
|
|
39
|
+
const handle = async (request, recorder) => {
|
|
40
|
+
const authResult = await authorizer.authorize(request, recorder);
|
|
41
|
+
if (!authResult.ok)
|
|
42
|
+
return authResult.response;
|
|
43
|
+
if (request.method !== "GET" && request.method !== "HEAD")
|
|
44
|
+
return methodNotAllowed("GET, HEAD, OPTIONS");
|
|
45
|
+
const response = Response.json(buildMcpListing(mcp));
|
|
46
|
+
return request.method === "HEAD" ? headResponse(response) : response;
|
|
47
|
+
};
|
|
48
|
+
return async (request, recorder = createNoopRecorder()) => {
|
|
49
|
+
if (request.method === "OPTIONS")
|
|
50
|
+
return corsPreflightResponse("GET, HEAD, OPTIONS");
|
|
51
|
+
return withCors(await handle(request, recorder));
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
buildMcpListing,
|
|
57
|
+
createListToolsHandler
|
|
58
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/core/forwarded.ts
|
|
2
|
+
function applyForwardedOrigin(request, options) {
|
|
3
|
+
const proto = options.trustForwardedProto ? firstForwardedValue(request, "x-forwarded-proto") : void 0;
|
|
4
|
+
const host = options.trustForwardedHost ? firstForwardedValue(request, "x-forwarded-host") : void 0;
|
|
5
|
+
if (proto === void 0 && host === void 0)
|
|
6
|
+
return request;
|
|
7
|
+
const url = new URL(request.url);
|
|
8
|
+
let changed = false;
|
|
9
|
+
if (proto !== void 0 && `${proto}:` !== url.protocol) {
|
|
10
|
+
url.protocol = `${proto}:`;
|
|
11
|
+
changed = true;
|
|
12
|
+
}
|
|
13
|
+
if (host !== void 0 && host !== url.host) {
|
|
14
|
+
url.host = host;
|
|
15
|
+
changed = true;
|
|
16
|
+
}
|
|
17
|
+
return changed ? new Request(url.href, request) : request;
|
|
18
|
+
}
|
|
19
|
+
function firstForwardedValue(request, header) {
|
|
20
|
+
const value = request.headers.get(header)?.split(",")[0]?.trim();
|
|
21
|
+
return value ? value : void 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
applyForwardedOrigin
|
|
26
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/stacks/supabase/paths.ts
|
|
2
|
+
var FUNCTIONS_MOUNT_PREFIX = "/functions/v1/";
|
|
3
|
+
function assertFunctionName(value, label = "functionName") {
|
|
4
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(value)) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
`@lovable.dev/mcp-js: ${label} must be a single path segment matching [A-Za-z0-9_-], got ${JSON.stringify(value)}`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
FUNCTIONS_MOUNT_PREFIX,
|
|
13
|
+
assertFunctionName
|
|
14
|
+
};
|
|
@@ -1,134 +1,219 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/manifest/io.ts
|
|
5
|
+
var import_node_crypto = require("crypto");
|
|
6
|
+
var import_node_fs = require("fs");
|
|
7
|
+
var import_node_path = require("path");
|
|
8
|
+
var import_vite2 = require("vite");
|
|
9
|
+
|
|
10
|
+
// src/core/fs-errors.ts
|
|
11
|
+
function isFileMissing(err) {
|
|
12
|
+
return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// package.json
|
|
16
|
+
var version = "0.22.0";
|
|
17
|
+
|
|
18
|
+
// src/protocols/rest/list-tools.ts
|
|
19
|
+
var import_zod_compat = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
20
|
+
var import_zod_json_schema_compat = require("@modelcontextprotocol/sdk/server/zod-json-schema-compat.js");
|
|
21
|
+
|
|
22
|
+
// src/core/logger.ts
|
|
23
|
+
var LEVEL_RANK = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
|
|
24
|
+
function isLogLevel(value) {
|
|
25
|
+
return typeof value === "string" && value in LEVEL_RANK;
|
|
26
|
+
}
|
|
27
|
+
var LOG_LEVEL_ENV_VAR = "LOVABLE_MCP_LOG_LEVEL";
|
|
28
|
+
function readEnvLevel() {
|
|
29
|
+
try {
|
|
30
|
+
const raw = typeof process !== "undefined" ? process.env?.[LOG_LEVEL_ENV_VAR] : void 0;
|
|
31
|
+
const normalized = raw?.trim().toLowerCase();
|
|
32
|
+
return isLogLevel(normalized) ? normalized : void 0;
|
|
33
|
+
} catch {
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var currentLevel = readEnvLevel() ?? "debug";
|
|
38
|
+
|
|
39
|
+
// src/auth/verifier.ts
|
|
40
|
+
var import_jose = require("jose");
|
|
41
|
+
|
|
42
|
+
// src/protocols/rest/list-tools.ts
|
|
43
|
+
function shapeToJsonSchema(shape) {
|
|
44
|
+
if (!shape)
|
|
45
|
+
return null;
|
|
46
|
+
try {
|
|
47
|
+
return (0, import_zod_json_schema_compat.toJsonSchemaCompat)((0, import_zod_compat.objectFromShape)(shape));
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function buildMcpListing(mcp) {
|
|
53
|
+
return {
|
|
54
|
+
server: { name: mcp.name, version: mcp.version, title: mcp.title },
|
|
55
|
+
tools: mcp.tools.map((tool) => ({
|
|
56
|
+
name: tool.name,
|
|
57
|
+
title: tool.title,
|
|
58
|
+
description: tool.description,
|
|
59
|
+
annotations: tool.annotations,
|
|
60
|
+
inputSchema: shapeToJsonSchema(tool.inputSchema),
|
|
61
|
+
outputSchema: shapeToJsonSchema(tool.outputSchema)
|
|
62
|
+
}))
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/manifest/extract.ts
|
|
67
|
+
var MANIFEST_VERSION = 1;
|
|
68
|
+
var MANIFEST_RELATIVE_PATH = ".lovable/mcp/manifest.json";
|
|
10
69
|
function manifestAuth(auth) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
70
|
+
if (!auth)
|
|
71
|
+
return { type: "none" };
|
|
72
|
+
const oauth = { type: "oauth", issuer: auth.issuer };
|
|
73
|
+
if (auth.resource !== void 0)
|
|
74
|
+
oauth.resource = auth.resource;
|
|
75
|
+
if (auth.resourceName !== void 0)
|
|
76
|
+
oauth.resource_name = auth.resourceName;
|
|
77
|
+
if (auth.resourceDocumentation !== void 0)
|
|
78
|
+
oauth.resource_documentation = auth.resourceDocumentation;
|
|
79
|
+
if (auth.protectedResourceMetadataUrl !== void 0)
|
|
80
|
+
oauth.protected_resource_metadata_url = auth.protectedResourceMetadataUrl;
|
|
81
|
+
if (auth.requireOAuthClientClaim !== void 0)
|
|
82
|
+
oauth.require_oauth_client_claim = auth.requireOAuthClientClaim;
|
|
83
|
+
if (auth.acceptResourceClaim !== void 0)
|
|
84
|
+
oauth.accept_resource_claim = auth.acceptResourceClaim;
|
|
85
|
+
if (auth.acceptedAudiences !== void 0)
|
|
86
|
+
oauth.accepted_audiences = auth.acceptedAudiences;
|
|
87
|
+
if (auth.requiredScopes !== void 0)
|
|
88
|
+
oauth.required_scopes = auth.requiredScopes;
|
|
89
|
+
if (auth.jwksUri !== void 0)
|
|
90
|
+
oauth.jwks_uri = auth.jwksUri;
|
|
91
|
+
if (auth.algorithms !== void 0)
|
|
92
|
+
oauth.algorithms = auth.algorithms;
|
|
93
|
+
if (auth.clockToleranceSeconds !== void 0)
|
|
94
|
+
oauth.clock_tolerance_seconds = auth.clockToleranceSeconds;
|
|
95
|
+
return oauth;
|
|
28
96
|
}
|
|
29
97
|
function isToolShape(tool) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
98
|
+
if (typeof tool !== "object" || tool === null)
|
|
99
|
+
return false;
|
|
100
|
+
const t = tool;
|
|
101
|
+
return typeof t.name === "string" && typeof t.title === "string" && typeof t.description === "string";
|
|
33
102
|
}
|
|
34
103
|
function isAuthShape(auth) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
104
|
+
if (auth === void 0)
|
|
105
|
+
return true;
|
|
106
|
+
if (typeof auth !== "object" || auth === null)
|
|
107
|
+
return false;
|
|
108
|
+
const a = auth;
|
|
109
|
+
return a.type === "oauth" && typeof a.issuer === "string" && a.issuer.length > 0;
|
|
39
110
|
}
|
|
40
111
|
function manifestFromDefinition(definition, urlPath, source = "the MCP entry") {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
112
|
+
const def = definition;
|
|
113
|
+
const validShape = !!def && typeof def === "object" && typeof def.name === "string" && typeof def.title === "string" && typeof def.version === "string" && Array.isArray(def.tools) && def.tools.every(isToolShape) && isAuthShape(def.auth);
|
|
114
|
+
if (!validShape) {
|
|
115
|
+
const got = definition == null ? "no default export" : typeof definition;
|
|
116
|
+
throw new Error(`@lovable.dev/mcp-js: ${source} must \`export default defineMcp(...)\` (got ${got}).`);
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
version: MANIFEST_VERSION,
|
|
120
|
+
sdk_version: version,
|
|
121
|
+
path: urlPath,
|
|
122
|
+
auth: manifestAuth(def.auth),
|
|
123
|
+
mcp: buildMcpListing(def)
|
|
124
|
+
};
|
|
50
125
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await server.close();
|
|
70
|
-
}
|
|
126
|
+
|
|
127
|
+
// src/manifest/ssr-loader.ts
|
|
128
|
+
var import_vite = require("vite");
|
|
129
|
+
async function produceViaSsr(projectRoot2, alias, entryAbs, urlPath) {
|
|
130
|
+
const server = await (0, import_vite.createServer)({
|
|
131
|
+
configFile: false,
|
|
132
|
+
root: projectRoot2,
|
|
133
|
+
logLevel: "silent",
|
|
134
|
+
server: { middlewareMode: true, hmr: false, watch: null },
|
|
135
|
+
optimizeDeps: { noDiscovery: true },
|
|
136
|
+
resolve: { alias }
|
|
137
|
+
});
|
|
138
|
+
try {
|
|
139
|
+
const mod = await server.ssrLoadModule(entryAbs);
|
|
140
|
+
return manifestFromDefinition(mod.default, urlPath, entryAbs);
|
|
141
|
+
} finally {
|
|
142
|
+
await server.close();
|
|
143
|
+
}
|
|
71
144
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
145
|
+
|
|
146
|
+
// src/manifest/io.ts
|
|
147
|
+
var MCP_PLUGIN_NAME_PREFIX = "@lovable.dev/mcp-js";
|
|
148
|
+
var DEFAULT_MCP_ENTRY = "src/lib/mcp/index.ts";
|
|
149
|
+
var DEFAULT_MCP_PATH = "/mcp";
|
|
75
150
|
function writeManifestIfChanged(file, manifest) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
151
|
+
const content = JSON.stringify(manifest, null, 2) + "\n";
|
|
152
|
+
let existing;
|
|
153
|
+
try {
|
|
154
|
+
existing = (0, import_node_fs.readFileSync)(file, "utf8");
|
|
155
|
+
} catch (err) {
|
|
156
|
+
if (!isFileMissing(err))
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
if (existing === content)
|
|
160
|
+
return;
|
|
161
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(file), { recursive: true });
|
|
162
|
+
const tmp = `${file}.${(0, import_node_crypto.randomUUID)()}.tmp`;
|
|
163
|
+
try {
|
|
164
|
+
(0, import_node_fs.writeFileSync)(tmp, content, "utf8");
|
|
165
|
+
(0, import_node_fs.renameSync)(tmp, file);
|
|
166
|
+
} catch (err) {
|
|
167
|
+
try {
|
|
168
|
+
(0, import_node_fs.unlinkSync)(tmp);
|
|
169
|
+
} catch {
|
|
170
|
+
}
|
|
171
|
+
throw err;
|
|
172
|
+
}
|
|
95
173
|
}
|
|
96
174
|
function removeManifest(file) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
175
|
+
try {
|
|
176
|
+
(0, import_node_fs.unlinkSync)(file);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
if (!isFileMissing(err))
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
102
181
|
}
|
|
103
182
|
async function syncManifest(manifestFile, entryAbs, urlPath, produce) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
183
|
+
let entryExists = true;
|
|
184
|
+
try {
|
|
185
|
+
(0, import_node_fs.lstatSync)(entryAbs);
|
|
186
|
+
} catch (err) {
|
|
187
|
+
if (!isFileMissing(err))
|
|
188
|
+
throw err;
|
|
189
|
+
entryExists = false;
|
|
190
|
+
}
|
|
191
|
+
if (!entryExists) {
|
|
192
|
+
removeManifest(manifestFile);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const manifest = await produce(entryAbs, urlPath);
|
|
196
|
+
writeManifestIfChanged(manifestFile, manifest);
|
|
116
197
|
}
|
|
117
|
-
async function runExtract(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
198
|
+
async function runExtract(projectRoot2) {
|
|
199
|
+
const resolved = await (0, import_vite2.resolveConfig)({ root: projectRoot2, logLevel: "silent" }, "serve");
|
|
200
|
+
const alias = resolved.resolve?.alias ?? [];
|
|
201
|
+
const pluginApi = resolved.plugins.find(
|
|
202
|
+
(p) => typeof p.name === "string" && p.name.startsWith(MCP_PLUGIN_NAME_PREFIX)
|
|
203
|
+
)?.api;
|
|
204
|
+
const entryAbs = pluginApi?.mcpEntry ?? (0, import_node_path.resolve)(projectRoot2, DEFAULT_MCP_ENTRY);
|
|
205
|
+
const urlPath = pluginApi?.urlPath ?? DEFAULT_MCP_PATH;
|
|
206
|
+
await syncManifest(
|
|
207
|
+
(0, import_node_path.resolve)(projectRoot2, MANIFEST_RELATIVE_PATH),
|
|
208
|
+
entryAbs,
|
|
209
|
+
urlPath,
|
|
210
|
+
(entry, path) => produceViaSsr(projectRoot2, alias, entry, path)
|
|
211
|
+
);
|
|
127
212
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
213
|
+
|
|
214
|
+
// src/cli/extract-manifest.ts
|
|
215
|
+
var projectRoot = process.argv[2] ?? process.cwd();
|
|
216
|
+
runExtract(projectRoot).catch((err) => {
|
|
217
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
218
|
+
process.exit(1);
|
|
133
219
|
});
|
|
134
|
-
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|