@lovable.dev/mcp-js 2.1.0-rc.0 → 2.2.0-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.
- package/README.md +15 -7
- package/dist/{authorize-BC4TM__8.d.cts → authorize-BmYO5_-I.d.cts} +1 -1
- package/dist/{authorize-DEsM-zTN.d.ts → authorize-d9-8n9u3.d.ts} +1 -1
- package/dist/{base-BnlJz6TE.d.ts → base-BAxrhVjq.d.ts} +1 -1
- package/dist/{base-4G2k3bMl.d.cts → base-Bmw6Wrb-.d.cts} +1 -1
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-D4BjUpgU.js → cors-BfacizN-.js} +2 -2
- package/dist/{cors-0ZCwmwyK.cjs → cors-Dm9Yn8E5.cjs} +2 -2
- package/dist/{errors-CdrGi5aP.cjs → errors-CpTdzogX.cjs} +1 -2
- package/dist/{errors-DTvfh8lb.js → errors-DGcJ8jPK.js} +1 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +5 -8
- package/dist/index.d.ts +5 -8
- package/dist/index.js +2 -2
- package/dist/{io-BLZ8jYW6.d.ts → io-7U860POB.d.ts} +1 -1
- package/dist/{io-9jGNgPfl.d.cts → io-CL1GeE3D.d.cts} +1 -1
- package/dist/{io-BEoJ_gb5.js → io-DD8wjGjd.js} +1 -1
- package/dist/{io-Cz81GsrM.cjs → io-DaqblVaG.cjs} +1 -1
- package/dist/{logger-CN1q-KNn.cjs → logger-C-Hdu57K.cjs} +5 -1
- package/dist/{logger-Ctv5xUSD.js → logger-CpLgYbCG.js} +5 -1
- package/dist/{mcp-Q_rjpR99.cjs → mcp-BGsPYWs1.cjs} +3 -3
- package/dist/{mcp-CuHyVOZK.js → mcp-DdJJjYYZ.js} +3 -3
- package/dist/{package-BAYb-3dX.js → package-cPx-zYIb.js} +1 -1
- package/dist/{package-DlouusYQ.cjs → package-hWM0Ru0w.cjs} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +3 -3
- package/dist/protocols/mcp/index.d.ts +3 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +2 -2
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +2 -2
- package/dist/stacks/supabase/index.cjs +3 -3
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +3 -3
- package/dist/stacks/supabase/vite.cjs +1 -1
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +1 -1
- package/dist/stacks/tanstack/index.cjs +2 -2
- package/dist/stacks/tanstack/index.d.cts +2 -2
- package/dist/stacks/tanstack/index.d.ts +2 -2
- package/dist/stacks/tanstack/index.js +2 -2
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/{types-S6J_QTXw.d.ts → types-BCKyT2wb.d.cts} +17 -4
- package/dist/{types-S6J_QTXw.d.cts → types-BCKyT2wb.d.ts} +17 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -216,21 +216,29 @@ The SDK only uses discovery + JWKS. It never calls the authorization or token en
|
|
|
216
216
|
|
|
217
217
|
Tool handlers receive their input args plus a `ToolContext` as the second
|
|
218
218
|
argument. The SDK constructs one per request from the verified token and passes
|
|
219
|
-
it to the handler
|
|
220
|
-
|
|
219
|
+
it to the handler. `ToolContext` extends `AuthContext`, which is also what
|
|
220
|
+
`createAppContext` receives as `auth`; helpers that need the auth should take an
|
|
221
|
+
`AuthContext` parameter so both call sites can share them.
|
|
221
222
|
|
|
222
223
|
```ts
|
|
223
|
-
import type {
|
|
224
|
+
import type { AuthContext } from "@lovable.dev/mcp-js";
|
|
225
|
+
|
|
226
|
+
// Usable from tool handlers (`ctx`) and from `createAppContext` (`auth`).
|
|
227
|
+
function requireUserId(auth: AuthContext): string {
|
|
228
|
+
const userId = auth.getUserId(); // token `sub`, or undefined when unauthenticated
|
|
229
|
+
if (!userId) throw new Error("Authenticated caller required");
|
|
230
|
+
return userId;
|
|
231
|
+
}
|
|
224
232
|
|
|
225
233
|
handler: async ({ title }, ctx) => {
|
|
226
|
-
const userId = ctx
|
|
234
|
+
const userId = requireUserId(ctx);
|
|
227
235
|
// Apply app/business permissions here using ctx.getClaims() / ctx.getClientId().
|
|
228
236
|
// For Supabase RLS, pass ctx.getToken() through to Supabase.
|
|
229
237
|
return { content: [{ type: "text", text: `user=${userId}` }] };
|
|
230
238
|
};
|
|
231
239
|
```
|
|
232
240
|
|
|
233
|
-
| `
|
|
241
|
+
| `AuthContext` method (inherited by `ToolContext`) | Returns |
|
|
234
242
|
| --- | --- |
|
|
235
243
|
| `isAuthenticated()` | `true` when the call carries a verified auth context. |
|
|
236
244
|
| `getUserId()` | The token `sub` (subject) — the user id. |
|
|
@@ -338,11 +346,11 @@ setLogLevel("debug"); // "silent" | "error" | "warn" | "info" | "debug"
|
|
|
338
346
|
LOVABLE_MCP_LOG_LEVEL=debug
|
|
339
347
|
```
|
|
340
348
|
|
|
341
|
-
A `500` on an OAuth-protected route is always one of
|
|
349
|
+
A `500` on an OAuth-protected route is always one of three causes, logged at `error`: an `OAuthConfigurationError` from issuer-metadata discovery or a JWKS *fetch* failure (`oauth.discovery.config_error` / `oauth.jwks.fetch_failed` → `auth.config_error`), a throw from the app's own `createAppContext` or an `enabled` predicate (`mcp.app_context_error`, carrying that error's name and message), or a transport-level fault in the MCP handler (`mcp.transport_error`). Auth outcomes are logged at `info`: a granted request as `oauth.verify.ok`, a request with no parseable bearer as `auth.no_bearer_token`, and a rejected token as `auth.token_rejected` (a `jose` rejection such as an expired token carries the `jose` error name and code; the full reason appears at `debug` as `oauth.verify.rejected`) — so a request rejected for insufficient scope shows both `oauth.verify.ok` and the `auth.token_rejected` that follows it. A sustained flood of `auth.token_rejected` whose `code` is `ERR_JOSE_NOT_SUPPORTED` or `ERR_JOSE_ALG_NOT_ALLOWED` (rather than `ERR_JWT_EXPIRED`) points at server-side key or algorithm configuration, not client error.
|
|
342
350
|
|
|
343
351
|
## Usage metrics
|
|
344
352
|
|
|
345
|
-
Each MCP server records per-invocation telemetry — tool name, JSON-RPC method, outcome, latency, request and response sizes when available, and the verified token `sub` for authenticated calls — as **OTLP/HTTP JSON logs**, one awaited POST per record, bounded by a 3-second timeout; a failed or slow POST is logged (`metrics.failed`) and swallowed, never failing the request. Outcomes cover tool results (`ok`, `tool_error`, `handler_error`, `transport_error`), the authorization gate — `auth_challenge` for an unauthenticated request answered with the `401` challenge (so probe traffic produces records), and the `auth_*` discovery/JWKS failure outcomes — and `origin_rejected` for a request refused `403` by the origin policy. Tool-call records also carry the protocol era (`mcp.protocol`: `2026-07-28` or `legacy`); records emitted before protocol classification (auth challenges, transport errors, origin rejections) have no protocol attribute. The bearer token, full claims, tool arguments, and response payloads are never captured. Emission is **on by default** and self-disables at runtime when `LOVABLE_API_KEY` is absent: records are dropped and one `metrics.disabled_no_api_key` warning is logged per process, so a local `vite dev` stays quiet. With `metrics: false` the recorder never runs — on Deno and Cloudflare Workers that also means `LOVABLE_MCP_LOG_LEVEL` is never applied (use `setLogLevel()` instead).
|
|
353
|
+
Each MCP server records per-invocation telemetry — tool name, JSON-RPC method, outcome, latency, request and response sizes when available, and the verified token `sub` for authenticated calls — as **OTLP/HTTP JSON logs**, one awaited POST per record, bounded by a 3-second timeout; a failed or slow POST is logged (`metrics.failed`) and swallowed, never failing the request. Outcomes cover tool results (`ok`, `tool_error`, `handler_error`, `transport_error`), `app_context_error` for a request failed by a throwing `createAppContext` or `enabled`, the authorization gate — `auth_challenge` for an unauthenticated request answered with the `401` challenge (so probe traffic produces records), and the `auth_*` discovery/JWKS failure outcomes — and `origin_rejected` for a request refused `403` by the origin policy. Tool-call records also carry the protocol era (`mcp.protocol`: `2026-07-28` or `legacy`); records emitted before protocol classification (auth challenges, transport errors, origin rejections) have no protocol attribute. The bearer token, full claims, tool arguments, and response payloads are never captured. Emission is **on by default** and self-disables at runtime when `LOVABLE_API_KEY` is absent: records are dropped and one `metrics.disabled_no_api_key` warning is logged per process, so a local `vite dev` stays quiet. With `metrics: false` the recorder never runs — on Deno and Cloudflare Workers that also means `LOVABLE_MCP_LOG_LEVEL` is never applied (use `setLogLevel()` instead).
|
|
346
354
|
|
|
347
355
|
Configure it on the MCP definition:
|
|
348
356
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as McpProtocolEra } from "./types-BCKyT2wb.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" | "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 {
|
|
1
|
+
import { j as McpProtocolEra } from "./types-BCKyT2wb.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" | "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,7 @@ 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-
|
|
7
|
+
}).then(() => Promise.resolve().then(() => require("../io-DaqblVaG.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
|
|
8
8
|
console.error(err instanceof Error ? err.message : String(err));
|
|
9
9
|
process.exit(1);
|
|
10
10
|
});
|
|
@@ -4,7 +4,7 @@ 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-
|
|
7
|
+
}).then(() => import("../io-DD8wjGjd.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
|
|
8
8
|
console.error(err instanceof Error ? err.message : String(err));
|
|
9
9
|
process.exit(1);
|
|
10
10
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
2
|
-
import { t as version } from "./package-
|
|
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-cPx-zYIb.js";
|
|
3
3
|
import "./metadata-path-CAkNcfyY.js";
|
|
4
4
|
import { createLocalJWKSet, decodeProtectedHeader, errors, jwtVerify } from "jose";
|
|
5
5
|
//#region src/core/http.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_logger = require("./logger-
|
|
2
|
-
const require_package = require("./package-
|
|
1
|
+
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
2
|
+
const require_package = require("./package-hWM0Ru0w.cjs");
|
|
3
3
|
require("./metadata-path-zd7NSNoa.cjs");
|
|
4
4
|
let jose = require("jose");
|
|
5
5
|
//#region src/core/http.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_logger = require("./logger-
|
|
1
|
+
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
2
2
|
const require_schema = require("./schema-D3vClxb7.cjs");
|
|
3
3
|
//#region src/core/define.ts
|
|
4
4
|
function toolRequiresAppContext(tool) {
|
|
@@ -118,7 +118,6 @@ function assertToolSchemas(mcp) {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
/** Bind app context once while retaining input/output inference for every tool. */
|
|
122
121
|
const defineStaticTool = (def) => def;
|
|
123
122
|
const defineTool = Object.assign(defineStaticTool, { withAppContext: () => (def) => {
|
|
124
123
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as parseSafeUrl, s as trimTrailingSlash, u as resolveMetricsConfig } from "./logger-
|
|
1
|
+
import { o as parseSafeUrl, s as trimTrailingSlash, u as resolveMetricsConfig } from "./logger-CpLgYbCG.js";
|
|
2
2
|
import { t as jsonSchemaFromDefinition } from "./schema-CW1jKvio.js";
|
|
3
3
|
//#region src/core/define.ts
|
|
4
4
|
function toolRequiresAppContext(tool) {
|
|
@@ -118,7 +118,6 @@ function assertToolSchemas(mcp) {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
/** Bind app context once while retaining input/output inference for every tool. */
|
|
122
121
|
const defineStaticTool = (def) => def;
|
|
123
122
|
const defineTool = Object.assign(defineStaticTool, { withAppContext: () => (def) => {
|
|
124
123
|
return {
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_logger = require("./logger-
|
|
3
|
-
const require_errors = require("./errors-
|
|
2
|
+
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
3
|
+
const require_errors = require("./errors-CpTdzogX.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
|
|
1
|
+
import { A as McpClientInfo, C as ToolVisibilityContext, D as MetricsConfig, E as ZodSchema, F as McpAuthConfig, M as ProgressUpdate, N as ToolContext, O as MetricsOptions, P as JwtClaims, 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 McpProtocolEra, k as AuthContext, 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-BCKyT2wb.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
|
|
@@ -9,12 +9,9 @@ import { A as McpProtocolEra, C as ZodOutputSchema, D as MetricsOptions, E as Me
|
|
|
9
9
|
* and the raw shape is what the JSON-RPC `tools/list` payload exposes.
|
|
10
10
|
*/
|
|
11
11
|
interface DefineTool {
|
|
12
|
-
<TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly enabled?: never;
|
|
16
|
-
};
|
|
17
|
-
withAppContext<TAppContext>(): <TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: ToolDefinition<TInput, TOutput, TAppContext>) => AppContextToolDefinition<TInput, TOutput, TAppContext>;
|
|
12
|
+
<TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: ToolDefinition<TInput, TOutput>): ToolDefinition<TInput, TOutput>;
|
|
13
|
+
/** Bind app context once while retaining input/output inference for every tool. */
|
|
14
|
+
withAppContext<TAppContext>(): <TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: AppContextToolDefinitionInput<TInput, TOutput, TAppContext>) => AppContextToolDefinition<TInput, TOutput, TAppContext>;
|
|
18
15
|
}
|
|
19
16
|
declare const defineTool: DefineTool;
|
|
20
17
|
/**
|
|
@@ -79,4 +76,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
79
76
|
*/
|
|
80
77
|
declare function setLogLevel(level: LogLevel): LogLevel;
|
|
81
78
|
//#endregion
|
|
82
|
-
export { type AppContextToolDefinition, 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 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 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 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
|
|
1
|
+
import { A as McpClientInfo, C as ToolVisibilityContext, D as MetricsConfig, E as ZodSchema, F as McpAuthConfig, M as ProgressUpdate, N as ToolContext, O as MetricsOptions, P as JwtClaims, 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 McpProtocolEra, k as AuthContext, 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-BCKyT2wb.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
|
|
@@ -9,12 +9,9 @@ import { A as McpProtocolEra, C as ZodOutputSchema, D as MetricsOptions, E as Me
|
|
|
9
9
|
* and the raw shape is what the JSON-RPC `tools/list` payload exposes.
|
|
10
10
|
*/
|
|
11
11
|
interface DefineTool {
|
|
12
|
-
<TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly enabled?: never;
|
|
16
|
-
};
|
|
17
|
-
withAppContext<TAppContext>(): <TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: ToolDefinition<TInput, TOutput, TAppContext>) => AppContextToolDefinition<TInput, TOutput, TAppContext>;
|
|
12
|
+
<TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: ToolDefinition<TInput, TOutput>): ToolDefinition<TInput, TOutput>;
|
|
13
|
+
/** Bind app context once while retaining input/output inference for every tool. */
|
|
14
|
+
withAppContext<TAppContext>(): <TInput extends ZodRawShape | undefined = undefined, TOutput extends ZodOutputSchema | undefined = undefined>(def: AppContextToolDefinitionInput<TInput, TOutput, TAppContext>) => AppContextToolDefinition<TInput, TOutput, TAppContext>;
|
|
18
15
|
}
|
|
19
16
|
declare const defineTool: DefineTool;
|
|
20
17
|
/**
|
|
@@ -79,4 +76,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
79
76
|
*/
|
|
80
77
|
declare function setLogLevel(level: LogLevel): LogLevel;
|
|
81
78
|
//#endregion
|
|
82
|
-
export { type AppContextToolDefinition, 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 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 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 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
|
-
import { a as setLogLevel } from "./logger-
|
|
2
|
-
import { a as ToolContext, i as AuthContext, o as defineMcp, s as defineTool, t as ToolError } from "./errors-
|
|
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-DGcJ8jPK.js";
|
|
3
3
|
//#region src/auth/config.ts
|
|
4
4
|
function frozenArray(value) {
|
|
5
5
|
return value === void 0 ? void 0 : Object.freeze([...value]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as jsonSchemaFromDefinition } from "./schema-CW1jKvio.js";
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version } from "./package-cPx-zYIb.js";
|
|
3
3
|
import { t as isFileMissing } from "./fs-errors-PA2t1TIp.js";
|
|
4
4
|
import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, resolve } from "node:path";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_schema = require("./schema-D3vClxb7.cjs");
|
|
2
|
-
const require_package = require("./package-
|
|
2
|
+
const require_package = require("./package-hWM0Ru0w.cjs");
|
|
3
3
|
const require_fs_errors = require("./fs-errors-CWNzOV75.cjs");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
@@ -139,7 +139,11 @@ function describeError(err) {
|
|
|
139
139
|
...typeof code === "string" ? { code } : {}
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
try {
|
|
143
|
+
return { value: String(err) };
|
|
144
|
+
} catch {
|
|
145
|
+
return { value: "[unprintable object]" };
|
|
146
|
+
}
|
|
143
147
|
}
|
|
144
148
|
//#endregion
|
|
145
149
|
Object.defineProperty(exports, "DEFAULT_METRICS_ENDPOINT", {
|
|
@@ -139,7 +139,11 @@ function describeError(err) {
|
|
|
139
139
|
...typeof code === "string" ? { code } : {}
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
try {
|
|
143
|
+
return { value: String(err) };
|
|
144
|
+
} catch {
|
|
145
|
+
return { value: "[unprintable object]" };
|
|
146
|
+
}
|
|
143
147
|
}
|
|
144
148
|
//#endregion
|
|
145
149
|
export { setLogLevel as a, DEFAULT_METRICS_ENDPOINT as c, log as i, LEGACY_METRICS_ENDPOINT as l, applyLogLevelFromEnv as n, parseSafeUrl as o, describeError as r, trimTrailingSlash as s, LOG_LEVEL_ENV_VAR as t, resolveMetricsConfig as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_logger = require("./logger-
|
|
1
|
+
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
2
2
|
const require_schema = require("./schema-D3vClxb7.cjs");
|
|
3
|
-
const require_errors = require("./errors-
|
|
4
|
-
const require_cors = require("./cors-
|
|
3
|
+
const require_errors = require("./errors-CpTdzogX.cjs");
|
|
4
|
+
const require_cors = require("./cors-Dm9Yn8E5.cjs");
|
|
5
5
|
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
6
6
|
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
7
7
|
//#region src/core/content.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as log, r as describeError } from "./logger-
|
|
1
|
+
import { i as log, r as describeError } from "./logger-CpLgYbCG.js";
|
|
2
2
|
import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-CW1jKvio.js";
|
|
3
|
-
import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-
|
|
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-
|
|
3
|
+
import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-DGcJ8jPK.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-BfacizN-.js";
|
|
5
5
|
import { getParseErrorMessage, safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
6
6
|
import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, createMcpHandler } from "@modelcontextprotocol/server";
|
|
7
7
|
//#region src/core/content.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-BCKyT2wb.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-Bmw6Wrb-.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-BmYO5_-I.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 {
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-BCKyT2wb.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-BAxrhVjq.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-d9-8n9u3.js";
|
|
4
4
|
//#region src/protocols/mcp/protocol.d.ts
|
|
5
5
|
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { t as createMcpProtocolHandler } from "../../mcp-DdJJjYYZ.js";
|
|
2
2
|
export { createMcpProtocolHandler };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_logger = require("../logger-
|
|
3
|
-
const require_cors = require("../cors-
|
|
2
|
+
const require_logger = require("../logger-C-Hdu57K.cjs");
|
|
3
|
+
const require_cors = require("../cors-Dm9Yn8E5.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 {
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../types-BCKyT2wb.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-Bmw6Wrb-.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-BmYO5_-I.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 {
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../types-BCKyT2wb.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-BAxrhVjq.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-d9-8n9u3.js";
|
|
4
4
|
//#region src/protocols/oauth-metadata.d.ts
|
|
5
5
|
type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as log, r as describeError } from "../logger-
|
|
2
|
-
import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-
|
|
1
|
+
import { 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-BfacizN-.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
|
-
const require_logger = require("../../logger-
|
|
3
|
-
const require_cors = require("../../cors-
|
|
2
|
+
const require_logger = require("../../logger-C-Hdu57K.cjs");
|
|
3
|
+
const require_cors = require("../../cors-Dm9Yn8E5.cjs");
|
|
4
4
|
const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
|
|
5
|
-
const require_mcp = require("../../mcp-
|
|
5
|
+
const require_mcp = require("../../mcp-BGsPYWs1.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 {
|
|
1
|
+
import { m as McpDefinition } from "../../types-BCKyT2wb.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 {
|
|
1
|
+
import { m as McpDefinition } from "../../types-BCKyT2wb.js";
|
|
2
2
|
//#region src/stacks/supabase/handler.d.ts
|
|
3
3
|
type SupabaseHandler = (request: Request) => Promise<Response>;
|
|
4
4
|
interface SupabaseHandlerOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as trimTrailingSlash } from "../../logger-
|
|
2
|
-
import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-
|
|
1
|
+
import { s as trimTrailingSlash } from "../../logger-CpLgYbCG.js";
|
|
2
|
+
import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-BfacizN-.js";
|
|
3
3
|
import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
|
|
4
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
4
|
+
import { t as createMcpProtocolHandler } from "../../mcp-DdJJjYYZ.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-
|
|
5
|
+
const require_package = require("../../package-hWM0Ru0w.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 version } from "../../package-
|
|
1
|
+
import { t as version } from "../../package-cPx-zYIb.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,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cors = require("../../cors-
|
|
3
|
-
const require_mcp = require("../../mcp-
|
|
2
|
+
const require_cors = require("../../cors-Dm9Yn8E5.cjs");
|
|
3
|
+
const require_mcp = require("../../mcp-BGsPYWs1.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 {
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-BCKyT2wb.cjs";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-BmYO5_-I.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 {
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-BCKyT2wb.js";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-d9-8n9u3.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-
|
|
2
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { c as createRecorderForRuntime } from "../../cors-BfacizN-.js";
|
|
2
|
+
import { t as createMcpProtocolHandler } from "../../mcp-DdJJjYYZ.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
|
|
@@ -303,6 +303,11 @@ interface ToolAnnotations {
|
|
|
303
303
|
idempotentHint?: boolean;
|
|
304
304
|
/** Tool interacts with external/unbounded systems (DB, network, third-party APIs). */
|
|
305
305
|
openWorldHint?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Asks the Lovable agent to keep up to 50 KB of this tool's result in context instead of the default 5 KB.
|
|
308
|
+
* Honored for the app's published MCP server; meant for results the agent must read whole.
|
|
309
|
+
*/
|
|
310
|
+
largeOutputHint?: boolean;
|
|
306
311
|
}
|
|
307
312
|
interface ToolHandlerResult {
|
|
308
313
|
content?: ToolContent;
|
|
@@ -318,7 +323,7 @@ interface CreateAppContextInput {
|
|
|
318
323
|
interface ToolVisibilityContext<TAppContext> {
|
|
319
324
|
readonly appContext: TAppContext;
|
|
320
325
|
}
|
|
321
|
-
interface
|
|
326
|
+
interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
|
|
322
327
|
readonly name: string;
|
|
323
328
|
/** Human-readable display name shown to the user in MCP clients. Required. */
|
|
324
329
|
readonly title: string;
|
|
@@ -327,11 +332,19 @@ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$
|
|
|
327
332
|
readonly inputSchema?: TInput;
|
|
328
333
|
readonly outputSchema?: TOutput;
|
|
329
334
|
readonly annotations?: ToolAnnotations;
|
|
335
|
+
}
|
|
336
|
+
type ToolHandler<TInput extends ZodRawShape$1 | undefined, TAppContext> = TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult>;
|
|
337
|
+
/** A tool that exists for every caller. Its handler receives the plain `ToolContext`. */
|
|
338
|
+
interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
|
|
339
|
+
readonly handler: ToolHandler<TInput, undefined>;
|
|
340
|
+
}
|
|
341
|
+
/** Input to `defineTool.withAppContext<TAppContext>()`. */
|
|
342
|
+
interface AppContextToolDefinitionInput<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
|
|
330
343
|
/** Synchronously decide whether this tool exists for the current caller. */
|
|
331
344
|
readonly enabled?: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
|
|
332
|
-
readonly handler:
|
|
345
|
+
readonly handler: ToolHandler<TInput, TAppContext>;
|
|
333
346
|
}
|
|
334
|
-
interface AppContextToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends
|
|
347
|
+
interface AppContextToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
|
|
335
348
|
readonly requiresAppContext: true;
|
|
336
349
|
}
|
|
337
350
|
/** Type-erased element of `McpDefinition.tools`; per-tool generic typing
|
|
@@ -394,4 +407,4 @@ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>
|
|
|
394
407
|
readonly [McpDefinitionBrand]: never;
|
|
395
408
|
};
|
|
396
409
|
//#endregion
|
|
397
|
-
export {
|
|
410
|
+
export { McpClientInfo as A, ToolVisibilityContext as C, MetricsConfig as D, ZodSchema as E, McpAuthConfig as F, ProgressUpdate as M, ToolContext as N, MetricsOptions as O, JwtClaims 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, McpProtocolEra as j, AuthContext 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 };
|
|
@@ -303,6 +303,11 @@ interface ToolAnnotations {
|
|
|
303
303
|
idempotentHint?: boolean;
|
|
304
304
|
/** Tool interacts with external/unbounded systems (DB, network, third-party APIs). */
|
|
305
305
|
openWorldHint?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Asks the Lovable agent to keep up to 50 KB of this tool's result in context instead of the default 5 KB.
|
|
308
|
+
* Honored for the app's published MCP server; meant for results the agent must read whole.
|
|
309
|
+
*/
|
|
310
|
+
largeOutputHint?: boolean;
|
|
306
311
|
}
|
|
307
312
|
interface ToolHandlerResult {
|
|
308
313
|
content?: ToolContent;
|
|
@@ -318,7 +323,7 @@ interface CreateAppContextInput {
|
|
|
318
323
|
interface ToolVisibilityContext<TAppContext> {
|
|
319
324
|
readonly appContext: TAppContext;
|
|
320
325
|
}
|
|
321
|
-
interface
|
|
326
|
+
interface ToolDefinitionBase<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> {
|
|
322
327
|
readonly name: string;
|
|
323
328
|
/** Human-readable display name shown to the user in MCP clients. Required. */
|
|
324
329
|
readonly title: string;
|
|
@@ -327,11 +332,19 @@ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$
|
|
|
327
332
|
readonly inputSchema?: TInput;
|
|
328
333
|
readonly outputSchema?: TOutput;
|
|
329
334
|
readonly annotations?: ToolAnnotations;
|
|
335
|
+
}
|
|
336
|
+
type ToolHandler<TInput extends ZodRawShape$1 | undefined, TAppContext> = TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext<TAppContext>) => ToolHandlerResult | Promise<ToolHandlerResult>;
|
|
337
|
+
/** A tool that exists for every caller. Its handler receives the plain `ToolContext`. */
|
|
338
|
+
interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined> extends ToolDefinitionBase<TInput, TOutput> {
|
|
339
|
+
readonly handler: ToolHandler<TInput, undefined>;
|
|
340
|
+
}
|
|
341
|
+
/** Input to `defineTool.withAppContext<TAppContext>()`. */
|
|
342
|
+
interface AppContextToolDefinitionInput<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends ToolDefinitionBase<TInput, TOutput> {
|
|
330
343
|
/** Synchronously decide whether this tool exists for the current caller. */
|
|
331
344
|
readonly enabled?: (ctx: ToolVisibilityContext<TAppContext>) => boolean;
|
|
332
|
-
readonly handler:
|
|
345
|
+
readonly handler: ToolHandler<TInput, TAppContext>;
|
|
333
346
|
}
|
|
334
|
-
interface AppContextToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends
|
|
347
|
+
interface AppContextToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$1 | undefined, TOutput extends ZodOutputSchema | undefined = ZodOutputSchema | undefined, TAppContext = unknown> extends AppContextToolDefinitionInput<TInput, TOutput, TAppContext> {
|
|
335
348
|
readonly requiresAppContext: true;
|
|
336
349
|
}
|
|
337
350
|
/** Type-erased element of `McpDefinition.tools`; per-tool generic typing
|
|
@@ -394,4 +407,4 @@ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>
|
|
|
394
407
|
readonly [McpDefinitionBrand]: never;
|
|
395
408
|
};
|
|
396
409
|
//#endregion
|
|
397
|
-
export {
|
|
410
|
+
export { McpClientInfo as A, ToolVisibilityContext as C, MetricsConfig as D, ZodSchema as E, McpAuthConfig as F, ProgressUpdate as M, ToolContext as N, MetricsOptions as O, JwtClaims 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, McpProtocolEra as j, AuthContext 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 };
|