@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
@@ -1,135 +1,174 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "../package-7EUptuSJ.js";
3
- import { t as buildMcpListing } from "../list-tools-D75RGtgs.js";
4
- import { t as isFileMissing } from "../fs-errors-PA2t1TIp.js";
5
- import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
6
- import { dirname, resolve } from "node:path";
7
- import { createServer, resolveConfig } from "vite";
8
- import { randomUUID } from "node:crypto";
9
- const MANIFEST_RELATIVE_PATH = ".lovable/mcp/manifest.json";
2
+ import {
3
+ buildMcpListing
4
+ } from "../chunk-RLE4UE63.js";
5
+ import "../chunk-RK62EMPY.js";
6
+ import "../chunk-H37EB22A.js";
7
+ import "../chunk-6DXGZZA4.js";
8
+ import {
9
+ isFileMissing
10
+ } from "../chunk-Y3ZFPEQH.js";
11
+ import {
12
+ version
13
+ } from "../chunk-EOFPMSND.js";
14
+
15
+ // src/manifest/io.ts
16
+ import { randomUUID } from "crypto";
17
+ import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
18
+ import { dirname, resolve } from "path";
19
+ import { resolveConfig } from "vite";
20
+
21
+ // src/manifest/extract.ts
22
+ var MANIFEST_VERSION = 1;
23
+ var MANIFEST_RELATIVE_PATH = ".lovable/mcp/manifest.json";
10
24
  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;
25
+ if (!auth)
26
+ return { type: "none" };
27
+ const oauth = { type: "oauth", issuer: auth.issuer };
28
+ if (auth.resource !== void 0)
29
+ oauth.resource = auth.resource;
30
+ if (auth.resourceName !== void 0)
31
+ oauth.resource_name = auth.resourceName;
32
+ if (auth.resourceDocumentation !== void 0)
33
+ oauth.resource_documentation = auth.resourceDocumentation;
34
+ if (auth.protectedResourceMetadataUrl !== void 0)
35
+ oauth.protected_resource_metadata_url = auth.protectedResourceMetadataUrl;
36
+ if (auth.requireOAuthClientClaim !== void 0)
37
+ oauth.require_oauth_client_claim = auth.requireOAuthClientClaim;
38
+ if (auth.acceptResourceClaim !== void 0)
39
+ oauth.accept_resource_claim = auth.acceptResourceClaim;
40
+ if (auth.acceptedAudiences !== void 0)
41
+ oauth.accepted_audiences = auth.acceptedAudiences;
42
+ if (auth.requiredScopes !== void 0)
43
+ oauth.required_scopes = auth.requiredScopes;
44
+ if (auth.jwksUri !== void 0)
45
+ oauth.jwks_uri = auth.jwksUri;
46
+ if (auth.algorithms !== void 0)
47
+ oauth.algorithms = auth.algorithms;
48
+ if (auth.clockToleranceSeconds !== void 0)
49
+ oauth.clock_tolerance_seconds = auth.clockToleranceSeconds;
50
+ return oauth;
28
51
  }
29
52
  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";
53
+ if (typeof tool !== "object" || tool === null)
54
+ return false;
55
+ const t = tool;
56
+ return typeof t.name === "string" && typeof t.title === "string" && typeof t.description === "string";
33
57
  }
34
58
  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;
59
+ if (auth === void 0)
60
+ return true;
61
+ if (typeof auth !== "object" || auth === null)
62
+ return false;
63
+ const a = auth;
64
+ return a.type === "oauth" && typeof a.issuer === "string" && a.issuer.length > 0;
39
65
  }
40
66
  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: version,
46
- path: urlPath,
47
- auth: manifestAuth(def.auth),
48
- mcp: buildMcpListing(def)
49
- };
67
+ const def = definition;
68
+ 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);
69
+ if (!validShape) {
70
+ const got = definition == null ? "no default export" : typeof definition;
71
+ throw new Error(`@lovable.dev/mcp-js: ${source} must \`export default defineMcp(...)\` (got ${got}).`);
72
+ }
73
+ return {
74
+ version: MANIFEST_VERSION,
75
+ sdk_version: version,
76
+ path: urlPath,
77
+ auth: manifestAuth(def.auth),
78
+ mcp: buildMcpListing(def)
79
+ };
50
80
  }
51
- //#endregion
52
- //#region src/manifest/ssr-loader.ts
53
- async function produceViaSsr(projectRoot, alias, entryAbs, urlPath) {
54
- const server = await 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
- }
81
+
82
+ // src/manifest/ssr-loader.ts
83
+ import { createServer } from "vite";
84
+ async function produceViaSsr(projectRoot2, alias, entryAbs, urlPath) {
85
+ const server = await createServer({
86
+ configFile: false,
87
+ root: projectRoot2,
88
+ logLevel: "silent",
89
+ server: { middlewareMode: true, hmr: false, watch: null },
90
+ optimizeDeps: { noDiscovery: true },
91
+ resolve: { alias }
92
+ });
93
+ try {
94
+ const mod = await server.ssrLoadModule(entryAbs);
95
+ return manifestFromDefinition(mod.default, urlPath, entryAbs);
96
+ } finally {
97
+ await server.close();
98
+ }
71
99
  }
