@lovable.dev/mcp-js 0.29.0-rc.2 → 0.29.0-rc.4

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 (53) hide show
  1. package/README.internal.md +3 -3
  2. package/README.md +2 -25
  3. package/dist/{cors-DNzLB6qa.cjs → authorize-CKMlIxm9.cjs} +29 -78
  4. package/dist/{authorize-Bpz8oxjF.d.ts → authorize-CqYsQYfa.d.ts} +1 -1
  5. package/dist/{authorize-Cqr7Jps0.d.cts → authorize-DIYS7zBP.d.cts} +1 -1
  6. package/dist/{cors-C_VffY86.js → authorize-b3VqTC_7.js} +24 -73
  7. package/dist/cli/extract-manifest.cjs +12 -7
  8. package/dist/cli/extract-manifest.js +12 -7
  9. package/dist/{errors-Cr95rSkB.cjs → errors-CN6Da8iz.cjs} +8 -23
  10. package/dist/{errors-Bwd1L0Rf.js → errors-DSe96Ffd.js} +8 -23
  11. package/dist/{forwarded-BC_RHnn5.cjs → forwarded-Bhwcj22u.cjs} +3 -3
  12. package/dist/{forwarded-B3EBjHnA.js → forwarded-BlLF3dfc.js} +3 -3
  13. package/dist/index.cjs +1 -38
  14. package/dist/index.d.cts +3 -3
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +1 -38
  17. package/dist/{io-DrHivYt0.d.ts → io-DP3icuxa.d.ts} +1 -1
  18. package/dist/{io-Bh_WpbxU.d.cts → io-Dx0nPc1-.d.cts} +1 -1
  19. package/dist/mcp-BLs6_g8i.js +174 -0
  20. package/dist/mcp-DtHM-41c.cjs +179 -0
  21. package/dist/{package-CYA-5C24.js → package-DMs4EVwG.js} +1 -1
  22. package/dist/{package-DNSwCau1.cjs → package-Xk8p8Q_E.cjs} +1 -1
  23. package/dist/protocols/mcp/index.cjs +1 -1
  24. package/dist/protocols/mcp/index.d.cts +3 -6
  25. package/dist/protocols/mcp/index.d.ts +3 -6
  26. package/dist/protocols/mcp/index.js +1 -1
  27. package/dist/protocols/oauth-metadata.cjs +9 -11
  28. package/dist/protocols/oauth-metadata.d.cts +2 -2
  29. package/dist/protocols/oauth-metadata.d.ts +2 -2
  30. package/dist/protocols/oauth-metadata.js +3 -5
  31. package/dist/stacks/supabase/index.cjs +5 -5
  32. package/dist/stacks/supabase/index.d.cts +1 -1
  33. package/dist/stacks/supabase/index.d.ts +1 -1
  34. package/dist/stacks/supabase/index.js +3 -3
  35. package/dist/stacks/supabase/vite.cjs +1 -1
  36. package/dist/stacks/supabase/vite.d.cts +1 -1
  37. package/dist/stacks/supabase/vite.d.ts +1 -1
  38. package/dist/stacks/supabase/vite.js +1 -1
  39. package/dist/stacks/tanstack/index.cjs +4 -4
  40. package/dist/stacks/tanstack/index.d.cts +2 -2
  41. package/dist/stacks/tanstack/index.d.ts +2 -2
  42. package/dist/stacks/tanstack/index.js +3 -3
  43. package/dist/stacks/tanstack/vite.cjs +4 -8
  44. package/dist/stacks/tanstack/vite.d.cts +1 -4
  45. package/dist/stacks/tanstack/vite.d.ts +1 -4
  46. package/dist/stacks/tanstack/vite.js +4 -8
  47. package/dist/{types-DnGEKnvI.d.cts → types-C0Wgm9zp.d.cts} +26 -57
  48. package/dist/{types-DnGEKnvI.d.ts → types-C0Wgm9zp.d.ts} +26 -57
  49. package/package.json +1 -5
  50. package/dist/mcp-Bl7pQYdv.js +0 -346
  51. package/dist/mcp-CRdT2Fai.cjs +0 -351
  52. package/dist/schema-CW1jKvio.js +0 -65
  53. package/dist/schema-D3vClxb7.cjs +0 -76
