@lovable.dev/mcp-js 3.3.1 → 3.5.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/README.internal.md +38 -12
- package/README.md +140 -12
- package/dist/THIRD_PARTY_NOTICES +75 -0
- package/dist/apps-CWG3rGhB.js +132 -0
- package/dist/apps-DyoDrwfi.cjs +185 -0
- package/dist/{authorize-CoaAw6wg.d.cts → authorize--W1XtwdB.d.cts} +1 -1
- package/dist/{authorize-BV62MDan.d.ts → authorize-DpNYioXM.d.ts} +1 -1
- package/dist/{base-Cx0spfMk.d.ts → base-Ce9JYirF.d.ts} +1 -1
- package/dist/{base-CzWe8AD1.d.cts → base-qEX8YVcD.d.cts} +1 -1
- package/dist/cli/check-server.cjs +1 -1
- package/dist/cli/check-server.js +1 -1
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-3HjrsmEW.cjs → cors-B_Oui5La.cjs} +1 -1
- package/dist/{cors-CNNmKKIg.js → cors-D83r8WUF.js} +1 -1
- package/dist/dist-CIu-UFye.js +6738 -0
- package/dist/dist-CqY2qXpc.cjs +6738 -0
- package/dist/{errors-CIpFAb6i.js → errors-CfaxXr2T.js} +15 -2
- package/dist/{errors-C97I7VOC.cjs → errors-xJ_7Su1K.cjs} +20 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -2
- package/dist/{io-D7cpdBJO.d.ts → io-BEpyfk4G.d.ts} +1 -1
- package/dist/{io-CaBSlPwS.cjs → io-CUnV4kTL.cjs} +12 -2
- package/dist/{io-DC-Y6R61.d.cts → io-Di5ljvZY.d.cts} +1 -1
- package/dist/{io-CahnhUhA.js → io-STpVLkbi.js} +13 -3
- package/dist/{mcp-DC8AoD18.js → mcp-BgIFUoo1.js} +110 -49
- package/dist/{mcp-DlWLIwX9.cjs → mcp-DpI0wwnW.cjs} +110 -49
- package/dist/mcp-app.d.ts +4 -0
- package/dist/{package-B488glmj.cjs → package-CuCho6-k.cjs} +1 -1
- package/dist/{package-CukfP_vq.js → package-Cz6Z5F_X.js} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +3 -3
- package/dist/protocols/mcp/index.d.ts +3 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/src-D7RtXSV0.cjs +311 -0
- package/dist/src-sWQwyLwS.js +310 -0
- package/dist/stacks/supabase/index.cjs +2 -2
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +2 -2
- package/dist/stacks/supabase/vite.cjs +10 -1
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +21 -12
- package/dist/stacks/tanstack/index.cjs +33 -2
- package/dist/stacks/tanstack/index.d.cts +7 -4
- package/dist/stacks/tanstack/index.d.ts +7 -4
- package/dist/stacks/tanstack/index.js +33 -2
- package/dist/stacks/tanstack/vite.cjs +995 -15
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/stacks/tanstack/vite.js +1001 -21
- package/dist/testing/browser/LICENSE.ext-apps +218 -0
- package/dist/testing/browser/host.ts +151 -0
- package/dist/testing/browser/sandbox.ts +137 -0
- package/dist/testing/browser.cjs +382 -0
- package/dist/testing/browser.d.cts +46 -0
- package/dist/testing/browser.d.ts +46 -0
- package/dist/testing/browser.js +381 -0
- package/dist/testing/index.cjs +2 -1
- package/dist/testing/index.d.cts +2 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/server.cjs +36 -0
- package/dist/testing/server.d.cts +6 -2
- package/dist/testing/server.d.ts +6 -2
- package/dist/testing/server.js +36 -1
- package/dist/{tool-result-DcNioyiI.js → tool-result-BG-HsSQu.js} +8 -1
- package/dist/{tool-result-rU-PpNNi.cjs → tool-result-BQcr7VV-.cjs} +8 -1
- package/dist/{types-z7T5bBIU.d.cts → types-B_dVw-zM.d.cts} +55 -1
- package/dist/{types-z7T5bBIU.d.ts → types-B_dVw-zM.d.ts} +55 -1
- package/package.json +66 -25
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { o as parseSafeUrl, s as trimTrailingSlash, u as resolveMetricsConfig } from "./logger-CpLgYbCG.js";
|
|
2
2
|
import { n as validateSkills } from "./format-DKEuO8Tn.js";
|
|
3
|
+
import { c as freezeApp, i as assertAppDefinitionInput, l as freezeToolUi, o as assertToolUi, s as collectApps } from "./apps-CWG3rGhB.js";
|
|
3
4
|
import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
|
|
4
5
|
//#region src/core/define.ts
|
|
5
6
|
function toolRequiresAppContext(tool) {
|
|
@@ -136,6 +137,13 @@ const defineTool = Object.assign(defineStaticTool, { withAppContext: () => (def)
|
|
|
136
137
|
requiresAppContext: true
|
|
137
138
|
};
|
|
138
139
|
} });
|
|
140
|
+
/** MCP Apps is beta with normal semver guarantees.
|
|
141
|
+
* See {@link https://www.npmjs.com/package/@lovable.dev/mcp-js?activeTab=readme | beta policy in the package README}. */
|
|
142
|
+
function defineApp(def) {
|
|
143
|
+
assertAppDefinitionInput(def);
|
|
144
|
+
freezeApp(def);
|
|
145
|
+
return def;
|
|
146
|
+
}
|
|
139
147
|
/**
|
|
140
148
|
* Declare the MCP server. `export default` the result from your MCP
|
|
141
149
|
* entrypoint (default `lib/mcp/index.ts`); the Vite plugin reads it to
|
|
@@ -151,12 +159,17 @@ function defineMcp(def) {
|
|
|
151
159
|
assertAllowedOrigins(def.allowedOrigins);
|
|
152
160
|
assertLimits(def.limits);
|
|
153
161
|
assertToolSchemas(def);
|
|
162
|
+
for (const tool of def.tools) assertToolUi(tool);
|
|
163
|
+
collectApps(def.tools);
|
|
154
164
|
resolveMetricsConfig(def.metrics);
|
|
155
165
|
freezeAuth(def.auth);
|
|
156
166
|
if (def.limits) Object.freeze(def.limits);
|
|
157
167
|
if (Array.isArray(def.allowedOrigins)) Object.freeze(def.allowedOrigins);
|
|
158
168
|
Object.freeze(def.tools);
|
|
159
|
-
for (const tool of def.tools)
|
|
169
|
+
for (const tool of def.tools) {
|
|
170
|
+
freezeToolUi(tool);
|
|
171
|
+
Object.freeze(tool);
|
|
172
|
+
}
|
|
160
173
|
if (def.skills !== void 0) {
|
|
161
174
|
if (!Array.isArray(def.skills)) throw new TypeError("@lovable.dev/mcp-js: skills must be an array of ?skill imports");
|
|
162
175
|
validateSkills(def.skills.map((entry) => {
|
|
@@ -283,4 +296,4 @@ function errorSummary(err) {
|
|
|
283
296
|
}
|
|
284
297
|
}
|
|
285
298
|
//#endregion
|
|
286
|
-
export { ToolContext as a,
|
|
299
|
+
export { ToolContext as a, defineTool as c, AuthContext as i, toolRequiresAppContext as l, errorSummary as n, defineApp as o, resolveToolErrorMessage as r, defineMcp as s, ToolError as t };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_schema = require("./schema-DNMsvJwE.cjs");
|
|
2
2
|
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
3
3
|
const require_format = require("./format-DDzvc92Z.cjs");
|
|
4
|
+
const require_apps = require("./apps-DyoDrwfi.cjs");
|
|
4
5
|
//#region src/core/define.ts
|
|
5
6
|
function toolRequiresAppContext(tool) {
|
|
6
7
|
return "requiresAppContext" in tool && tool.requiresAppContext === true;
|
|
@@ -136,6 +137,13 @@ const defineTool = Object.assign(defineStaticTool, { withAppContext: () => (def)
|
|
|
136
137
|
requiresAppContext: true
|
|
137
138
|
};
|
|
138
139
|
} });
|
|
140
|
+
/** MCP Apps is beta with normal semver guarantees.
|
|
141
|
+
* See {@link https://www.npmjs.com/package/@lovable.dev/mcp-js?activeTab=readme | beta policy in the package README}. */
|
|
142
|
+
function defineApp(def) {
|
|
143
|
+
require_apps.assertAppDefinitionInput(def);
|
|
144
|
+
require_apps.freezeApp(def);
|
|
145
|
+
return def;
|
|
146
|
+
}
|
|
139
147
|
/**
|
|
140
148
|
* Declare the MCP server. `export default` the result from your MCP
|
|
141
149
|
* entrypoint (default `lib/mcp/index.ts`); the Vite plugin reads it to
|
|
@@ -151,12 +159,17 @@ function defineMcp(def) {
|
|
|
151
159
|
assertAllowedOrigins(def.allowedOrigins);
|
|
152
160
|
assertLimits(def.limits);
|
|
153
161
|
assertToolSchemas(def);
|
|
162
|
+
for (const tool of def.tools) require_apps.assertToolUi(tool);
|
|
163
|
+
require_apps.collectApps(def.tools);
|
|
154
164
|
require_logger.resolveMetricsConfig(def.metrics);
|
|
155
165
|
freezeAuth(def.auth);
|
|
156
166
|
if (def.limits) Object.freeze(def.limits);
|
|
157
167
|
if (Array.isArray(def.allowedOrigins)) Object.freeze(def.allowedOrigins);
|
|
158
168
|
Object.freeze(def.tools);
|
|
159
|
-
for (const tool of def.tools)
|
|
169
|
+
for (const tool of def.tools) {
|
|
170
|
+
require_apps.freezeToolUi(tool);
|
|
171
|
+
Object.freeze(tool);
|
|
172
|
+
}
|
|
160
173
|
if (def.skills !== void 0) {
|
|
161
174
|
if (!Array.isArray(def.skills)) throw new TypeError("@lovable.dev/mcp-js: skills must be an array of ?skill imports");
|
|
162
175
|
require_format.validateSkills(def.skills.map((entry) => {
|
|
@@ -301,6 +314,12 @@ Object.defineProperty(exports, "ToolError", {
|
|
|
301
314
|
return ToolError;
|
|
302
315
|
}
|
|
303
316
|
});
|
|
317
|
+
Object.defineProperty(exports, "defineApp", {
|
|
318
|
+
enumerable: true,
|
|
319
|
+
get: function() {
|
|
320
|
+
return defineApp;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
304
323
|
Object.defineProperty(exports, "defineMcp", {
|
|
305
324
|
enumerable: true,
|
|
306
325
|
get: function() {
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
3
|
-
const require_errors = require("./errors-
|
|
3
|
+
const require_errors = require("./errors-xJ_7Su1K.cjs");
|
|
4
4
|
//#region src/auth/config.ts
|
|
5
5
|
function frozenArray(value) {
|
|
6
6
|
return value === void 0 ? void 0 : Object.freeze([...value]);
|
|
@@ -39,6 +39,7 @@ exports.AuthContext = require_errors.AuthContext;
|
|
|
39
39
|
exports.ToolContext = require_errors.ToolContext;
|
|
40
40
|
exports.ToolError = require_errors.ToolError;
|
|
41
41
|
exports.auth = auth;
|
|
42
|
+
exports.defineApp = require_errors.defineApp;
|
|
42
43
|
exports.defineMcp = require_errors.defineMcp;
|
|
43
44
|
exports.defineTool = require_errors.defineTool;
|
|
44
45
|
exports.setLogLevel = require_logger.setLogLevel;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="./mcp-app.d.ts" />
|
|
2
|
+
import { A as ToolVisibilityContext, B as ProgressUpdate, C as TextContent, D as ToolHandlerResult, E as ToolDefinition, F as MetricsConfig, H as JwtClaims, I as MetricsOptions, L as AuthContext, M as ZodRawShape, N as ZodSchema, O as ToolUiOptions, P as Skill, R as McpClientInfo, S as ResourceLinkIcon, T as ToolContent, U as McpAuthConfig, V as ToolContext, _ as JsonValueInput, a as AppDefinitionInput, b as McpDefinitionInput, c as ConditionalSkill, d as CreateAppContextInput, f as EmbeddedBlobResource, g as JsonValue, h as ImageContent, i as AppDefinition, j as ZodOutputSchema, k as ToolUiVisibility, l as ContentAnnotations, m as EmbeddedTextResource, n as AppContextToolDefinitionInput, o as AppPermissions, p as EmbeddedResource, r as AppCsp, s as AudioContent, t as AppContextToolDefinition, u as ContentBlock, v as McpAllowedOrigins, w as ToolAnnotations, x as ResourceLink, y as McpDefinition, z as McpProtocolEra } from "./types-B_dVw-zM.cjs";
|
|
2
3
|
//#region src/core/define.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Declare a single MCP tool. Import the result into your MCP definition's
|
|
@@ -14,6 +15,9 @@ interface DefineTool {
|
|
|
14
15
|
withAppContext<TAppContext>(): <TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: AppContextToolDefinitionInput<TInput, TOutput, TAppContext>) => AppContextToolDefinition<TInput, TOutput, TAppContext>;
|
|
15
16
|
}
|
|
16
17
|
declare const defineTool: DefineTool;
|
|
18
|
+
/** MCP Apps is beta with normal semver guarantees.
|
|
19
|
+
* See {@link https://www.npmjs.com/package/@lovable.dev/mcp-js?activeTab=readme | beta policy in the package README}. */
|
|
20
|
+
declare function defineApp(def: AppDefinitionInput): AppDefinition;
|
|
17
21
|
/**
|
|
18
22
|
* Declare the MCP server. `export default` the result from your MCP
|
|
19
23
|
* entrypoint (default `lib/mcp/index.ts`); the Vite plugin reads it to
|
|
@@ -76,4 +80,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
76
80
|
*/
|
|
77
81
|
declare function setLogLevel(level: LogLevel): LogLevel;
|
|
78
82
|
//#endregion
|
|
79
|
-
export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AudioContent, AuthContext, type ConditionalSkill, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
|
83
|
+
export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AppCsp, type AppDefinition, type AppDefinitionInput, type AppPermissions, type AudioContent, AuthContext, type ConditionalSkill, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolUiOptions, type ToolUiVisibility, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineApp, defineMcp, defineTool, setLogLevel };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="./mcp-app.d.ts" />
|
|
2
|
+
import { A as ToolVisibilityContext, B as ProgressUpdate, C as TextContent, D as ToolHandlerResult, E as ToolDefinition, F as MetricsConfig, H as JwtClaims, I as MetricsOptions, L as AuthContext, M as ZodRawShape, N as ZodSchema, O as ToolUiOptions, P as Skill, R as McpClientInfo, S as ResourceLinkIcon, T as ToolContent, U as McpAuthConfig, V as ToolContext, _ as JsonValueInput, a as AppDefinitionInput, b as McpDefinitionInput, c as ConditionalSkill, d as CreateAppContextInput, f as EmbeddedBlobResource, g as JsonValue, h as ImageContent, i as AppDefinition, j as ZodOutputSchema, k as ToolUiVisibility, l as ContentAnnotations, m as EmbeddedTextResource, n as AppContextToolDefinitionInput, o as AppPermissions, p as EmbeddedResource, r as AppCsp, s as AudioContent, t as AppContextToolDefinition, u as ContentBlock, v as McpAllowedOrigins, w as ToolAnnotations, x as ResourceLink, y as McpDefinition, z as McpProtocolEra } from "./types-B_dVw-zM.js";
|
|
2
3
|
//#region src/core/define.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Declare a single MCP tool. Import the result into your MCP definition's
|
|
@@ -14,6 +15,9 @@ interface DefineTool {
|
|
|
14
15
|
withAppContext<TAppContext>(): <TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: AppContextToolDefinitionInput<TInput, TOutput, TAppContext>) => AppContextToolDefinition<TInput, TOutput, TAppContext>;
|
|
15
16
|
}
|
|
16
17
|
declare const defineTool: DefineTool;
|
|
18
|
+
/** MCP Apps is beta with normal semver guarantees.
|
|
19
|
+
* See {@link https://www.npmjs.com/package/@lovable.dev/mcp-js?activeTab=readme | beta policy in the package README}. */
|
|
20
|
+
declare function defineApp(def: AppDefinitionInput): AppDefinition;
|
|
17
21
|
/**
|
|
18
22
|
* Declare the MCP server. `export default` the result from your MCP
|
|
19
23
|
* entrypoint (default `lib/mcp/index.ts`); the Vite plugin reads it to
|
|
@@ -76,4 +80,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
76
80
|
*/
|
|
77
81
|
declare function setLogLevel(level: LogLevel): LogLevel;
|
|
78
82
|
//#endregion
|
|
79
|
-
export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AudioContent, AuthContext, type ConditionalSkill, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
|
83
|
+
export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AppCsp, type AppDefinition, type AppDefinitionInput, type AppPermissions, type AudioContent, AuthContext, type ConditionalSkill, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolUiOptions, type ToolUiVisibility, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineApp, defineMcp, defineTool, setLogLevel };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as setLogLevel } from "./logger-CpLgYbCG.js";
|
|
2
|
-
import { a as ToolContext, i as AuthContext, o as
|
|
2
|
+
import { a as ToolContext, c as defineTool, i as AuthContext, o as defineApp, s as defineMcp, t as ToolError } from "./errors-CfaxXr2T.js";
|
|
3
3
|
//#region src/auth/config.ts
|
|
4
4
|
function frozenArray(value) {
|
|
5
5
|
return value === void 0 ? void 0 : Object.freeze([...value]);
|
|
@@ -34,4 +34,4 @@ function issuer(options) {
|
|
|
34
34
|
const oauth = Object.freeze({ issuer });
|
|
35
35
|
const auth = Object.freeze({ oauth });
|
|
36
36
|
//#endregion
|
|
37
|
-
export { AuthContext, ToolContext, ToolError, auth, defineMcp, defineTool, setLogLevel };
|
|
37
|
+
export { AuthContext, ToolContext, ToolError, auth, defineApp, defineMcp, defineTool, setLogLevel };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_schema = require("./schema-DNMsvJwE.cjs");
|
|
2
|
-
const require_package = require("./package-
|
|
2
|
+
const require_package = require("./package-CuCho6-k.cjs");
|
|
3
3
|
const require_hooks = require("./hooks-xQl3EkDa.cjs");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
@@ -79,6 +79,16 @@ function manifestFromDefinition(definition, urlPath, source = "the MCP entry") {
|
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/manifest/ssr-loader.ts
|
|
82
|
+
const stubMcpAppImports = {
|
|
83
|
+
name: "@lovable.dev/mcp-js:manifest-mcp-app-stub",
|
|
84
|
+
enforce: "pre",
|
|
85
|
+
resolveId(source) {
|
|
86
|
+
return source.endsWith("?mcp-app") ? `\0mcp-app-stub:${source}` : null;
|
|
87
|
+
},
|
|
88
|
+
load(id) {
|
|
89
|
+
return id.startsWith("\0mcp-app-stub:") ? "export default \"<!doctype html>\";\n" : null;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
82
92
|
async function produceViaSsr(projectRoot, alias, ssr, entryAbs, urlPath) {
|
|
83
93
|
const server = await (0, vite.createServer)({
|
|
84
94
|
configFile: false,
|
|
@@ -91,7 +101,7 @@ async function produceViaSsr(projectRoot, alias, ssr, entryAbs, urlPath) {
|
|
|
91
101
|
},
|
|
92
102
|
optimizeDeps: { noDiscovery: true },
|
|
93
103
|
resolve: { alias },
|
|
94
|
-
plugins: [require_hooks.skillImportVitePlugin({ report: () => {} })],
|
|
104
|
+
plugins: [require_hooks.skillImportVitePlugin({ report: () => {} }), stubMcpAppImports],
|
|
95
105
|
ssr
|
|
96
106
|
});
|
|
97
107
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version$1 } from "./package-Cz6Z5F_X.js";
|
|
3
3
|
import { a as isFileMissing, i as readSupabaseProjectRef, r as skillImportVitePlugin } from "./hooks-BOdDe251.js";
|
|
4
4
|
import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, resolve } from "node:path";
|
|
@@ -71,7 +71,7 @@ function manifestFromDefinition(definition, urlPath, source = "the MCP entry") {
|
|
|
71
71
|
if (issuer !== void 0 && hasBlankIssuerHost(issuer)) throw new Error(`@lovable.dev/mcp-js: ${source} resolves its OAuth issuer to "${issuer}", which has no project host. Set VITE_SUPABASE_PROJECT_ID or the top-level project_id in supabase/config.toml, then extract the manifest again.`);
|
|
72
72
|
return {
|
|
73
73
|
version: 1,
|
|
74
|
-
sdk_version: version,
|
|
74
|
+
sdk_version: version$1,
|
|
75
75
|
path: urlPath,
|
|
76
76
|
auth: manifestAuth(def.auth),
|
|
77
77
|
mcp: buildMcpListing(def)
|
|
@@ -79,6 +79,16 @@ function manifestFromDefinition(definition, urlPath, source = "the MCP entry") {
|
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/manifest/ssr-loader.ts
|
|
82
|
+
const stubMcpAppImports = {
|
|
83
|
+
name: "@lovable.dev/mcp-js:manifest-mcp-app-stub",
|
|
84
|
+
enforce: "pre",
|
|
85
|
+
resolveId(source) {
|
|
86
|
+
return source.endsWith("?mcp-app") ? `\0mcp-app-stub:${source}` : null;
|
|
87
|
+
},
|
|
88
|
+
load(id) {
|
|
89
|
+
return id.startsWith("\0mcp-app-stub:") ? "export default \"<!doctype html>\";\n" : null;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
82
92
|
async function produceViaSsr(projectRoot, alias, ssr, entryAbs, urlPath) {
|
|
83
93
|
const server = await createServer({
|
|
84
94
|
configFile: false,
|
|
@@ -91,7 +101,7 @@ async function produceViaSsr(projectRoot, alias, ssr, entryAbs, urlPath) {
|
|
|
91
101
|
},
|
|
92
102
|
optimizeDeps: { noDiscovery: true },
|
|
93
103
|
resolve: { alias },
|
|
94
|
-
plugins: [skillImportVitePlugin({ report: () => {} })],
|
|
104
|
+
plugins: [skillImportVitePlugin({ report: () => {} }), stubMcpAppImports],
|
|
95
105
|
ssr
|
|
96
106
|
});
|
|
97
107
|
try {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { i as log, r as describeError } from "./logger-CpLgYbCG.js";
|
|
2
|
+
import { n as UI_EXTENSION_ID, r as appResourceUri, s as collectApps, t as APP_RESOURCE_MIME_TYPE } from "./apps-CWG3rGhB.js";
|
|
2
3
|
import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
|
|
3
|
-
import { a as ToolContext,
|
|
4
|
-
import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-
|
|
5
|
-
import { t as finalizeToolResult } from "./tool-result-
|
|
4
|
+
import { a as ToolContext, i as AuthContext, l as toolRequiresAppContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-CfaxXr2T.js";
|
|
5
|
+
import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-D83r8WUF.js";
|
|
6
|
+
import { t as finalizeToolResult } from "./tool-result-BG-HsSQu.js";
|
|
6
7
|
import { safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
7
8
|
import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler, readRequestBody } from "@modelcontextprotocol/server";
|
|
8
9
|
//#region src/core/content.ts
|
|
@@ -116,18 +117,18 @@ function createGatedHandler(gate) {
|
|
|
116
117
|
const MODERN_PROTOCOL_VERSION = "2026-07-28";
|
|
117
118
|
const NO_OPERATIONS = {
|
|
118
119
|
listTools: false,
|
|
120
|
+
exposeApps: false,
|
|
119
121
|
calledTools: /* @__PURE__ */ new Set()
|
|
120
122
|
};
|
|
121
|
-
function collectRequestOperations(value,
|
|
123
|
+
function collectRequestOperations(value, operations) {
|
|
122
124
|
if (Array.isArray(value)) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return listTools;
|
|
125
|
+
for (const item of value) collectRequestOperations(item, operations);
|
|
126
|
+
return;
|
|
126
127
|
}
|
|
127
|
-
if (!isPlainObject(value)) return
|
|
128
|
-
if (value.method === "tools/list")
|
|
129
|
-
if (value.method === "
|
|
130
|
-
|
|
128
|
+
if (!isPlainObject(value)) return;
|
|
129
|
+
if (value.method === "tools/list") operations.listTools = true;
|
|
130
|
+
if (value.method === "initialize" || value.method === "server/discover" || value.method === "resources/list" || value.method === "resources/read" && isPlainObject(value.params) && typeof value.params.uri === "string" && URL.canParse(value.params.uri) && new URL(value.params.uri).protocol === "ui:") operations.exposeApps = true;
|
|
131
|
+
if (value.method === "tools/call" && isPlainObject(value.params) && typeof value.params.name === "string") operations.calledTools.add(value.params.name);
|
|
131
132
|
}
|
|
132
133
|
/** Marks a failure in app-owned `createAppContext` or `enabled` code so telemetry
|
|
133
134
|
* can attribute it to the author rather than to the transport. */
|
|
@@ -146,15 +147,17 @@ async function withAppContextError(run) {
|
|
|
146
147
|
}
|
|
147
148
|
async function classifyRequest(request, maxRequestBodySize) {
|
|
148
149
|
try {
|
|
149
|
-
const body = await readRequestBody(request
|
|
150
|
+
const body = await readRequestBody(request, maxRequestBodySize);
|
|
150
151
|
if (body.tooLarge) return { operations: NO_OPERATIONS };
|
|
151
152
|
const parsedBody = JSON.parse(body.text);
|
|
152
|
-
const
|
|
153
|
+
const operations = {
|
|
154
|
+
listTools: false,
|
|
155
|
+
exposeApps: false,
|
|
156
|
+
calledTools: /* @__PURE__ */ new Set()
|
|
157
|
+
};
|
|
158
|
+
collectRequestOperations(parsedBody, operations);
|
|
153
159
|
return {
|
|
154
|
-
operations
|
|
155
|
-
listTools: collectRequestOperations(parsedBody, calledTools),
|
|
156
|
-
calledTools
|
|
157
|
-
},
|
|
160
|
+
operations,
|
|
158
161
|
parsedBody
|
|
159
162
|
};
|
|
160
163
|
} catch {
|
|
@@ -324,11 +327,50 @@ function adaptToolCallback(tool, auth, recorder, protocol, appContext) {
|
|
|
324
327
|
return {
|
|
325
328
|
content: result.content ?? [],
|
|
326
329
|
structuredContent: result.structuredContent,
|
|
327
|
-
isError: result.isError
|
|
330
|
+
isError: result.isError,
|
|
331
|
+
_meta: result._meta
|
|
328
332
|
};
|
|
329
333
|
};
|
|
330
334
|
}
|
|
331
|
-
|
|
335
|
+
function appResourceMeta(app) {
|
|
336
|
+
const ui = {};
|
|
337
|
+
if (app.csp) ui.csp = app.csp;
|
|
338
|
+
if (app.permissions) ui.permissions = app.permissions;
|
|
339
|
+
if (app.domain !== void 0) ui.domain = app.domain;
|
|
340
|
+
if (app.prefersBorder !== void 0) ui.prefersBorder = app.prefersBorder;
|
|
341
|
+
return Object.keys(ui).length > 0 ? { ui } : void 0;
|
|
342
|
+
}
|
|
343
|
+
function registerApps(server, apps) {
|
|
344
|
+
for (const app of apps) {
|
|
345
|
+
const uri = appResourceUri(app.name);
|
|
346
|
+
const meta = appResourceMeta(app);
|
|
347
|
+
const withMeta = meta ? { _meta: meta } : {};
|
|
348
|
+
server.registerResource(app.name, uri, {
|
|
349
|
+
title: app.title,
|
|
350
|
+
description: app.description,
|
|
351
|
+
mimeType: APP_RESOURCE_MIME_TYPE,
|
|
352
|
+
cacheHint: PRIVATE_CACHE,
|
|
353
|
+
...withMeta
|
|
354
|
+
}, () => ({ contents: [{
|
|
355
|
+
uri,
|
|
356
|
+
mimeType: APP_RESOURCE_MIME_TYPE,
|
|
357
|
+
text: app.html,
|
|
358
|
+
...withMeta
|
|
359
|
+
}] }));
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function toolUiMeta(tool) {
|
|
363
|
+
if (!tool.ui) return void 0;
|
|
364
|
+
const resourceUri = tool.ui.app ? appResourceUri(tool.ui.app.name) : void 0;
|
|
365
|
+
return {
|
|
366
|
+
ui: {
|
|
367
|
+
...resourceUri ? { resourceUri } : {},
|
|
368
|
+
...tool.ui.visibility ? { visibility: tool.ui.visibility } : {}
|
|
369
|
+
},
|
|
370
|
+
...resourceUri ? { "ui/resourceUri": resourceUri } : {}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
const PRIVATE_CACHE = {
|
|
332
374
|
ttlMs: 0,
|
|
333
375
|
cacheScope: "private"
|
|
334
376
|
};
|
|
@@ -360,14 +402,14 @@ function skillEntry(skill) {
|
|
|
360
402
|
function registerSkills(server, skills, era) {
|
|
361
403
|
const resultMetadata = era === "modern" ? {
|
|
362
404
|
resultType: "complete",
|
|
363
|
-
...
|
|
405
|
+
...PRIVATE_CACHE
|
|
364
406
|
} : {};
|
|
365
407
|
for (const file of skills.files.values()) {
|
|
366
408
|
const owner = skills.skillsByUri.get(file.uri);
|
|
367
409
|
server.registerResource(owner ? owner.frontmatter.name : file.uri, file.uri, {
|
|
368
410
|
mimeType: file.mimeType,
|
|
369
411
|
...owner ? { description: owner.frontmatter.description } : {},
|
|
370
|
-
cacheHint:
|
|
412
|
+
cacheHint: PRIVATE_CACHE
|
|
371
413
|
}, async () => ({ contents: [{
|
|
372
414
|
uri: file.uri,
|
|
373
415
|
mimeType: file.mimeType,
|
|
@@ -388,16 +430,27 @@ function registerSkills(server, skills, era) {
|
|
|
388
430
|
});
|
|
389
431
|
}
|
|
390
432
|
async function buildServer(mcp, auth, recorder, era, signal, operations, skills) {
|
|
433
|
+
const hasApps = mcp.tools.some((tool) => tool.ui?.app !== void 0);
|
|
391
434
|
const calledTools = operations ? mcp.tools.filter((tool) => operations.calledTools.has(tool.name)) : mcp.tools;
|
|
392
435
|
const selectedTools = !operations || operations.listTools ? mcp.tools : calledTools;
|
|
393
|
-
const
|
|
394
|
-
const needsAppContext = skills !== void 0 && skills.prepared === void 0 ||
|
|
436
|
+
const exposureTools = operations?.exposeApps ? mcp.tools.filter((tool) => tool.ui?.app !== void 0 || selectedTools.includes(tool)) : selectedTools;
|
|
437
|
+
const needsAppContext = skills !== void 0 && skills.prepared === void 0 || exposureTools.some((tool) => tool.enabled !== void 0) || calledTools.some(toolRequiresAppContext);
|
|
395
438
|
const { createAppContext } = mcp;
|
|
396
439
|
const appContext = needsAppContext && createAppContext ? await withAppContextError(() => createAppContext({
|
|
397
440
|
auth: new AuthContext(auth),
|
|
398
441
|
signal
|
|
399
442
|
})) : void 0;
|
|
400
443
|
const visibilityContext = Object.freeze({ appContext });
|
|
444
|
+
const enabledTools = /* @__PURE__ */ new Set();
|
|
445
|
+
for (const tool of exposureTools) if (await withAppContextError(() => {
|
|
446
|
+
const value = tool.enabled ? tool.enabled(visibilityContext) : true;
|
|
447
|
+
if (typeof value !== "boolean") {
|
|
448
|
+
Promise.resolve(value).catch(() => {});
|
|
449
|
+
throw new TypeError(`@lovable.dev/mcp-js: tool "${tool.name}" enabled must return a boolean synchronously`);
|
|
450
|
+
}
|
|
451
|
+
return value;
|
|
452
|
+
})) enabledTools.add(tool);
|
|
453
|
+
const apps = collectApps([...enabledTools]);
|
|
401
454
|
let preparedSkills = skills?.prepared;
|
|
402
455
|
if (skills && !preparedSkills) {
|
|
403
456
|
const enabledSkills = await withAppContextError(() => mcp.skills.flatMap((entry) => {
|
|
@@ -418,14 +471,19 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
|
|
|
418
471
|
}, {
|
|
419
472
|
maxToolInputElements: mcp.limits?.maxToolInputElements ?? 1e4,
|
|
420
473
|
instructions: preparedSkills ? composeInstructions(mcp.instructions, preparedSkills, skills.declared) : mcp.instructions,
|
|
421
|
-
capabilities:
|
|
474
|
+
capabilities: {
|
|
422
475
|
tools: { listChanged: false },
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
476
|
+
...hasApps || skills ? {
|
|
477
|
+
resources: {
|
|
478
|
+
listChanged: false,
|
|
479
|
+
subscribe: false
|
|
480
|
+
},
|
|
481
|
+
extensions: {
|
|
482
|
+
...apps.length > 0 ? { [UI_EXTENSION_ID]: { mimeTypes: [APP_RESOURCE_MIME_TYPE] } } : {},
|
|
483
|
+
...skills ? { [SKILLS_EXTENSION_ID]: {} } : {}
|
|
484
|
+
}
|
|
485
|
+
} : {}
|
|
486
|
+
},
|
|
429
487
|
cacheHints: {
|
|
430
488
|
"tools/list": {
|
|
431
489
|
ttlMs: 0,
|
|
@@ -435,26 +493,22 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
|
|
|
435
493
|
ttlMs: 0,
|
|
436
494
|
cacheScope: "private"
|
|
437
495
|
},
|
|
438
|
-
...skills ? {
|
|
439
|
-
"resources/list":
|
|
440
|
-
"resources/read":
|
|
496
|
+
...hasApps || skills ? {
|
|
497
|
+
"resources/list": PRIVATE_CACHE,
|
|
498
|
+
"resources/read": PRIVATE_CACHE
|
|
441
499
|
} : {}
|
|
442
500
|
}
|
|
443
501
|
});
|
|
502
|
+
registerApps(server, apps);
|
|
444
503
|
if (preparedSkills) registerSkills(server, preparedSkills, era);
|
|
445
504
|
for (const tool of selectedTools) {
|
|
446
|
-
if (tool
|
|
447
|
-
|
|
448
|
-
if (!await withAppContextError(() => {
|
|
449
|
-
const value = enabled(visibilityContext);
|
|
450
|
-
if (typeof value !== "boolean") throw new TypeError(`@lovable.dev/mcp-js: tool "${tool.name}" enabled must return a boolean synchronously`);
|
|
451
|
-
return value;
|
|
452
|
-
})) continue;
|
|
453
|
-
}
|
|
505
|
+
if (!enabledTools.has(tool)) continue;
|
|
506
|
+
const _meta = toolUiMeta(tool);
|
|
454
507
|
const config = {
|
|
455
508
|
title: tool.title,
|
|
456
509
|
description: tool.description,
|
|
457
510
|
annotations: tool.annotations,
|
|
511
|
+
..._meta ? { _meta } : {},
|
|
458
512
|
...tool.outputSchema ? { outputSchema: standardSchemaFromDefinition(tool.outputSchema, false) } : {}
|
|
459
513
|
};
|
|
460
514
|
const callback = adaptToolCallback(tool, auth, recorder, era === "legacy" ? "legacy" : MODERN_PROTOCOL_VERSION, appContext);
|
|
@@ -494,21 +548,26 @@ function createMcpProtocolHandler(mcp, options = {}) {
|
|
|
494
548
|
outcome: "500 internal error"
|
|
495
549
|
});
|
|
496
550
|
};
|
|
551
|
+
let classificationRequest;
|
|
497
552
|
try {
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
553
|
+
classificationRequest = mcp.createAppContext || hasSkills ? request.clone() : void 0;
|
|
554
|
+
const response = await createMcpHandler(async ({ era, requestInfo }) => {
|
|
555
|
+
const classified = classificationRequest ? await classifyRequest(classificationRequest, maxRequestBodySize) : void 0;
|
|
556
|
+
const operations = mcp.createAppContext ? classified?.operations : void 0;
|
|
557
|
+
const skills = hasSkills ? {
|
|
558
|
+
prepared: preparedSkills,
|
|
559
|
+
declared: declaresSkillsSupport(classified?.parsedBody)
|
|
560
|
+
} : void 0;
|
|
561
|
+
return buildServer(mcp, authResult.auth, recorder, era, requestInfo?.signal ?? request.signal, operations, skills);
|
|
562
|
+
}, {
|
|
505
563
|
legacy: "stateless",
|
|
506
564
|
maxRequestBodySize,
|
|
507
565
|
maxSubscriptions: 0,
|
|
508
566
|
onerror: (error) => {
|
|
509
567
|
protocolError = error;
|
|
510
568
|
}
|
|
511
|
-
}).fetch(request
|
|
569
|
+
}).fetch(request);
|
|
570
|
+
response.headers.append("Cache-Control", "no-store");
|
|
512
571
|
if (response.status >= 500) await reportTransportError(protocolError);
|
|
513
572
|
return response;
|
|
514
573
|
} catch (err) {
|
|
@@ -521,6 +580,8 @@ function createMcpProtocolHandler(mcp, options = {}) {
|
|
|
521
580
|
message: "internal error"
|
|
522
581
|
}
|
|
523
582
|
}, { status: 500 });
|
|
583
|
+
} finally {
|
|
584
|
+
if (classificationRequest?.body && !classificationRequest.bodyUsed) classificationRequest.body.cancel().catch(() => {});
|
|
524
585
|
}
|
|
525
586
|
};
|
|
526
587
|
return createGatedHandler({
|