@lovable.dev/mcp-js 0.29.0-rc.0 → 0.29.0-rc.2
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.internal.md +22 -31
- package/README.md +23 -13
- package/dist/{authorize-BjNE3LPr.d.ts → authorize-Bpz8oxjF.d.ts} +2 -5
- package/dist/{authorize-BzZFS0zi.d.cts → authorize-Cqr7Jps0.d.cts} +2 -5
- package/dist/cli/extract-manifest.cjs +25 -3
- package/dist/cli/extract-manifest.js +24 -2
- package/dist/{cors-D4YbODs-.js → cors-C_VffY86.js} +15 -21
- package/dist/{cors-CmKzDN7k.cjs → cors-DNzLB6qa.cjs} +14 -26
- package/dist/{errors-DSe96Ffd.js → errors-Bwd1L0Rf.js} +23 -8
- package/dist/{errors-CN6Da8iz.cjs → errors-Cr95rSkB.cjs} +23 -8
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{io-CvALf9NE.d.ts → io-Bh_WpbxU.d.cts} +1 -1
- package/dist/{io-BEwvgN8s.d.cts → io-DrHivYt0.d.ts} +1 -1
- package/dist/mcp-Bl7pQYdv.js +346 -0
- package/dist/mcp-CRdT2Fai.cjs +351 -0
- package/dist/{package-DzB_5Hur.js → package-CYA-5C24.js} +1 -1
- package/dist/{package-C3YVYgxp.cjs → package-DNSwCau1.cjs} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +36 -3
- package/dist/protocols/mcp/index.d.ts +36 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.d.cts +2 -2
- package/dist/protocols/oauth-metadata.d.ts +2 -2
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/stacks/supabase/index.cjs +6 -35
- package/dist/stacks/supabase/index.d.cts +1 -4
- package/dist/stacks/supabase/index.d.ts +1 -4
- package/dist/stacks/supabase/index.js +6 -35
- 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 -23
- package/dist/stacks/tanstack/index.d.cts +3 -20
- package/dist/stacks/tanstack/index.d.ts +3 -20
- package/dist/stacks/tanstack/index.js +3 -22
- package/dist/stacks/tanstack/vite.cjs +5 -33
- package/dist/stacks/tanstack/vite.d.cts +5 -32
- package/dist/stacks/tanstack/vite.d.ts +5 -32
- package/dist/stacks/tanstack/vite.js +5 -33
- package/dist/{types-D1cgsnPu.d.cts → types-DnGEKnvI.d.cts} +43 -20
- package/dist/{types-D1cgsnPu.d.ts → types-DnGEKnvI.d.ts} +43 -20
- package/package.json +4 -11
- package/dist/base-DSH8NnPj.d.cts +0 -36
- package/dist/base-DSH8NnPj.d.ts +0 -36
- package/dist/gate-n_HX6eQ5.cjs +0 -26
- package/dist/gate-pGsVlY_4.js +0 -21
- package/dist/list-tools-Dkyyje7j.cjs +0 -48
- package/dist/list-tools-ePP9tXND.js +0 -37
- package/dist/list-tools-qIvVJeWZ.d.ts +0 -8
- package/dist/list-tools-zagoI477.d.cts +0 -8
- package/dist/mcp-Cs4zfvSi.js +0 -336
- package/dist/mcp-DQ1Vdv4v.cjs +0 -341
- package/dist/protocols/rest/index.cjs +0 -5
- package/dist/protocols/rest/index.d.cts +0 -9
- package/dist/protocols/rest/index.d.ts +0 -9
- package/dist/protocols/rest/index.js +0 -3
- package/dist/rest-DSclWpIt.js +0 -129
- package/dist/rest-P6XZWP42.cjs +0 -134
- package/dist/tool-result-CK6hXO43.cjs +0 -89
- package/dist/tool-result-DfCk445b.js +0 -78
|
@@ -85,16 +85,46 @@ interface McpAuthConfig {
|
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region src/auth/context.d.ts
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
/** What the client declared about itself on the in-flight request. Unverified
|
|
89
|
+
* client input — a hint, never an authorization signal (use the auth accessors). */
|
|
90
|
+
interface McpClientInfo {
|
|
91
|
+
/** Protocol era of the in-flight request. */
|
|
92
|
+
protocol: "2026-07-28" | "legacy";
|
|
93
|
+
/** Client name/version from the request envelope (`2026-07-28` era only). */
|
|
94
|
+
info?: {
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
title?: string;
|
|
98
|
+
};
|
|
99
|
+
/** Client capabilities from the request envelope (`2026-07-28` era only). */
|
|
100
|
+
capabilities?: Record<string, unknown>;
|
|
101
|
+
/** Extension declarations (`capabilities.extensions`), keyed by extension id. */
|
|
102
|
+
extensions?: Record<string, Record<string, unknown>>;
|
|
103
|
+
}
|
|
104
|
+
/** A progress notification payload. `progress` should increase monotonically. */
|
|
105
|
+
interface ProgressUpdate {
|
|
106
|
+
progress: number;
|
|
107
|
+
total?: number;
|
|
108
|
+
message?: string;
|
|
109
|
+
}
|
|
110
|
+
/** Per-request runtime surface threaded into `ToolContext` by the protocol layer. */
|
|
111
|
+
interface ToolRequestContext {
|
|
112
|
+
signal?: AbortSignal;
|
|
113
|
+
client?: McpClientInfo;
|
|
114
|
+
sendProgress?: (update: ProgressUpdate) => Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
/** The per-request context passed to every tool handler as its second argument. The
|
|
117
|
+
* auth context lives in a private field so the accessors are the only way out; `getToken()` is the sole bearer escape hatch. */
|
|
95
118
|
declare class ToolContext {
|
|
96
119
|
#private;
|
|
97
|
-
constructor(auth: McpAuthContext | undefined);
|
|
120
|
+
constructor(auth: McpAuthContext | undefined, request?: ToolRequestContext);
|
|
121
|
+
/** Aborts when the client cancels the request or disconnects. */
|
|
122
|
+
get signal(): AbortSignal;
|
|
123
|
+
/** What the client declared about itself on this request. Unverified input. */
|
|
124
|
+
get client(): McpClientInfo;
|
|
125
|
+
/** Send a progress notification for this call. A no-op when the client
|
|
126
|
+
* didn't request progress (no `progressToken` on the request). */
|
|
127
|
+
progress(update: ProgressUpdate): Promise<void>;
|
|
98
128
|
/** Whether the in-flight tool call carries a verified auth context. */
|
|
99
129
|
isAuthenticated(): boolean;
|
|
100
130
|
/** The verified bearer token, or `undefined` when unauthenticated. Pass it to downstream APIs; never return or log it. */
|
|
@@ -278,10 +308,8 @@ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$
|
|
|
278
308
|
readonly annotations?: ToolAnnotations;
|
|
279
309
|
readonly handler: TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
|
|
280
310
|
}
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
* happens at the `defineTool` call site; see README §6 for the rationale.
|
|
284
|
-
*/
|
|
311
|
+
/** Type-erased element of `McpDefinition.tools`; per-tool generic typing
|
|
312
|
+
* happens at the `defineTool` call site. */
|
|
285
313
|
interface AnyToolDefinition {
|
|
286
314
|
readonly name: string;
|
|
287
315
|
readonly title: string;
|
|
@@ -291,13 +319,8 @@ interface AnyToolDefinition {
|
|
|
291
319
|
readonly annotations?: ToolAnnotations;
|
|
292
320
|
readonly handler: (args: any, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
|
|
293
321
|
}
|
|
294
|
-
/**
|
|
295
|
-
*
|
|
296
|
-
* shape to `defineMcp(...)` — its return type is the branded `McpDefinition`,
|
|
297
|
-
* which is the type every internal factory (`createInvokeToolHandler`,
|
|
298
|
-
* `createMcpProtocolHandler`, …) consumes. The brand forces consumers
|
|
299
|
-
* through `defineMcp`'s `assertUniqueNames` + freeze.
|
|
300
|
-
*/
|
|
322
|
+
/** Input shape for `defineMcp(...)`, whose branded `McpDefinition` return type is what
|
|
323
|
+
* `createMcpProtocolHandler` consumes — the brand forces validation + freeze. */
|
|
301
324
|
interface McpDefinitionInput {
|
|
302
325
|
readonly name: string;
|
|
303
326
|
/** Human-readable display name shown to MCP clients. Required. */
|
|
@@ -326,4 +349,4 @@ type McpDefinition = McpDefinitionInput & {
|
|
|
326
349
|
readonly [McpDefinitionBrand]: never;
|
|
327
350
|
};
|
|
328
351
|
//#endregion
|
|
329
|
-
export { MetricsOptions as C,
|
|
352
|
+
export { MetricsOptions as C, JwtClaims as D, ToolContext as E, McpAuthConfig as O, MetricsConfig as S, ProgressUpdate as T, ToolDefinition as _, EmbeddedResource as a, ZodRawShape$1 as b, JsonValue as c, McpDefinitionInput as d, ResourceLink as f, ToolContent as g, ToolAnnotations as h, EmbeddedBlobResource as i, McpAllowedOrigins as l, TextContent as m, ContentAnnotations as n, EmbeddedTextResource as o, ResourceLinkIcon as p, ContentBlock as r, ImageContent as s, AudioContent as t, McpDefinition as u, ToolHandlerResult as v, McpClientInfo as w, ZodSchema as x, ZodOutputSchema as y };
|
|
@@ -85,16 +85,46 @@ interface McpAuthConfig {
|
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region src/auth/context.d.ts
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
/** What the client declared about itself on the in-flight request. Unverified
|
|
89
|
+
* client input — a hint, never an authorization signal (use the auth accessors). */
|
|
90
|
+
interface McpClientInfo {
|
|
91
|
+
/** Protocol era of the in-flight request. */
|
|
92
|
+
protocol: "2026-07-28" | "legacy";
|
|
93
|
+
/** Client name/version from the request envelope (`2026-07-28` era only). */
|
|
94
|
+
info?: {
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
title?: string;
|
|
98
|
+
};
|
|
99
|
+
/** Client capabilities from the request envelope (`2026-07-28` era only). */
|
|
100
|
+
capabilities?: Record<string, unknown>;
|
|
101
|
+
/** Extension declarations (`capabilities.extensions`), keyed by extension id. */
|
|
102
|
+
extensions?: Record<string, Record<string, unknown>>;
|
|
103
|
+
}
|
|
104
|
+
/** A progress notification payload. `progress` should increase monotonically. */
|
|
105
|
+
interface ProgressUpdate {
|
|
106
|
+
progress: number;
|
|
107
|
+
total?: number;
|
|
108
|
+
message?: string;
|
|
109
|
+
}
|
|
110
|
+
/** Per-request runtime surface threaded into `ToolContext` by the protocol layer. */
|
|
111
|
+
interface ToolRequestContext {
|
|
112
|
+
signal?: AbortSignal;
|
|
113
|
+
client?: McpClientInfo;
|
|
114
|
+
sendProgress?: (update: ProgressUpdate) => Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
/** The per-request context passed to every tool handler as its second argument. The
|
|
117
|
+
* auth context lives in a private field so the accessors are the only way out; `getToken()` is the sole bearer escape hatch. */
|
|
95
118
|
declare class ToolContext {
|
|
96
119
|
#private;
|
|
97
|
-
constructor(auth: McpAuthContext | undefined);
|
|
120
|
+
constructor(auth: McpAuthContext | undefined, request?: ToolRequestContext);
|
|
121
|
+
/** Aborts when the client cancels the request or disconnects. */
|
|
122
|
+
get signal(): AbortSignal;
|
|
123
|
+
/** What the client declared about itself on this request. Unverified input. */
|
|
124
|
+
get client(): McpClientInfo;
|
|
125
|
+
/** Send a progress notification for this call. A no-op when the client
|
|
126
|
+
* didn't request progress (no `progressToken` on the request). */
|
|
127
|
+
progress(update: ProgressUpdate): Promise<void>;
|
|
98
128
|
/** Whether the in-flight tool call carries a verified auth context. */
|
|
99
129
|
isAuthenticated(): boolean;
|
|
100
130
|
/** The verified bearer token, or `undefined` when unauthenticated. Pass it to downstream APIs; never return or log it. */
|
|
@@ -278,10 +308,8 @@ interface ToolDefinition<TInput extends ZodRawShape$1 | undefined = ZodRawShape$
|
|
|
278
308
|
readonly annotations?: ToolAnnotations;
|
|
279
309
|
readonly handler: TInput extends ZodRawShape$1 ? (args: ShapeOutput<TInput>, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult> : (args: Record<string, never> | undefined, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
|
|
280
310
|
}
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
* happens at the `defineTool` call site; see README §6 for the rationale.
|
|
284
|
-
*/
|
|
311
|
+
/** Type-erased element of `McpDefinition.tools`; per-tool generic typing
|
|
312
|
+
* happens at the `defineTool` call site. */
|
|
285
313
|
interface AnyToolDefinition {
|
|
286
314
|
readonly name: string;
|
|
287
315
|
readonly title: string;
|
|
@@ -291,13 +319,8 @@ interface AnyToolDefinition {
|
|
|
291
319
|
readonly annotations?: ToolAnnotations;
|
|
292
320
|
readonly handler: (args: any, ctx: ToolContext) => ToolHandlerResult | Promise<ToolHandlerResult>;
|
|
293
321
|
}
|
|
294
|
-
/**
|
|
295
|
-
*
|
|
296
|
-
* shape to `defineMcp(...)` — its return type is the branded `McpDefinition`,
|
|
297
|
-
* which is the type every internal factory (`createInvokeToolHandler`,
|
|
298
|
-
* `createMcpProtocolHandler`, …) consumes. The brand forces consumers
|
|
299
|
-
* through `defineMcp`'s `assertUniqueNames` + freeze.
|
|
300
|
-
*/
|
|
322
|
+
/** Input shape for `defineMcp(...)`, whose branded `McpDefinition` return type is what
|
|
323
|
+
* `createMcpProtocolHandler` consumes — the brand forces validation + freeze. */
|
|
301
324
|
interface McpDefinitionInput {
|
|
302
325
|
readonly name: string;
|
|
303
326
|
/** Human-readable display name shown to MCP clients. Required. */
|
|
@@ -326,4 +349,4 @@ type McpDefinition = McpDefinitionInput & {
|
|
|
326
349
|
readonly [McpDefinitionBrand]: never;
|
|
327
350
|
};
|
|
328
351
|
//#endregion
|
|
329
|
-
export { MetricsOptions as C,
|
|
352
|
+
export { MetricsOptions as C, JwtClaims as D, ToolContext as E, McpAuthConfig as O, MetricsConfig as S, ProgressUpdate as T, ToolDefinition as _, EmbeddedResource as a, ZodRawShape$1 as b, JsonValue as c, McpDefinitionInput as d, ResourceLink as f, ToolContent as g, ToolAnnotations as h, EmbeddedBlobResource as i, McpAllowedOrigins as l, TextContent as m, ContentAnnotations as n, EmbeddedTextResource as o, ResourceLinkIcon as p, ContentBlock as r, ImageContent as s, AudioContent as t, McpDefinition as u, ToolHandlerResult as v, McpClientInfo as w, ZodSchema as x, ZodOutputSchema as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/mcp-js",
|
|
3
|
-
"version": "0.29.0-rc.
|
|
3
|
+
"version": "0.29.0-rc.2",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=20"
|
|
6
|
+
},
|
|
4
7
|
"description": "Author MCP servers for Lovable apps. Declare tools with defineTool, register them in defineMcp, and a framework adapter (TanStack or Supabase Edge Functions) emits the route(s) at build time.",
|
|
5
8
|
"type": "module",
|
|
6
9
|
"repository": {
|
|
@@ -49,16 +52,6 @@
|
|
|
49
52
|
"default": "./dist/protocols/oauth-metadata.cjs"
|
|
50
53
|
}
|
|
51
54
|
},
|
|
52
|
-
"./protocols/rest": {
|
|
53
|
-
"import": {
|
|
54
|
-
"types": "./dist/protocols/rest/index.d.ts",
|
|
55
|
-
"default": "./dist/protocols/rest/index.js"
|
|
56
|
-
},
|
|
57
|
-
"require": {
|
|
58
|
-
"types": "./dist/protocols/rest/index.d.cts",
|
|
59
|
-
"default": "./dist/protocols/rest/index.cjs"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
55
|
"./stacks/tanstack": {
|
|
63
56
|
"import": {
|
|
64
57
|
"types": "./dist/stacks/tanstack/index.d.ts",
|
package/dist/base-DSH8NnPj.d.cts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//#region src/metrics/impl/base.d.ts
|
|
2
|
-
type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "auth_challenge" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
|
|
3
|
-
/** One recorded MCP call. Carries no arguments or response payloads — only the
|
|
4
|
-
* tool name, the JSON-RPC method, the result class, timing, and byte sizes.
|
|
5
|
-
* `errorText` is the sole exception: it is logged locally for debugging and
|
|
6
|
-
* deliberately never included in the OTLP payload (see `emit` / `buildLogsPayload`). */
|
|
7
|
-
interface InvocationRecord {
|
|
8
|
-
/** Tool name for `tools/call`; `null` for list/initialize, transport faults, and `authorize` records. */
|
|
9
|
-
tool: string | null;
|
|
10
|
-
/** JSON-RPC method, e.g. `tools/call`; `authorize` for records from the authorization gate. */
|
|
11
|
-
method: string;
|
|
12
|
-
outcome: InvocationOutcome;
|
|
13
|
-
durationMs: number;
|
|
14
|
-
reqBytes?: number;
|
|
15
|
-
resBytes?: number;
|
|
16
|
-
/** HTTP request method. Set on `auth_challenge` so probe traffic (GET vs
|
|
17
|
-
* POST discovery) is distinguishable; absent on tool-call records. */
|
|
18
|
-
httpMethod?: string;
|
|
19
|
-
/** Wire surface that served the call: the modern stateless revision, the
|
|
20
|
-
* initialization-era path, or the REST companion. Absent on records emitted
|
|
21
|
-
* before protocol classification (auth gate, transport faults). */
|
|
22
|
-
protocol?: "2026-07-28" | "legacy" | "rest";
|
|
23
|
-
/** The app end-user that made the call (the access token `sub`), or
|
|
24
|
-
* `undefined` when the request is unauthenticated. Not a Lovable identity. */
|
|
25
|
-
endUserId?: string;
|
|
26
|
-
/** Caller-visible `isError` text (`tool_error`) or a bounded internal-exception
|
|
27
|
-
* summary (`handler_error`). Local log only — never sent to the collector. */
|
|
28
|
-
errorText?: string;
|
|
29
|
-
}
|
|
30
|
-
/** A per-request telemetry recorder. `emit` logs the invocation and sends it as a
|
|
31
|
-
* single OTLP POST, awaited so it lands before the request ends. */
|
|
32
|
-
interface MetricsRecorder {
|
|
33
|
-
emit(ev: InvocationRecord): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { MetricsRecorder as t };
|
package/dist/base-DSH8NnPj.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//#region src/metrics/impl/base.d.ts
|
|
2
|
-
type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "auth_challenge" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
|
|
3
|
-
/** One recorded MCP call. Carries no arguments or response payloads — only the
|
|
4
|
-
* tool name, the JSON-RPC method, the result class, timing, and byte sizes.
|
|
5
|
-
* `errorText` is the sole exception: it is logged locally for debugging and
|
|
6
|
-
* deliberately never included in the OTLP payload (see `emit` / `buildLogsPayload`). */
|
|
7
|
-
interface InvocationRecord {
|
|
8
|
-
/** Tool name for `tools/call`; `null` for list/initialize, transport faults, and `authorize` records. */
|
|
9
|
-
tool: string | null;
|
|
10
|
-
/** JSON-RPC method, e.g. `tools/call`; `authorize` for records from the authorization gate. */
|
|
11
|
-
method: string;
|
|
12
|
-
outcome: InvocationOutcome;
|
|
13
|
-
durationMs: number;
|
|
14
|
-
reqBytes?: number;
|
|
15
|
-
resBytes?: number;
|
|
16
|
-
/** HTTP request method. Set on `auth_challenge` so probe traffic (GET vs
|
|
17
|
-
* POST discovery) is distinguishable; absent on tool-call records. */
|
|
18
|
-
httpMethod?: string;
|
|
19
|
-
/** Wire surface that served the call: the modern stateless revision, the
|
|
20
|
-
* initialization-era path, or the REST companion. Absent on records emitted
|
|
21
|
-
* before protocol classification (auth gate, transport faults). */
|
|
22
|
-
protocol?: "2026-07-28" | "legacy" | "rest";
|
|
23
|
-
/** The app end-user that made the call (the access token `sub`), or
|
|
24
|
-
* `undefined` when the request is unauthenticated. Not a Lovable identity. */
|
|
25
|
-
endUserId?: string;
|
|
26
|
-
/** Caller-visible `isError` text (`tool_error`) or a bounded internal-exception
|
|
27
|
-
* summary (`handler_error`). Local log only — never sent to the collector. */
|
|
28
|
-
errorText?: string;
|
|
29
|
-
}
|
|
30
|
-
/** A per-request telemetry recorder. `emit` logs the invocation and sends it as a
|
|
31
|
-
* single OTLP POST, awaited so it lands before the request ends. */
|
|
32
|
-
interface MetricsRecorder {
|
|
33
|
-
emit(ev: InvocationRecord): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { MetricsRecorder as t };
|
package/dist/gate-n_HX6eQ5.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const require_cors = require("./cors-CmKzDN7k.cjs");
|
|
2
|
-
//#region src/protocols/gate.ts
|
|
3
|
-
function createGatedHandler(gate) {
|
|
4
|
-
const allow = [...gate.methods, "OPTIONS"].join(", ");
|
|
5
|
-
const respond = async (request, recorder, ...extra) => {
|
|
6
|
-
const authResult = await gate.authorizer.authorize(request, recorder);
|
|
7
|
-
if (!authResult.ok) return authResult.response;
|
|
8
|
-
if (!gate.methods.includes(request.method)) return gate.methodNotAllowed(allow);
|
|
9
|
-
return gate.handle(request, authResult, recorder, ...extra);
|
|
10
|
-
};
|
|
11
|
-
return async (request, recorder = require_cors.createNoopRecorder(), ...extra) => {
|
|
12
|
-
const cors = require_cors.evaluateCors(request, gate.allowedOrigins);
|
|
13
|
-
if (!cors.ok) return require_cors.finalizeWireResponse(request, cors.response);
|
|
14
|
-
if (request.method === "OPTIONS") return cors.preflight(allow);
|
|
15
|
-
const final = require_cors.finalizeWireResponse(request, cors.withHeaders(await respond(request, recorder, ...extra)));
|
|
16
|
-
if (!final.headers.has("Cache-Control")) final.headers.set("Cache-Control", "no-store");
|
|
17
|
-
return final;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
Object.defineProperty(exports, "createGatedHandler", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function() {
|
|
24
|
-
return createGatedHandler;
|
|
25
|
-
}
|
|
26
|
-
});
|
package/dist/gate-pGsVlY_4.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { f as finalizeWireResponse, l as createNoopRecorder, t as evaluateCors } from "./cors-D4YbODs-.js";
|
|
2
|
-
//#region src/protocols/gate.ts
|
|
3
|
-
function createGatedHandler(gate) {
|
|
4
|
-
const allow = [...gate.methods, "OPTIONS"].join(", ");
|
|
5
|
-
const respond = async (request, recorder, ...extra) => {
|
|
6
|
-
const authResult = await gate.authorizer.authorize(request, recorder);
|
|
7
|
-
if (!authResult.ok) return authResult.response;
|
|
8
|
-
if (!gate.methods.includes(request.method)) return gate.methodNotAllowed(allow);
|
|
9
|
-
return gate.handle(request, authResult, recorder, ...extra);
|
|
10
|
-
};
|
|
11
|
-
return async (request, recorder = createNoopRecorder(), ...extra) => {
|
|
12
|
-
const cors = evaluateCors(request, gate.allowedOrigins);
|
|
13
|
-
if (!cors.ok) return finalizeWireResponse(request, cors.response);
|
|
14
|
-
if (request.method === "OPTIONS") return cors.preflight(allow);
|
|
15
|
-
const final = finalizeWireResponse(request, cors.withHeaders(await respond(request, recorder, ...extra)));
|
|
16
|
-
if (!final.headers.has("Cache-Control")) final.headers.set("Cache-Control", "no-store");
|
|
17
|
-
return final;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { createGatedHandler as t };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const require_schema = require("./schema-D3vClxb7.cjs");
|
|
2
|
-
const require_cors = require("./cors-CmKzDN7k.cjs");
|
|
3
|
-
const require_gate = require("./gate-n_HX6eQ5.cjs");
|
|
4
|
-
//#region src/protocols/rest/list-tools.ts
|
|
5
|
-
function schemaToJsonSchema(definition, pipeStrategy) {
|
|
6
|
-
if (!definition) return null;
|
|
7
|
-
return require_schema.jsonSchemaFromDefinition(definition, pipeStrategy);
|
|
8
|
-
}
|
|
9
|
-
function buildMcpListing(mcp) {
|
|
10
|
-
return {
|
|
11
|
-
server: {
|
|
12
|
-
name: mcp.name,
|
|
13
|
-
version: mcp.version,
|
|
14
|
-
title: mcp.title
|
|
15
|
-
},
|
|
16
|
-
tools: mcp.tools.map((tool) => ({
|
|
17
|
-
name: tool.name,
|
|
18
|
-
title: tool.title,
|
|
19
|
-
description: tool.description,
|
|
20
|
-
annotations: tool.annotations,
|
|
21
|
-
inputSchema: schemaToJsonSchema(tool.inputSchema, "input"),
|
|
22
|
-
outputSchema: schemaToJsonSchema(tool.outputSchema, "output")
|
|
23
|
-
}))
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function createListToolsHandler(mcp, options = {}) {
|
|
27
|
-
require_cors.assertRestResourceBinding(mcp, options);
|
|
28
|
-
return require_gate.createGatedHandler({
|
|
29
|
-
authorizer: require_cors.createRequestAuthorizer(mcp, options),
|
|
30
|
-
allowedOrigins: mcp.allowedOrigins,
|
|
31
|
-
methods: ["GET", "HEAD"],
|
|
32
|
-
methodNotAllowed: require_cors.methodNotAllowed,
|
|
33
|
-
handle: async () => Response.json(buildMcpListing(mcp))
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
Object.defineProperty(exports, "buildMcpListing", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function() {
|
|
40
|
-
return buildMcpListing;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, "createListToolsHandler", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function() {
|
|
46
|
-
return createListToolsHandler;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { t as jsonSchemaFromDefinition } from "./schema-CW1jKvio.js";
|
|
2
|
-
import { n as assertRestResourceBinding, p as methodNotAllowed, r as createRequestAuthorizer } from "./cors-D4YbODs-.js";
|
|
3
|
-
import { t as createGatedHandler } from "./gate-pGsVlY_4.js";
|
|
4
|
-
//#region src/protocols/rest/list-tools.ts
|
|
5
|
-
function schemaToJsonSchema(definition, pipeStrategy) {
|
|
6
|
-
if (!definition) return null;
|
|
7
|
-
return jsonSchemaFromDefinition(definition, pipeStrategy);
|
|
8
|
-
}
|
|
9
|
-
function buildMcpListing(mcp) {
|
|
10
|
-
return {
|
|
11
|
-
server: {
|
|
12
|
-
name: mcp.name,
|
|
13
|
-
version: mcp.version,
|
|
14
|
-
title: mcp.title
|
|
15
|
-
},
|
|
16
|
-
tools: mcp.tools.map((tool) => ({
|
|
17
|
-
name: tool.name,
|
|
18
|
-
title: tool.title,
|
|
19
|
-
description: tool.description,
|
|
20
|
-
annotations: tool.annotations,
|
|
21
|
-
inputSchema: schemaToJsonSchema(tool.inputSchema, "input"),
|
|
22
|
-
outputSchema: schemaToJsonSchema(tool.outputSchema, "output")
|
|
23
|
-
}))
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function createListToolsHandler(mcp, options = {}) {
|
|
27
|
-
assertRestResourceBinding(mcp, options);
|
|
28
|
-
return createGatedHandler({
|
|
29
|
-
authorizer: createRequestAuthorizer(mcp, options),
|
|
30
|
-
allowedOrigins: mcp.allowedOrigins,
|
|
31
|
-
methods: ["GET", "HEAD"],
|
|
32
|
-
methodNotAllowed,
|
|
33
|
-
handle: async () => Response.json(buildMcpListing(mcp))
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
export { createListToolsHandler as n, buildMcpListing as t };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { u as McpDefinition } from "./types-D1cgsnPu.js";
|
|
2
|
-
import { t as MetricsRecorder } from "./base-DSH8NnPj.js";
|
|
3
|
-
import { t as McpRuntimeOptions } from "./authorize-BjNE3LPr.js";
|
|
4
|
-
//#region src/protocols/rest/list-tools.d.ts
|
|
5
|
-
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
6
|
-
declare function createListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestListToolsHandler;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { createListToolsHandler as n, RestListToolsHandler as t };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { u as McpDefinition } from "./types-D1cgsnPu.cjs";
|
|
2
|
-
import { t as MetricsRecorder } from "./base-DSH8NnPj.cjs";
|
|
3
|
-
import { t as McpRuntimeOptions } from "./authorize-BzZFS0zi.cjs";
|
|
4
|
-
//#region src/protocols/rest/list-tools.d.ts
|
|
5
|
-
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
6
|
-
declare function createListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestListToolsHandler;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { createListToolsHandler as n, RestListToolsHandler as t };
|