@lovable.dev/mcp-js 0.22.1 → 0.22.2-rc.1
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-CumVyk7p.d.cts +27 -0
- package/dist/authorize-D6p4-9_D.d.ts +27 -0
- package/dist/base-DCe0kP79.d.cts +29 -0
- package/dist/base-DCe0kP79.d.ts +29 -0
- package/dist/cli/extract-manifest.cjs +116 -201
- package/dist/cli/extract-manifest.d.cts +1 -1
- package/dist/cli/extract-manifest.d.ts +1 -1
- package/dist/cli/extract-manifest.js +117 -156
- package/dist/content-D5LJAHyM.js +12 -0
- package/dist/content-NCYIGgOb.cjs +17 -0
- package/dist/context-BweeEcoA.cjs +56 -0
- package/dist/context-CIpPzN7P.js +51 -0
- package/dist/cors-C2n2LxrC.js +830 -0
- package/dist/cors-Cga2PWEg.cjs +913 -0
- package/dist/forwarded--h4efJy-.js +43 -0
- package/dist/forwarded-Pi8Hs5Ps.cjs +48 -0
- package/dist/fs-errors-CWNzOV75.cjs +11 -0
- package/dist/fs-errors-PA2t1TIp.js +6 -0
- package/dist/index.cjs +129 -329
- package/dist/index.d.cts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/index.js +118 -177
- package/dist/{io-D4srzRKc.d.ts → io-CfSPxeBN.d.ts} +6 -4
- package/dist/io-DPYvBqET.d.cts +15 -0
- package/dist/list-tools-07OV14rK.cjs +57 -0
- package/dist/list-tools-B4TTPEl1.d.cts +8 -0
- package/dist/list-tools-I8Hvub9P.js +46 -0
- package/dist/list-tools-bh6-eqZM.d.ts +8 -0
- package/dist/logger-2OXtfiIW.js +141 -0
- package/dist/logger-BqPOa_E1.cjs +194 -0
- package/dist/mcp-B6z5Givq.js +123 -0
- package/dist/mcp-DLv_c1O5.cjs +128 -0
- package/dist/metadata-path-CAkNcfyY.js +12 -0
- package/dist/metadata-path-zd7NSNoa.cjs +17 -0
- package/dist/package-CxQcGWdU.cjs +9 -0
- package/dist/package-xS6mk-b_.js +4 -0
- package/dist/paths-IS65L6TA.js +7 -0
- package/dist/paths-OP318a6c.cjs +18 -0
- package/dist/protocols/mcp/index.cjs +3 -750
- package/dist/protocols/mcp/index.d.cts +6 -7
- package/dist/protocols/mcp/index.d.ts +6 -7
- package/dist/protocols/mcp/index.js +2 -12
- package/dist/protocols/oauth-metadata.cjs +48 -539
- package/dist/protocols/oauth-metadata.d.cts +5 -6
- package/dist/protocols/oauth-metadata.d.ts +5 -6
- package/dist/protocols/oauth-metadata.js +52 -10
- package/dist/protocols/rest/index.cjs +5 -843
- package/dist/protocols/rest/index.d.cts +7 -10
- package/dist/protocols/rest/index.d.ts +7 -10
- package/dist/protocols/rest/index.js +3 -16
- package/dist/rest-CggWx00c.js +117 -0
- package/dist/rest-DxhK7-3b.cjs +122 -0
- package/dist/stacks/supabase/index.cjs +76 -1318
- package/dist/stacks/supabase/index.d.cts +29 -30
- package/dist/stacks/supabase/index.d.ts +29 -30
- package/dist/stacks/supabase/index.js +73 -89
- package/dist/stacks/supabase/vite.cjs +258 -287
- 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 +42 -1272
- package/dist/stacks/tanstack/index.d.cts +8 -9
- package/dist/stacks/tanstack/index.d.ts +8 -9
- package/dist/stacks/tanstack/index.js +36 -41
- package/dist/stacks/tanstack/vite.cjs +223 -312
- package/dist/stacks/tanstack/vite.d.cts +80 -81
- package/dist/stacks/tanstack/vite.d.ts +80 -81
- package/dist/stacks/tanstack/vite.js +216 -282
- package/dist/types-BYdYYTjk.d.cts +321 -0
- package/dist/types-BYdYYTjk.d.ts +321 -0
- package/package.json +4 -4
- package/dist/authorize-BMeXd_Sh.d.ts +0 -25
- package/dist/base-CM-KCpp6.d.ts +0 -28
- package/dist/chunk-5HVSJCKE.js +0 -114
- package/dist/chunk-6DXGZZA4.js +0 -6
- package/dist/chunk-6QFZYYUV.js +0 -11
- package/dist/chunk-6SZOFKGH.js +0 -58
- package/dist/chunk-H37EB22A.js +0 -125
- package/dist/chunk-IFDWUM7L.js +0 -741
- package/dist/chunk-IXZIFYO6.js +0 -79
- package/dist/chunk-MA5H6PSF.js +0 -46
- package/dist/chunk-TJN33K5U.js +0 -141
- package/dist/chunk-UQK5UO6C.js +0 -26
- package/dist/chunk-XQWJN6DC.js +0 -14
- package/dist/chunk-Y3ZFPEQH.js +0 -8
- package/dist/chunk-ZQXSWTPU.js +0 -6
- package/dist/types-qqrmJ736.d.ts +0 -321
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import 'zod';
|
|
4
|
-
|
|
1
|
+
import { C as McpAuthConfig, S as JwtClaims, _ as ZodRawShape, a as EmbeddedResource, b as MetricsOptions, c as McpDefinition, d as ResourceLinkIcon, f as TextContent, g as ToolHandlerResult, h as ToolDefinition, i as EmbeddedBlobResource, l as McpDefinitionInput, m as ToolContent, n as ContentAnnotations, o as EmbeddedTextResource, p as ToolAnnotations, r as ContentBlock, s as ImageContent, t as AudioContent, u as ResourceLink, v as ZodSchema, x as ToolContext, y as MetricsConfig } from "./types-BYdYYTjk.cjs";
|
|
2
|
+
//#region src/core/define.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Declare a single MCP tool. Import the result into your MCP definition's
|
|
7
5
|
* `tools` array — `defineMcp({ tools: [echoTool, ...] })`.
|
|
@@ -17,27 +15,28 @@ declare function defineTool<TInput extends ZodRawShape | undefined = undefined,
|
|
|
17
15
|
* emit the framework-specific route(s) at build time.
|
|
18
16
|
*/
|
|
19
17
|
declare function defineMcp(def: McpDefinitionInput): McpDefinition;
|
|
20
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/auth/config.d.ts
|
|
21
20
|
type IssuerAcceptedAudiences = string | readonly string[];
|
|
22
21
|
interface IssuerOAuthOptionsBase {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
readonly resourceName?: string;
|
|
23
|
+
readonly resourceDocumentation?: string;
|
|
24
|
+
readonly protectedResourceMetadataUrl?: string;
|
|
25
|
+
readonly requireOAuthClientClaim?: boolean;
|
|
26
|
+
readonly acceptResourceClaim?: boolean;
|
|
27
|
+
readonly issuer: string;
|
|
28
|
+
readonly requiredScopes?: readonly string[];
|
|
29
|
+
readonly jwksUri?: string;
|
|
30
|
+
readonly algorithms?: readonly string[];
|
|
31
|
+
readonly clockToleranceSeconds?: number;
|
|
32
|
+
readonly accessTokenTyp?: readonly string[];
|
|
34
33
|
}
|
|
35
34
|
type IssuerOAuthOptions = IssuerOAuthOptionsBase & ({
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
readonly resource: string;
|
|
36
|
+
readonly acceptedAudiences?: IssuerAcceptedAudiences;
|
|
38
37
|
} | {
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
readonly resource?: string;
|
|
39
|
+
readonly acceptedAudiences: IssuerAcceptedAudiences;
|
|
41
40
|
});
|
|
42
41
|
/**
|
|
43
42
|
* Configure OAuth against an issuer. `acceptedAudiences` (or `resource`) is the
|
|
@@ -50,11 +49,12 @@ type IssuerOAuthOptions = IssuerOAuthOptionsBase & ({
|
|
|
50
49
|
*/
|
|
51
50
|
declare function issuer(options: IssuerOAuthOptions): McpAuthConfig;
|
|
52
51
|
declare const auth: Readonly<{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
oauth: Readonly<{
|
|
53
|
+
issuer: typeof issuer;
|
|
54
|
+
}>;
|
|
56
55
|
}>;
|
|
57
|
-
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/core/logger.d.ts
|
|
58
58
|
type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
59
59
|
/**
|
|
60
60
|
* Set the runtime log level programmatically. Use this when the deployment can't
|
|
@@ -62,5 +62,5 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
62
62
|
* passes vars via bindings): call `setLogLevel("debug")` once at server startup.
|
|
63
63
|
*/
|
|
64
64
|
declare function setLogLevel(level: LogLevel): void;
|
|
65
|
-
|
|
66
|
-
export { type IssuerOAuthOptions, type LogLevel, McpDefinitionInput, ToolDefinition, ZodRawShape, auth, defineMcp, defineTool, setLogLevel };
|
|
65
|
+
//#endregion
|
|
66
|
+
export { type AudioContent, type ContentAnnotations, type ContentBlock, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JwtClaims, type LogLevel, type McpDefinitionInput, type MetricsConfig, type MetricsOptions, type ResourceLink, type ResourceLinkIcon, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, type ToolHandlerResult, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import 'zod';
|
|
4
|
-
|
|
1
|
+
import { C as McpAuthConfig, S as JwtClaims, _ as ZodRawShape, a as EmbeddedResource, b as MetricsOptions, c as McpDefinition, d as ResourceLinkIcon, f as TextContent, g as ToolHandlerResult, h as ToolDefinition, i as EmbeddedBlobResource, l as McpDefinitionInput, m as ToolContent, n as ContentAnnotations, o as EmbeddedTextResource, p as ToolAnnotations, r as ContentBlock, s as ImageContent, t as AudioContent, u as ResourceLink, v as ZodSchema, x as ToolContext, y as MetricsConfig } from "./types-BYdYYTjk.js";
|
|
2
|
+
//#region src/core/define.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Declare a single MCP tool. Import the result into your MCP definition's
|
|
7
5
|
* `tools` array — `defineMcp({ tools: [echoTool, ...] })`.
|
|
@@ -17,27 +15,28 @@ declare function defineTool<TInput extends ZodRawShape | undefined = undefined,
|
|
|
17
15
|
* emit the framework-specific route(s) at build time.
|
|
18
16
|
*/
|
|
19
17
|
declare function defineMcp(def: McpDefinitionInput): McpDefinition;
|
|
20
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/auth/config.d.ts
|
|
21
20
|
type IssuerAcceptedAudiences = string | readonly string[];
|
|
22
21
|
interface IssuerOAuthOptionsBase {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
readonly resourceName?: string;
|
|
23
|
+
readonly resourceDocumentation?: string;
|
|
24
|
+
readonly protectedResourceMetadataUrl?: string;
|
|
25
|
+
readonly requireOAuthClientClaim?: boolean;
|
|
26
|
+
readonly acceptResourceClaim?: boolean;
|
|
27
|
+
readonly issuer: string;
|
|
28
|
+
readonly requiredScopes?: readonly string[];
|
|
29
|
+
readonly jwksUri?: string;
|
|
30
|
+
readonly algorithms?: readonly string[];
|
|
31
|
+
readonly clockToleranceSeconds?: number;
|
|
32
|
+
readonly accessTokenTyp?: readonly string[];
|
|
34
33
|
}
|
|
35
34
|
type IssuerOAuthOptions = IssuerOAuthOptionsBase & ({
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
readonly resource: string;
|
|
36
|
+
readonly acceptedAudiences?: IssuerAcceptedAudiences;
|
|
38
37
|
} | {
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
readonly resource?: string;
|
|
39
|
+
readonly acceptedAudiences: IssuerAcceptedAudiences;
|
|
41
40
|
});
|
|
42
41
|
/**
|
|
43
42
|
* Configure OAuth against an issuer. `acceptedAudiences` (or `resource`) is the
|
|
@@ -50,11 +49,12 @@ type IssuerOAuthOptions = IssuerOAuthOptionsBase & ({
|
|
|
50
49
|
*/
|
|
51
50
|
declare function issuer(options: IssuerOAuthOptions): McpAuthConfig;
|
|
52
51
|
declare const auth: Readonly<{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
oauth: Readonly<{
|
|
53
|
+
issuer: typeof issuer;
|
|
54
|
+
}>;
|
|
56
55
|
}>;
|
|
57
|
-
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/core/logger.d.ts
|
|
58
58
|
type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
59
59
|
/**
|
|
60
60
|
* Set the runtime log level programmatically. Use this when the deployment can't
|
|
@@ -62,5 +62,5 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
62
62
|
* passes vars via bindings): call `setLogLevel("debug")` once at server startup.
|
|
63
63
|
*/
|
|
64
64
|
declare function setLogLevel(level: LogLevel): void;
|
|
65
|
-
|
|
66
|
-
export { type IssuerOAuthOptions, type LogLevel, McpDefinitionInput, ToolDefinition, ZodRawShape, auth, defineMcp, defineTool, setLogLevel };
|
|
65
|
+
//#endregion
|
|
66
|
+
export { type AudioContent, type ContentAnnotations, type ContentBlock, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JwtClaims, type LogLevel, type McpDefinitionInput, type MetricsConfig, type MetricsOptions, type ResourceLink, type ResourceLinkIcon, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, type ToolHandlerResult, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
package/dist/index.js
CHANGED
|
@@ -1,203 +1,144 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
parseSafeUrl,
|
|
6
|
-
resolveMetricsConfig,
|
|
7
|
-
setLogLevel,
|
|
8
|
-
trimTrailingSlash
|
|
9
|
-
} from "./chunk-H37EB22A.js";
|
|
10
|
-
|
|
11
|
-
// src/core/define.ts
|
|
1
|
+
import { a as setLogLevel, l as resolveMetricsConfig, o as parseSafeUrl, s as trimTrailingSlash } from "./logger-2OXtfiIW.js";
|
|
2
|
+
import { t as ToolContext } from "./context-CIpPzN7P.js";
|
|
3
|
+
//#region src/core/define.ts
|
|
12
4
|
function assertUniqueNames(mcp) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
seen.add(tool.name);
|
|
19
|
-
}
|
|
5
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6
|
+
for (const tool of mcp.tools) {
|
|
7
|
+
if (seen.has(tool.name)) throw new Error(`@lovable.dev/mcp-js: duplicate tool name "${tool.name}"`);
|
|
8
|
+
seen.add(tool.name);
|
|
9
|
+
}
|
|
20
10
|
}
|
|
21
11
|
function assertNonEmptyString(label, value) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
if (value !== value.trim()) {
|
|
26
|
-
throw new Error(`@lovable.dev/mcp-js: ${label} must not have leading or trailing whitespace`);
|
|
27
|
-
}
|
|
12
|
+
if (value.trim() === "") throw new Error(`@lovable.dev/mcp-js: ${label} must not be empty`);
|
|
13
|
+
if (value !== value.trim()) throw new Error(`@lovable.dev/mcp-js: ${label} must not have leading or trailing whitespace`);
|
|
28
14
|
}
|
|
29
15
|
function assertHttpsUrlField(name, value) {
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
assertNonEmptyString(`auth.${name}`, value);
|
|
17
|
+
parseSafeUrl(`@lovable.dev/mcp-js: auth.${name}`, value);
|
|
32
18
|
}
|
|
33
19
|
function assertScope(scope) {
|
|
34
|
-
|
|
35
|
-
throw new Error(`@lovable.dev/mcp-js: OAuth scopes must be non-empty space-free tokens`);
|
|
36
|
-
}
|
|
20
|
+
if (scope.trim() === "" || /\s/.test(scope)) throw new Error(`@lovable.dev/mcp-js: OAuth scopes must be non-empty space-free tokens`);
|
|
37
21
|
}
|
|
38
22
|
function assertJwtAlgorithm(algorithm) {
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
}
|
|
23
|
+
if (algorithm.trim() === "" || /\s/.test(algorithm)) throw new Error(`@lovable.dev/mcp-js: auth.algorithms must contain non-empty space-free tokens`);
|
|
24
|
+
if (/^HS\d+$/i.test(algorithm) || algorithm.toLowerCase() === "none") throw new Error(`@lovable.dev/mcp-js: auth.algorithms cannot include "${algorithm}"; this verifier is JWKS-only`);
|
|
45
25
|
}
|
|
46
|
-
|
|
26
|
+
const MAX_CLOCK_TOLERANCE_SECONDS = 300;
|
|
47
27
|
function assertClockToleranceSeconds(value) {
|
|
48
|
-
|
|
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
|
-
}
|
|
28
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > MAX_CLOCK_TOLERANCE_SECONDS) throw new Error(`@lovable.dev/mcp-js: auth.clockToleranceSeconds must be a non-negative number of seconds no greater than ${MAX_CLOCK_TOLERANCE_SECONDS}`);
|
|
53
29
|
}
|
|
54
|
-
function assertOAuthConfig(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
}
|
|
30
|
+
function assertOAuthConfig(auth) {
|
|
31
|
+
if (auth.type !== "oauth") {
|
|
32
|
+
const authType = String(auth.type);
|
|
33
|
+
throw new Error(`@lovable.dev/mcp-js: unsupported auth type "${authType}"`);
|
|
34
|
+
}
|
|
35
|
+
if (auth.issuer === void 0) throw new Error(`@lovable.dev/mcp-js: auth.issuer is required`);
|
|
36
|
+
assertHttpsUrlField("issuer", auth.issuer);
|
|
37
|
+
if (auth.jwksUri !== void 0) assertHttpsUrlField("jwksUri", auth.jwksUri);
|
|
38
|
+
if (auth.resource !== void 0) assertHttpsUrlField("resource", auth.resource);
|
|
39
|
+
if (auth.resourceName !== void 0) assertNonEmptyString("auth.resourceName", auth.resourceName);
|
|
40
|
+
if (auth.resourceDocumentation !== void 0) assertHttpsUrlField("resourceDocumentation", auth.resourceDocumentation);
|
|
41
|
+
if (auth.protectedResourceMetadataUrl !== void 0) assertHttpsUrlField("protectedResourceMetadataUrl", auth.protectedResourceMetadataUrl);
|
|
42
|
+
if (auth.acceptedAudiences !== void 0) {
|
|
43
|
+
if (!Array.isArray(auth.acceptedAudiences)) throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must be an array`);
|
|
44
|
+
if (auth.acceptedAudiences.length === 0) throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must not be empty`);
|
|
45
|
+
for (const audience of auth.acceptedAudiences) {
|
|
46
|
+
if (typeof audience !== "string") throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must contain strings`);
|
|
47
|
+
assertNonEmptyString("auth.acceptedAudiences", audience);
|
|
48
|
+
if (trimTrailingSlash(audience) === "") throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences entries must not be only slashes`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (auth.requireOAuthClientClaim !== void 0 && typeof auth.requireOAuthClientClaim !== "boolean") throw new Error(`@lovable.dev/mcp-js: auth.requireOAuthClientClaim must be a boolean`);
|
|
52
|
+
if (auth.acceptResourceClaim !== void 0 && typeof auth.acceptResourceClaim !== "boolean") throw new Error(`@lovable.dev/mcp-js: auth.acceptResourceClaim must be a boolean`);
|
|
53
|
+
if (auth.requiredScopes !== void 0) {
|
|
54
|
+
if (!Array.isArray(auth.requiredScopes)) throw new Error(`@lovable.dev/mcp-js: auth.requiredScopes must be an array`);
|
|
55
|
+
for (const scope of auth.requiredScopes) assertScope(scope);
|
|
56
|
+
}
|
|
57
|
+
if (auth.algorithms !== void 0) {
|
|
58
|
+
if (!Array.isArray(auth.algorithms)) throw new Error(`@lovable.dev/mcp-js: auth.algorithms must be an array`);
|
|
59
|
+
if (auth.algorithms.length === 0) throw new Error(`@lovable.dev/mcp-js: auth.algorithms must not be empty`);
|
|
60
|
+
for (const algorithm of auth.algorithms) assertJwtAlgorithm(algorithm);
|
|
61
|
+
}
|
|
62
|
+
if (auth.accessTokenTyp !== void 0) {
|
|
63
|
+
if (!Array.isArray(auth.accessTokenTyp)) throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must be an array`);
|
|
64
|
+
if (auth.accessTokenTyp.length === 0) throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must not be empty`);
|
|
65
|
+
for (const typ of auth.accessTokenTyp) {
|
|
66
|
+
if (typeof typ !== "string") throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must contain strings`);
|
|
67
|
+
assertNonEmptyString("auth.accessTokenTyp", typ);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (auth.clockToleranceSeconds !== void 0) assertClockToleranceSeconds(auth.clockToleranceSeconds);
|
|
71
|
+
if (auth.resource === void 0 && auth.acceptedAudiences === void 0) throw new Error(`@lovable.dev/mcp-js: auth.resource or auth.acceptedAudiences is required`);
|
|
137
72
|
}
|
|
138
|
-
function freezeAuth(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (auth2.algorithms)
|
|
146
|
-
Object.freeze(auth2.algorithms);
|
|
147
|
-
if (auth2.accessTokenTyp)
|
|
148
|
-
Object.freeze(auth2.accessTokenTyp);
|
|
149
|
-
Object.freeze(auth2);
|
|
73
|
+
function freezeAuth(auth) {
|
|
74
|
+
if (!auth) return;
|
|
75
|
+
if (auth.acceptedAudiences) Object.freeze(auth.acceptedAudiences);
|
|
76
|
+
if (auth.requiredScopes) Object.freeze(auth.requiredScopes);
|
|
77
|
+
if (auth.algorithms) Object.freeze(auth.algorithms);
|
|
78
|
+
if (auth.accessTokenTyp) Object.freeze(auth.accessTokenTyp);
|
|
79
|
+
Object.freeze(auth);
|
|
150
80
|
}
|
|
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
|
+
*/
|
|
151
89
|
function defineTool(def) {
|
|
152
|
-
|
|
90
|
+
return def;
|
|
153
91
|
}
|
|
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
|
+
*/
|
|
154
97
|
function defineMcp(def) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
Object.freeze(tool);
|
|
166
|
-
return def;
|
|
98
|
+
assertNonEmptyString("name", def.name);
|
|
99
|
+
assertNonEmptyString("title", def.title);
|
|
100
|
+
assertNonEmptyString("version", def.version);
|
|
101
|
+
assertUniqueNames(def);
|
|
102
|
+
if (def.auth) assertOAuthConfig(def.auth);
|
|
103
|
+
resolveMetricsConfig(def.metrics);
|
|
104
|
+
freezeAuth(def.auth);
|
|
105
|
+
Object.freeze(def.tools);
|
|
106
|
+
for (const tool of def.tools) Object.freeze(tool);
|
|
107
|
+
return def;
|
|
167
108
|
}
|
|
168
|
-
|
|
169
|
-
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/auth/config.ts
|
|
170
111
|
function frozenArray(value) {
|
|
171
|
-
|
|
112
|
+
return value === void 0 ? void 0 : Object.freeze([...value]);
|
|
172
113
|
}
|
|
173
114
|
function frozenAudiences(value) {
|
|
174
|
-
|
|
115
|
+
return frozenArray(typeof value === "string" ? [value] : value);
|
|
175
116
|
}
|
|
117
|
+
/** Mutates `value` in place; callers pass a fresh literal so deleting keys is safe. */
|
|
176
118
|
function stripUndefined(value) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
delete value[key];
|
|
180
|
-
}
|
|
181
|
-
return value;
|
|
119
|
+
for (const key of Object.keys(value)) if (value[key] === void 0) delete value[key];
|
|
120
|
+
return value;
|
|
182
121
|
}
|
|
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
|
+
*/
|
|
183
131
|
function issuer(options) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
})
|
|
193
|
-
);
|
|
132
|
+
return Object.freeze(stripUndefined({
|
|
133
|
+
type: "oauth",
|
|
134
|
+
...options,
|
|
135
|
+
acceptedAudiences: frozenAudiences(options.acceptedAudiences),
|
|
136
|
+
requiredScopes: frozenArray(options.requiredScopes),
|
|
137
|
+
algorithms: frozenArray(options.algorithms),
|
|
138
|
+
accessTokenTyp: frozenArray(options.accessTokenTyp)
|
|
139
|
+
}));
|
|
194
140
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
auth,
|
|
200
|
-
defineMcp,
|
|
201
|
-
defineTool,
|
|
202
|
-
setLogLevel
|
|
203
|
-
};
|
|
141
|
+
const oauth = Object.freeze({ issuer });
|
|
142
|
+
const auth = Object.freeze({ oauth });
|
|
143
|
+
//#endregion
|
|
144
|
+
export { ToolContext, auth, defineMcp, defineTool, setLogLevel };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "./list-tools-bh6-eqZM.js";
|
|
2
|
+
//#region src/manifest/io.d.ts
|
|
1
3
|
/**
|
|
2
4
|
* Shape every MCP Vite plugin exposes on its `api` so `runExtract` can read
|
|
3
5
|
* back the resolved entry path and the URL the stack mounts the MCP server at.
|
|
@@ -6,8 +8,8 @@
|
|
|
6
8
|
* which the function and its companion routes live).
|
|
7
9
|
*/
|
|
8
10
|
interface McpPluginApi {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
readonly mcpEntry: string;
|
|
12
|
+
readonly urlPath: string;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
+
//#endregion
|
|
15
|
+
export { McpPluginApi as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./list-tools-B4TTPEl1.cjs";
|
|
2
|
+
//#region src/manifest/io.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shape every MCP Vite plugin exposes on its `api` so `runExtract` can read
|
|
5
|
+
* back the resolved entry path and the URL the stack mounts the MCP server at.
|
|
6
|
+
* TanStack sets `urlPath` to the configured route path (default `/mcp`);
|
|
7
|
+
* Supabase sets it to `/functions/v1/<functionName>` (the public mount under
|
|
8
|
+
* which the function and its companion routes live).
|
|
9
|
+
*/
|
|
10
|
+
interface McpPluginApi {
|
|
11
|
+
readonly mcpEntry: string;
|
|
12
|
+
readonly urlPath: string;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { McpPluginApi as t };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const require_cors = require("./cors-Cga2PWEg.cjs");
|
|
2
|
+
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
3
|
+
let _modelcontextprotocol_sdk_server_zod_json_schema_compat_js = require("@modelcontextprotocol/sdk/server/zod-json-schema-compat.js");
|
|
4
|
+
//#region src/protocols/rest/list-tools.ts
|
|
5
|
+
function shapeToJsonSchema(shape) {
|
|
6
|
+
if (!shape) return null;
|
|
7
|
+
try {
|
|
8
|
+
return (0, _modelcontextprotocol_sdk_server_zod_json_schema_compat_js.toJsonSchemaCompat)((0, _modelcontextprotocol_sdk_server_zod_compat_js.objectFromShape)(shape));
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function buildMcpListing(mcp) {
|
|
14
|
+
return {
|
|
15
|
+
server: {
|
|
16
|
+
name: mcp.name,
|
|
17
|
+
version: mcp.version,
|
|
18
|
+
title: mcp.title
|
|
19
|
+
},
|
|
20
|
+
tools: mcp.tools.map((tool) => ({
|
|
21
|
+
name: tool.name,
|
|
22
|
+
title: tool.title,
|
|
23
|
+
description: tool.description,
|
|
24
|
+
annotations: tool.annotations,
|
|
25
|
+
inputSchema: shapeToJsonSchema(tool.inputSchema),
|
|
26
|
+
outputSchema: shapeToJsonSchema(tool.outputSchema)
|
|
27
|
+
}))
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function createListToolsHandler(mcp, options = {}) {
|
|
31
|
+
require_cors.assertRestResourceBinding(mcp, options);
|
|
32
|
+
const authorizer = require_cors.createRequestAuthorizer(mcp, options);
|
|
33
|
+
const handle = async (request, recorder) => {
|
|
34
|
+
const authResult = await authorizer.authorize(request, recorder);
|
|
35
|
+
if (!authResult.ok) return authResult.response;
|
|
36
|
+
if (request.method !== "GET" && request.method !== "HEAD") return require_cors.methodNotAllowed("GET, HEAD, OPTIONS");
|
|
37
|
+
const response = Response.json(buildMcpListing(mcp));
|
|
38
|
+
return request.method === "HEAD" ? require_cors.headResponse(response) : response;
|
|
39
|
+
};
|
|
40
|
+
return async (request, recorder = require_cors.createNoopRecorder()) => {
|
|
41
|
+
if (request.method === "OPTIONS") return require_cors.corsPreflightResponse("GET, HEAD, OPTIONS");
|
|
42
|
+
return require_cors.withCors(await handle(request, recorder));
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
Object.defineProperty(exports, "buildMcpListing", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function() {
|
|
49
|
+
return buildMcpListing;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "createListToolsHandler", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function() {
|
|
55
|
+
return createListToolsHandler;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { c as McpDefinition } from "./types-BYdYYTjk.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "./base-DCe0kP79.cjs";
|
|
3
|
+
import { t as McpRuntimeOptions } from "./authorize-CumVyk7p.cjs";
|
|
4
|
+
//#region src/protocols/rest/list-tools.d.ts
|
|
5
|
+
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
6
|
+
declare function createListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestListToolsHandler;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createListToolsHandler as n, RestListToolsHandler as t };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { i as createRequestAuthorizer, m as methodNotAllowed, n as withCors, p as headResponse, r as assertRestResourceBinding, t as corsPreflightResponse, u as createNoopRecorder } from "./cors-C2n2LxrC.js";
|
|
2
|
+
import { objectFromShape } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
3
|
+
import { toJsonSchemaCompat } from "@modelcontextprotocol/sdk/server/zod-json-schema-compat.js";
|
|
4
|
+
//#region src/protocols/rest/list-tools.ts
|
|
5
|
+
function shapeToJsonSchema(shape) {
|
|
6
|
+
if (!shape) return null;
|
|
7
|
+
try {
|
|
8
|
+
return toJsonSchemaCompat(objectFromShape(shape));
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function buildMcpListing(mcp) {
|
|
14
|
+
return {
|
|
15
|
+
server: {
|
|
16
|
+
name: mcp.name,
|
|
17
|
+
version: mcp.version,
|
|
18
|
+
title: mcp.title
|
|
19
|
+
},
|
|
20
|
+
tools: mcp.tools.map((tool) => ({
|
|
21
|
+
name: tool.name,
|
|
22
|
+
title: tool.title,
|
|
23
|
+
description: tool.description,
|
|
24
|
+
annotations: tool.annotations,
|
|
25
|
+
inputSchema: shapeToJsonSchema(tool.inputSchema),
|
|
26
|
+
outputSchema: shapeToJsonSchema(tool.outputSchema)
|
|
27
|
+
}))
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function createListToolsHandler(mcp, options = {}) {
|
|
31
|
+
assertRestResourceBinding(mcp, options);
|
|
32
|
+
const authorizer = createRequestAuthorizer(mcp, options);
|
|
33
|
+
const handle = async (request, recorder) => {
|
|
34
|
+
const authResult = await authorizer.authorize(request, recorder);
|
|
35
|
+
if (!authResult.ok) return authResult.response;
|
|
36
|
+
if (request.method !== "GET" && request.method !== "HEAD") return methodNotAllowed("GET, HEAD, OPTIONS");
|
|
37
|
+
const response = Response.json(buildMcpListing(mcp));
|
|
38
|
+
return request.method === "HEAD" ? headResponse(response) : response;
|
|
39
|
+
};
|
|
40
|
+
return async (request, recorder = createNoopRecorder()) => {
|
|
41
|
+
if (request.method === "OPTIONS") return corsPreflightResponse("GET, HEAD, OPTIONS");
|
|
42
|
+
return withCors(await handle(request, recorder));
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { createListToolsHandler as n, buildMcpListing as t };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { c as McpDefinition } from "./types-BYdYYTjk.js";
|
|
2
|
+
import { t as MetricsRecorder } from "./base-DCe0kP79.js";
|
|
3
|
+
import { t as McpRuntimeOptions } from "./authorize-D6p4-9_D.js";
|
|
4
|
+
//#region src/protocols/rest/list-tools.d.ts
|
|
5
|
+
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
6
|
+
declare function createListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestListToolsHandler;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createListToolsHandler as n, RestListToolsHandler as t };
|