@lovable.dev/mcp-js 3.2.1 → 3.3.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 (50) hide show
  1. package/README.md +17 -1
  2. package/dist/{authorize-DUEaDXjU.d.ts → authorize-DxnyFNHv.d.ts} +1 -1
  3. package/dist/{authorize-bDiUiJco.d.cts → authorize-r6jB-Gl2.d.cts} +1 -1
  4. package/dist/{base-D2d7lJY5.d.cts → base-CzPzbI3q.d.cts} +1 -1
  5. package/dist/{base-CLO7XsxC.d.ts → base-ff0LwIA2.d.ts} +1 -1
  6. package/dist/cli/extract-manifest.cjs +4 -1
  7. package/dist/cli/extract-manifest.js +4 -1
  8. package/dist/{cors-CAjdoGLn.cjs → cors-Bjo6NPjV.cjs} +1 -1
  9. package/dist/{cors-DqGRvw0A.js → cors-COjc9O73.js} +1 -1
  10. package/dist/{errors-CljrUVby.js → errors-D0UPHnG3.js} +13 -1
  11. package/dist/{errors-CLfxIB-l.cjs → errors-DSHt3Jqs.cjs} +13 -1
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.cts +2 -2
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.js +1 -1
  16. package/dist/{io-CFyHLyvs.d.ts → io-CQ60Nc2J.d.ts} +1 -1
  17. package/dist/{io-DewJxgO4.js → io-DTz7efSK.js} +1 -1
  18. package/dist/{io-DfUvQ-SV.d.cts → io-DnRCu_HX.d.cts} +1 -1
  19. package/dist/{io-C-KJpQde.cjs → io-Dzy5Bu6h.cjs} +1 -1
  20. package/dist/{mcp-FRaH2mQW.cjs → mcp-Buu1riaY.cjs} +24 -9
  21. package/dist/{mcp-ClL3tmtt.js → mcp-DIR9MCwQ.js} +24 -9
  22. package/dist/{package-B0CFKfHW.cjs → package-DL4uNmL0.cjs} +1 -1
  23. package/dist/{package-tjBEL0hN.js → package-DV8zBoEy.js} +1 -1
  24. package/dist/protocols/mcp/index.cjs +1 -1
  25. package/dist/protocols/mcp/index.d.cts +3 -3
  26. package/dist/protocols/mcp/index.d.ts +3 -3
  27. package/dist/protocols/mcp/index.js +1 -1
  28. package/dist/protocols/oauth-metadata.cjs +1 -1
  29. package/dist/protocols/oauth-metadata.d.cts +3 -3
  30. package/dist/protocols/oauth-metadata.d.ts +3 -3
  31. package/dist/protocols/oauth-metadata.js +1 -1
  32. package/dist/stacks/supabase/index.cjs +2 -2
  33. package/dist/stacks/supabase/index.d.cts +1 -1
  34. package/dist/stacks/supabase/index.d.ts +1 -1
  35. package/dist/stacks/supabase/index.js +2 -2
  36. package/dist/stacks/supabase/vite.cjs +1 -1
  37. package/dist/stacks/supabase/vite.d.cts +1 -1
  38. package/dist/stacks/supabase/vite.d.ts +1 -1
  39. package/dist/stacks/supabase/vite.js +1 -1
  40. package/dist/stacks/tanstack/index.cjs +2 -2
  41. package/dist/stacks/tanstack/index.d.cts +2 -2
  42. package/dist/stacks/tanstack/index.d.ts +2 -2
  43. package/dist/stacks/tanstack/index.js +2 -2
  44. package/dist/stacks/tanstack/vite.d.cts +1 -1
  45. package/dist/stacks/tanstack/vite.d.ts +1 -1
  46. package/dist/testing/index.d.cts +1 -1
  47. package/dist/testing/index.d.ts +1 -1
  48. package/dist/{types-CAFCH0yK.d.ts → types-BtoYHhdt.d.cts} +9 -3
  49. package/dist/{types-CAFCH0yK.d.cts → types-BtoYHhdt.d.ts} +9 -3
  50. package/package.json +6 -1
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Author MCP servers for Lovable apps. Declare tools with `defineTool`, register them with `defineMcp`, and a Vite plugin emits the framework-specific routes at build time (TanStack today, Supabase Edge Functions next).
4
4
 
5
+ Vite is an optional peer dependency: deployed MCP handlers do not need it. Both `/stacks/*/vite` plugins and `lovable-mcp-extract-manifest` require an explicitly installed Vite version `>=5.0.0 <9.0.0`. Keep your project's existing compatible version, or install one with `npm install -D vite@^7`. Build and manifest-extraction jobs must include dev dependencies; runtime-only deployments can omit them.
6
+
5
7
  ```ts
6
8
  // src/lib/mcp/tools/echo.ts
7
9
  import { defineTool } from "@lovable.dev/mcp-js";
@@ -64,7 +66,7 @@ import refunds from "./skills/refunds?allowHidden=templates/.prettierrc&allowHid
64
66
 
65
67
  Repeat `allowHidden` for each exact, case-sensitive file path relative to the skill directory. Directory-wide grants, globs, traversal paths, duplicate entries and entries that do not name an existing file are rejected. A hidden directory is traversed only for listed descendants; every file beneath it needs its own entry. An empty hidden directory fails too. Allowed files still pass the text-only and symlink checks. Combine `allowHidden` with `path` in either order, keeping `skill` last; percent-encode reserved characters in values (for example `%26` for `&` and `%25` for `%`).
66
68
 
67
- Use dedicated publication directories without credentials or private documents. The allowlist prevents accidental hidden-file publication, not secrets in ordinary or explicitly approved files. Files use the same server-level OAuth and origin policy as tools; conditional tool permissions do not hide skills or their contents.
69
+ Use dedicated publication directories without credentials or private documents. The allowlist prevents accidental hidden-file publication, not secrets in ordinary or explicitly approved files. Files use the same server-level OAuth and origin policy as tools. Tool visibility does not control Skill visibility; use a conditional Skill registration when callers need different procedures.
68
70
 
69
71
  By default, `./skills/refunds?skill` publishes `skill://refunds/SKILL.md` and its supporting files. Use root-relative file references such as `references/rules.md` inside a skill. Reference a different skill with its complete URI; the host resolves it through `skills/get` and its skill-loading path. Reading `SKILL.md` as an ordinary resource does not activate it.
70
72
 