72
- //#endregion
73
- //#region src/manifest/io.ts
74
- const MCP_PLUGIN_NAME_PREFIX = "@lovable.dev/mcp-js";
100
+
101
+ // src/manifest/io.ts
102
+ var MCP_PLUGIN_NAME_PREFIX = "@lovable.dev/mcp-js";
103
+ var DEFAULT_MCP_ENTRY = "src/lib/mcp/index.ts";
104
+ var DEFAULT_MCP_PATH = "/mcp";
75
105
  function writeManifestIfChanged(file, manifest) {
76
- const content = JSON.stringify(manifest, null, 2) + "\n";
77
- let existing;
78
- try {
79
- existing = readFileSync(file, "utf8");
80
- } catch (err) {
81
- if (!isFileMissing(err)) throw err;
82
- }
83
- if (existing === content) return;
84
- mkdirSync(dirname(file), { recursive: true });
85
- const tmp = `${file}.${randomUUID()}.tmp`;
86
- try {
87
- writeFileSync(tmp, content, "utf8");
88
- renameSync(tmp, file);
89
- } catch (err) {
90
- try {
91
- unlinkSync(tmp);
92
- } catch {}
93
- throw err;
94
- }
106
+ const content = JSON.stringify(manifest, null, 2) + "\n";
107
+ let existing;
108
+ try {
109
+ existing = readFileSync(file, "utf8");
110
+ } catch (err) {
111
+ if (!isFileMissing(err))
112
+ throw err;
113
+ }
114
+ if (existing === content)
115
+ return;
116
+ mkdirSync(dirname(file), { recursive: true });
117
+ const tmp = `${file}.${randomUUID()}.tmp`;
118
+ try {
119
+ writeFileSync(tmp, content, "utf8");
120
+ renameSync(tmp, file);
121
+ } catch (err) {
122
+ try {
123
+ unlinkSync(tmp);
124
+ } catch {
125
+ }
126
+ throw err;
127
+ }
95
128
  }
96
129
  function removeManifest(file) {
97
- try {
98
- unlinkSync(file);
99
- } catch (err) {
100
- if (!isFileMissing(err)) throw err;
101
- }
130
+ try {
131
+ unlinkSync(file);
132
+ } catch (err) {
133
+ if (!isFileMissing(err))
134
+ throw err;
135
+ }
102
136
  }
103
137
  async function syncManifest(manifestFile, entryAbs, urlPath, produce) {
104
- let entryExists = true;
105
- try {
106
- lstatSync(entryAbs);
107
- } catch (err) {
108
- if (!isFileMissing(err)) throw err;
109
- entryExists = false;
110
- }
111
- if (!entryExists) {
112
- removeManifest(manifestFile);
113
- return;
114
- }
115
- writeManifestIfChanged(manifestFile, await produce(entryAbs, urlPath));
138
+ let entryExists = true;
139
+ try {
140
+ lstatSync(entryAbs);
141
+ } catch (err) {
142
+ if (!isFileMissing(err))
143
+ throw err;
144
+ entryExists = false;
145
+ }
146
+ if (!entryExists) {
147
+ removeManifest(manifestFile);
148
+ return;
149
+ }
150
+ const manifest = await produce(entryAbs, urlPath);
151
+ writeManifestIfChanged(manifestFile, manifest);
116
152
  }
117
- async function runExtract(projectRoot) {
118
- const resolved = await 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 ?? resolve(projectRoot, "src/lib/mcp/index.ts");
125
- const urlPath = pluginApi?.urlPath ?? "/mcp";
126
- await syncManifest(resolve(projectRoot, MANIFEST_RELATIVE_PATH), entryAbs, urlPath, (entry, path) => produceViaSsr(projectRoot, alias, entry, path));
153
+ async function runExtract(projectRoot2) {
154
+ const resolved = await resolveConfig({ root: projectRoot2, logLevel: "silent" }, "serve");
155
+ const alias = resolved.resolve?.alias ?? [];
156
+ const pluginApi = resolved.plugins.find(
157
+ (p) => typeof p.name === "string" && p.name.startsWith(MCP_PLUGIN_NAME_PREFIX)
158
+ )?.api;
159
+ const entryAbs = pluginApi?.mcpEntry ?? resolve(projectRoot2, DEFAULT_MCP_ENTRY);
160
+ const urlPath = pluginApi?.urlPath ?? DEFAULT_MCP_PATH;
161
+ await syncManifest(
162
+ resolve(projectRoot2, MANIFEST_RELATIVE_PATH),
163
+ entryAbs,
164
+ urlPath,
165
+ (entry, path) => produceViaSsr(projectRoot2, alias, entry, path)
166
+ );
127
167
  }
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);
168
+
169
+ // src/cli/extract-manifest.ts
170
+ var projectRoot = process.argv[2] ?? process.cwd();
171
+ runExtract(projectRoot).catch((err) => {
172
+ console.error(err instanceof Error ? err.message : String(err));
173
+ process.exit(1);
133
174
  });
134
- //#endregion
135
- export {};