@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.
Files changed (87) hide show
  1. package/dist/authorize-BMeXd_Sh.d.ts +25 -0
  2. package/dist/base-CM-KCpp6.d.ts +28 -0
  3. package/dist/chunk-4EHZUUS5.js +141 -0
  4. package/dist/chunk-6DXGZZA4.js +6 -0
  5. package/dist/chunk-6KNM7RGD.js +79 -0
  6. package/dist/chunk-6QFZYYUV.js +11 -0
  7. package/dist/chunk-EOFPMSND.js +6 -0
  8. package/dist/chunk-H37EB22A.js +125 -0
  9. package/dist/chunk-MA5H6PSF.js +46 -0
  10. package/dist/chunk-P43FIUMZ.js +114 -0
  11. package/dist/chunk-RK62EMPY.js +741 -0
  12. package/dist/chunk-RLE4UE63.js +58 -0
  13. package/dist/chunk-UQK5UO6C.js +26 -0
  14. package/dist/chunk-XQWJN6DC.js +14 -0
  15. package/dist/chunk-Y3ZFPEQH.js +8 -0
  16. package/dist/cli/extract-manifest.cjs +201 -116
  17. package/dist/cli/extract-manifest.d.cts +1 -1
  18. package/dist/cli/extract-manifest.d.ts +1 -1
  19. package/dist/cli/extract-manifest.js +156 -117
  20. package/dist/index.cjs +329 -129
  21. package/dist/index.d.cts +26 -26
  22. package/dist/index.d.ts +26 -26
  23. package/dist/index.js +177 -118
  24. package/dist/{io-CS4UL6_A.d.ts → io-D4srzRKc.d.ts} +4 -6
  25. package/dist/protocols/mcp/index.cjs +750 -3
  26. package/dist/protocols/mcp/index.d.cts +7 -6
  27. package/dist/protocols/mcp/index.d.ts +7 -6
  28. package/dist/protocols/mcp/index.js +12 -2
  29. package/dist/protocols/oauth-metadata.cjs +539 -48
  30. package/dist/protocols/oauth-metadata.d.cts +6 -5
  31. package/dist/protocols/oauth-metadata.d.ts +6 -5
  32. package/dist/protocols/oauth-metadata.js +10 -52
  33. package/dist/protocols/rest/index.cjs +843 -5
  34. package/dist/protocols/rest/index.d.cts +10 -7
  35. package/dist/protocols/rest/index.d.ts +10 -7
  36. package/dist/protocols/rest/index.js +16 -3
  37. package/dist/stacks/supabase/index.cjs +1318 -76
  38. package/dist/stacks/supabase/index.d.cts +30 -29
  39. package/dist/stacks/supabase/index.d.ts +30 -29
  40. package/dist/stacks/supabase/index.js +89 -73
  41. package/dist/stacks/supabase/vite.cjs +287 -258
  42. package/dist/stacks/supabase/vite.d.cts +24 -24
  43. package/dist/stacks/supabase/vite.d.ts +24 -24
  44. package/dist/stacks/supabase/vite.js +252 -252
  45. package/dist/stacks/tanstack/index.cjs +1272 -42
  46. package/dist/stacks/tanstack/index.d.cts +9 -8
  47. package/dist/stacks/tanstack/index.d.ts +9 -8
  48. package/dist/stacks/tanstack/index.js +41 -36
  49. package/dist/stacks/tanstack/vite.cjs +312 -223
  50. package/dist/stacks/tanstack/vite.d.cts +81 -80
  51. package/dist/stacks/tanstack/vite.d.ts +81 -80
  52. package/dist/stacks/tanstack/vite.js +282 -216
  53. package/dist/types-qqrmJ736.d.ts +321 -0
  54. package/package.json +28 -71
  55. package/dist/authorize-CumVyk7p.d.cts +0 -27
  56. package/dist/authorize-D6p4-9_D.d.ts +0 -27
  57. package/dist/base-CoIFvAmS.d.cts +0 -26
  58. package/dist/base-CoIFvAmS.d.ts +0 -26
  59. package/dist/content-D5LJAHyM.js +0 -12
  60. package/dist/content-NCYIGgOb.cjs +0 -17
  61. package/dist/context-BweeEcoA.cjs +0 -56
  62. package/dist/context-CIpPzN7P.js +0 -51
  63. package/dist/cors-B7CTXIHD.js +0 -829
  64. package/dist/cors-BebjKPrc.cjs +0 -912
  65. package/dist/forwarded--h4efJy-.js +0 -43
  66. package/dist/forwarded-Pi8Hs5Ps.cjs +0 -48
  67. package/dist/fs-errors-CWNzOV75.cjs +0 -11
  68. package/dist/fs-errors-PA2t1TIp.js +0 -6
  69. package/dist/io-CbbUbPY3.d.cts +0 -15
  70. package/dist/list-tools-CBCuS1Tv.cjs +0 -57
  71. package/dist/list-tools-CsWgiRy1.d.ts +0 -8
  72. package/dist/list-tools-CtZHOuPv.d.cts +0 -8
  73. package/dist/list-tools-D75RGtgs.js +0 -46
  74. package/dist/logger-2OXtfiIW.js +0 -141
  75. package/dist/logger-BqPOa_E1.cjs +0 -194
  76. package/dist/mcp-Cdj0AYst.cjs +0 -123
  77. package/dist/mcp-GngXbcqN.js +0 -118
  78. package/dist/metadata-path-CAkNcfyY.js +0 -12
  79. package/dist/metadata-path-zd7NSNoa.cjs +0 -17
  80. package/dist/package-7EUptuSJ.js +0 -4
  81. package/dist/package-BwCGVRcB.cjs +0 -9
  82. package/dist/paths-IS65L6TA.js +0 -7
  83. package/dist/paths-OP318a6c.cjs +0 -18
  84. package/dist/rest-CXH6-zv9.js +0 -113
  85. package/dist/rest-CyV8LHeB.cjs +0 -118
  86. package/dist/types-BYdYYTjk.d.cts +0 -321
  87. 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
