@lovable.dev/mcp-js 3.5.0 → 3.6.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.md +25 -6
- package/dist/{authorize--W1XtwdB.d.cts → authorize-Bea6qCAA.d.cts} +1 -1
- package/dist/{authorize-DpNYioXM.d.ts → authorize-Q0m8G9Hp.d.ts} +1 -1
- package/dist/{base-qEX8YVcD.d.cts → base-B3gSCNnJ.d.cts} +2 -2
- package/dist/{base-Ce9JYirF.d.ts → base-BjvWv8Jx.d.ts} +2 -2
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-D83r8WUF.js → cors-BaElJs06.js} +24 -44
- package/dist/{cors-B_Oui5La.cjs → cors-Brxo6miH.cjs} +92 -112
- package/dist/{errors-CfaxXr2T.js → errors-DzKZv9OC.js} +11 -2
- package/dist/{errors-xJ_7Su1K.cjs → errors-PS8N0oRK.cjs} +14 -5
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +2 -2
- package/dist/{io-STpVLkbi.js → io-B5n6fVX1.js} +2 -1
- package/dist/{io-Di5ljvZY.d.cts → io-BlRXZ_R_.d.cts} +1 -1
- package/dist/{io-BEpyfk4G.d.ts → io-BteA1cwT.d.ts} +1 -1
- package/dist/{io-CUnV4kTL.cjs → io-DZxlvNBF.cjs} +2 -1
- package/dist/{mcp-DpI0wwnW.cjs → mcp-BanAUaeS.cjs} +7 -7
- package/dist/{mcp-BgIFUoo1.js → mcp-D7K2Z_S0.js} +3 -3
- package/dist/{package-CuCho6-k.cjs → package-BUaaSbJm.cjs} +1 -1
- package/dist/{package-Cz6Z5F_X.js → package-DEUoZczA.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 +8 -6
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +4 -2
- package/dist/stacks/supabase/index.cjs +5 -4
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +4 -3
- package/dist/stacks/supabase/vite.cjs +1 -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 +1 -1
- package/dist/stacks/tanstack/index.cjs +11 -6
- package/dist/stacks/tanstack/index.d.cts +2 -2
- package/dist/stacks/tanstack/index.d.ts +2 -2
- package/dist/stacks/tanstack/index.js +10 -5
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/{types-B_dVw-zM.d.ts → types-NORvAwbQ.d.cts} +6 -0
- package/dist/{types-B_dVw-zM.d.cts → types-NORvAwbQ.d.ts} +6 -0
- package/dist/{logger-C-Hdu57K.cjs → validation-D6hthH5Q.cjs} +162 -72
- package/dist/{logger-CpLgYbCG.js → validation-xzkdIA-x.js} +133 -73
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +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-
|
|
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-NORvAwbQ.js";
|
|
3
3
|
//#region src/core/define.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Declare a single MCP tool. Import the result into your MCP definition's
|
|
@@ -43,9 +43,16 @@ interface IssuerOAuthOptionsBase {
|
|
|
43
43
|
type IssuerOAuthOptions = IssuerOAuthOptionsBase & ({
|
|
44
44
|
readonly resource: string;
|
|
45
45
|
readonly acceptedAudiences?: IssuerAcceptedAudiences;
|
|
46
|
+
readonly resourceMode?: never;
|
|
46
47
|
} | {
|
|
47
48
|
readonly resource?: string;
|
|
48
49
|
readonly acceptedAudiences: IssuerAcceptedAudiences;
|
|
50
|
+
readonly resourceMode?: never;
|
|
51
|
+
} | {
|
|
52
|
+
readonly resourceMode: "lovable-managed";
|
|
53
|
+
readonly resource?: never;
|
|
54
|
+
readonly acceptedAudiences?: never;
|
|
55
|
+
readonly protectedResourceMetadataUrl?: never;
|
|
49
56
|
});
|
|
50
57
|
/**
|
|
51
58
|
* Configure OAuth against an issuer. `acceptedAudiences` (or `resource`) is the
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ToolContext, c as defineTool, i as AuthContext, o as defineApp, s as defineMcp, t as ToolError } from "./errors-
|
|
1
|
+
import { h as setLogLevel } from "./validation-xzkdIA-x.js";
|
|
2
|
+
import { a as ToolContext, c as defineTool, i as AuthContext, o as defineApp, s as defineMcp, t as ToolError } from "./errors-DzKZv9OC.js";
|
|
3
3
|
//#region src/auth/config.ts
|
|
4
4
|
function frozenArray(value) {
|
|
5
5
|
return value === void 0 ? void 0 : Object.freeze([...value]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
|
|
2
|
-
import { t as version$1 } from "./package-
|
|
2
|
+
import { t as version$1 } from "./package-DEUoZczA.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";
|
|
@@ -36,6 +36,7 @@ function manifestAuth(auth) {
|
|
|
36
36
|
issuer: auth.issuer
|
|
37
37
|
};
|
|
38
38
|
if (auth.resource !== void 0) oauth.resource = auth.resource;
|
|
39
|
+
if (auth.resourceMode !== void 0) oauth.resource_mode = auth.resourceMode;
|
|
39
40
|
if (auth.resourceName !== void 0) oauth.resource_name = auth.resourceName;
|
|
40
41
|
if (auth.resourceDocumentation !== void 0) oauth.resource_documentation = auth.resourceDocumentation;
|
|
41
42
|
if (auth.protectedResourceMetadataUrl !== void 0) oauth.protected_resource_metadata_url = auth.protectedResourceMetadataUrl;
|
|
@@ -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-BUaaSbJm.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");
|
|
@@ -36,6 +36,7 @@ function manifestAuth(auth) {
|
|
|
36
36
|
issuer: auth.issuer
|
|
37
37
|
};
|
|
38
38
|
if (auth.resource !== void 0) oauth.resource = auth.resource;
|
|
39
|
+
if (auth.resourceMode !== void 0) oauth.resource_mode = auth.resourceMode;
|
|
39
40
|
if (auth.resourceName !== void 0) oauth.resource_name = auth.resourceName;
|
|
40
41
|
if (auth.resourceDocumentation !== void 0) oauth.resource_documentation = auth.resourceDocumentation;
|
|
41
42
|
if (auth.protectedResourceMetadataUrl !== void 0) oauth.protected_resource_metadata_url = auth.protectedResourceMetadataUrl;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_schema = require("./schema-DNMsvJwE.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_validation = require("./validation-D6hthH5Q.cjs");
|
|
3
3
|
const require_apps = require("./apps-DyoDrwfi.cjs");
|
|
4
|
-
const require_errors = require("./errors-
|
|
5
|
-
const require_cors = require("./cors-
|
|
4
|
+
const require_errors = require("./errors-PS8N0oRK.cjs");
|
|
5
|
+
const require_cors = require("./cors-Brxo6miH.cjs");
|
|
6
6
|
const require_tool_result = require("./tool-result-BQcr7VV-.cjs");
|
|
7
7
|
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
8
8
|
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
@@ -93,7 +93,7 @@ function createGatedHandler(gate) {
|
|
|
93
93
|
const cors = require_cors.evaluateCors(request, gate.allowedOrigins);
|
|
94
94
|
if (!cors.ok) {
|
|
95
95
|
const httpMethod = require_cors.normalizeHttpMethod(request.method);
|
|
96
|
-
|
|
96
|
+
require_validation.log.info("cors.origin_rejected", {
|
|
97
97
|
origin: request.headers.get("Origin"),
|
|
98
98
|
httpMethod
|
|
99
99
|
});
|
|
@@ -244,7 +244,7 @@ function toolRequestContext(sdkCtx, protocol) {
|
|
|
244
244
|
}
|
|
245
245
|
});
|
|
246
246
|
} catch (err) {
|
|
247
|
-
|
|
247
|
+
require_validation.log.debug("mcp.progress_notify_failed", require_validation.describeError(err));
|
|
248
248
|
}
|
|
249
249
|
} : void 0;
|
|
250
250
|
return {
|
|
@@ -543,8 +543,8 @@ function createMcpProtocolHandler(mcp, options = {}) {
|
|
|
543
543
|
durationMs: 0,
|
|
544
544
|
endUserId: authResult.auth?.principal.sub
|
|
545
545
|
});
|
|
546
|
-
|
|
547
|
-
...error === void 0 ? {} :
|
|
546
|
+
require_validation.log.error(appContextFailure ? "mcp.app_context_error" : "mcp.transport_error", {
|
|
547
|
+
...error === void 0 ? {} : require_validation.describeError(appContextFailure ? error.cause : error),
|
|
548
548
|
outcome: "500 internal error"
|
|
549
549
|
});
|
|
550
550
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as log, p as describeError } from "./validation-xzkdIA-x.js";
|
|
2
2
|
import { n as UI_EXTENSION_ID, r as appResourceUri, s as collectApps, t as APP_RESOURCE_MIME_TYPE } from "./apps-CWG3rGhB.js";
|
|
3
3
|
import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
|
|
4
|
-
import { a as ToolContext, i as AuthContext, l as toolRequiresAppContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-
|
|
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-
|
|
4
|
+
import { a as ToolContext, i as AuthContext, l as toolRequiresAppContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-DzKZv9OC.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-BaElJs06.js";
|
|
6
6
|
import { t as finalizeToolResult } from "./tool-result-BG-HsSQu.js";
|
|
7
7
|
import { safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
8
8
|
import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler, readRequestBody } from "@modelcontextprotocol/server";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize
|
|
1
|
+
import { y as McpDefinition } from "../../types-NORvAwbQ.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-B3gSCNnJ.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Bea6qCAA.cjs";
|
|
4
4
|
//#region src/protocols/mcp/protocol.d.ts
|
|
5
5
|
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { y as McpDefinition } from "../../types-NORvAwbQ.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-BjvWv8Jx.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Q0m8G9Hp.js";
|
|
4
4
|
//#region src/protocols/mcp/protocol.d.ts
|
|
5
5
|
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { t as createMcpProtocolHandler } from "../../mcp-D7K2Z_S0.js";
|
|
2
2
|
export { createMcpProtocolHandler };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_cors = require("../cors-
|
|
2
|
+
const require_validation = require("../validation-D6hthH5Q.cjs");
|
|
3
|
+
const require_cors = require("../cors-Brxo6miH.cjs");
|
|
4
4
|
//#region src/protocols/oauth-metadata.ts
|
|
5
5
|
function notFound() {
|
|
6
6
|
return new Response(JSON.stringify({ error: "not found" }), {
|
|
@@ -25,9 +25,10 @@ async function buildProtectedResourceMetadata(mcp, auth, request, options, disco
|
|
|
25
25
|
}
|
|
26
26
|
function createOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
27
27
|
const runtime = require_cors.getOAuthRuntime(mcp, options);
|
|
28
|
+
const managedResource = runtime.kind === "configured" && require_validation.isLovableManagedResource(runtime.auth);
|
|
28
29
|
if (runtime.kind === "configured" && runtime.auth.protectedResourceMetadataUrl === void 0 && runtime.auth.resource === void 0) {
|
|
29
30
|
if (runtime.options.resourcePath === void 0) throw new Error(`@lovable.dev/mcp-js: auth.resource or a resourcePath is required so the protected-resource metadata doesn't advertise the well-known URL as the resource`);
|
|
30
|
-
if (runtime.options.trustForwardedHost === true && runtime.options.forwardedHostTrustedByPlatform !== true)
|
|
31
|
+
if (runtime.options.trustForwardedHost === true && runtime.options.forwardedHostTrustedByPlatform !== true) require_validation.log.warn("oauth.metadata.host_derived_resource", { detail: "trustForwardedHost is on and auth.resource is unpinned; the advertised resource follows X-Forwarded-Host. Pin auth.resource unless a trusted proxy overwrites that header." });
|
|
31
32
|
}
|
|
32
33
|
const varyHeaders = ["Host"];
|
|
33
34
|
if (runtime.options.trustForwardedHost === true) varyHeaders.push("X-Forwarded-Host");
|
|
@@ -36,6 +37,7 @@ function createOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
|
36
37
|
const respond = async (request) => {
|
|
37
38
|
if (runtime.kind !== "configured" || runtime.auth.protectedResourceMetadataUrl !== void 0) return notFound();
|
|
38
39
|
if (request.method !== "GET" && request.method !== "HEAD") return require_cors.methodNotAllowed("GET, HEAD, OPTIONS");
|
|
40
|
+
if (managedResource && !await require_validation.hasLovableManagedOrigin(request)) return require_cors.oauthConfigurationErrorResponse();
|
|
39
41
|
const headers = {
|
|
40
42
|
...require_cors.JSON_HEADERS,
|
|
41
43
|
"Cache-Control": "public, max-age=300",
|
|
@@ -45,8 +47,8 @@ function createOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
|
45
47
|
const metadata = await buildProtectedResourceMetadata(mcp, runtime.auth, request, runtime.options, runtime.discovery);
|
|
46
48
|
return Response.json(metadata, { headers });
|
|
47
49
|
} catch (err) {
|
|
48
|
-
|
|
49
|
-
...
|
|
50
|
+
require_validation.log.error("oauth.metadata.config_error", {
|
|
51
|
+
...require_validation.describeError(err),
|
|
50
52
|
outcome: "500 oauth configuration error"
|
|
51
53
|
});
|
|
52
54
|
return require_cors.oauthConfigurationErrorResponse();
|
|
@@ -56,7 +58,7 @@ function createOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
|
56
58
|
const cors = require_cors.evaluateCors(request, mcp.allowedOrigins);
|
|
57
59
|
if (!cors.ok) {
|
|
58
60
|
const httpMethod = require_cors.normalizeHttpMethod(request.method);
|
|
59
|
-
|
|
61
|
+
require_validation.log.info("cors.origin_rejected", {
|
|
60
62
|
origin: request.headers.get("Origin"),
|
|
61
63
|
httpMethod,
|
|
62
64
|
route: "oauth-metadata"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize
|
|
1
|
+
import { y as McpDefinition } from "../types-NORvAwbQ.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-B3gSCNnJ.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-Bea6qCAA.cjs";
|
|
4
4
|
//#region src/protocols/oauth-metadata.d.ts
|
|
5
5
|
type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-
|
|
1
|
+
import { y as McpDefinition } from "../types-NORvAwbQ.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-BjvWv8Jx.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-Q0m8G9Hp.js";
|
|
4
4
|
//#region src/protocols/oauth-metadata.d.ts
|
|
5
5
|
type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-
|
|
1
|
+
import { c as isLovableManagedResource, m as log, p as describeError, s as hasLovableManagedOrigin } from "../validation-xzkdIA-x.js";
|
|
2
|
+
import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-BaElJs06.js";
|
|
3
3
|
//#region src/protocols/oauth-metadata.ts
|
|
4
4
|
function notFound() {
|
|
5
5
|
return new Response(JSON.stringify({ error: "not found" }), {
|
|
@@ -24,6 +24,7 @@ async function buildProtectedResourceMetadata(mcp, auth, request, options, disco
|
|
|
24
24
|
}
|
|
25
25
|
function createOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
26
26
|
const runtime = getOAuthRuntime(mcp, options);
|
|
27
|
+
const managedResource = runtime.kind === "configured" && isLovableManagedResource(runtime.auth);
|
|
27
28
|
if (runtime.kind === "configured" && runtime.auth.protectedResourceMetadataUrl === void 0 && runtime.auth.resource === void 0) {
|
|
28
29
|
if (runtime.options.resourcePath === void 0) throw new Error(`@lovable.dev/mcp-js: auth.resource or a resourcePath is required so the protected-resource metadata doesn't advertise the well-known URL as the resource`);
|
|
29
30
|
if (runtime.options.trustForwardedHost === true && runtime.options.forwardedHostTrustedByPlatform !== true) log.warn("oauth.metadata.host_derived_resource", { detail: "trustForwardedHost is on and auth.resource is unpinned; the advertised resource follows X-Forwarded-Host. Pin auth.resource unless a trusted proxy overwrites that header." });
|
|
@@ -35,6 +36,7 @@ function createOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
|
35
36
|
const respond = async (request) => {
|
|
36
37
|
if (runtime.kind !== "configured" || runtime.auth.protectedResourceMetadataUrl !== void 0) return notFound();
|
|
37
38
|
if (request.method !== "GET" && request.method !== "HEAD") return methodNotAllowed("GET, HEAD, OPTIONS");
|
|
39
|
+
if (managedResource && !await hasLovableManagedOrigin(request)) return oauthConfigurationErrorResponse();
|
|
38
40
|
const headers = {
|
|
39
41
|
...JSON_HEADERS,
|
|
40
42
|
"Cache-Control": "public, max-age=300",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_cors = require("../../cors-
|
|
2
|
+
const require_validation = require("../../validation-D6hthH5Q.cjs");
|
|
3
|
+
const require_cors = require("../../cors-Brxo6miH.cjs");
|
|
4
4
|
const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
|
|
5
|
-
const require_mcp = require("../../mcp-
|
|
5
|
+
const require_mcp = require("../../mcp-BanAUaeS.cjs");
|
|
6
6
|
const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
|
|
7
7
|
const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
|
|
8
8
|
const require_paths = require("../../paths-OP318a6c.cjs");
|
|
@@ -34,10 +34,11 @@ function getScheduleBackground() {
|
|
|
34
34
|
* Pass the handler to `Deno.serve(...)` in the emitted function entry.
|
|
35
35
|
*/
|
|
36
36
|
function createSupabaseHandler(mcp, options = {}) {
|
|
37
|
+
if (require_validation.isLovableManagedResource(mcp.auth)) throw new Error(`@lovable.dev/mcp-js: auth.resourceMode "${require_validation.LOVABLE_MANAGED_RESOURCE}" needs Lovable hosting; pin auth.resource or set auth.acceptedAudiences for Supabase Edge Functions`);
|
|
37
38
|
const resourcePath = deriveResourcePath(options);
|
|
38
39
|
if (resourcePath !== void 0) require_cors.assertResourcePathShape(resourcePath);
|
|
39
40
|
const servesOwnPrm = !(mcp.auth?.type === "oauth" && mcp.auth.protectedResourceMetadataUrl !== void 0);
|
|
40
|
-
const metadataPath = resourcePath === void 0 || !servesOwnPrm ? void 0 : `${
|
|
41
|
+
const metadataPath = resourcePath === void 0 || !servesOwnPrm ? void 0 : `${require_validation.trimTrailingSlash(resourcePath)}${require_metadata_path.OAUTH_PROTECTED_RESOURCE_METADATA_PATH}`;
|
|
41
42
|
const runtimeOptions = {
|
|
42
43
|
...resourcePath === void 0 ? {} : {
|
|
43
44
|
resourcePath,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../../types-
|
|
1
|
+
import { y as McpDefinition } from "../../types-NORvAwbQ.cjs";
|
|
2
2
|
//#region src/stacks/supabase/handler.d.ts
|
|
3
3
|
type SupabaseHandler = (request: Request) => Promise<Response>;
|
|
4
4
|
interface SupabaseHandlerOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../../types-
|
|
1
|
+
import { y as McpDefinition } from "../../types-NORvAwbQ.js";
|
|
2
2
|
//#region src/stacks/supabase/handler.d.ts
|
|
3
3
|
type SupabaseHandler = (request: Request) => Promise<Response>;
|
|
4
4
|
interface SupabaseHandlerOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-
|
|
1
|
+
import { c as isLovableManagedResource, n as trimTrailingSlash, o as LOVABLE_MANAGED_RESOURCE } from "../../validation-xzkdIA-x.js";
|
|
2
|
+
import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-BaElJs06.js";
|
|
3
3
|
import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
|
|
4
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
4
|
+
import { t as createMcpProtocolHandler } from "../../mcp-D7K2Z_S0.js";
|
|
5
5
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
6
6
|
import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
|
|
7
7
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|
|
@@ -33,6 +33,7 @@ function getScheduleBackground() {
|
|
|
33
33
|
* Pass the handler to `Deno.serve(...)` in the emitted function entry.
|
|
34
34
|
*/
|
|
35
35
|
function createSupabaseHandler(mcp, options = {}) {
|
|
36
|
+
if (isLovableManagedResource(mcp.auth)) throw new Error(`@lovable.dev/mcp-js: auth.resourceMode "${LOVABLE_MANAGED_RESOURCE}" needs Lovable hosting; pin auth.resource or set auth.acceptedAudiences for Supabase Edge Functions`);
|
|
36
37
|
const resourcePath = deriveResourcePath(options);
|
|
37
38
|
if (resourcePath !== void 0) assertResourcePathShape(resourcePath);
|
|
38
39
|
const servesOwnPrm = !(mcp.auth?.type === "oauth" && mcp.auth.protectedResourceMetadataUrl !== void 0);
|
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_package = require("../../package-
|
|
5
|
+
const require_package = require("../../package-BUaaSbJm.cjs");
|
|
6
6
|
const require_hooks = require("../../hooks-xQl3EkDa.cjs");
|
|
7
7
|
const require_paths = require("../../paths-OP318a6c.cjs");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version$1 } from "../../package-
|
|
1
|
+
import { t as version$1 } from "../../package-DEUoZczA.js";
|
|
2
2
|
import { a as isFileMissing, i as readSupabaseProjectRef, n as skillImportEsbuildPlugin, t as isSkillImportInput } from "../../hooks-BOdDe251.js";
|
|
3
3
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|
|
4
4
|
import { lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_cors = require("../../cors-
|
|
4
|
-
const require_mcp = require("../../mcp-
|
|
2
|
+
const require_validation = require("../../validation-D6hthH5Q.cjs");
|
|
3
|
+
const require_cors = require("../../cors-Brxo6miH.cjs");
|
|
4
|
+
const require_mcp = require("../../mcp-BanAUaeS.cjs");
|
|
5
5
|
const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
|
|
6
6
|
const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
|
|
7
7
|
//#region src/stacks/tanstack/handlers.ts
|
|
@@ -18,12 +18,15 @@ function resolveHandler(source, create, errorResponse) {
|
|
|
18
18
|
};
|
|
19
19
|
handler = cached.handler;
|
|
20
20
|
} catch {
|
|
21
|
-
|
|
21
|
+
require_validation.log.error("mcp.route_load_error", { outcome: "500 internal error" });
|
|
22
22
|
return require_cors.finalizeWireResponse(ctx.request, errorResponse());
|
|
23
23
|
}
|
|
24
24
|
return handler(ctx);
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
function forwardedOriginOptions(mcp, options) {
|
|
28
|
+
return require_validation.isLovableManagedResource(mcp.auth) ? {} : options;
|
|
29
|
+
}
|
|
27
30
|
function getScheduleBackground(request) {
|
|
28
31
|
const waitUntil = request.waitUntil;
|
|
29
32
|
if (typeof waitUntil !== "function") return void 0;
|
|
@@ -46,7 +49,8 @@ function createTanStackMcpHandler(mcp, options = {}) {
|
|
|
46
49
|
headers: { "Cache-Control": "no-store" }
|
|
47
50
|
}));
|
|
48
51
|
const handler = require_mcp.createMcpProtocolHandler(mcp, options);
|
|
49
|
-
|
|
52
|
+
const forwarded = forwardedOriginOptions(mcp, options);
|
|
53
|
+
return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, forwarded), require_cors.createRecorderForRuntime(mcp, { stack: STACK }), getScheduleBackground(request));
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
52
56
|
* Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
|
|
@@ -55,7 +59,8 @@ function createTanStackMcpHandler(mcp, options = {}) {
|
|
|
55
59
|
function createTanStackOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
56
60
|
if (typeof mcp === "function") return resolveHandler(mcp, (definition) => createTanStackOAuthProtectedResourceMetadataHandler(definition, options), require_cors.oauthConfigurationErrorResponse);
|
|
57
61
|
const handler = require_protocols_oauth_metadata.createOAuthProtectedResourceMetadataHandler(mcp, options);
|
|
58
|
-
|
|
62
|
+
const forwarded = forwardedOriginOptions(mcp, options);
|
|
63
|
+
return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, forwarded), require_cors.createRecorderForRuntime(mcp, { stack: STACK }), getScheduleBackground(request));
|
|
59
64
|
}
|
|
60
65
|
//#endregion
|
|
61
66
|
exports.createTanStackMcpHandler = createTanStackMcpHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../../types-
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize
|
|
1
|
+
import { y as McpDefinition } from "../../types-NORvAwbQ.cjs";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Bea6qCAA.cjs";
|
|
3
3
|
//#region src/stacks/tanstack/handlers.d.ts
|
|
4
4
|
interface TanStackRequest extends Request {
|
|
5
5
|
waitUntil?: ScheduleBackground;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { y as McpDefinition } from "../../types-
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { y as McpDefinition } from "../../types-NORvAwbQ.js";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-Q0m8G9Hp.js";
|
|
3
3
|
//#region src/stacks/tanstack/handlers.d.ts
|
|
4
4
|
interface TanStackRequest extends Request {
|
|
5
5
|
waitUntil?: ScheduleBackground;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as oauthConfigurationErrorResponse, c as createRecorderForRuntime, p as finalizeWireResponse } from "../../cors-
|
|
3
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { c as isLovableManagedResource, m as log } from "../../validation-xzkdIA-x.js";
|
|
2
|
+
import { a as oauthConfigurationErrorResponse, c as createRecorderForRuntime, p as finalizeWireResponse } from "../../cors-BaElJs06.js";
|
|
3
|
+
import { t as createMcpProtocolHandler } from "../../mcp-D7K2Z_S0.js";
|
|
4
4
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
5
5
|
import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
|
|
6
6
|
//#region src/stacks/tanstack/handlers.ts
|
|
@@ -23,6 +23,9 @@ function resolveHandler(source, create, errorResponse) {
|
|
|
23
23
|
return handler(ctx);
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
function forwardedOriginOptions(mcp, options) {
|
|
27
|
+
return isLovableManagedResource(mcp.auth) ? {} : options;
|
|
28
|
+
}
|
|
26
29
|
function getScheduleBackground(request) {
|
|
27
30
|
const waitUntil = request.waitUntil;
|
|
28
31
|
if (typeof waitUntil !== "function") return void 0;
|
|
@@ -45,7 +48,8 @@ function createTanStackMcpHandler(mcp, options = {}) {
|
|
|
45
48
|
headers: { "Cache-Control": "no-store" }
|
|
46
49
|
}));
|
|
47
50
|
const handler = createMcpProtocolHandler(mcp, options);
|
|
48
|
-
|
|
51
|
+
const forwarded = forwardedOriginOptions(mcp, options);
|
|
52
|
+
return ({ request }) => handler(applyForwardedOrigin(request, forwarded), createRecorderForRuntime(mcp, { stack: STACK }), getScheduleBackground(request));
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
|
|
@@ -54,7 +58,8 @@ function createTanStackMcpHandler(mcp, options = {}) {
|
|
|
54
58
|
function createTanStackOAuthProtectedResourceMetadataHandler(mcp, options = {}) {
|
|
55
59
|
if (typeof mcp === "function") return resolveHandler(mcp, (definition) => createTanStackOAuthProtectedResourceMetadataHandler(definition, options), oauthConfigurationErrorResponse);
|
|
56
60
|
const handler = createOAuthProtectedResourceMetadataHandler(mcp, options);
|
|
57
|
-
|
|
61
|
+
const forwarded = forwardedOriginOptions(mcp, options);
|
|
62
|
+
return ({ request }) => handler(applyForwardedOrigin(request, forwarded), createRecorderForRuntime(mcp, { stack: STACK }), getScheduleBackground(request));
|
|
58
63
|
}
|
|
59
64
|
//#endregion
|
|
60
65
|
export { createTanStackMcpHandler, createTanStackOAuthProtectedResourceMetadataHandler };
|
package/dist/testing/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as ZodOutputSchema } from "../types-
|
|
1
|
+
import { j as ZodOutputSchema } from "../types-NORvAwbQ.cjs";
|
|
2
2
|
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.cjs";
|
|
3
3
|
//#region src/testing/result.d.ts
|
|
4
4
|
interface ToolResultExpectation {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as ZodOutputSchema } from "../types-
|
|
1
|
+
import { j as ZodOutputSchema } from "../types-NORvAwbQ.js";
|
|
2
2
|
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.js";
|
|
3
3
|
//#region src/testing/result.d.ts
|
|
4
4
|
interface ToolResultExpectation {
|
|
@@ -46,6 +46,12 @@ interface McpAuthConfig {
|
|
|
46
46
|
readonly type: "oauth";
|
|
47
47
|
readonly issuer: string;
|
|
48
48
|
readonly resource?: string;
|
|
49
|
+
/**
|
|
50
|
+
* `"lovable-managed"` takes `resource` and the accepted audience from the address Lovable hosting serves.
|
|
51
|
+
*
|
|
52
|
+
* Requests fail closed with a 500 elsewhere; see the README's "Lovable-managed resource".
|
|
53
|
+
*/
|
|
54
|
+
readonly resourceMode?: "lovable-managed";
|
|
49
55
|
readonly resourceName?: string;
|
|
50
56
|
readonly resourceDocumentation?: string;
|
|
51
57
|
/**
|
|
@@ -46,6 +46,12 @@ interface McpAuthConfig {
|
|
|
46
46
|
readonly type: "oauth";
|
|
47
47
|
readonly issuer: string;
|
|
48
48
|
readonly resource?: string;
|
|
49
|
+
/**
|
|
50
|
+
* `"lovable-managed"` takes `resource` and the accepted audience from the address Lovable hosting serves.
|
|
51
|
+
*
|
|
52
|
+
* Requests fail closed with a 500 elsewhere; see the README's "Lovable-managed resource".
|
|
53
|
+
*/
|
|
54
|
+
readonly resourceMode?: "lovable-managed";
|
|
49
55
|
readonly resourceName?: string;
|
|
50
56
|
readonly resourceDocumentation?: string;
|
|
51
57
|
/**
|