@@ -1,4 +1,4 @@
1
- import { u as McpDefinition } from "../../types-DnGEKnvI.cjs";
1
+ import { c as McpDefinition } from "../../types-C0Wgm9zp.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 { u as McpDefinition } from "../../types-DnGEKnvI.js";
1
+ import { c as McpDefinition } from "../../types-C0Wgm9zp.js";
2
2
  //#region src/stacks/supabase/handler.d.ts
3
3
  type SupabaseHandler = (request: Request) => Promise<Response>;
4
4
  interface SupabaseHandlerOptions {
@@ -1,9 +1,9 @@
1
1
  import { s as trimTrailingSlash } from "../../logger-Ctv5xUSD.js";
2
- import { a as assertResourcePathShape, s as createRecorderForRuntime } from "../../cors-C_VffY86.js";
2
+ import { i as assertResourcePathShape, o as createRecorderForRuntime } from "../../authorize-b3VqTC_7.js";
3
3
  import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
4
- import { t as createMcpProtocolHandler } from "../../mcp-Bl7pQYdv.js";
4
+ import { t as createMcpProtocolHandler } from "../../mcp-BLs6_g8i.js";
5
5
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
6
- import { t as applyForwardedOrigin } from "../../forwarded-B3EBjHnA.js";
6
+ import { t as applyForwardedOrigin } from "../../forwarded-BlLF3dfc.js";
7
7
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
8
8
  //#region src/stacks/supabase/handler.ts
9
9
  function deriveResourcePath(options) {
@@ -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-DNSwCau1.cjs");
5
+ const require_package = require("../../package-Xk8p8Q_E.cjs");
6
6
  const require_fs_errors = require("../../fs-errors-CWNzOV75.cjs");
7
7
  const require_supabase_config = require("../../supabase-config-Dz7dnUv0.cjs");
8
8
  const require_paths = require("../../paths-OP318a6c.cjs");
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-Bh_WpbxU.cjs";
1
+ import { t as McpPluginApi } from "../../io-Dx0nPc1-.cjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/supabase/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-DrHivYt0.js";
1
+ import { t as McpPluginApi } from "../../io-DP3icuxa.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/supabase/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { t as version } from "../../package-CYA-5C24.js";
1
+ import { t as version } from "../../package-DMs4EVwG.js";
2
2
  import { t as isFileMissing } from "../../fs-errors-PA2t1TIp.js";
3
3
  import { t as readSupabaseProjectRef } from "../../supabase-config-CakTU8YF.js";
4
4
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cors = require("../../cors-DNzLB6qa.cjs");
3
- const require_mcp = require("../../mcp-CRdT2Fai.cjs");
2
+ const require_authorize = require("../../authorize-CKMlIxm9.cjs");
3
+ const require_mcp = require("../../mcp-DtHM-41c.cjs");
4
4
  const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
5
- const require_forwarded = require("../../forwarded-BC_RHnn5.cjs");
5
+ const require_forwarded = require("../../forwarded-Bhwcj22u.cjs");
6
6
  //#region src/stacks/tanstack/handlers.ts
7
7
  const STACK = "tanstack";
8
8
  /**
@@ -11,7 +11,7 @@ const STACK = "tanstack";
11
11
  */
12
12
  function createTanStackMcpHandler(mcp, options = {}) {
13
13
  const handler = require_mcp.createMcpProtocolHandler(mcp, options);
14
- return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_cors.createRecorderForRuntime(mcp, { stack: STACK }));
14
+ return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_authorize.createRecorderForRuntime(mcp, { stack: STACK }));
15
15
  }
