@lovable.dev/mcp-js 0.22.1 → 0.22.2-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/authorize-CumVyk7p.d.cts +27 -0
  2. package/dist/authorize-D6p4-9_D.d.ts +27 -0
  3. package/dist/base-DCe0kP79.d.cts +29 -0
  4. package/dist/base-DCe0kP79.d.ts +29 -0
  5. package/dist/cli/extract-manifest.cjs +116 -201
  6. package/dist/cli/extract-manifest.d.cts +1 -1
  7. package/dist/cli/extract-manifest.d.ts +1 -1
  8. package/dist/cli/extract-manifest.js +117 -156
  9. package/dist/content-D5LJAHyM.js +12 -0
  10. package/dist/content-NCYIGgOb.cjs +17 -0
  11. package/dist/context-BweeEcoA.cjs +56 -0
  12. package/dist/context-CIpPzN7P.js +51 -0
  13. package/dist/cors-CSDhBjFd.cjs +913 -0
  14. package/dist/cors-rWp_tbLZ.js +830 -0
  15. package/dist/forwarded--h4efJy-.js +43 -0
  16. package/dist/forwarded-Pi8Hs5Ps.cjs +48 -0
  17. package/dist/fs-errors-CWNzOV75.cjs +11 -0
  18. package/dist/fs-errors-PA2t1TIp.js +6 -0
  19. package/dist/index.cjs +129 -329
  20. package/dist/index.d.cts +26 -26
  21. package/dist/index.d.ts +26 -26
  22. package/dist/index.js +118 -177
  23. package/dist/{io-D4srzRKc.d.ts → io-CfSPxeBN.d.ts} +6 -4
  24. package/dist/io-DPYvBqET.d.cts +15 -0
  25. package/dist/list-tools-B4TTPEl1.d.cts +8 -0
  26. package/dist/list-tools-CFUX-uo-.cjs +57 -0
  27. package/dist/list-tools-DVJrjtmH.js +46 -0
  28. package/dist/list-tools-bh6-eqZM.d.ts +8 -0
  29. package/dist/logger-2OXtfiIW.js +141 -0
  30. package/dist/logger-BqPOa_E1.cjs +194 -0
  31. package/dist/mcp-BNcpj8o7.cjs +128 -0
  32. package/dist/mcp-Bx3bJHzH.js +123 -0
  33. package/dist/metadata-path-CAkNcfyY.js +12 -0
  34. package/dist/metadata-path-zd7NSNoa.cjs +17 -0
  35. package/dist/package-CgwD4Ywz.js +4 -0
  36. package/dist/package-DzstF8Ih.cjs +9 -0
  37. package/dist/paths-IS65L6TA.js +7 -0
  38. package/dist/paths-OP318a6c.cjs +18 -0
  39. package/dist/protocols/mcp/index.cjs +3 -750
  40. package/dist/protocols/mcp/index.d.cts +6 -7
  41. package/dist/protocols/mcp/index.d.ts +6 -7
  42. package/dist/protocols/mcp/index.js +2 -12
  43. package/dist/protocols/oauth-metadata.cjs +48 -539
  44. package/dist/protocols/oauth-metadata.d.cts +5 -6
  45. package/dist/protocols/oauth-metadata.d.ts +5 -6
  46. package/dist/protocols/oauth-metadata.js +52 -10
  47. package/dist/protocols/rest/index.cjs +5 -843
  48. package/dist/protocols/rest/index.d.cts +7 -10
  49. package/dist/protocols/rest/index.d.ts +7 -10
  50. package/dist/protocols/rest/index.js +3 -16
  51. package/dist/rest-BRshnow2.js +117 -0
  52. package/dist/rest-C4ZEGSIV.cjs +122 -0
  53. package/dist/stacks/supabase/index.cjs +76 -1318
  54. package/dist/stacks/supabase/index.d.cts +29 -30
  55. package/dist/stacks/supabase/index.d.ts +29 -30
  56. package/dist/stacks/supabase/index.js +73 -89
  57. package/dist/stacks/supabase/vite.cjs +258 -287
  58. package/dist/stacks/supabase/vite.d.cts +24 -24
  59. package/dist/stacks/supabase/vite.d.ts +24 -24
  60. package/dist/stacks/supabase/vite.js +252 -252
  61. package/dist/stacks/tanstack/index.cjs +42 -1272
  62. package/dist/stacks/tanstack/index.d.cts +8 -9
  63. package/dist/stacks/tanstack/index.d.ts +8 -9
  64. package/dist/stacks/tanstack/index.js +36 -41
  65. package/dist/stacks/tanstack/vite.cjs +223 -312
  66. package/dist/stacks/tanstack/vite.d.cts +80 -81
  67. package/dist/stacks/tanstack/vite.d.ts +80 -81
  68. package/dist/stacks/tanstack/vite.js +216 -282
  69. package/dist/types-BYdYYTjk.d.cts +321 -0
  70. package/dist/types-BYdYYTjk.d.ts +321 -0
  71. package/package.json +4 -4
  72. package/dist/authorize-BMeXd_Sh.d.ts +0 -25
  73. package/dist/base-CM-KCpp6.d.ts +0 -28
  74. package/dist/chunk-5HVSJCKE.js +0 -114
  75. package/dist/chunk-6DXGZZA4.js +0 -6
  76. package/dist/chunk-6QFZYYUV.js +0 -11
  77. package/dist/chunk-6SZOFKGH.js +0 -58
  78. package/dist/chunk-H37EB22A.js +0 -125
  79. package/dist/chunk-IFDWUM7L.js +0 -741
  80. package/dist/chunk-IXZIFYO6.js +0 -79
  81. package/dist/chunk-MA5H6PSF.js +0 -46
  82. package/dist/chunk-TJN33K5U.js +0 -141
  83. package/dist/chunk-UQK5UO6C.js +0 -26
  84. package/dist/chunk-XQWJN6DC.js +0 -14
  85. package/dist/chunk-Y3ZFPEQH.js +0 -8
  86. package/dist/chunk-ZQXSWTPU.js +0 -6
  87. package/dist/types-qqrmJ736.d.ts +0 -321
