@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
package/dist/index.js
CHANGED
|
@@ -1,144 +1,203 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
ToolContext
|
|
3
|
+
} from "./chunk-MA5H6PSF.js";
|
|
4
|
+
import {
|
|
5
|
+
parseSafeUrl,
|
|
6
|
+
resolveMetricsConfig,
|
|
7
|
+
setLogLevel,
|
|
8
|
+
trimTrailingSlash
|
|
9
|
+
} from "./chunk-H37EB22A.js";
|
|
10
|
+
|
|
11
|
+
// src/core/define.ts
|
|
4
12
|
function assertUniqueNames(mcp) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
const seen = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const tool of mcp.tools) {
|
|
15
|
+
if (seen.has(tool.name)) {
|
|
16
|
+
throw new Error(`@lovable.dev/mcp-js: duplicate tool name "${tool.name}"`);
|
|
17
|
+
}
|
|
18
|
+
seen.add(tool.name);
|
|
19
|
+
}
|
|
10
20
|
}
|
|
11
21
|
function assertNonEmptyString(label, value) {
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
if (value.trim() === "") {
|
|
23
|
+
throw new Error(`@lovable.dev/mcp-js: ${label} must not be empty`);
|
|
24
|
+
}
|
|
25
|
+
if (value !== value.trim()) {
|
|
26
|
+
throw new Error(`@lovable.dev/mcp-js: ${label} must not have leading or trailing whitespace`);
|
|
27
|
+
}
|
|
14
28
|
}
|
|
15
29
|
function assertHttpsUrlField(name, value) {
|
|
16
|
-
|
|
17
|
-
|
|
30
|
+
assertNonEmptyString(`auth.${name}`, value);
|
|
31
|
+
parseSafeUrl(`@lovable.dev/mcp-js: auth.${name}`, value);
|
|
18
32
|
}
|
|
19
33
|
function assertScope(scope) {
|
|
20
|
-
|
|
34
|
+
if (scope.trim() === "" || /\s/.test(scope)) {
|
|
35
|
+
throw new Error(`@lovable.dev/mcp-js: OAuth scopes must be non-empty space-free tokens`);
|
|
36
|
+
}
|
|
21
37
|
}
|
|
22
38
|
function assertJwtAlgorithm(algorithm) {
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
if (algorithm.trim() === "" || /\s/.test(algorithm)) {
|
|
40
|
+
throw new Error(`@lovable.dev/mcp-js: auth.algorithms must contain non-empty space-free tokens`);
|
|
41
|
+
}
|
|
42
|
+
if (/^HS\d+$/i.test(algorithm) || algorithm.toLowerCase() === "none") {
|
|
43
|
+
throw new Error(`@lovable.dev/mcp-js: auth.algorithms cannot include "${algorithm}"; this verifier is JWKS-only`);
|
|
44
|
+
}
|
|
25
45
|
}
|
|
26
|
-
|
|
46
|
+
var MAX_CLOCK_TOLERANCE_SECONDS = 300;
|
|
27
47
|
function assertClockToleranceSeconds(value) {
|
|
28
|
-
|
|
48
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > MAX_CLOCK_TOLERANCE_SECONDS) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`@lovable.dev/mcp-js: auth.clockToleranceSeconds must be a non-negative number of seconds no greater than ${MAX_CLOCK_TOLERANCE_SECONDS}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
29
53
|
}
|
|
30
|
-
function assertOAuthConfig(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
function assertOAuthConfig(auth2) {
|
|
55
|
+
if (auth2.type !== "oauth") {
|
|
56
|
+
const authType = String(auth2.type);
|
|
57
|
+
throw new Error(`@lovable.dev/mcp-js: unsupported auth type "${authType}"`);
|
|
58
|
+
}
|
|
59
|
+
if (auth2.issuer === void 0) {
|
|
60
|
+
throw new Error(`@lovable.dev/mcp-js: auth.issuer is required`);
|
|
61
|
+
}
|
|
62
|
+
assertHttpsUrlField("issuer", auth2.issuer);
|
|
63
|
+
if (auth2.jwksUri !== void 0) {
|
|
64
|
+
assertHttpsUrlField("jwksUri", auth2.jwksUri);
|
|
65
|
+
}
|
|
66
|
+
if (auth2.resource !== void 0) {
|
|
67
|
+
assertHttpsUrlField("resource", auth2.resource);
|
|
68
|
+
}
|
|
69
|
+
if (auth2.resourceName !== void 0) {
|
|
70
|
+
assertNonEmptyString("auth.resourceName", auth2.resourceName);
|
|
71
|
+
}
|
|
72
|
+
if (auth2.resourceDocumentation !== void 0) {
|
|
73
|
+
assertHttpsUrlField("resourceDocumentation", auth2.resourceDocumentation);
|
|
74
|
+
}
|
|
75
|
+
if (auth2.protectedResourceMetadataUrl !== void 0) {
|
|
76
|
+
assertHttpsUrlField("protectedResourceMetadataUrl", auth2.protectedResourceMetadataUrl);
|
|
77
|
+
}
|
|
78
|
+
if (auth2.acceptedAudiences !== void 0) {
|
|
79
|
+
if (!Array.isArray(auth2.acceptedAudiences)) {
|
|
80
|
+
throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must be an array`);
|
|
81
|
+
}
|
|
82
|
+
if (auth2.acceptedAudiences.length === 0) {
|
|
83
|
+
throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must not be empty`);
|
|
84
|
+
}
|
|
85
|
+
for (const audience of auth2.acceptedAudiences) {
|
|
86
|
+
if (typeof audience !== "string") {
|
|
87
|
+
throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must contain strings`);
|
|
88
|
+
}
|
|
89
|
+
assertNonEmptyString("auth.acceptedAudiences", audience);
|
|
90
|
+
if (trimTrailingSlash(audience) === "") {
|
|
91
|
+
throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences entries must not be only slashes`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (auth2.requireOAuthClientClaim !== void 0 && typeof auth2.requireOAuthClientClaim !== "boolean") {
|
|
96
|
+
throw new Error(`@lovable.dev/mcp-js: auth.requireOAuthClientClaim must be a boolean`);
|
|
97
|
+
}
|
|
98
|
+
if (auth2.acceptResourceClaim !== void 0 && typeof auth2.acceptResourceClaim !== "boolean") {
|
|
99
|
+
throw new Error(`@lovable.dev/mcp-js: auth.acceptResourceClaim must be a boolean`);
|
|
100
|
+
}
|
|
101
|
+
if (auth2.requiredScopes !== void 0) {
|
|
102
|
+
if (!Array.isArray(auth2.requiredScopes)) {
|
|
103
|
+
throw new Error(`@lovable.dev/mcp-js: auth.requiredScopes must be an array`);
|
|
104
|
+
}
|
|
105
|
+
for (const scope of auth2.requiredScopes)
|
|
106
|
+
assertScope(scope);
|
|
107
|
+
}
|
|
108
|
+
if (auth2.algorithms !== void 0) {
|
|
109
|
+
if (!Array.isArray(auth2.algorithms)) {
|
|
110
|
+
throw new Error(`@lovable.dev/mcp-js: auth.algorithms must be an array`);
|
|
111
|
+
}
|
|
112
|
+
if (auth2.algorithms.length === 0) {
|
|
113
|
+
throw new Error(`@lovable.dev/mcp-js: auth.algorithms must not be empty`);
|
|
114
|
+
}
|
|
115
|
+
for (const algorithm of auth2.algorithms)
|
|
116
|
+
assertJwtAlgorithm(algorithm);
|
|
117
|
+
}
|
|
118
|
+
if (auth2.accessTokenTyp !== void 0) {
|
|
119
|
+
if (!Array.isArray(auth2.accessTokenTyp)) {
|
|
120
|
+
throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must be an array`);
|
|
121
|
+
}
|
|
122
|
+
if (auth2.accessTokenTyp.length === 0) {
|
|
123
|
+
throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must not be empty`);
|
|
124
|
+
}
|
|
125
|
+
for (const typ of auth2.accessTokenTyp) {
|
|
126
|
+
if (typeof typ !== "string") {
|
|
127
|
+
throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must contain strings`);
|
|
128
|
+
}
|
|
129
|
+
assertNonEmptyString("auth.accessTokenTyp", typ);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (auth2.clockToleranceSeconds !== void 0)
|
|
133
|
+
assertClockToleranceSeconds(auth2.clockToleranceSeconds);
|
|
134
|
+
if (auth2.resource === void 0 && auth2.acceptedAudiences === void 0) {
|
|
135
|
+
throw new Error(`@lovable.dev/mcp-js: auth.resource or auth.acceptedAudiences is required`);
|
|
136
|
+
}
|
|
72
137
|
}
|
|
73
|
-
function freezeAuth(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
138
|
+
function freezeAuth(auth2) {
|
|
139
|
+
if (!auth2)
|
|
140
|
+
return;
|
|
141
|
+
if (auth2.acceptedAudiences)
|
|
142
|
+
Object.freeze(auth2.acceptedAudiences);
|
|
143
|
+
if (auth2.requiredScopes)
|
|
144
|
+
Object.freeze(auth2.requiredScopes);
|
|
145
|
+
if (auth2.algorithms)
|
|
146
|
+
Object.freeze(auth2.algorithms);
|
|
147
|
+
if (auth2.accessTokenTyp)
|
|
148
|
+
Object.freeze(auth2.accessTokenTyp);
|
|
149
|
+
Object.freeze(auth2);
|
|
80
150
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Declare a single MCP tool. Import the result into your MCP definition's
|
|
83
|
-
* `tools` array — `defineMcp({ tools: [echoTool, ...] })`.
|
|
84
|
-
*
|
|
85
|
-
* `inputSchema` is a raw zod shape (e.g. `{ text: z.string() }`), not a
|
|
86
|
-
* full `z.object(...)` — the MCP SDK builds the object wrapper internally
|
|
87
|
-
* and the raw shape is what the JSON-RPC `tools/list` payload exposes.
|
|
88
|
-
*/
|
|
89
151
|
function defineTool(def) {
|
|
90
|
-
|
|
152
|
+
return def;
|
|
91
153
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Declare the MCP server. `export default` the result from your MCP
|
|
94
|
-
* entrypoint (default `lib/mcp/index.ts`); the Vite plugin reads it to
|
|
95
|
-
* emit the framework-specific route(s) at build time.
|
|
96
|
-
*/
|
|
97
154
|
function defineMcp(def) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
155
|
+
assertNonEmptyString("name", def.name);
|
|
156
|
+
assertNonEmptyString("title", def.title);
|
|
157
|
+
assertNonEmptyString("version", def.version);
|
|
158
|
+
assertUniqueNames(def);
|
|
159
|
+
if (def.auth)
|
|
160
|
+
assertOAuthConfig(def.auth);
|
|
161
|
+
resolveMetricsConfig(def.metrics);
|
|
162
|
+
freezeAuth(def.auth);
|
|
163
|
+
Object.freeze(def.tools);
|
|
164
|
+
for (const tool of def.tools)
|
|
165
|
+
Object.freeze(tool);
|
|
166
|
+
return def;
|
|
108
167
|
}
|
|
109
|
-
|
|
110
|
-
|
|
168
|
+
|
|
169
|
+
// src/auth/config.ts
|
|
111
170
|
function frozenArray(value) {
|
|
112
|
-
|
|
171
|
+
return value === void 0 ? void 0 : Object.freeze([...value]);
|
|
113
172
|
}
|
|
114
173
|
function frozenAudiences(value) {
|
|
115
|
-
|
|
174
|
+
return frozenArray(typeof value === "string" ? [value] : value);
|
|
116
175
|
}
|
|
117
|
-
/** Mutates `value` in place; callers pass a fresh literal so deleting keys is safe. */
|
|
118
176
|
function stripUndefined(value) {
|
|
119
|
-
|
|
120
|
-
|
|
177
|
+
for (const key of Object.keys(value)) {
|
|
178
|
+
if (value[key] === void 0)
|
|
179
|
+
delete value[key];
|
|
180
|
+
}
|
|
181
|
+
return value;
|
|
121
182
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Configure OAuth against an issuer. `acceptedAudiences` (or `resource`) is the
|
|
124
|
-
* token-acceptance policy, not a per-request authorization decision: any token
|
|
125
|
-
* carrying an accepted `aud` passes. When an issuer mints broad project-wide
|
|
126
|
-
* audiences (e.g. Supabase's `aud: "authenticated"`), a token for one resource
|
|
127
|
-
* is structurally accepted by another sharing that audience — so gate per-tool
|
|
128
|
-
* authorization on `ctx.getClaims()` / `ctx.getClientId()`, never on the
|
|
129
|
-
* accepted audience.
|
|
130
|
-
*/
|
|
131
183
|
function issuer(options) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
184
|
+
return Object.freeze(
|
|
185
|
+
stripUndefined({
|
|
186
|
+
type: "oauth",
|
|
187
|
+
...options,
|
|
188
|
+
acceptedAudiences: frozenAudiences(options.acceptedAudiences),
|
|
189
|
+
requiredScopes: frozenArray(options.requiredScopes),
|
|
190
|
+
algorithms: frozenArray(options.algorithms),
|
|
191
|
+
accessTokenTyp: frozenArray(options.accessTokenTyp)
|
|
192
|
+
})
|
|
193
|
+
);
|
|
140
194
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
195
|
+
var oauth = Object.freeze({ issuer });
|
|
196
|
+
var auth = Object.freeze({ oauth });
|
|
197
|
+
export {
|
|
198
|
+
ToolContext,
|
|
199
|
+
auth,
|
|
200
|
+
defineMcp,
|
|
201
|
+
defineTool,
|
|
202
|
+
setLogLevel
|
|
203
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./list-tools-CsWgiRy1.js";
|
|
2
|
-
//#region src/manifest/io.d.ts
|
|
3
1
|
/**
|
|
4
2
|
* Shape every MCP Vite plugin exposes on its `api` so `runExtract` can read
|
|
5
3
|
* back the resolved entry path and the URL the stack mounts the MCP server at.
|
|
@@ -8,8 +6,8 @@ import "./list-tools-CsWgiRy1.js";
|
|
|
8
6
|
* which the function and its companion routes live).
|
|
9
7
|
*/
|
|
10
8
|
interface McpPluginApi {
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
readonly mcpEntry: string;
|
|
10
|
+
readonly urlPath: string;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
export { McpPluginApi as
|
|
12
|
+
|
|
13
|
+
export type { McpPluginApi as M };
|