16
16
  /**
17
17
  * Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
@@ -1,5 +1,5 @@
1
- import { u as McpDefinition } from "../../types-DnGEKnvI.cjs";
2
- import { t as McpRuntimeOptions } from "../../authorize-Cqr7Jps0.cjs";
1
+ import { c as McpDefinition } from "../../types-C0Wgm9zp.cjs";
2
+ import { t as McpRuntimeOptions } from "../../authorize-DIYS7zBP.cjs";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRouteCtx {
5
5
  request: Request;
@@ -1,5 +1,5 @@
1
- import { u as McpDefinition } from "../../types-DnGEKnvI.js";
2
- import { t as McpRuntimeOptions } from "../../authorize-Bpz8oxjF.js";
1
+ import { c as McpDefinition } from "../../types-C0Wgm9zp.js";
2
+ import { t as McpRuntimeOptions } from "../../authorize-CqYsQYfa.js";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRouteCtx {
5
5
  request: Request;
@@ -1,7 +1,7 @@
1
- import { s as createRecorderForRuntime } from "../../cors-C_VffY86.js";
2
- import { t as createMcpProtocolHandler } from "../../mcp-Bl7pQYdv.js";
1
+ import { o as createRecorderForRuntime } from "../../authorize-b3VqTC_7.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-BLs6_g8i.js";
3
3
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
4
- import { t as applyForwardedOrigin } from "../../forwarded-B3EBjHnA.js";
4
+ import { t as applyForwardedOrigin } from "../../forwarded-BlLF3dfc.js";
5
5
  //#region src/stacks/tanstack/handlers.ts
6
6
  const STACK = "tanstack";
7
7
  /**
@@ -64,16 +64,13 @@ function relativeImportSpecifier(routeFile, target) {
64
64
  const withoutExt = normalizePath((0, node_path.relative)((0, node_path.dirname)(routeFile), target)).replace(/\.ts$/, "");
65
65
  return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
66
66
  }
67
- function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
67
+ function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, mcpEntry, projectRoot) {
68
68
  const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
69
69
  const routeRel = normalizePath((0, node_path.relative)(projectRoot, route.file));
70
70
  const optionEntries = [`resourcePath: "${resourcePath}"`];
71
71
  if (metadataPath !== void 0) optionEntries.push(`metadataPath: "${metadataPath}"`);
72
- if (trustForwardedHost) if (route.attestsForwardedHost) {
73
- const trustNote = trustForwardedProto ? "// Trusting X-Forwarded-Host/-Proto is safe on Lovable hosting only (its\n // proxies overwrite both headers); remove these options behind other proxies." : "// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.";
74
- optionEntries.push(`${trustNote}\n trustForwardedHost: true`, "forwardedHostTrustedByPlatform: true");
75
- } else optionEntries.push("trustForwardedHost: true");
76
- if (trustForwardedProto) optionEntries.push("trustForwardedProto: true");
72
+ if (trustForwardedHost) if (route.attestsForwardedHost) optionEntries.push("// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.\n trustForwardedHost: true", "forwardedHostTrustedByPlatform: true");
73
+ else optionEntries.push("trustForwardedHost: true");
77
74
  const optionsObject = `{\n${optionEntries.map((entry) => ` ${entry},`).join("\n")}\n }`;
78
75
  const inlineRouteOpen = `export const Route = createFileRoute("${route.routeLiteral}")({`;
79
76
  const routeOpen = inlineRouteOpen.length <= OXFMT_PRINT_WIDTH ? inlineRouteOpen : `export const Route = createFileRoute(\n "${route.routeLiteral}",\n)({`;
@@ -179,7 +176,6 @@ function mcpPlugin(options = {}) {
179
176
  const metadataUrlPath = canonicalUrlPath(options.metadataPath ?? "/.well-known/oauth-protected-resource");
180
177
  const injectedMetadataPath = emitProtectedResourceMetadataRoute ? metadataUrlPath : void 0;
181
178
  const trustForwardedHost = options.trustForwardedHost !== false;
182
- const trustForwardedProto = options.trustForwardedProto !== false;
183
179
  let projectRoot = process.cwd();
184
180
  let mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
185
181
  let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
@@ -206,7 +202,7 @@ function mcpPlugin(options = {}) {
206
202
  });
207
203
  for (const route of routes) {
208
204
  expected.add(route.file);
209
- writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
205
+ writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, mcpEntry, projectRoot));
210
206
  }
211
207
  }
212
208
  for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-Bh_WpbxU.cjs";
1
+ import { t as McpPluginApi } from "../../io-Dx0nPc1-.cjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -57,9 +57,6 @@ interface McpPluginOptions {
57
57
  * @default true
58
58
  */
59
59
  trustForwardedHost?: boolean;
60
- /** Derive the public scheme from `X-Forwarded-Proto`; safe only behind an
61
- * overwriting proxy. @default true */
62
- trustForwardedProto?: boolean;
63
60
  }
64
61
  declare function assertUrlPathShape(urlPath: string): string;
65
62
  declare function deriveRouteFileName(urlPath: string): string;
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-DrHivYt0.js";
1
+ import { t as McpPluginApi } from "../../io-DP3icuxa.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -57,9 +57,6 @@ interface McpPluginOptions {
57
57
  * @default true
58
58
  */
59
59
  trustForwardedHost?: boolean;