+ };
@@ -0,0 +1,8 @@
1
+ // src/core/fs-errors.ts
2
+ function isFileMissing(err) {
3
+ return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
4
+ }
5
+
6
+ export {
7
+ isFileMissing
8
+ };
@@ -1,134 +1,219 @@
1
1
  #!/usr/bin/env node
2
- const require_package = require("../package-BwCGVRcB.cjs");
3
- const require_list_tools = require("../list-tools-CBCuS1Tv.cjs");
4
- const require_fs_errors = require("../fs-errors-CWNzOV75.cjs");
5
- let node_fs = require("node:fs");
6
- let node_path = require("node:path");
7
- let vite = require("vite");
8
- let node_crypto = require("node:crypto");
9
- const MANIFEST_RELATIVE_PATH = ".lovable/mcp/manifest.json";
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
- if (!auth) return { type: "none" };
12
- const oauth = {
13
- type: "oauth",
14
- issuer: auth.issuer
15
- };
16
- if (auth.resource !== void 0) oauth.resource = auth.resource;
17
- if (auth.resourceName !== void 0) oauth.resource_name = auth.resourceName;
18
- if (auth.resourceDocumentation !== void 0) oauth.resource_documentation = auth.resourceDocumentation;
19
- if (auth.protectedResourceMetadataUrl !== void 0) oauth.protected_resource_metadata_url = auth.protectedResourceMetadataUrl;
20
- if (auth.requireOAuthClientClaim !== void 0) oauth.require_oauth_client_claim = auth.requireOAuthClientClaim;
21
- if (auth.acceptResourceClaim !== void 0) oauth.accept_resource_claim = auth.acceptResourceClaim;
22
- if (auth.acceptedAudiences !== void 0) oauth.accepted_audiences = auth.acceptedAudiences;
23
- if (auth.requiredScopes !== void 0) oauth.required_scopes = auth.requiredScopes;
24
- if (auth.jwksUri !== void 0) oauth.jwks_uri = auth.jwksUri;
25
- if (auth.algorithms !== void 0) oauth.algorithms = auth.algorithms;
26
- if (auth.clockToleranceSeconds !== void 0) oauth.clock_tolerance_seconds = auth.clockToleranceSeconds;
27
- return oauth;
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
- if (typeof tool !== "object" || tool === null) return false;
31
- const t = tool;
32
- return typeof t.name === "string" && typeof t.title === "string" && typeof t.description === "string";
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
- if (auth === void 0) return true;
36
- if (typeof auth !== "object" || auth === null) return false;
37
- const a = auth;
38
- return a.type === "oauth" && typeof a.issuer === "string" && a.issuer.length > 0;
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
- const def = definition;
42
- if (!(!!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))) throw new Error(`@lovable.dev/mcp-js: ${source} must \`export default defineMcp(...)\` (got ${definition == null ? "no default export" : typeof definition}).`);
43
- return {
44
- version: 1,
45
- sdk_version: require_package.version,
46
- path: urlPath,
47
- auth: manifestAuth(def.auth),
48
- mcp: require_list_tools.buildMcpListing(def)
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
- //#endregion
52
- //#region src/manifest/ssr-loader.ts
53
- async function produceViaSsr(projectRoot, alias, entryAbs, urlPath) {
54
- const server = await (0, vite.createServer)({
55
- configFile: false,
56
- root: projectRoot,
57
- logLevel: "silent",
58
- server: {
59
- middlewareMode: true,
60
- hmr: false,
61
- watch: null
62
- },
63
- optimizeDeps: { noDiscovery: true },
64
- resolve: { alias }
65
- });
66
- try {
67
- return manifestFromDefinition((await server.ssrLoadModule(entryAbs)).default, urlPath, entryAbs);
68
- } finally {
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
- //#endregion
73
- //#region src/manifest/io.ts
74
- const MCP_PLUGIN_NAME_PREFIX = "@lovable.dev/mcp-js";
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
- const content = JSON.stringify(manifest, null, 2) + "\n";
77
- let existing;
78
- try {
79
- existing = (0, node_fs.readFileSync)(file, "utf8");
80
- } catch (err) {
81
- if (!require_fs_errors.isFileMissing(err)) throw err;
82
- }
83
- if (existing === content) return;
84
- (0, node_fs.mkdirSync)((0, node_path.dirname)(file), { recursive: true });
85
- const tmp = `${file}.${(0, node_crypto.randomUUID)()}.tmp`;
86
- try {
87
- (0, node_fs.writeFileSync)(tmp, content, "utf8");
88
- (0, node_fs.renameSync)(tmp, file);
89
- } catch (err) {
90
- try {
91
- (0, node_fs.unlinkSync)(tmp);
92
- } catch {}
93
- throw err;
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
- try {
98
- (0, node_fs.unlinkSync)(file);
99
- } catch (err) {
100
- if (!require_fs_errors.isFileMissing(err)) throw err;
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
- let entryExists = true;
105
- try {
106
- (0, node_fs.lstatSync)(entryAbs);
107
- } catch (err) {
108
- if (!require_fs_errors.isFileMissing(err)) throw err;
109
- entryExists = false;
110
- }
111
- if (!entryExists) {
112
- removeManifest(manifestFile);
113
- return;
114
- }
115
- writeManifestIfChanged(manifestFile, await produce(entryAbs, urlPath));
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(projectRoot) {
118
- const resolved = await (0, vite.resolveConfig)({
119
- root: projectRoot,
120
- logLevel: "silent"
121
- }, "serve");
122
- const alias = resolved.resolve?.alias ?? [];
123
- const pluginApi = resolved.plugins.find((p) => typeof p.name === "string" && p.name.startsWith(MCP_PLUGIN_NAME_PREFIX))?.api;
124
- const entryAbs = pluginApi?.mcpEntry ?? (0, node_path.resolve)(projectRoot, "src/lib/mcp/index.ts");
125
- const urlPath = pluginApi?.urlPath ?? "/mcp";
126
- await syncManifest((0, node_path.resolve)(projectRoot, MANIFEST_RELATIVE_PATH), entryAbs, urlPath, (entry, path) => produceViaSsr(projectRoot, alias, entry, path));
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
- //#endregion
129
- //#region src/cli/extract-manifest.ts
130
- runExtract(process.argv[2] ?? process.cwd()).catch((err) => {
131
- console.error(err instanceof Error ? err.message : String(err));
132
- process.exit(1);
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
- export { };
1
+ #!/usr/bin/env node
@@ -1 +1 @@
1
- export { };
1
+ #!/usr/bin/env node