@lovable.dev/mcp-js 0.22.1-rc.9 → 0.22.2-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/authorize-CumVyk7p.d.cts +27 -0
  2. package/dist/authorize-D6p4-9_D.d.ts +27 -0
  3. package/dist/base-DCe0kP79.d.cts +29 -0
  4. package/dist/base-DCe0kP79.d.ts +29 -0
  5. package/dist/cli/extract-manifest.cjs +116 -201
  6. package/dist/cli/extract-manifest.d.cts +1 -1
  7. package/dist/cli/extract-manifest.d.ts +1 -1
  8. package/dist/cli/extract-manifest.js +117 -156
  9. package/dist/content-D5LJAHyM.js +12 -0
  10. package/dist/content-NCYIGgOb.cjs +17 -0
  11. package/dist/context-BweeEcoA.cjs +56 -0
  12. package/dist/context-CIpPzN7P.js +51 -0
  13. package/dist/cors-CSDhBjFd.cjs +913 -0
  14. package/dist/cors-rWp_tbLZ.js +830 -0
  15. package/dist/forwarded--h4efJy-.js +43 -0
  16. package/dist/forwarded-Pi8Hs5Ps.cjs +48 -0
  17. package/dist/fs-errors-CWNzOV75.cjs +11 -0
  18. package/dist/fs-errors-PA2t1TIp.js +6 -0
  19. package/dist/index.cjs +129 -329
  20. package/dist/index.d.cts +26 -26
  21. package/dist/index.d.ts +26 -26
  22. package/dist/index.js +118 -177
  23. package/dist/{io-D4srzRKc.d.ts → io-CfSPxeBN.d.ts} +6 -4
  24. package/dist/io-DPYvBqET.d.cts +15 -0
  25. package/dist/list-tools-B4TTPEl1.d.cts +8 -0
  26. package/dist/list-tools-CFUX-uo-.cjs +57 -0
  27. package/dist/list-tools-DVJrjtmH.js +46 -0
  28. package/dist/list-tools-bh6-eqZM.d.ts +8 -0
  29. package/dist/logger-2OXtfiIW.js +141 -0
  30. package/dist/logger-BqPOa_E1.cjs +194 -0
  31. package/dist/mcp-BNcpj8o7.cjs +128 -0
  32. package/dist/mcp-Bx3bJHzH.js +123 -0
  33. package/dist/metadata-path-CAkNcfyY.js +12 -0
  34. package/dist/metadata-path-zd7NSNoa.cjs +17 -0
  35. package/dist/package-CgwD4Ywz.js +4 -0
  36. package/dist/package-DzstF8Ih.cjs +9 -0
  37. package/dist/paths-IS65L6TA.js +7 -0
  38. package/dist/paths-OP318a6c.cjs +18 -0
  39. package/dist/protocols/mcp/index.cjs +3 -750
  40. package/dist/protocols/mcp/index.d.cts +6 -7
  41. package/dist/protocols/mcp/index.d.ts +6 -7
  42. package/dist/protocols/mcp/index.js +2 -12
  43. package/dist/protocols/oauth-metadata.cjs +48 -539
  44. package/dist/protocols/oauth-metadata.d.cts +5 -6
  45. package/dist/protocols/oauth-metadata.d.ts +5 -6
  46. package/dist/protocols/oauth-metadata.js +52 -10
  47. package/dist/protocols/rest/index.cjs +5 -843
  48. package/dist/protocols/rest/index.d.cts +7 -10
  49. package/dist/protocols/rest/index.d.ts +7 -10
  50. package/dist/protocols/rest/index.js +3 -16
  51. package/dist/rest-BRshnow2.js +117 -0
  52. package/dist/rest-C4ZEGSIV.cjs +122 -0
  53. package/dist/stacks/supabase/index.cjs +76 -1318
  54. package/dist/stacks/supabase/index.d.cts +29 -30
  55. package/dist/stacks/supabase/index.d.ts +29 -30
  56. package/dist/stacks/supabase/index.js +73 -89
  57. package/dist/stacks/supabase/vite.cjs +258 -287
  58. package/dist/stacks/supabase/vite.d.cts +24 -24
  59. package/dist/stacks/supabase/vite.d.ts +24 -24
  60. package/dist/stacks/supabase/vite.js +252 -252
  61. package/dist/stacks/tanstack/index.cjs +42 -1272
  62. package/dist/stacks/tanstack/index.d.cts +8 -9
  63. package/dist/stacks/tanstack/index.d.ts +8 -9
  64. package/dist/stacks/tanstack/index.js +36 -41
  65. package/dist/stacks/tanstack/vite.cjs +223 -312
  66. package/dist/stacks/tanstack/vite.d.cts +80 -81
  67. package/dist/stacks/tanstack/vite.d.ts +80 -81
  68. package/dist/stacks/tanstack/vite.js +216 -282
  69. package/dist/types-BYdYYTjk.d.cts +321 -0
  70. package/dist/types-BYdYYTjk.d.ts +321 -0
  71. package/package.json +4 -4
  72. package/dist/authorize-BMeXd_Sh.d.ts +0 -25
  73. package/dist/base-CM-KCpp6.d.ts +0 -28
  74. package/dist/chunk-5DFH6VN6.js +0 -741
  75. package/dist/chunk-6DXGZZA4.js +0 -6
  76. package/dist/chunk-6QFZYYUV.js +0 -11
  77. package/dist/chunk-AYV4CWAJ.js +0 -141
  78. package/dist/chunk-H37EB22A.js +0 -125
  79. package/dist/chunk-K3OSKUCH.js +0 -79
  80. package/dist/chunk-KUYKBTCQ.js +0 -58
  81. package/dist/chunk-MA5H6PSF.js +0 -46
  82. package/dist/chunk-MTJQGT2W.js +0 -6
  83. package/dist/chunk-UQK5UO6C.js +0 -26
  84. package/dist/chunk-XQWJN6DC.js +0 -14
  85. package/dist/chunk-Y3ZFPEQH.js +0 -8
  86. package/dist/chunk-Z3ICQ7MB.js +0 -114
  87. package/dist/types-qqrmJ736.d.ts +0 -321