60
- /** Derive the public scheme from `X-Forwarded-Proto`; safe only behind an
61
- * overwriting proxy. @default true */
62
- trustForwardedProto?: boolean;
63
60
  }
64
61
  declare function assertUrlPathShape(urlPath: string): string;
65
62
  declare function deriveRouteFileName(urlPath: string): string;
@@ -60,16 +60,13 @@ function relativeImportSpecifier(routeFile, target) {
60
60
  const withoutExt = normalizePath(relative(dirname(routeFile), target)).replace(/\.ts$/, "");
61
61
  return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
62
62
  }
63
- function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
63
+ function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, mcpEntry, projectRoot) {
64
64
  const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
65
65
  const routeRel = normalizePath(relative(projectRoot, route.file));
66
66
  const optionEntries = [`resourcePath: "${resourcePath}"`];
67
67
  if (metadataPath !== void 0) optionEntries.push(`metadataPath: "${metadataPath}"`);
68
- if (trustForwardedHost) if (route.attestsForwardedHost) {
69
- const trustNote = trustForwardedProto ? "// Trusting X-Forwarded-Host/-Proto is safe on Lovable hosting only (its\n // proxies overwrite both headers); remove these options behind other proxies." : "// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.";
70
- optionEntries.push(`${trustNote}\n trustForwardedHost: true`, "forwardedHostTrustedByPlatform: true");
71
- } else optionEntries.push("trustForwardedHost: true");
72
- if (trustForwardedProto) optionEntries.push("trustForwardedProto: true");
68
+ if (trustForwardedHost) if (route.attestsForwardedHost) optionEntries.push("// Trusting X-Forwarded-Host is safe on Lovable hosting only (its proxy\n // overwrites the header); remove both options behind other proxies.\n trustForwardedHost: true", "forwardedHostTrustedByPlatform: true");
69
+ else optionEntries.push("trustForwardedHost: true");
73
70
  const optionsObject = `{\n${optionEntries.map((entry) => ` ${entry},`).join("\n")}\n }`;
74
71
  const inlineRouteOpen = `export const Route = createFileRoute("${route.routeLiteral}")({`;
75
72
  const routeOpen = inlineRouteOpen.length <= OXFMT_PRINT_WIDTH ? inlineRouteOpen : `export const Route = createFileRoute(\n "${route.routeLiteral}",\n)({`;
@@ -175,7 +172,6 @@ function mcpPlugin(options = {}) {
175
172
  const metadataUrlPath = canonicalUrlPath(options.metadataPath ?? "/.well-known/oauth-protected-resource");
176
173
  const injectedMetadataPath = emitProtectedResourceMetadataRoute ? metadataUrlPath : void 0;
177
174
  const trustForwardedHost = options.trustForwardedHost !== false;
178
- const trustForwardedProto = options.trustForwardedProto !== false;
179
175
  let projectRoot = process.cwd();
180
176
  let mcpEntry = resolve(projectRoot, mcpEntryOption);
181
177
  let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
@@ -202,7 +198,7 @@ function mcpPlugin(options = {}) {
202
198
  });
203
199
  for (const route of routes) {
204
200
  expected.add(route.file);
205
- writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
201
+ writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, mcpEntry, projectRoot));
206
202
  }
207
203
  }