package/dist/index.d.cts CHANGED
@@ -1,7 +1,5 @@
1
- import { e as McpDefinitionInput, d as McpDefinition, Z as ZodRawShape, l as ToolDefinition, M as McpAuthConfig } from './types-qqrmJ736.js';
2
- export { A as AudioContent, C as ContentAnnotations, a as ContentBlock, E as EmbeddedBlobResource, b as EmbeddedResource, c as EmbeddedTextResource, I as ImageContent, J as JwtClaims, f as MetricsConfig, g as MetricsOptions, R as ResourceLink, h as ResourceLinkIcon, T as TextContent, i as ToolAnnotations, j as ToolContent, k as ToolContext, m as ToolHandlerResult, n as ZodSchema } from './types-qqrmJ736.js';
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
- readonly resourceName?: string;
24
- readonly resourceDocumentation?: string;
25
- readonly protectedResourceMetadataUrl?: string;
26
- readonly requireOAuthClientClaim?: boolean;
27
- readonly acceptResourceClaim?: boolean;
28
- readonly issuer: string;
29
- readonly requiredScopes?: readonly string[];
30
- readonly jwksUri?: string;
31
- readonly algorithms?: readonly string[];
32
- readonly clockToleranceSeconds?: number;
33
- readonly accessTokenTyp?: readonly string[];
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
- readonly resource: string;
37
- readonly acceptedAudiences?: IssuerAcceptedAudiences;
35
+ readonly resource: string;
36
+ readonly acceptedAudiences?: IssuerAcceptedAudiences;
38
37
  } | {
39
- readonly resource?: string;
40
- readonly acceptedAudiences: IssuerAcceptedAudiences;
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
- oauth: Readonly<{
54
- issuer: typeof issuer;
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 { e as McpDefinitionInput, d as McpDefinition, Z as ZodRawShape, l as ToolDefinition, M as McpAuthConfig } from './types-qqrmJ736.js';
2
- export { A as AudioContent, C as ContentAnnotations, a as ContentBlock, E as EmbeddedBlobResource, b as EmbeddedResource, c as EmbeddedTextResource, I as ImageContent, J as JwtClaims, f as MetricsConfig, g as MetricsOptions, R as ResourceLink, h as ResourceLinkIcon, T as TextContent, i as ToolAnnotations, j as ToolContent, k as ToolContext, m as ToolHandlerResult, n as ZodSchema } from './types-qqrmJ736.js';
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
- readonly resourceName?: string;
24
- readonly resourceDocumentation?: string;
25
- readonly protectedResourceMetadataUrl?: string;
26
- readonly requireOAuthClientClaim?: boolean;
27
- readonly acceptResourceClaim?: boolean;
28
- readonly issuer: string;
29
- readonly requiredScopes?: readonly string[];
30
- readonly jwksUri?: string;
31
- readonly algorithms?: readonly string[];
32
- readonly clockToleranceSeconds?: number;
33
- readonly accessTokenTyp?: readonly string[];
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
- readonly resource: string;
37
- readonly acceptedAudiences?: IssuerAcceptedAudiences;
35
+ readonly resource: string;
36
+ readonly acceptedAudiences?: IssuerAcceptedAudiences;
38
37
  } | {
39
- readonly resource?: string;
40
- readonly acceptedAudiences: IssuerAcceptedAudiences;
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
- oauth: Readonly<{
54
- issuer: typeof issuer;
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
- ToolContext
3
- } from "./chunk-MA5H6PSF.js";
4
- import {
5
- parseSafeUrl,
6
- resolveMetricsConfig,
7
- setLogLevel,
8
- trimTrailingSlash
9
- } from "./chunk-H37EB22A.js";
10
-
11
- // src/core/define.ts
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
- const seen = /* @__PURE__ */ new Set();
14
- for (const tool of mcp.tools) {
15
- if (seen.has(tool.name)) {
16
- throw new Error(`@lovable.dev/mcp-js: duplicate tool name "${tool.name}"`);
17
- }
18
- seen.add(tool.name);
19
- }
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
- if (value.trim() === "") {
23
- throw new Error(`@lovable.dev/mcp-js: ${label} must not be empty`);
24
- }
25
- if (value !== value.trim()) {
26
- throw new Error(`@lovable.dev/mcp-js: ${label} must not have leading or trailing whitespace`);
27
- }
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
- assertNonEmptyString(`auth.${name}`, value);
31
- parseSafeUrl(`@lovable.dev/mcp-js: auth.${name}`, value);
16
+ assertNonEmptyString(`auth.${name}`, value);
17
+ parseSafeUrl(`@lovable.dev/mcp-js: auth.${name}`, value);
32
18
  }
33
19
  function assertScope(scope) {
34
- if (scope.trim() === "" || /\s/.test(scope)) {
35
- throw new Error(`@lovable.dev/mcp-js: OAuth scopes must be non-empty space-free tokens`);
36
- }
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
- if (algorithm.trim() === "" || /\s/.test(algorithm)) {
40
- throw new Error(`@lovable.dev/mcp-js: auth.algorithms must contain non-empty space-free tokens`);
41
- }
42
- if (/^HS\d+$/i.test(algorithm) || algorithm.toLowerCase() === "none") {
43
- throw new Error(`@lovable.dev/mcp-js: auth.algorithms cannot include "${algorithm}"; this verifier is JWKS-only`);
44
- }
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
- var MAX_CLOCK_TOLERANCE_SECONDS = 300;
26
+ const MAX_CLOCK_TOLERANCE_SECONDS = 300;
47
27
  function assertClockToleranceSeconds(value) {
48
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > MAX_CLOCK_TOLERANCE_SECONDS) {
49
- throw new Error(
50
- `@lovable.dev/mcp-js: auth.clockToleranceSeconds must be a non-negative number of seconds no greater than ${MAX_CLOCK_TOLERANCE_SECONDS}`
51
- );
52
- }
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(auth2) {
55
- if (auth2.type !== "oauth") {
56
- const authType = String(auth2.type);
57
- throw new Error(`@lovable.dev/mcp-js: unsupported auth type "${authType}"`);
58
- }
59
- if (auth2.issuer === void 0) {
60
- throw new Error(`@lovable.dev/mcp-js: auth.issuer is required`);
61
- }
62
- assertHttpsUrlField("issuer", auth2.issuer);
63
- if (auth2.jwksUri !== void 0) {
64
- assertHttpsUrlField("jwksUri", auth2.jwksUri);
65
- }
66
- if (auth2.resource !== void 0) {
67
- assertHttpsUrlField("resource", auth2.resource);
68
- }
69
- if (auth2.resourceName !== void 0) {
70
- assertNonEmptyString("auth.resourceName", auth2.resourceName);
71
- }
72
- if (auth2.resourceDocumentation !== void 0) {
73
- assertHttpsUrlField("resourceDocumentation", auth2.resourceDocumentation);
74
- }
75
- if (auth2.protectedResourceMetadataUrl !== void 0) {
76
- assertHttpsUrlField("protectedResourceMetadataUrl", auth2.protectedResourceMetadataUrl);
77
- }
78
- if (auth2.acceptedAudiences !== void 0) {
79
- if (!Array.isArray(auth2.acceptedAudiences)) {
80
- throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must be an array`);
81
- }
82
- if (auth2.acceptedAudiences.length === 0) {
83
- throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must not be empty`);
84
- }
85
- for (const audience of auth2.acceptedAudiences) {
86
- if (typeof audience !== "string") {
87
- throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences must contain strings`);
88
- }
89
- assertNonEmptyString("auth.acceptedAudiences", audience);
90
- if (trimTrailingSlash(audience) === "") {
91
- throw new Error(`@lovable.dev/mcp-js: auth.acceptedAudiences entries must not be only slashes`);
92
- }
93
- }
94
- }
95
- if (auth2.requireOAuthClientClaim !== void 0 && typeof auth2.requireOAuthClientClaim !== "boolean") {
96
- throw new Error(`@lovable.dev/mcp-js: auth.requireOAuthClientClaim must be a boolean`);
97
- }
98
- if (auth2.acceptResourceClaim !== void 0 && typeof auth2.acceptResourceClaim !== "boolean") {
99
- throw new Error(`@lovable.dev/mcp-js: auth.acceptResourceClaim must be a boolean`);
100
- }
101
- if (auth2.requiredScopes !== void 0) {
102
- if (!Array.isArray(auth2.requiredScopes)) {
103
- throw new Error(`@lovable.dev/mcp-js: auth.requiredScopes must be an array`);
104
- }
105
- for (const scope of auth2.requiredScopes)
106
- assertScope(scope);
107
- }
108
- if (auth2.algorithms !== void 0) {
109
- if (!Array.isArray(auth2.algorithms)) {
110
- throw new Error(`@lovable.dev/mcp-js: auth.algorithms must be an array`);
111
- }
112
- if (auth2.algorithms.length === 0) {
113
- throw new Error(`@lovable.dev/mcp-js: auth.algorithms must not be empty`);
114
- }
115
- for (const algorithm of auth2.algorithms)
116
- assertJwtAlgorithm(algorithm);
117
- }
118
- if (auth2.accessTokenTyp !== void 0) {
119
- if (!Array.isArray(auth2.accessTokenTyp)) {
120
- throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must be an array`);
121
- }
122
- if (auth2.accessTokenTyp.length === 0) {
123
- throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must not be empty`);
124
- }
125
- for (const typ of auth2.accessTokenTyp) {
126
- if (typeof typ !== "string") {
127
- throw new Error(`@lovable.dev/mcp-js: auth.accessTokenTyp must contain strings`);
128
- }
129
- assertNonEmptyString("auth.accessTokenTyp", typ);
130
- }
131
- }
132
- if (auth2.clockToleranceSeconds !== void 0)
133
- assertClockToleranceSeconds(auth2.clockToleranceSeconds);
134
- if (auth2.resource === void 0 && auth2.acceptedAudiences === void 0) {
135
- throw new Error(`@lovable.dev/mcp-js: auth.resource or auth.acceptedAudiences is required`);
136
- }
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(auth2) {
139
- if (!auth2)
140
- return;
141
- if (auth2.acceptedAudiences)
142
- Object.freeze(auth2.acceptedAudiences);
143
- if (auth2.requiredScopes)
144
- Object.freeze(auth2.requiredScopes);
145
- if (auth2.algorithms)
146
- Object.freeze(auth2.algorithms);
147
- if (auth2.accessTokenTyp)
148
- Object.freeze(auth2.accessTokenTyp);
149
- Object.freeze(auth2);
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
- return def;
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
- assertNonEmptyString("name", def.name);
156
- assertNonEmptyString("title", def.title);
157
- assertNonEmptyString("version", def.version);
158
- assertUniqueNames(def);
159
- if (def.auth)
160
- assertOAuthConfig(def.auth);
161
- resolveMetricsConfig(def.metrics);
162
- freezeAuth(def.auth);
163
- Object.freeze(def.tools);
164
- for (const tool of def.tools)
165
- Object.freeze(tool);
166
- return def;
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
- // src/auth/config.ts
109
+ //#endregion
110
+ //#region src/auth/config.ts
170
111
  function frozenArray(value) {
171
- return value === void 0 ? void 0 : Object.freeze([...value]);
112
+ return value === void 0 ? void 0 : Object.freeze([...value]);
172
113
  }
173
114
  function frozenAudiences(value) {
174
- return frozenArray(typeof value === "string" ? [value] : value);
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
- for (const key of Object.keys(value)) {
178
- if (value[key] === void 0)
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
- return Object.freeze(
185
- stripUndefined({
186
- type: "oauth",
187
- ...options,
188
- acceptedAudiences: frozenAudiences(options.acceptedAudiences),
189
- requiredScopes: frozenArray(options.requiredScopes),
190
- algorithms: frozenArray(options.algorithms),
191
- accessTokenTyp: frozenArray(options.accessTokenTyp)
192
- })
193
- );
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
- var oauth = Object.freeze({ issuer });
196
- var auth = Object.freeze({ oauth });
197
- export {
198
- ToolContext,
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
- readonly mcpEntry: string;
10
- readonly urlPath: string;
11
+ readonly mcpEntry: string;
12
+ readonly urlPath: string;
11
13
  }
12
-
13
- export type { McpPluginApi as M };
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,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,57 @@
1
+ const require_cors = require("./cors-CSDhBjFd.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,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-rWp_tbLZ.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 };