@@ -0,0 +1,27 @@
1
+ import "./types-BYdYYTjk.cjs";
2
+ //#region src/auth/authorize.d.ts
3
+ interface McpRuntimeOptions {
4
+ /**
5
+ * Public MCP protocol path. REST companion handlers pass this so OAuth
6
+ * resource/audience checks bind to `/mcp`, not internal `/.mcp/*` RPC URLs.
7
+ */
8
+ resourcePath?: string;
9
+ /**
10
+ * Host-relative path of the SDK-served protected-resource metadata document.
11
+ * The Vite plugin injects it into every emitted handler when it generates the
12
+ * PRM route, so the 401 challenge advertises the same path the route serves.
13
+ * Its presence is the signal that the SDK owns the PRM document, so it is
14
+ * mutually exclusive with `auth.protectedResourceMetadataUrl` (which points at
15
+ * an externally hosted document). Defaults to the well-known path when absent.
16
+ */
17
+ metadataPath?: string;
18
+ /**
19
+ * Derive the request origin (and thus the advertised `resource`/metadata URLs)
20
+ * from `X-Forwarded-Host` rather than the rewritten `Host`. Stack adapters read
21
+ * this before invoking the handler, so the OAuth runtime never sees it; safe
22
+ * only behind a proxy that overwrites the header (see `core/forwarded.ts`).
23
+ */
24
+ trustForwardedHost?: boolean;
25
+ }
26
+ //#endregion
27
+ export { McpRuntimeOptions as t };
@@ -0,0 +1,27 @@
1
+ import "./types-BYdYYTjk.js";
2
+ //#region src/auth/authorize.d.ts
3
+ interface McpRuntimeOptions {
4
+ /**
5
+ * Public MCP protocol path. REST companion handlers pass this so OAuth
6
+ * resource/audience checks bind to `/mcp`, not internal `/.mcp/*` RPC URLs.
7
+ */
8
+ resourcePath?: string;
9
+ /**
10
+ * Host-relative path of the SDK-served protected-resource metadata document.
11
+ * The Vite plugin injects it into every emitted handler when it generates the
12
+ * PRM route, so the 401 challenge advertises the same path the route serves.
13
+ * Its presence is the signal that the SDK owns the PRM document, so it is
14
+ * mutually exclusive with `auth.protectedResourceMetadataUrl` (which points at
15
+ * an externally hosted document). Defaults to the well-known path when absent.
16
+ */
17
+ metadataPath?: string;
18
+ /**
19
+ * Derive the request origin (and thus the advertised `resource`/metadata URLs)
20
+ * from `X-Forwarded-Host` rather than the rewritten `Host`. Stack adapters read
21
+ * this before invoking the handler, so the OAuth runtime never sees it; safe
22
+ * only behind a proxy that overwrites the header (see `core/forwarded.ts`).
23
+ */
24
+ trustForwardedHost?: boolean;
25
+ }
26
+ //#endregion
27
+ export { McpRuntimeOptions as t };
@@ -0,0 +1,29 @@
1
+ //#region src/metrics/impl/base.d.ts
2
+ type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "auth_config_error";
3
+ /** One recorded MCP call. Carries no arguments or response payloads — only the
4
+ * tool name, the JSON-RPC method, the result class, timing, and byte sizes.
5
+ * `errorText` is the sole exception: it is logged locally for debugging and
6
+ * deliberately never included in the OTLP payload (see `emit` / `buildLogsPayload`). */
7
+ interface InvocationRecord {
8
+ /** Tool name for `tools/call`; `null` for list/initialize, transport faults, and auth-config failures. */
9
+ tool: string | null;
10
+ /** JSON-RPC method, e.g. `tools/call`; `authorize` for auth-config failures. */
11
+ method: string;
12
+ outcome: InvocationOutcome;
13
+ durationMs: number;
14
+ reqBytes?: number;
15
+ resBytes?: number;
16
+ /** The app end-user that made the call (the access token `sub`), or
17
+ * `undefined` when the request is unauthenticated. Not a Lovable identity. */
18
+ endUserId?: string;
19
+ /** The `tool_error` message (text content of an `isError` result). Local log
20
+ * only — never sent to the collector, so it stays on-box for the operator. */
21
+ errorText?: string;
22
+ }
23
+ /** A per-request telemetry recorder. `emit` logs the invocation and sends it as a
24
+ * single OTLP POST, awaited so it lands before the request ends. */
25
+ interface MetricsRecorder {
26
+ emit(ev: InvocationRecord): Promise<void>;
27
+ }
28
+ //#endregion
29
+ export { MetricsRecorder as t };
@@ -0,0 +1,29 @@
1
+ //#region src/metrics/impl/base.d.ts
2
+ type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "auth_config_error";
3
+ /** One recorded MCP call. Carries no arguments or response payloads — only the
4
+ * tool name, the JSON-RPC method, the result class, timing, and byte sizes.
5
+ * `errorText` is the sole exception: it is logged locally for debugging and
6
+ * deliberately never included in the OTLP payload (see `emit` / `buildLogsPayload`). */
7
+ interface InvocationRecord {
8
+ /** Tool name for `tools/call`; `null` for list/initialize, transport faults, and auth-config failures. */
9
+ tool: string | null;
10
+ /** JSON-RPC method, e.g. `tools/call`; `authorize` for auth-config failures. */
11
+ method: string;
12
+ outcome: InvocationOutcome;
13
+ durationMs: number;
14
+ reqBytes?: number;
15
+ resBytes?: number;
16
+ /** The app end-user that made the call (the access token `sub`), or
17
+ * `undefined` when the request is unauthenticated. Not a Lovable identity. */
18
+ endUserId?: string;
19
+ /** The `tool_error` message (text content of an `isError` result). Local log
20
+ * only — never sent to the collector, so it stays on-box for the operator. */
21
+ errorText?: string;
22
+ }
23
+ /** A per-request telemetry recorder. `emit` logs the invocation and sends it as a
24
+ * single OTLP POST, awaited so it lands before the request ends. */
25
+ interface MetricsRecorder {
26
+ emit(ev: InvocationRecord): Promise<void>;
27
+ }
28
+ //#endregion
29
+ export { MetricsRecorder as t };
@@ -1,219 +1,134 @@
1
1
  #!/usr/bin/env node
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.1-rc.9";
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";
2
+ const require_package = require("../package-DzstF8Ih.cjs");
3
+ const require_list_tools = require("../list-tools-CFUX-uo-.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";
69
10
  function manifestAuth(auth) {
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;
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;
96
28
  }
97
29
  function isToolShape(tool) {
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";
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";
102
33
  }
103
34
  function isAuthShape(auth) {
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;
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;
110
39
  }
111
40
  function manifestFromDefinition(definition, urlPath, source = "the MCP entry") {
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
- };
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
+ };
125
50
  }
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
- }
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
+ }
144
71
  }
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";
72
+ //#endregion
73
+ //#region src/manifest/io.ts
74
+ const MCP_PLUGIN_NAME_PREFIX = "@lovable.dev/mcp-js";
150
75
  function writeManifestIfChanged(file, manifest) {
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
- }
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
+ }
173
95
  }
174
96
  function removeManifest(file) {
175
- try {
176
- (0, import_node_fs.unlinkSync)(file);
177
- } catch (err) {
178
- if (!isFileMissing(err))
179
- throw err;
180
- }
97
+ try {
98
+ (0, node_fs.unlinkSync)(file);
99
+ } catch (err) {
100
+ if (!require_fs_errors.isFileMissing(err)) throw err;
101
+ }
181
102
  }
182
103
  async function syncManifest(manifestFile, entryAbs, urlPath, produce) {
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);
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));
197
116
  }
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
- );
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));
212
127
  }
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);
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);
219
133
  });
134
+ //#endregion
@@ -1 +1 @@
1
- #!/usr/bin/env node
1
+ export { };
@@ -1 +1 @@
1
- #!/usr/bin/env node
1
+ export { };