@@ -86,6 +88,20 @@ The server advertises the [Skills extension](https://modelcontextprotocol.io/ext
86
88
 
87
89
  Fallback is reference text, not installation, execution or a permission grant. It preserves source text rather than summarizing it or rewriting links. A capable client that omits the declaration can receive both representations, even if its native skill loader is disabled. Host context limits still apply: the SDK does not truncate instructions or guarantee that a host will retain them. Build output lists published file sizes; the standard recommends at most 512 files and 16 MiB per skill, and fallback instructions should be substantially smaller for practical model context. Omit `skills` to retain existing tools-only behavior.
88
90
 
91
+ ### Caller-specific skills
92
+
93
+ With SDK 3.3.0, mix unconditional imports with conditional registrations:
94
+
95
+ ```ts
96
+ skills: [memberGuide, { skill: adminGuide, enabled: ({ appContext }) => appContext.isAdmin }],
97
+ ```
98
+
99
+ Use `defineMcp<AppContext>` and an authenticated `createAppContext`, as in [caller-dependent tool catalogs](#caller-dependent-tool-catalogs). Derive permissions from verified `auth`, not client metadata. `enabled` receives only `{ appContext }` and must be a pure synchronous boolean predicate. The SDK creates context once per protocol request that builds a server, shared with tools, including discovery, resource reads and static tool calls when conditional Skills are configured. A context or predicate failure fails the request with a redacted 500; asynchronous and non-boolean predicates are rejected. Unconditional-only servers retain their existing context-loading behavior.
100
+
101
+ Disabled registrations are absent from `skills/list` and unavailable through `skills/get`. Resources and fallback contain exactly the union of enabled bundles. Each enabled registration grants its entire recursive directory: an enabled parent still publishes a disabled child's files, including its `SKILL.md`, without registering that child as a Skill. Disabling a registration does not revoke copies independently published by another registration, another URI, or authored `instructions`. Keep restricted content outside directories granted to other callers. A reference requiring `skills/get` for a disabled registration cannot activate it, even if its text remains readable through a parent.
102
+
103
+ This selects static authored content; it does not generate personalized Skill text. Keep handler/service/RLS authorization independent. ChatGPT currently imports submission-time snapshots: do not rely on these predicates for per-user ChatGPT delivery or submit admin-only content assuming it will be filtered for later users.
104
+
89
105
  ## What the plugin emits
90
106
 
91
107
  | URL | File | Purpose |
@@ -1,4 +1,4 @@
1
- import "./types-CAFCH0yK.js";
1
+ import "./types-BtoYHhdt.js";
2
2
  //#region src/metrics/recorder.d.ts
3
3
  type ScheduleBackground = (task: Promise<unknown>) => void;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import "./types-CAFCH0yK.cjs";
1
+ import "./types-BtoYHhdt.cjs";
2
2
  //#region src/metrics/recorder.d.ts
3
3
  type ScheduleBackground = (task: Promise<unknown>) => void;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { M as McpProtocolEra } from "./types-CAFCH0yK.cjs";
1
+ import { N as McpProtocolEra } from "./types-BtoYHhdt.cjs";
2
2
  //#region src/metrics/impl/base.d.ts
3
3
  type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "auth_token_expired" | "auth_token_invalid" | "auth_insufficient_scope" | "auth_unexpected_error" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
4
4
  /** One recorded MCP call. Carries no arguments or response payloads — only the
@@ -1,4 +1,4 @@
1
- import { M as McpProtocolEra } from "./types-CAFCH0yK.js";
1
+ import { N as McpProtocolEra } from "./types-BtoYHhdt.js";
2
2
  //#region src/metrics/impl/base.d.ts
3
3
  type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "auth_token_expired" | "auth_token_invalid" | "auth_insufficient_scope" | "auth_unexpected_error" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
4
4
  /** One recorded MCP call. Carries no arguments or response payloads — only the
@@ -4,7 +4,10 @@ const projectRoot = process.argv[2] ?? process.cwd();
4
4
  import("zod/v3").catch((err) => {
5
5
  const message = err instanceof Error ? err.message : String(err);
6
6
  throw new Error(`@lovable.dev/mcp-js requires zod ^3.25 or ^4.0 to extract MCP schemas. Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
7
- }).then(() => Promise.resolve().then(() => require("../io-C-KJpQde.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
7
+ }).then(() => import("vite").catch((err) => {
8
+ const message = err instanceof Error ? err.message : String(err);
9
+ throw new Error(`@lovable.dev/mcp-js requires vite >=5.0.0 <9.0.0 for manifest extraction. Install a compatible Vite version in the project (for example, npm install -D vite@^7) and include dev dependencies when running this command. Underlying error: ${message}`);
10
+ })).then(() => Promise.resolve().then(() => require("../io-Dzy5Bu6h.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
8
11
  console.error(err instanceof Error ? err.message : String(err));
9
12
  process.exit(1);
10
13
  });
@@ -4,7 +4,10 @@ const projectRoot = process.argv[2] ?? process.cwd();
4
4
  import("zod/v3").catch((err) => {
5
5
  const message = err instanceof Error ? err.message : String(err);
6
6
  throw new Error(`@lovable.dev/mcp-js requires zod ^3.25 or ^4.0 to extract MCP schemas. Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
7
- }).then(() => import("../io-DewJxgO4.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
7
+ }).then(() => import("vite").catch((err) => {
8
+ const message = err instanceof Error ? err.message : String(err);
9
+ throw new Error(`@lovable.dev/mcp-js requires vite >=5.0.0 <9.0.0 for manifest extraction. Install a compatible Vite version in the project (for example, npm install -D vite@^7) and include dev dependencies when running this command. Underlying error: ${message}`);
10
+ })).then(() => import("../io-DTz7efSK.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
8
11
  console.error(err instanceof Error ? err.message : String(err));
9
12
  process.exit(1);
10
13
  });
@@ -1,5 +1,5 @@
1
1
  const require_logger = require("./logger-C-Hdu57K.cjs");
2
- const require_package = require("./package-B0CFKfHW.cjs");
2
+ const require_package = require("./package-DL4uNmL0.cjs");
3
3
  require("./metadata-path-zd7NSNoa.cjs");
4
4
  let jose = require("jose");
5
5
  //#region src/core/http.ts
@@ -1,5 +1,5 @@
1
1
  import { i as log, n as applyLogLevelFromEnv, o as parseSafeUrl, r as describeError, s as trimTrailingSlash, t as LOG_LEVEL_ENV_VAR, u as resolveMetricsConfig } from "./logger-CpLgYbCG.js";
2
- import { t as version } from "./package-tjBEL0hN.js";
2
+ import { t as version } from "./package-DV8zBoEy.js";
3
3
  import "./metadata-path-CAkNcfyY.js";
4
4
  import { createLocalJWKSet, decodeProtectedHeader, errors, jwtVerify } from "jose";
5
5
  //#region src/core/http.ts
@@ -147,7 +147,19 @@ function defineMcp(def) {
147
147
  if (Array.isArray(def.allowedOrigins)) Object.freeze(def.allowedOrigins);
148
148
  Object.freeze(def.tools);
149
149
  for (const tool of def.tools) Object.freeze(tool);
150
- if (def.skills !== void 0) validateSkills(def.skills);
150
+ if (def.skills !== void 0) {
151
+ if (!Array.isArray(def.skills)) throw new TypeError("@lovable.dev/mcp-js: skills must be an array of ?skill imports");
152
+ validateSkills(def.skills.map((entry) => {
153
+ if (entry && "skill" in entry) {
154
+ if (typeof entry.enabled !== "function") throw new TypeError("@lovable.dev/mcp-js: conditional skills require an enabled predicate");
155
+ if (!def.createAppContext) throw new Error("@lovable.dev/mcp-js: conditional skills require createAppContext");
156
+ Object.freeze(entry);
157
+ return entry.skill;
158
+ }
159
+ return entry;
160
+ }));
161
+ Object.freeze(def.skills);
162
+ }
151
163
  return def;
152
164
  }
153
165
  //#endregion
@@ -147,7 +147,19 @@ function defineMcp(def) {
147
147
  if (Array.isArray(def.allowedOrigins)) Object.freeze(def.allowedOrigins);
148
148
  Object.freeze(def.tools);
149
149
  for (const tool of def.tools) Object.freeze(tool);
150
- if (def.skills !== void 0) require_format.validateSkills(def.skills);
150
+ if (def.skills !== void 0) {
151
+ if (!Array.isArray(def.skills)) throw new TypeError("@lovable.dev/mcp-js: skills must be an array of ?skill imports");
152
+ require_format.validateSkills(def.skills.map((entry) => {
153
+ if (entry && "skill" in entry) {
154
+ if (typeof entry.enabled !== "function") throw new TypeError("@lovable.dev/mcp-js: conditional skills require an enabled predicate");
155
+ if (!def.createAppContext) throw new Error("@lovable.dev/mcp-js: conditional skills require createAppContext");
156
+ Object.freeze(entry);
157
+ return entry.skill;
158
+ }
159
+ return entry;
160
+ }));
161
+ Object.freeze(def.skills);
162
+ }
151
163
  return def;
152
164
  }
153
165
  //#endregion
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_logger = require("./logger-C-Hdu57K.cjs");
3
- const require_errors = require("./errors-CLfxIB-l.cjs");
3
+ const require_errors = require("./errors-DSHt3Jqs.cjs");
4
4
  //#region src/auth/config.ts
5
5
  function frozenArray(value) {
6
6
  return value === void 0 ? void 0 : Object.freeze([...value]);
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AuthContext, C as ToolVisibilityContext, D as Skill, E as ZodSchema, F as JwtClaims, I as McpAuthConfig, M as McpProtocolEra, N as ProgressUpdate, O as MetricsConfig, P as ToolContext, S as ToolHandlerResult, T as ZodRawShape, _ as ResourceLinkIcon, a as ContentBlock, b as ToolContent, c as EmbeddedResource, d as JsonValue, f as JsonValueInput, g as ResourceLink, h as McpDefinitionInput, i as ContentAnnotations, j as McpClientInfo, k as MetricsOptions, l as EmbeddedTextResource, m as McpDefinition, n as AppContextToolDefinitionInput, o as CreateAppContextInput, p as McpAllowedOrigins, r as AudioContent, s as EmbeddedBlobResource, t as AppContextToolDefinition, u as ImageContent, v as TextContent, w as ZodOutputSchema, x as ToolDefinition, y as ToolAnnotations } from "./types-CAFCH0yK.cjs";
1
+ import { A as MetricsOptions, C as ToolHandlerResult, D as ZodSchema, E as ZodRawShape, F as ToolContext, I as JwtClaims, L as McpAuthConfig, M as McpClientInfo, N as McpProtocolEra, O as Skill, P as ProgressUpdate, S as ToolDefinition, T as ZodOutputSchema, _ as ResourceLink, a as ContentAnnotations, b as ToolAnnotations, c as EmbeddedBlobResource, d as ImageContent, f as JsonValue, g as McpDefinitionInput, h as McpDefinition, i as ConditionalSkill, j as AuthContext, k as MetricsConfig, l as EmbeddedResource, m as McpAllowedOrigins, n as AppContextToolDefinitionInput, o as ContentBlock, p as JsonValueInput, r as AudioContent, s as CreateAppContextInput, t as AppContextToolDefinition, u as EmbeddedTextResource, v as ResourceLinkIcon, w as ToolVisibilityContext, x as ToolContent, y as TextContent } from "./types-BtoYHhdt.cjs";
2
2
  //#region src/core/define.d.ts
3
3
  /**
4
4
  * Declare a single MCP tool. Import the result into your MCP definition's
@@ -76,4 +76,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
76
76
  */
77
77
  declare function setLogLevel(level: LogLevel): LogLevel;
78
78
  //#endregion
79
- export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AudioContent, AuthContext, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
79
+ export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AudioContent, AuthContext, type ConditionalSkill, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AuthContext, C as ToolVisibilityContext, D as Skill, E as ZodSchema, F as JwtClaims, I as McpAuthConfig, M as McpProtocolEra, N as ProgressUpdate, O as MetricsConfig, P as ToolContext, S as ToolHandlerResult, T as ZodRawShape, _ as ResourceLinkIcon, a as ContentBlock, b as ToolContent, c as EmbeddedResource, d as JsonValue, f as JsonValueInput, g as ResourceLink, h as McpDefinitionInput, i as ContentAnnotations, j as McpClientInfo, k as MetricsOptions, l as EmbeddedTextResource, m as McpDefinition, n as AppContextToolDefinitionInput, o as CreateAppContextInput, p as McpAllowedOrigins, r as AudioContent, s as EmbeddedBlobResource, t as AppContextToolDefinition, u as ImageContent, v as TextContent, w as ZodOutputSchema, x as ToolDefinition, y as ToolAnnotations } from "./types-CAFCH0yK.js";
1
+ import { A as MetricsOptions, C as ToolHandlerResult, D as ZodSchema, E as ZodRawShape, F as ToolContext, I as JwtClaims, L as McpAuthConfig, M as McpClientInfo, N as McpProtocolEra, O as Skill, P as ProgressUpdate, S as ToolDefinition, T as ZodOutputSchema, _ as ResourceLink, a as ContentAnnotations, b as ToolAnnotations, c as EmbeddedBlobResource, d as ImageContent, f as JsonValue, g as McpDefinitionInput, h as McpDefinition, i as ConditionalSkill, j as AuthContext, k as MetricsConfig, l as EmbeddedResource, m as McpAllowedOrigins, n as AppContextToolDefinitionInput, o as ContentBlock, p as JsonValueInput, r as AudioContent, s as CreateAppContextInput, t as AppContextToolDefinition, u as EmbeddedTextResource, v as ResourceLinkIcon, w as ToolVisibilityContext, x as ToolContent, y as TextContent } from "./types-BtoYHhdt.js";
2
2
  //#region src/core/define.d.ts
3
3
  /**
4
4
  * Declare a single MCP tool. Import the result into your MCP definition's
@@ -76,4 +76,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
76
76
  */
77
77
  declare function setLogLevel(level: LogLevel): LogLevel;
78
78
  //#endregion
79
- export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AudioContent, AuthContext, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
79
+ export { type AppContextToolDefinition, type AppContextToolDefinitionInput, type AudioContent, AuthContext, type ConditionalSkill, type ContentAnnotations, type ContentBlock, type CreateAppContextInput, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JsonValue, type JsonValueInput, type JwtClaims, type LogLevel, type McpAllowedOrigins, type McpClientInfo, type McpDefinitionInput, type McpProtocolEra, type MetricsConfig, type MetricsOptions, type ProgressUpdate, type ResourceLink, type ResourceLinkIcon, type Skill, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ToolVisibilityContext, type ZodOutputSchema, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as setLogLevel } from "./logger-CpLgYbCG.js";
2
- import { a as ToolContext, i as AuthContext, o as defineMcp, s as defineTool, t as ToolError } from "./errors-CljrUVby.js";
2
+ import { a as ToolContext, i as AuthContext, o as defineMcp, s as defineTool, t as ToolError } from "./errors-D0UPHnG3.js";
3
3
  //#region src/auth/config.ts
4
4
  function frozenArray(value) {
5
5
  return value === void 0 ? void 0 : Object.freeze([...value]);
@@ -1,4 +1,4 @@
1
- import "./types-CAFCH0yK.js";
1
+ import "./types-BtoYHhdt.js";
2
2
  //#region src/manifest/io.d.ts
3
3
  /**
4
4
  * Shape every MCP Vite plugin exposes on its `api` so `runExtract` can read
@@ -1,5 +1,5 @@
1
1
  import { t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
2
- import { t as version } from "./package-tjBEL0hN.js";
2
+ import { t as version } from "./package-DV8zBoEy.js";
3
3
  import { a as isFileMissing, i as readSupabaseProjectRef, r as skillImportVitePlugin } from "./hooks-BOdDe251.js";
4
4
  import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { dirname, resolve } from "node:path";
@@ -1,4 +1,4 @@
1
- import "./types-CAFCH0yK.cjs";
1
+ import "./types-BtoYHhdt.cjs";
2
2
  //#region src/manifest/io.d.ts
3
3
  /**
4
4
  * Shape every MCP Vite plugin exposes on its `api` so `runExtract` can read
@@ -1,5 +1,5 @@
1
1
  const require_schema = require("./schema-DNMsvJwE.cjs");
2
- const require_package = require("./package-B0CFKfHW.cjs");
2
+ const require_package = require("./package-DL4uNmL0.cjs");
3
3
  const require_hooks = require("./hooks-xQl3EkDa.cjs");
4
4
  let node_fs = require("node:fs");
5
5
  let node_path = require("node:path");
@@ -1,7 +1,7 @@
1
1
  const require_schema = require("./schema-DNMsvJwE.cjs");
2
2
  const require_logger = require("./logger-C-Hdu57K.cjs");
3
- const require_errors = require("./errors-CLfxIB-l.cjs");
4
- const require_cors = require("./cors-CAjdoGLn.cjs");
3
+ const require_errors = require("./errors-DSHt3Jqs.cjs");
4
+ const require_cors = require("./cors-Bjo6NPjV.cjs");
5
5
  const require_tool_result = require("./tool-result-rU-PpNNi.cjs");
6
6
  let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
7
7
  let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
@@ -74,6 +74,7 @@ function prepareSkills(serverName, importedSkills) {
74
74
  };
75
75
  }
76
76
  function composeInstructions(authored, prepared, declared) {
77
+ if (prepared.skills.length === 0) return authored;
77
78
  const addition = declared ? prepared.indexText : prepared.fallbackText;
78
79
  return authored.length > 0 ? `${authored}\n\n${addition}` : addition;
79
80
  }
@@ -388,19 +389,32 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
388
389
  const calledTools = operations ? mcp.tools.filter((tool) => operations.calledTools.has(tool.name)) : mcp.tools;
389
390
  const selectedTools = !operations || operations.listTools ? mcp.tools : calledTools;
390
391
  const hasConditionalTools = mcp.tools.some((tool) => tool.enabled !== void 0);
391
- const needsAppContext = operations?.listTools === true && hasConditionalTools || calledTools.some((tool) => tool.enabled !== void 0 || require_errors.toolRequiresAppContext(tool));
392
+ const needsAppContext = skills !== void 0 && skills.prepared === void 0 || operations?.listTools === true && hasConditionalTools || calledTools.some((tool) => tool.enabled !== void 0 || require_errors.toolRequiresAppContext(tool));
392
393
  const { createAppContext } = mcp;
393
394
  const appContext = needsAppContext && createAppContext ? await withAppContextError(() => createAppContext({
394
395
  auth: new require_errors.AuthContext(auth),
395
396
  signal
396
397
  })) : void 0;
397
398
  const visibilityContext = Object.freeze({ appContext });
399
+ let preparedSkills = skills?.prepared;
400
+ if (skills && !preparedSkills) {
401
+ const enabledSkills = await withAppContextError(() => mcp.skills.flatMap((entry) => {
402
+ if (!("skill" in entry)) return [entry];
403
+ const enabled = entry.enabled(visibilityContext);
404
+ if (typeof enabled !== "boolean") {
405
+ Promise.resolve(enabled).catch(() => {});
406
+ throw new TypeError("@lovable.dev/mcp-js: skill enabled must return a boolean synchronously");
407
+ }
408
+ return enabled ? [entry.skill] : [];
409
+ }));
410
+ preparedSkills = prepareSkills(mcp.name, enabledSkills);
411
+ }
398
412
  const server = new _modelcontextprotocol_server.McpServer({
399
413
  name: mcp.name,
400
414
  version: mcp.version,
401
415
  title: mcp.title
402
416
  }, {
403
- instructions: skills ? skills.instructions : mcp.instructions,
417
+ instructions: preparedSkills ? composeInstructions(mcp.instructions, preparedSkills, skills.declared) : mcp.instructions,
404
418
  capabilities: skills ? {
405
419
  tools: { listChanged: false },
406
420
  resources: {
@@ -424,7 +438,7 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
424
438
  } : {}
425
439
  }
426
440
  });
427
- if (skills) registerSkills(server, skills.prepared, era);
441
+ if (preparedSkills) registerSkills(server, preparedSkills, era);
428
442
  for (const tool of selectedTools) {
429
443
  if (tool.enabled) {
430
444
  const { enabled } = tool;
@@ -458,7 +472,8 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
458
472
  */
459
473
  function createMcpProtocolHandler(mcp, options = {}) {
460
474
  const authorizer = require_cors.createRequestAuthorizer(mcp, options);
461
- const preparedSkills = mcp.skills && mcp.skills.length > 0 ? prepareSkills(mcp.name, mcp.skills) : void 0;
475
+ const hasSkills = mcp.skills !== void 0 && mcp.skills.length > 0;
476
+ const preparedSkills = mcp.skills?.length && mcp.skills.every((entry) => !("skill" in entry)) ? prepareSkills(mcp.name, mcp.skills) : void 0;
462
477
  const handle = async (request, authResult, recorder) => {
463
478
  let protocolError;
464
479
  const reportTransportError = async (error) => {
@@ -476,11 +491,11 @@ function createMcpProtocolHandler(mcp, options = {}) {
476
491
  });
477
492
  };
478
493
  try {
479
- const classified = mcp.createAppContext || preparedSkills ? await classifyRequest(request) : void 0;
494
+ const classified = mcp.createAppContext || hasSkills ? await classifyRequest(request) : void 0;
480
495
  const operations = mcp.createAppContext ? classified?.operations : void 0;
481
- const skills = preparedSkills ? {
496
+ const skills = hasSkills ? {
482
497
  prepared: preparedSkills,
483
- instructions: composeInstructions(mcp.instructions, preparedSkills, declaresSkillsSupport(classified?.parsedBody))
498
+ declared: declaresSkillsSupport(classified?.parsedBody)
484
499
  } : void 0;
485
500
  const response = await (0, _modelcontextprotocol_server.createMcpHandler)(({ era, requestInfo }) => buildServer(mcp, authResult.auth, recorder, era, requestInfo?.signal ?? request.signal, operations, skills), {
486
501
  legacy: "stateless",
@@ -1,7 +1,7 @@
1
1
  import { i as log, r as describeError } from "./logger-CpLgYbCG.js";
2
2
  import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
3
- import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-CljrUVby.js";
4
- import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-DqGRvw0A.js";
3
+ import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-D0UPHnG3.js";
4
+ import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-COjc9O73.js";
5
5
  import { t as finalizeToolResult } from "./tool-result-DcNioyiI.js";
6
6
  import { safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
7
7
  import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler } from "@modelcontextprotocol/server";
@@ -74,6 +74,7 @@ function prepareSkills(serverName, importedSkills) {
74
74
  };
75
75
  }
76
76
  function composeInstructions(authored, prepared, declared) {
77
+ if (prepared.skills.length === 0) return authored;
77
78
  const addition = declared ? prepared.indexText : prepared.fallbackText;
78
79
  return authored.length > 0 ? `${authored}\n\n${addition}` : addition;
79
80
  }
@@ -388,19 +389,32 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
388
389
  const calledTools = operations ? mcp.tools.filter((tool) => operations.calledTools.has(tool.name)) : mcp.tools;
389
390
  const selectedTools = !operations || operations.listTools ? mcp.tools : calledTools;
390
391
  const hasConditionalTools = mcp.tools.some((tool) => tool.enabled !== void 0);
391
- const needsAppContext = operations?.listTools === true && hasConditionalTools || calledTools.some((tool) => tool.enabled !== void 0 || toolRequiresAppContext(tool));
392
+ const needsAppContext = skills !== void 0 && skills.prepared === void 0 || operations?.listTools === true && hasConditionalTools || calledTools.some((tool) => tool.enabled !== void 0 || toolRequiresAppContext(tool));
392
393
  const { createAppContext } = mcp;
393
394
  const appContext = needsAppContext && createAppContext ? await withAppContextError(() => createAppContext({
394
395
  auth: new AuthContext(auth),
395
396
  signal
396
397
  })) : void 0;
397
398
  const visibilityContext = Object.freeze({ appContext });
399
+ let preparedSkills = skills?.prepared;
400
+ if (skills && !preparedSkills) {
401
+ const enabledSkills = await withAppContextError(() => mcp.skills.flatMap((entry) => {
402
+ if (!("skill" in entry)) return [entry];
403
+ const enabled = entry.enabled(visibilityContext);
404
+ if (typeof enabled !== "boolean") {
405
+ Promise.resolve(enabled).catch(() => {});
406
+ throw new TypeError("@lovable.dev/mcp-js: skill enabled must return a boolean synchronously");
407
+ }
408
+ return enabled ? [entry.skill] : [];
409
+ }));
410
+ preparedSkills = prepareSkills(mcp.name, enabledSkills);
411
+ }
398
412
  const server = new McpServer({
399
413
  name: mcp.name,
400
414
  version: mcp.version,
401
415
  title: mcp.title
402
416
  }, {
403
- instructions: skills ? skills.instructions : mcp.instructions,
417
+ instructions: preparedSkills ? composeInstructions(mcp.instructions, preparedSkills, skills.declared) : mcp.instructions,
404
418
  capabilities: skills ? {
405
419
  tools: { listChanged: false },
406
420
  resources: {
@@ -424,7 +438,7 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
424
438
  } : {}
425
439
  }
426
440
  });
427
- if (skills) registerSkills(server, skills.prepared, era);
441
+ if (preparedSkills) registerSkills(server, preparedSkills, era);
428
442
  for (const tool of selectedTools) {
429
443
  if (tool.enabled) {
430
444
  const { enabled } = tool;
@@ -458,7 +472,8 @@ async function buildServer(mcp, auth, recorder, era, signal, operations, skills)
458
472
  */
459
473
  function createMcpProtocolHandler(mcp, options = {}) {
460
474
  const authorizer = createRequestAuthorizer(mcp, options);
461
- const preparedSkills = mcp.skills && mcp.skills.length > 0 ? prepareSkills(mcp.name, mcp.skills) : void 0;
475
+ const hasSkills = mcp.skills !== void 0 && mcp.skills.length > 0;
476
+ const preparedSkills = mcp.skills?.length && mcp.skills.every((entry) => !("skill" in entry)) ? prepareSkills(mcp.name, mcp.skills) : void 0;
462
477
  const handle = async (request, authResult, recorder) => {
463
478
  let protocolError;
464
479
  const reportTransportError = async (error) => {
@@ -476,11 +491,11 @@ function createMcpProtocolHandler(mcp, options = {}) {
476
491
  });
477
492
  };
478
493
  try {
479
- const classified = mcp.createAppContext || preparedSkills ? await classifyRequest(request) : void 0;
494
+ const classified = mcp.createAppContext || hasSkills ? await classifyRequest(request) : void 0;
480
495
  const operations = mcp.createAppContext ? classified?.operations : void 0;
481
- const skills = preparedSkills ? {
496
+ const skills = hasSkills ? {
482
497
  prepared: preparedSkills,
483
- instructions: composeInstructions(mcp.instructions, preparedSkills, declaresSkillsSupport(classified?.parsedBody))
498
+ declared: declaresSkillsSupport(classified?.parsedBody)
484
499
  } : void 0;
485
500
  const response = await createMcpHandler(({ era, requestInfo }) => buildServer(mcp, authResult.auth, recorder, era, requestInfo?.signal ?? request.signal, operations, skills), {
486
501
  legacy: "stateless",
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.2.1";
2
+ var version = "3.3.0";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "3.2.1";
2
+ var version = "3.3.0";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mcp = require("../../mcp-FRaH2mQW.cjs");
2
+ const require_mcp = require("../../mcp-Buu1riaY.cjs");
3
3
  exports.createMcpProtocolHandler = require_mcp.createMcpProtocolHandler;
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../../types-CAFCH0yK.cjs";
2
- import { t as MetricsRecorder } from "../../base-D2d7lJY5.cjs";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-bDiUiJco.cjs";
1
+ import { h as McpDefinition } from "../../types-BtoYHhdt.cjs";
2
+ import { t as MetricsRecorder } from "../../base-CzPzbI3q.cjs";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-r6jB-Gl2.cjs";
4
4
  //#region src/protocols/mcp/protocol.d.ts
5
5
  type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../../types-CAFCH0yK.js";
2
- import { t as MetricsRecorder } from "../../base-CLO7XsxC.js";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-DUEaDXjU.js";
1
+ import { h as McpDefinition } from "../../types-BtoYHhdt.js";
2
+ import { t as MetricsRecorder } from "../../base-ff0LwIA2.js";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-DxnyFNHv.js";
4
4
  //#region src/protocols/mcp/protocol.d.ts
5
5
  type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  /**
@@ -1,2 +1,2 @@
1
- import { t as createMcpProtocolHandler } from "../../mcp-ClL3tmtt.js";
1
+ import { t as createMcpProtocolHandler } from "../../mcp-DIR9MCwQ.js";
2
2
  export { createMcpProtocolHandler };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_logger = require("../logger-C-Hdu57K.cjs");
3
- const require_cors = require("../cors-CAjdoGLn.cjs");
3
+ const require_cors = require("../cors-Bjo6NPjV.cjs");
4
4
  //#region src/protocols/oauth-metadata.ts
5
5
  function notFound() {
6
6
  return new Response(JSON.stringify({ error: "not found" }), {
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../types-CAFCH0yK.cjs";
2
- import { t as MetricsRecorder } from "../base-D2d7lJY5.cjs";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-bDiUiJco.cjs";
1
+ import { h as McpDefinition } from "../types-BtoYHhdt.cjs";
2
+ import { t as MetricsRecorder } from "../base-CzPzbI3q.cjs";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-r6jB-Gl2.cjs";
4
4
  //#region src/protocols/oauth-metadata.d.ts
5
5
  type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
@@ -1,6 +1,6 @@
1
- import { m as McpDefinition } from "../types-CAFCH0yK.js";
2
- import { t as MetricsRecorder } from "../base-CLO7XsxC.js";
3
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-DUEaDXjU.js";
1
+ import { h as McpDefinition } from "../types-BtoYHhdt.js";
2
+ import { t as MetricsRecorder } from "../base-ff0LwIA2.js";
3
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-DxnyFNHv.js";
4
4
  //#region src/protocols/oauth-metadata.d.ts
5
5
  type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
6
6
  declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
@@ -1,5 +1,5 @@
1
1
  import { i as log, r as describeError } from "../logger-CpLgYbCG.js";
2
- import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-DqGRvw0A.js";
2
+ import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-COjc9O73.js";
3
3
  //#region src/protocols/oauth-metadata.ts
4
4
  function notFound() {
5
5
  return new Response(JSON.stringify({ error: "not found" }), {
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_logger = require("../../logger-C-Hdu57K.cjs");
3
- const require_cors = require("../../cors-CAjdoGLn.cjs");
3
+ const require_cors = require("../../cors-Bjo6NPjV.cjs");
4
4
  const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
5
- const require_mcp = require("../../mcp-FRaH2mQW.cjs");
5
+ const require_mcp = require("../../mcp-Buu1riaY.cjs");
6
6
  const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
7
7
  const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
8
8
  const require_paths = require("../../paths-OP318a6c.cjs");
@@ -1,4 +1,4 @@
1
- import { m as McpDefinition } from "../../types-CAFCH0yK.cjs";
1
+ import { h as McpDefinition } from "../../types-BtoYHhdt.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 { m as McpDefinition } from "../../types-CAFCH0yK.js";
1
+ import { h as McpDefinition } from "../../types-BtoYHhdt.js";
2
2
  //#region src/stacks/supabase/handler.d.ts
3
3
  type SupabaseHandler = (request: Request) => Promise<Response>;
4
4
  interface SupabaseHandlerOptions {
@@ -1,7 +1,7 @@
1
1
  import { s as trimTrailingSlash } from "../../logger-CpLgYbCG.js";
2
- import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-DqGRvw0A.js";
2
+ import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-COjc9O73.js";
3
3
  import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
4
- import { t as createMcpProtocolHandler } from "../../mcp-ClL3tmtt.js";
4
+ import { t as createMcpProtocolHandler } from "../../mcp-DIR9MCwQ.js";
5
5
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
6
6
  import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
7
7
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
@@ -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-B0CFKfHW.cjs");
5
+ const require_package = require("../../package-DL4uNmL0.cjs");
6
6
  const require_hooks = require("../../hooks-xQl3EkDa.cjs");
7
7
  const require_paths = require("../../paths-OP318a6c.cjs");
8
8
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-DfUvQ-SV.cjs";
1
+ import { t as McpPluginApi } from "../../io-DnRCu_HX.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-CFyHLyvs.js";
1
+ import { t as McpPluginApi } from "../../io-CQ60Nc2J.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-tjBEL0hN.js";
1
+ import { t as version } from "../../package-DV8zBoEy.js";
2
2
  import { a as isFileMissing, i as readSupabaseProjectRef, n as skillImportEsbuildPlugin, t as isSkillImportInput } from "../../hooks-BOdDe251.js";
3
3
  import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
4
4
  import { lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cors = require("../../cors-CAjdoGLn.cjs");
3
- const require_mcp = require("../../mcp-FRaH2mQW.cjs");
2
+ const require_cors = require("../../cors-Bjo6NPjV.cjs");
3
+ const require_mcp = require("../../mcp-Buu1riaY.cjs");
4
4
  const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
5
5
  const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
6
6
  //#region src/stacks/tanstack/handlers.ts
@@ -1,5 +1,5 @@
1
- import { m as McpDefinition } from "../../types-CAFCH0yK.cjs";
2
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-bDiUiJco.cjs";
1
+ import { h as McpDefinition } from "../../types-BtoYHhdt.cjs";
2
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-r6jB-Gl2.cjs";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRequest extends Request {
5
5
  waitUntil?: ScheduleBackground;
@@ -1,5 +1,5 @@
1
- import { m as McpDefinition } from "../../types-CAFCH0yK.js";
2
- import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-DUEaDXjU.js";
1
+ import { h as McpDefinition } from "../../types-BtoYHhdt.js";
2
+ import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-DxnyFNHv.js";
3
3
  //#region src/stacks/tanstack/handlers.d.ts
4
4
  interface TanStackRequest extends Request {
5
5
  waitUntil?: ScheduleBackground;
@@ -1,5 +1,5 @@
1
- import { c as createRecorderForRuntime } from "../../cors-DqGRvw0A.js";
2
- import { t as createMcpProtocolHandler } from "../../mcp-ClL3tmtt.js";
1
+ import { c as createRecorderForRuntime } from "../../cors-COjc9O73.js";
2
+ import { t as createMcpProtocolHandler } from "../../mcp-DIR9MCwQ.js";
3
3
  import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
4
4
  import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
5
5
  //#region src/stacks/tanstack/handlers.ts
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-DfUvQ-SV.cjs";
1
+ import { t as McpPluginApi } from "../../io-DnRCu_HX.cjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { t as McpPluginApi } from "../../io-CFyHLyvs.js";
1
+ import { t as McpPluginApi } from "../../io-CQ60Nc2J.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/stacks/tanstack/vite.d.ts
4
4
  interface McpPluginOptions {
@@ -1,4 +1,4 @@
1
- import { w as ZodOutputSchema } from "../types-CAFCH0yK.cjs";
1
+ import { T as ZodOutputSchema } from "../types-BtoYHhdt.cjs";
2
2
  import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.cjs";
3
3
  //#region src/testing/result.d.ts
4
4
  interface ToolResultExpectation {
@@ -1,4 +1,4 @@
1
- import { w as ZodOutputSchema } from "../types-CAFCH0yK.js";
1
+ import { T as ZodOutputSchema } from "../types-BtoYHhdt.js";
2
2
  import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.js";
3
3
  //#region src/testing/result.d.ts
4
4
  interface ToolResultExpectation {
@@ -328,6 +328,11 @@ interface CreateAppContextInput {
328
328
  interface ToolVisibilityContext<TAppContext> {
329
329
  readonly appContext: TAppContext;
330
330
  }
331
+ /** Publishes a static skill bundle only when the caller's app context permits it. */
332
+ interface ConditionalSkill<TAppContext> {
333
+ readonly skill: Skill;
334
+ readonly enabled: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
335
+ }
331
336
  interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
332
337
  readonly name: string;
333
338
  /** Human-readable display name shown to the user in MCP clients. Required. */
@@ -401,7 +406,7 @@ type McpDefinitionInput<TAppContext = undefined> = {
401
406
  */
402
407
  readonly instructions: string;
403
408
  readonly tools: readonly (AnyAppContextToolDefinition<TAppContext> | StaticToolDefinition)[];
404
- readonly skills?: readonly Skill[];
409
+ readonly skills?: readonly (Skill | ConditionalSkill<TAppContext>)[];
405
410
  /**
406
411
  * Usage-metrics emission (runtime telemetry), on by default. `false` opts out;
407
412
  * `{ endpoint, headers }` sends to your own OTLP collector. Self-disables at
@@ -410,10 +415,11 @@ type McpDefinitionInput<TAppContext = undefined> = {
410
415
  readonly metrics?: MetricsConfig;
411
416
  } & AppContextConfiguration<TAppContext>;
412
417
  declare const McpDefinitionBrand: unique symbol;
413
- type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>, "createAppContext" | "tools"> & {
418
+ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>, "createAppContext" | "tools" | "skills"> & {
414
419
  readonly createAppContext?: (input: CreateAppContextInput) => TAppContext | Promise<TAppContext>;
415
420
  readonly tools: readonly AnyToolDefinition[];
421
+ readonly skills?: readonly (Skill | ConditionalSkill<never>)[];
416
422
  readonly [McpDefinitionBrand]: never;
417
423
  };
418
424
  //#endregion
419
- export { AuthContext as A, ToolVisibilityContext as C, Skill as D, ZodSchema as E, JwtClaims as F, McpAuthConfig as I, McpProtocolEra as M, ProgressUpdate as N, MetricsConfig as O, ToolContext as P, ToolHandlerResult as S, ZodRawShape$1 as T, ResourceLinkIcon as _, ContentBlock as a, ToolContent as b, EmbeddedResource as c, JsonValue as d, JsonValueInput as f, ResourceLink as g, McpDefinitionInput as h, ContentAnnotations as i, McpClientInfo as j, MetricsOptions as k, EmbeddedTextResource as l, McpDefinition as m, AppContextToolDefinitionInput as n, CreateAppContextInput as o, McpAllowedOrigins as p, AudioContent as r, EmbeddedBlobResource as s, AppContextToolDefinition as t, ImageContent as u, TextContent as v, ZodOutputSchema as w, ToolDefinition as x, ToolAnnotations as y };
425
+ export { MetricsOptions as A, ToolHandlerResult as C, ZodSchema as D, ZodRawShape$1 as E, ToolContext as F, JwtClaims as I, McpAuthConfig as L, McpClientInfo as M, McpProtocolEra as N, Skill as O, ProgressUpdate as P, ToolDefinition as S, ZodOutputSchema as T, ResourceLink as _, ContentAnnotations as a, ToolAnnotations as b, EmbeddedBlobResource as c, ImageContent as d, JsonValue as f, McpDefinitionInput as g, McpDefinition as h, ConditionalSkill as i, AuthContext as j, MetricsConfig as k, EmbeddedResource as l, McpAllowedOrigins as m, AppContextToolDefinitionInput as n, ContentBlock as o, JsonValueInput as p, AudioContent as r, CreateAppContextInput as s, AppContextToolDefinition as t, EmbeddedTextResource as u, ResourceLinkIcon as v, ToolVisibilityContext as w, ToolContent as x, TextContent as y };
@@ -328,6 +328,11 @@ interface CreateAppContextInput {
328
328
  interface ToolVisibilityContext<TAppContext> {
329
329
  readonly appContext: TAppContext;
330
330
  }
331
+ /** Publishes a static skill bundle only when the caller's app context permits it. */
332
+ interface ConditionalSkill<TAppContext> {
333
+ readonly skill: Skill;
334
+ readonly enabled: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
335
+ }
331
336
  interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
332
337
  readonly name: string;
333
338
  /** Human-readable display name shown to the user in MCP clients. Required. */
@@ -401,7 +406,7 @@ type McpDefinitionInput<TAppContext = undefined> = {
401
406
  */
402
407
  readonly instructions: string;
403
408
  readonly tools: readonly (AnyAppContextToolDefinition<TAppContext> | StaticToolDefinition)[];
404
- readonly skills?: readonly Skill[];
409
+ readonly skills?: readonly (Skill | ConditionalSkill<TAppContext>)[];
405
410
  /**
406
411
  * Usage-metrics emission (runtime telemetry), on by default. `false` opts out;
407
412
  * `{ endpoint, headers }` sends to your own OTLP collector. Self-disables at
@@ -410,10 +415,11 @@ type McpDefinitionInput<TAppContext = undefined> = {
410
415
  readonly metrics?: MetricsConfig;
411
416
  } & AppContextConfiguration<TAppContext>;
412
417
  declare const McpDefinitionBrand: unique symbol;
413
- type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>, "createAppContext" | "tools"> & {
418
+ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>, "createAppContext" | "tools" | "skills"> & {
414
419
  readonly createAppContext?: (input: CreateAppContextInput) => TAppContext | Promise<TAppContext>;
415
420
  readonly tools: readonly AnyToolDefinition[];
421
+ readonly skills?: readonly (Skill | ConditionalSkill<never>)[];
416
422
  readonly [McpDefinitionBrand]: never;
417
423
  };
418
424
  //#endregion
419
- export { AuthContext as A, ToolVisibilityContext as C, Skill as D, ZodSchema as E, JwtClaims as F, McpAuthConfig as I, McpProtocolEra as M, ProgressUpdate as N, MetricsConfig as O, ToolContext as P, ToolHandlerResult as S, ZodRawShape$1 as T, ResourceLinkIcon as _, ContentBlock as a, ToolContent as b, EmbeddedResource as c, JsonValue as d, JsonValueInput as f, ResourceLink as g, McpDefinitionInput as h, ContentAnnotations as i, McpClientInfo as j, MetricsOptions as k, EmbeddedTextResource as l, McpDefinition as m, AppContextToolDefinitionInput as n, CreateAppContextInput as o, McpAllowedOrigins as p, AudioContent as r, EmbeddedBlobResource as s, AppContextToolDefinition as t, ImageContent as u, TextContent as v, ZodOutputSchema as w, ToolDefinition as x, ToolAnnotations as y };
425
+ export { MetricsOptions as A, ToolHandlerResult as C, ZodSchema as D, ZodRawShape$1 as E, ToolContext as F, JwtClaims as I, McpAuthConfig as L, McpClientInfo as M, McpProtocolEra as N, Skill as O, ProgressUpdate as P, ToolDefinition as S, ZodOutputSchema as T, ResourceLink as _, ContentAnnotations as a, ToolAnnotations as b, EmbeddedBlobResource as c, ImageContent as d, JsonValue as f, McpDefinitionInput as g, McpDefinition as h, ConditionalSkill as i, AuthContext as j, MetricsConfig as k, EmbeddedResource as l, McpAllowedOrigins as m, AppContextToolDefinitionInput as n, ContentBlock as o, JsonValueInput as p, AudioContent as r, CreateAppContextInput as s, AppContextToolDefinition as t, EmbeddedTextResource as u, ResourceLinkIcon as v, ToolVisibilityContext as w, ToolContent as x, TextContent as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/mcp-js",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -151,6 +151,11 @@
151
151
  "vite": ">=5.0.0 <9.0.0",
152
152
  "zod": "^3.25 || ^4.0"
153
153
  },
154
+ "peerDependenciesMeta": {
155
+ "vite": {
156
+ "optional": true
157
+ }
158
+ },
154
159
  "devDependencies": {
155
160
  "@types/node": "22.13.13",
156
161
  "rimraf": "^5.0.0",