208
204
  for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {
@@ -85,46 +85,16 @@ interface McpAuthConfig {
85
85
  }
86
86
  //#endregion
87
87
  //#region src/auth/context.d.ts
88
- /** What the client declared about itself on the in-flight request. Unverified
89
- * client input a hint, never an authorization signal (use the auth accessors). */
90
- interface McpClientInfo {
91
- /** Protocol era of the in-flight request. */
92
- protocol: "2026-07-28" | "legacy";
93
- /** Client name/version from the request envelope (`2026-07-28` era only). */
94
- info?: {
95
- name: string;
96
- version: string;
97
- title?: string;
98
- };
99
- /** Client capabilities from the request envelope (`2026-07-28` era only). */
100
- capabilities?: Record<string, unknown>;
101
- /** Extension declarations (`capabilities.extensions`), keyed by extension id. */
102
- extensions?: Record<string, Record<string, unknown>>;
103
- }
104
- /** A progress notification payload. `progress` should increase monotonically. */
105
- interface ProgressUpdate {
106
- progress: number;
107
- total?: number;
108
- message?: string;
109
- }
110
- /** Per-request runtime surface threaded into `ToolContext` by the protocol layer. */
111
- interface ToolRequestContext {
112
- signal?: AbortSignal;
113
- client?: McpClientInfo;
114
- sendProgress?: (update: ProgressUpdate) => Promise<void>;
115
- }
116
- /** The per-request context passed to every tool handler as its second argument. The
117
- * auth context lives in a private field so the accessors are the only way out; `getToken()` is the sole bearer escape hatch. */
88
+ /**
89
+ * The auth surface passed to every tool handler as its second argument. It wraps
90
+ * the verified per-request auth context in a private field, so the context — and
91
+ * the bearer token inside it — can't be read, enumerated, spread, or
92
+ * `JSON.stringify`'d off the instance; the accessors below are the only way out.
93
+ * `getToken()` is the single intentional escape hatch for the raw bearer.
94
+ */
118
95
  declare class ToolContext {
119
96
  #private;
120
- constructor(auth: McpAuthContext | undefined, request?: ToolRequestContext);
121
- /** Aborts when the client cancels the request or disconnects. */
122
- get signal(): AbortSignal;
123
- /** What the client declared about itself on this request. Unverified input. */
124
- get client(): McpClientInfo;
125
- /** Send a progress notification for this call. A no-op when the client
126
- * didn't request progress (no `progressToken` on the request). */
127
- progress(update: ProgressUpdate): Promise<void>;
97
+ constructor(auth: McpAuthContext | undefined);
128
98
  /** Whether the in-flight tool call carries a verified auth context. */
129
99
  isAuthenticated(): boolean;
130
100
  /** The verified bearer token, or `undefined` when unauthenticated. Pass it to downstream APIs; never return or log it. */
@@ -180,11 +150,9 @@ type MetricsConfig = boolean | MetricsOptions;
180
150
  type ZodSchema = ZodType;
181
151
  /**
182
152
  * A raw zod shape (`{ text: z.string(), n: z.number() }`) — the format
183
- * `defineTool`'s `inputSchema` expects and the object shorthand accepted by
184
- * `outputSchema`.
153
+ * `defineTool`'s `inputSchema`/`outputSchema` expects.
185
154
  */
186
155
  type ZodRawShape$1 = ZodRawShape;
187
- type ZodOutputSchema = ZodSchema | ZodRawShape$1;
188
156
  /**
189
157
  * Infer the parsed-output type of a zod raw shape — given
190
158
  * `{ text: ZodString, n: ZodNumber }`, produces `{ text: string, n: number }`.
@@ -249,8 +217,8 @@ type EmbeddedResource = EmbeddedTextResource | EmbeddedBlobResource;
249
217
  interface ResourceLinkIcon {
250
218
  src: string;
251
219
  mimeType?: string;
252
- /** Array per MCP 2026-07-28; legacy space-separated strings remain accepted. */
253
- sizes?: string | string[];
220
+ /** Space-separated dimension string, HTML `<link sizes>` convention (e.g. `"16x16 32x32"`). */
221
+ sizes?: string;
254
222
  theme?: "light" | "dark";
255
223
  }
256
224
  interface ResourceLink extends ContentBlockBase {
@@ -273,10 +241,6 @@ type ContentBlock = TextContent | ImageContent | AudioContent | EmbeddedResource
273
241
  * the tool returns to the caller.
274
242
  */
275
243
  type ToolContent = ContentBlock[];
276
- type JsonValue = null | boolean | number | string | JsonValue[] | {
277
- [key: string]: JsonValue;
278
- };
279
- type McpAllowedOrigins = "any" | readonly string[];
280
244
  /**
281
245
  * Per-tool client hints (not enforcement). `annotations.title` is
282
246
  * intentionally omitted — use `ToolDefinition.title`, which the MCP
@@ -294,10 +258,10 @@ interface ToolAnnotations {
294
258
  }
295
259
  interface ToolHandlerResult {
296
260
  content?: ToolContent;
297
- structuredContent?: JsonValue;
261
+ structuredContent?: Record<string, unknown>;
298
262
  isError?: boolean;
299
263
  }
300
- interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
264
+ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined> {
301
265
  readonly name: string;
302
266
  /** Human-readable display name shown to the user in MCP clients. Required. */
303
267
  readonly title: string;
@@ -308,27 +272,32 @@ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$
308
272
  readonly annotations?: ToolAnnotations;
309
273
  readonly handler: TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
310
274
  }
311
- /** Type-erased element of `McpDefinition.tools`; per-tool generic typing
312
- * happens at the `defineTool` call site. */
275
+ /**
276
+ * Type-erased element of `McpDefinition.tools`. Per-tool generic typing
277
+ * happens at the `defineTool` call site; see README §6 for the rationale.
278
+ */
313
279
  interface AnyToolDefinition {
314
280
  readonly name: string;
315
281
  readonly title: string;
316
282
  readonly description: string;
317
283
  readonly inputSchema?: ZodRawShape$1;
318
- readonly outputSchema?: ZodOutputSchema;
284
+ readonly outputSchema?: ZodRawShape$1;
319
285
  readonly annotations?: ToolAnnotations;
320
286
  readonly handler: (args: any, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
321
287
  }
322
- /** Input shape for `defineMcp(...)`, whose branded `McpDefinition` return type is what
323
- * `createMcpProtocolHandler` consumes the brand forces validation + freeze. */
288
+ /**
289
+ * Fields a caller supplies when constructing an MCP definition. Pass this
290
+ * shape to `defineMcp(...)` — its return type is the branded `McpDefinition`,
291
+ * which is the type every internal factory (`createInvokeToolHandler`,
292
+ * `createMcpProtocolHandler`, …) consumes. The brand forces consumers
293
+ * through `defineMcp`'s `assertUniqueNames` + freeze.
294
+ */
324
295
  interface McpDefinitionInput {
325
296
  readonly name: string;
326
297
  /** Human-readable display name shown to MCP clients. Required. */
327
298
  readonly title: string;
328
299
  readonly version: string;
329
300
  readonly auth?: McpAuthConfig;
330
- /** Cross-origin browser access. Omit to allow only same-origin and non-browser requests. */
331
- readonly allowedOrigins?: McpAllowedOrigins;
332
301
  /**
333
302
  * Server-level prose the LLM reads as context for all tools on this server.
334
303
  * Required for the same reason `ToolDefinition.description` is — optional
@@ -349,4 +318,4 @@ type McpDefinition = McpDefinitionInput & {
349
318
  readonly [McpDefinitionBrand]: never;
350
319
  };
351
320
  //#endregion
352
- export { MetricsOptions as C, JwtClaims as D, ToolContext as E, McpAuthConfig as O, MetricsConfig as S, ProgressUpdate as T, ToolDefinition as _, EmbeddedResource as a, ZodRawShape$1 as b, JsonValue as c, McpDefinitionInput as d, ResourceLink as f, ToolContent as g, ToolAnnotations as h, EmbeddedBlobResource as i, McpAllowedOrigins as l, TextContent as m, ContentAnnotations as n, EmbeddedTextResource as o, ResourceLinkIcon as p, ContentBlock as r, ImageContent as s, AudioContent as t, McpDefinition as u, ToolHandlerResult as v, McpClientInfo as w, ZodSchema as x, ZodOutputSchema as y };
321
+ export { McpAuthConfig as C, JwtClaims as S, ZodRawShape$1 as _, EmbeddedResource as a, MetricsOptions as b, McpDefinition as c, ResourceLinkIcon as d, TextContent as f, ToolHandlerResult as g, ToolDefinition as h, EmbeddedBlobResource as i, McpDefinitionInput as l, ToolContent as m, ContentAnnotations as n, EmbeddedTextResource as o, ToolAnnotations as p, ContentBlock as r, ImageContent as s, AudioContent as t, ResourceLink as u, ZodSchema as v, ToolContext as x, MetricsConfig as y };
@@ -85,46 +85,16 @@ interface McpAuthConfig {
85
85
  }
86
86
  //#endregion
87
87
  //#region src/auth/context.d.ts
88
- /** What the client declared about itself on the in-flight request. Unverified
89
- * client input a hint, never an authorization signal (use the auth accessors). */
90
- interface McpClientInfo {
91
- /** Protocol era of the in-flight request. */
92
- protocol: "2026-07-28" | "legacy";
93
- /** Client name/version from the request envelope (`2026-07-28` era only). */
94
- info?: {
95
- name: string;
96
- version: string;
97
- title?: string;
98
- };
99
- /** Client capabilities from the request envelope (`2026-07-28` era only). */
100
- capabilities?: Record<string, unknown>;
101
- /** Extension declarations (`capabilities.extensions`), keyed by extension id. */
102
- extensions?: Record<string, Record<string, unknown>>;
103
- }
104
- /** A progress notification payload. `progress` should increase monotonically. */
105
- interface ProgressUpdate {
106
- progress: number;
107
- total?: number;
108
- message?: string;
109
- }
110
- /** Per-request runtime surface threaded into `ToolContext` by the protocol layer. */
111
- interface ToolRequestContext {
112
- signal?: AbortSignal;
113
- client?: McpClientInfo;
114
- sendProgress?: (update: ProgressUpdate) => Promise<void>;
115
- }
116
- /** The per-request context passed to every tool handler as its second argument. The
117
- * auth context lives in a private field so the accessors are the only way out; `getToken()` is the sole bearer escape hatch. */
88
+ /**
89
+ * The auth surface passed to every tool handler as its second argument. It wraps
90
+ * the verified per-request auth context in a private field, so the context — and
91
+ * the bearer token inside it — can't be read, enumerated, spread, or
92
+ * `JSON.stringify`'d off the instance; the accessors below are the only way out.
93
+ * `getToken()` is the single intentional escape hatch for the raw bearer.
94
+ */
118
95
  declare class ToolContext {
119
96
  #private;
120
- constructor(auth: McpAuthContext | undefined, request?: ToolRequestContext);
121
- /** Aborts when the client cancels the request or disconnects. */
122
- get signal(): AbortSignal;
123
- /** What the client declared about itself on this request. Unverified input. */
124
- get client(): McpClientInfo;
125
- /** Send a progress notification for this call. A no-op when the client
126
- * didn't request progress (no `progressToken` on the request). */
127
- progress(update: ProgressUpdate): Promise<void>;
97
+ constructor(auth: McpAuthContext | undefined);
128
98
  /** Whether the in-flight tool call carries a verified auth context. */
129
99
  isAuthenticated(): boolean;
130
100
  /** The verified bearer token, or `undefined` when unauthenticated. Pass it to downstream APIs; never return or log it. */
@@ -180,11 +150,9 @@ type MetricsConfig = boolean | MetricsOptions;
180
150
  type ZodSchema = ZodType;
181
151
  /**
182
152
  * A raw zod shape (`{ text: z.string(), n: z.number() }`) — the format
183
- * `defineTool`'s `inputSchema` expects and the object shorthand accepted by
184
- * `outputSchema`.
153
+ * `defineTool`'s `inputSchema`/`outputSchema` expects.
185
154
  */
186
155
  type ZodRawShape$1 = ZodRawShape;
187
- type ZodOutputSchema = ZodSchema | ZodRawShape$1;
188
156
  /**
189
157
  * Infer the parsed-output type of a zod raw shape — given
190
158
  * `{ text: ZodString, n: ZodNumber }`, produces `{ text: string, n: number }`.
@@ -249,8 +217,8 @@ type EmbeddedResource = EmbeddedTextResource | EmbeddedBlobResource;
249
217
  interface ResourceLinkIcon {
250
218
  src: string;
251
219
  mimeType?: string;
252
- /** Array per MCP 2026-07-28; legacy space-separated strings remain accepted. */
253
- sizes?: string | string[];
220
+ /** Space-separated dimension string, HTML `<link sizes>` convention (e.g. `"16x16 32x32"`). */
221
+ sizes?: string;
254
222
  theme?: "light" | "dark";
255
223
  }
256
224
  interface ResourceLink extends ContentBlockBase {
@@ -273,10 +241,6 @@ type ContentBlock = TextContent | ImageContent | AudioContent | EmbeddedResource
273
241
  * the tool returns to the caller.
274
242
  */
275
243
  type ToolContent = ContentBlock[];
276
- type JsonValue = null | boolean | number | string | JsonValue[] | {
277
- [key: string]: JsonValue;
278
- };
279
- type McpAllowedOrigins = "any" | readonly string[];
280
244
  /**
281
245
  * Per-tool client hints (not enforcement). `annotations.title` is
282
246
  * intentionally omitted — use `ToolDefinition.title`, which the MCP
@@ -294,10 +258,10 @@ interface ToolAnnotations {
294
258
  }
295
259
  interface ToolHandlerResult {
296
260
  content?: ToolContent;
297
- structuredContent?: JsonValue;
261
+ structuredContent?: Record<string, unknown>;
298
262
  isError?: boolean;
299
263
  }
300
- interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
264
+ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined> {
301
265
  readonly name: string;
302
266
  /** Human-readable display name shown to the user in MCP clients. Required. */
303
267
  readonly title: string;
@@ -308,27 +272,32 @@ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$
308
272
  readonly annotations?: ToolAnnotations;
309
273
  readonly handler: TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
310
274
  }
311
- /** Type-erased element of `McpDefinition.tools`; per-tool generic typing
312
- * happens at the `defineTool` call site. */
275
+ /**
276
+ * Type-erased element of `McpDefinition.tools`. Per-tool generic typing
277
+ * happens at the `defineTool` call site; see README §6 for the rationale.
278
+ */
313
279
  interface AnyToolDefinition {
314
280
  readonly name: string;
315
281
  readonly title: string;
316
282
  readonly description: string;
317
283
  readonly inputSchema?: ZodRawShape$1;
318
- readonly outputSchema?: ZodOutputSchema;
284
+ readonly outputSchema?: ZodRawShape$1;
319
285
  readonly annotations?: ToolAnnotations;
320
286
  readonly handler: (args: any, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
321
287
  }
322
- /** Input shape for `defineMcp(...)`, whose branded `McpDefinition` return type is what
323
- * `createMcpProtocolHandler` consumes the brand forces validation + freeze. */
288
+ /**
289
+ * Fields a caller supplies when constructing an MCP definition. Pass this
290
+ * shape to `defineMcp(...)` — its return type is the branded `McpDefinition`,
291
+ * which is the type every internal factory (`createInvokeToolHandler`,
292
+ * `createMcpProtocolHandler`, …) consumes. The brand forces consumers
293
+ * through `defineMcp`'s `assertUniqueNames` + freeze.
294
+ */
324
295
  interface McpDefinitionInput {
325
296
  readonly name: string;
326
297
  /** Human-readable display name shown to MCP clients. Required. */
327
298
  readonly title: string;
328
299
  readonly version: string;
329
300
  readonly auth?: McpAuthConfig;
330
- /** Cross-origin browser access. Omit to allow only same-origin and non-browser requests. */
331
- readonly allowedOrigins?: McpAllowedOrigins;
332
301
  /**
333
302
  * Server-level prose the LLM reads as context for all tools on this server.
334
303
  * Required for the same reason `ToolDefinition.description` is — optional
@@ -349,4 +318,4 @@ type McpDefinition = McpDefinitionInput & {
349
318
  readonly [McpDefinitionBrand]: never;
350
319
  };
351
320
  //#endregion
352
- export { MetricsOptions as C, JwtClaims as D, ToolContext as E, McpAuthConfig as O, MetricsConfig as S, ProgressUpdate as T, ToolDefinition as _, EmbeddedResource as a, ZodRawShape$1 as b, JsonValue as c, McpDefinitionInput as d, ResourceLink as f, ToolContent as g, ToolAnnotations as h, EmbeddedBlobResource as i, McpAllowedOrigins as l, TextContent as m, ContentAnnotations as n, EmbeddedTextResource as o, ResourceLinkIcon as p, ContentBlock as r, ImageContent as s, AudioContent as t, McpDefinition as u, ToolHandlerResult as v, McpClientInfo as w, ZodSchema as x, ZodOutputSchema as y };
321
+ export { McpAuthConfig as C, JwtClaims as S, ZodRawShape$1 as _, EmbeddedResource as a, MetricsOptions as b, McpDefinition as c, ResourceLinkIcon as d, TextContent as f, ToolHandlerResult as g, ToolDefinition as h, EmbeddedBlobResource as i, McpDefinitionInput as l, ToolContent as m, ContentAnnotations as n, EmbeddedTextResource as o, ToolAnnotations as p, ContentBlock as r, ImageContent as s, AudioContent as t, ResourceLink as u, ZodSchema as v, ToolContext as x, MetricsConfig as y };
package/package.json CHANGED
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/mcp-js",
3
- "version": "0.29.0-rc.2",
4
- "engines": {
5
- "node": ">=20"
6
- },
3
+ "version": "0.29.0-rc.4",
7
4
  "description": "Author MCP servers for Lovable apps. Declare tools with defineTool, register them in defineMcp, and a framework adapter (TanStack or Supabase Edge Functions) emits the route(s) at build time.",
8
5
  "type": "module",
9
6
  "repository": {
@@ -109,7 +106,6 @@
109
106
  "license": "MIT",
110
107
  "dependencies": {
111
108
  "@modelcontextprotocol/sdk": "1.28.0",
112
- "@modelcontextprotocol/server": "2.0.0",
113
109
  "esbuild": "^0.27.0",
114
110
  "jose": "^6.2.2"
115
111
  },