@lovable.dev/mcp-js 0.17.0 → 0.19.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/dist/{recorder-qlzUKFxG.d.ts → base-C9rhAHZ0.d.ts} +3 -4
- package/dist/{chunk-WYXIX7XF.js → chunk-57ZH2WW5.js} +11 -12
- package/dist/{chunk-6TZNGFRM.js → chunk-5FX6IIQ6.js} +121 -136
- package/dist/{chunk-J5BTCP6T.js → chunk-CDZ7MBXC.js} +1 -1
- package/dist/{chunk-EL6YNP2R.js → chunk-CLXKPZZE.js} +13 -14
- package/dist/{chunk-VQQZAFRA.js → chunk-H37EB22A.js} +2 -10
- package/dist/{chunk-FW6YL5C5.js → chunk-OMWXY6WY.js} +8 -8
- package/dist/{chunk-H2HXKAMQ.js → chunk-UEOBGHXF.js} +2 -2
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +4 -4
- package/dist/index.cjs +1 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/protocols/mcp/index.cjs +16 -272
- package/dist/protocols/mcp/index.d.cts +6 -5
- package/dist/protocols/mcp/index.d.ts +6 -5
- package/dist/protocols/mcp/index.js +4 -4
- package/dist/protocols/oauth-metadata.d.cts +1 -1
- package/dist/protocols/oauth-metadata.d.ts +1 -1
- package/dist/protocols/oauth-metadata.js +4 -4
- package/dist/protocols/rest/index.cjs +21 -277
- package/dist/protocols/rest/index.d.cts +6 -6
- package/dist/protocols/rest/index.d.ts +6 -6
- package/dist/protocols/rest/index.js +5 -5
- package/dist/stacks/supabase/index.cjs +178 -201
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +14 -14
- package/dist/stacks/supabase/vite.cjs +1 -1
- package/dist/stacks/supabase/vite.js +1 -1
- package/dist/stacks/tanstack/index.cjs +187 -209
- package/dist/stacks/tanstack/index.d.cts +1 -1
- package/dist/stacks/tanstack/index.d.ts +1 -1
- package/dist/stacks/tanstack/index.js +13 -10
- package/dist/{types-COY42xux.d.ts → types-CPkhCRxc.d.ts} +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as McpDefinitionInput, d as McpDefinition, Z as ZodRawShape, l as ToolDefinition, M as McpAuthConfig } from './types-
|
|
2
|
-
export { A as AudioContent, C as ContentAnnotations, a as ContentBlock, E as EmbeddedBlobResource, b as EmbeddedResource, c as EmbeddedTextResource, I as ImageContent, J as JwtClaims, f as MetricsConfig, g as MetricsOptions, R as ResourceLink, h as ResourceLinkIcon, T as TextContent, i as ToolAnnotations, j as ToolContent, k as ToolContext, m as ToolHandlerResult, n as ZodSchema } from './types-
|
|
1
|
+
import { e as McpDefinitionInput, d as McpDefinition, Z as ZodRawShape, l as ToolDefinition, M as McpAuthConfig } from './types-CPkhCRxc.js';
|
|
2
|
+
export { A as AudioContent, C as ContentAnnotations, a as ContentBlock, E as EmbeddedBlobResource, b as EmbeddedResource, c as EmbeddedTextResource, I as ImageContent, J as JwtClaims, f as MetricsConfig, g as MetricsOptions, R as ResourceLink, h as ResourceLinkIcon, T as TextContent, i as ToolAnnotations, j as ToolContent, k as ToolContext, m as ToolHandlerResult, n as ZodSchema } from './types-CPkhCRxc.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -47,18 +47,6 @@ function readEnvLevel() {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
var currentLevel = readEnvLevel() ?? "debug";
|
|
50
|
-
function setLogLevel(level) {
|
|
51
|
-
currentLevel = level;
|
|
52
|
-
}
|
|
53
|
-
function parseLogLevel(raw) {
|
|
54
|
-
const normalized = raw?.trim().toLowerCase();
|
|
55
|
-
return isLogLevel(normalized) ? normalized : void 0;
|
|
56
|
-
}
|
|
57
|
-
function applyLogLevelFromEnv(raw) {
|
|
58
|
-
const level = parseLogLevel(raw);
|
|
59
|
-
if (level)
|
|
60
|
-
setLogLevel(level);
|
|
61
|
-
}
|
|
62
50
|
function enabled(level) {
|
|
63
51
|
return LEVEL_RANK[level] <= LEVEL_RANK[currentLevel];
|
|
64
52
|
}
|
|
@@ -85,259 +73,15 @@ function describeError(err) {
|
|
|
85
73
|
return { value: String(err) };
|
|
86
74
|
}
|
|
87
75
|
|
|
88
|
-
// src/metrics/
|
|
89
|
-
var DEFAULT_METRICS_ENDPOINT = "https://api.lovable.dev/v1/app-mcp-usage";
|
|
90
|
-
var METRICS_API_KEY_ENV_VAR = "LOVABLE_API_KEY";
|
|
91
|
-
var METRICS_SAMPLE_RATE = 1;
|
|
92
|
-
var METRICS_FLUSH_INTERVAL_MS = 5e3;
|
|
93
|
-
var METRICS_MAX_BATCH_SIZE = 50;
|
|
94
|
-
function assertMetricsEndpoint(endpoint) {
|
|
95
|
-
let url;
|
|
96
|
-
try {
|
|
97
|
-
url = new URL(endpoint);
|
|
98
|
-
} catch {
|
|
99
|
-
throw new Error(`@lovable.dev/mcp-js: metrics.endpoint must be an absolute URL, got ${JSON.stringify(endpoint)}`);
|
|
100
|
-
}
|
|
101
|
-
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
102
|
-
throw new Error(`@lovable.dev/mcp-js: metrics.endpoint must be http(s), got ${JSON.stringify(endpoint)}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function resolveMetricsConfig(config = true) {
|
|
106
|
-
const options = typeof config === "boolean" ? { enabled: config } : config;
|
|
107
|
-
const endpoint = options.endpoint ?? DEFAULT_METRICS_ENDPOINT;
|
|
108
|
-
assertMetricsEndpoint(endpoint);
|
|
109
|
-
return Object.freeze({
|
|
110
|
-
enabled: options.enabled ?? true,
|
|
111
|
-
endpoint,
|
|
112
|
-
headers: options.headers ?? {},
|
|
113
|
-
apiKeyEnvVar: METRICS_API_KEY_ENV_VAR,
|
|
114
|
-
sampleRate: METRICS_SAMPLE_RATE,
|
|
115
|
-
flushIntervalMs: METRICS_FLUSH_INTERVAL_MS,
|
|
116
|
-
maxBatchSize: METRICS_MAX_BATCH_SIZE
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// package.json
|
|
121
|
-
var version = "0.17.0";
|
|
122
|
-
|
|
123
|
-
// src/metrics/otlp.ts
|
|
124
|
-
var SCOPE_NAME = "@lovable.dev/mcp-js";
|
|
125
|
-
var EVENT_NAME = "mcp.tool.invocation";
|
|
126
|
-
var SEVERITY_INFO = 9;
|
|
127
|
-
function strAttr(key, value) {
|
|
128
|
-
return { key, value: { stringValue: value } };
|
|
129
|
-
}
|
|
130
|
-
function intAttr(key, value) {
|
|
131
|
-
return { key, value: { intValue: String(Math.round(value)) } };
|
|
132
|
-
}
|
|
133
|
-
function toLogRecord(rec) {
|
|
134
|
-
const attributes = [
|
|
135
|
-
strAttr("event.name", EVENT_NAME),
|
|
136
|
-
strAttr("mcp.method", rec.method),
|
|
137
|
-
strAttr("mcp.outcome", rec.outcome),
|
|
138
|
-
intAttr("mcp.duration_ms", rec.durationMs)
|
|
139
|
-
];
|
|
140
|
-
if (rec.tool !== null)
|
|
141
|
-
attributes.push(strAttr("mcp.tool", rec.tool));
|
|
142
|
-
if (rec.reqBytes !== void 0)
|
|
143
|
-
attributes.push(intAttr("mcp.request_size_bytes", rec.reqBytes));
|
|
144
|
-
if (rec.resBytes !== void 0)
|
|
145
|
-
attributes.push(intAttr("mcp.response_size_bytes", rec.resBytes));
|
|
146
|
-
return {
|
|
147
|
-
timeUnixNano: rec.timeUnixNano,
|
|
148
|
-
observedTimeUnixNano: rec.timeUnixNano,
|
|
149
|
-
severityNumber: SEVERITY_INFO,
|
|
150
|
-
severityText: "INFO",
|
|
151
|
-
body: { stringValue: EVENT_NAME },
|
|
152
|
-
attributes
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function buildLogsPayload(records, server) {
|
|
156
|
-
return JSON.stringify({
|
|
157
|
-
resourceLogs: [
|
|
158
|
-
{
|
|
159
|
-
resource: {
|
|
160
|
-
attributes: [
|
|
161
|
-
strAttr("service.name", server.name),
|
|
162
|
-
strAttr("service.version", server.version),
|
|
163
|
-
strAttr("telemetry.sdk.name", SCOPE_NAME),
|
|
164
|
-
strAttr("telemetry.sdk.version", version),
|
|
165
|
-
strAttr("telemetry.sdk.language", "webjs")
|
|
166
|
-
]
|
|
167
|
-
},
|
|
168
|
-
scopeLogs: [
|
|
169
|
-
{
|
|
170
|
-
scope: { name: SCOPE_NAME, version },
|
|
171
|
-
logRecords: records.map(toLogRecord)
|
|
172
|
-
}
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function nowUnixNano() {
|
|
179
|
-
return `${Date.now()}000000`;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// src/metrics/recorder.ts
|
|
76
|
+
// src/metrics/impl/base.ts
|
|
183
77
|
function nowMs() {
|
|
184
78
|
return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
185
79
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
recorder.record(ev);
|
|
189
|
-
}
|
|
190
|
-
var NOOP_RECORDER = {
|
|
191
|
-
record() {
|
|
192
|
-
},
|
|
193
|
-
async flush() {
|
|
194
|
-
}
|
|
195
|
-
};
|
|
80
|
+
var NOOP_RECORDER = { async emit() {
|
|
81
|
+
} };
|
|
196
82
|
function createNoopRecorder() {
|
|
197
83
|
return NOOP_RECORDER;
|
|
198
84
|
}
|
|
199
|
-
function readRuntimeEnv(name) {
|
|
200
|
-
try {
|
|
201
|
-
const denoEnv = globalThis.Deno?.env;
|
|
202
|
-
const value = denoEnv?.get?.(name);
|
|
203
|
-
if (value)
|
|
204
|
-
return value;
|
|
205
|
-
} catch {
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
if (typeof process !== "undefined") {
|
|
209
|
-
const value = process.env?.[name];
|
|
210
|
-
if (value)
|
|
211
|
-
return value;
|
|
212
|
-
}
|
|
213
|
-
} catch {
|
|
214
|
-
}
|
|
215
|
-
return void 0;
|
|
216
|
-
}
|
|
217
|
-
var cloudflareEnvPromise;
|
|
218
|
-
async function readCloudflareEnv(name) {
|
|
219
|
-
try {
|
|
220
|
-
const moduleSpecifier = "cloudflare:workers";
|
|
221
|
-
cloudflareEnvPromise ??= import(
|
|
222
|
-
/* @vite-ignore */
|
|
223
|
-
moduleSpecifier
|
|
224
|
-
).then((m) => m.env).catch(() => void 0);
|
|
225
|
-
const env = await cloudflareEnvPromise;
|
|
226
|
-
const value = env?.[name];
|
|
227
|
-
return typeof value === "string" && value ? value : void 0;
|
|
228
|
-
} catch {
|
|
229
|
-
return void 0;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function probeWaitUntil() {
|
|
233
|
-
const fn = globalThis.EdgeRuntime?.waitUntil;
|
|
234
|
-
return typeof fn === "function" ? fn.bind(globalThis.EdgeRuntime) : void 0;
|
|
235
|
-
}
|
|
236
|
-
function createMetricsRecorder(ctx, deps = {}) {
|
|
237
|
-
const { config, server } = ctx;
|
|
238
|
-
applyLogLevelFromEnv(readRuntimeEnv(LOG_LEVEL_ENV_VAR));
|
|
239
|
-
if (!config.enabled)
|
|
240
|
-
return NOOP_RECORDER;
|
|
241
|
-
const doFetch = deps.fetch ?? globalThis.fetch;
|
|
242
|
-
if (!doFetch) {
|
|
243
|
-
log.warn("metrics.disabled_no_fetch", { endpoint: config.endpoint });
|
|
244
|
-
return NOOP_RECORDER;
|
|
245
|
-
}
|
|
246
|
-
const usesLovableEndpoint = config.endpoint === DEFAULT_METRICS_ENDPOINT;
|
|
247
|
-
const waitUntil = deps.waitUntil ?? probeWaitUntil();
|
|
248
|
-
const buffer = [];
|
|
249
|
-
let timer;
|
|
250
|
-
let lazyLogLevelApplied = false;
|
|
251
|
-
const applyLazyLogLevel = async () => {
|
|
252
|
-
if (lazyLogLevelApplied)
|
|
253
|
-
return;
|
|
254
|
-
lazyLogLevelApplied = true;
|
|
255
|
-
applyLogLevelFromEnv(await readCloudflareEnv(LOG_LEVEL_ENV_VAR));
|
|
256
|
-
};
|
|
257
|
-
let apiKey;
|
|
258
|
-
const resolveApiKey = async () => {
|
|
259
|
-
if (apiKey)
|
|
260
|
-
return apiKey;
|
|
261
|
-
apiKey = (deps.getApiKey ? deps.getApiKey() : readRuntimeEnv(config.apiKeyEnvVar)) ?? await readCloudflareEnv(config.apiKeyEnvVar);
|
|
262
|
-
return apiKey;
|
|
263
|
-
};
|
|
264
|
-
const schedule = (p) => {
|
|
265
|
-
if (waitUntil) {
|
|
266
|
-
try {
|
|
267
|
-
waitUntil(p);
|
|
268
|
-
return;
|
|
269
|
-
} catch (err) {
|
|
270
|
-
log.warn("metrics.wait_until_failed", describeError(err));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
void p.catch(() => {
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
const baseHeaders = {};
|
|
277
|
-
if (!usesLovableEndpoint) {
|
|
278
|
-
for (const [key, value] of Object.entries(config.headers)) {
|
|
279
|
-
if (key.toLowerCase() !== "content-type")
|
|
280
|
-
baseHeaders[key] = value;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
baseHeaders["content-type"] = "application/json";
|
|
284
|
-
const flush = async () => {
|
|
285
|
-
void applyLazyLogLevel();
|
|
286
|
-
if (buffer.length === 0)
|
|
287
|
-
return;
|
|
288
|
-
const records = buffer.splice(0, buffer.length);
|
|
289
|
-
const dropped = records.length;
|
|
290
|
-
const headers = { ...baseHeaders };
|
|
291
|
-
if (usesLovableEndpoint) {
|
|
292
|
-
const key = await resolveApiKey();
|
|
293
|
-
if (!key) {
|
|
294
|
-
log.warn("metrics.disabled_no_api_key", {
|
|
295
|
-
envVar: config.apiKeyEnvVar,
|
|
296
|
-
endpoint: config.endpoint,
|
|
297
|
-
dropped
|
|
298
|
-
});
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
headers.authorization = `Bearer ${key}`;
|
|
302
|
-
}
|
|
303
|
-
try {
|
|
304
|
-
const res = await doFetch(config.endpoint, {
|
|
305
|
-
method: "POST",
|
|
306
|
-
headers,
|
|
307
|
-
body: buildLogsPayload(records, server),
|
|
308
|
-
keepalive: true
|
|
309
|
-
});
|
|
310
|
-
if (!res.ok) {
|
|
311
|
-
log.warn("metrics.flush_rejected", { status: res.status, dropped, endpoint: config.endpoint });
|
|
312
|
-
}
|
|
313
|
-
} catch (err) {
|
|
314
|
-
log.warn("metrics.flush_failed", { ...describeError(err), dropped, endpoint: config.endpoint });
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
const ensureTimer = () => {
|
|
318
|
-
if (timer !== void 0)
|
|
319
|
-
return;
|
|
320
|
-
timer = setInterval(() => schedule(flush()), config.flushIntervalMs);
|
|
321
|
-
timer.unref?.();
|
|
322
|
-
};
|
|
323
|
-
return {
|
|
324
|
-
record(ev) {
|
|
325
|
-
if (config.sampleRate < 1 && Math.random() >= config.sampleRate)
|
|
326
|
-
return;
|
|
327
|
-
buffer.push({ ...ev, timeUnixNano: nowUnixNano() });
|
|
328
|
-
ensureTimer();
|
|
329
|
-
if (buffer.length >= config.maxBatchSize)
|
|
330
|
-
schedule(flush());
|
|
331
|
-
},
|
|
332
|
-
flush
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
function createRecorderForRuntime(mcp) {
|
|
336
|
-
const config = resolveMetricsConfig(mcp.metrics);
|
|
337
|
-
if (!config.enabled)
|
|
338
|
-
return createNoopRecorder();
|
|
339
|
-
return createMetricsRecorder({ config, server: { name: mcp.name, version: mcp.version } });
|
|
340
|
-
}
|
|
341
85
|
|
|
342
86
|
// src/core/promise.ts
|
|
343
87
|
function cachedPromise(load, label) {
|
|
@@ -759,10 +503,10 @@ function assertRequiredScopes(auth, context) {
|
|
|
759
503
|
throw new OAuthTokenError(403, "insufficient_scope", "Additional OAuth scope is required");
|
|
760
504
|
}
|
|
761
505
|
}
|
|
762
|
-
function createRequestAuthorizer(mcp, options = {}
|
|
506
|
+
function createRequestAuthorizer(mcp, options = {}) {
|
|
763
507
|
const runtime = getOAuthRuntime(mcp, options);
|
|
764
508
|
return {
|
|
765
|
-
async authorize(request) {
|
|
509
|
+
async authorize(request, recorder) {
|
|
766
510
|
if (runtime.kind === "unconfigured")
|
|
767
511
|
return { ok: true };
|
|
768
512
|
const startedAt = nowMs();
|
|
@@ -778,7 +522,7 @@ function createRequestAuthorizer(mcp, options = {}, recorder) {
|
|
|
778
522
|
} catch (err) {
|
|
779
523
|
if (err instanceof OAuthConfigurationError) {
|
|
780
524
|
log.error("auth.config_error", { ...describeError(err), outcome: "500" });
|
|
781
|
-
recorder?.
|
|
525
|
+
await recorder?.emit({
|
|
782
526
|
tool: null,
|
|
783
527
|
method: "authorize",
|
|
784
528
|
outcome: "auth_config_error",
|
|
@@ -889,7 +633,7 @@ function adaptToolToSdkCallback(tool, auth, recorder) {
|
|
|
889
633
|
try {
|
|
890
634
|
result = await tool.handler(args, new ToolContext(auth));
|
|
891
635
|
} catch {
|
|
892
|
-
|
|
636
|
+
await recorder.emit({
|
|
893
637
|
tool: tool.name,
|
|
894
638
|
method: "tools/call",
|
|
895
639
|
outcome: "handler_error",
|
|
@@ -898,7 +642,7 @@ function adaptToolToSdkCallback(tool, auth, recorder) {
|
|
|
898
642
|
return { content: [{ type: "text", text: "tool execution failed" }], isError: true };
|
|
899
643
|
}
|
|
900
644
|
if (result == null) {
|
|
901
|
-
|
|
645
|
+
await recorder.emit({
|
|
902
646
|
tool: tool.name,
|
|
903
647
|
method: "tools/call",
|
|
904
648
|
outcome: "handler_error",
|
|
@@ -906,7 +650,7 @@ function adaptToolToSdkCallback(tool, auth, recorder) {
|
|
|
906
650
|
});
|
|
907
651
|
return { content: [{ type: "text", text: `tool "${tool.name}" returned no result` }], isError: true };
|
|
908
652
|
}
|
|
909
|
-
|
|
653
|
+
await recorder.emit({
|
|
910
654
|
tool: tool.name,
|
|
911
655
|
method: "tools/call",
|
|
912
656
|
outcome: result.isError ? "tool_error" : "ok",
|
|
@@ -915,10 +659,10 @@ function adaptToolToSdkCallback(tool, auth, recorder) {
|
|
|
915
659
|
return { content: result.content ?? [], structuredContent: result.structuredContent, isError: result.isError };
|
|
916
660
|
};
|
|
917
661
|
}
|
|
918
|
-
function createMcpProtocolHandler(mcp, options = {}
|
|
919
|
-
const authorizer = createRequestAuthorizer(mcp, options
|
|
920
|
-
const handle = async (request) => {
|
|
921
|
-
const authResult = await authorizer.authorize(request);
|
|
662
|
+
function createMcpProtocolHandler(mcp, options = {}) {
|
|
663
|
+
const authorizer = createRequestAuthorizer(mcp, options);
|
|
664
|
+
const handle = async (request, recorder) => {
|
|
665
|
+
const authResult = await authorizer.authorize(request, recorder);
|
|
922
666
|
if (!authResult.ok)
|
|
923
667
|
return authResult.response;
|
|
924
668
|
try {
|
|
@@ -945,7 +689,7 @@ function createMcpProtocolHandler(mcp, options = {}, recorder = createRecorderFo
|
|
|
945
689
|
await server.connect(transport);
|
|
946
690
|
return await transport.handleRequest(request);
|
|
947
691
|
} catch (err) {
|
|
948
|
-
recorder.
|
|
692
|
+
await recorder.emit({ tool: null, method: "transport", outcome: "transport_error", durationMs: 0 });
|
|
949
693
|
log.error("mcp.transport_error", { ...describeError(err), outcome: "500 internal error" });
|
|
950
694
|
return Response.json(
|
|
951
695
|
{ jsonrpc: "2.0", id: null, error: { code: -32603, message: "internal error" } },
|
|
@@ -953,10 +697,10 @@ function createMcpProtocolHandler(mcp, options = {}, recorder = createRecorderFo
|
|
|
953
697
|
);
|
|
954
698
|
}
|
|
955
699
|
};
|
|
956
|
-
return async (request) => {
|
|
700
|
+
return async (request, recorder = createNoopRecorder()) => {
|
|
957
701
|
if (request.method === "OPTIONS")
|
|
958
702
|
return corsPreflightResponse("GET, POST, DELETE, OPTIONS");
|
|
959
|
-
return withCors(await handle(request));
|
|
703
|
+
return withCors(await handle(request, recorder));
|
|
960
704
|
};
|
|
961
705
|
}
|
|
962
706
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { M as McpRuntimeOptions } from '../../authorize-BMeXd_Sh.js';
|
|
2
|
-
import { d as McpDefinition } from '../../types-
|
|
3
|
-
import { M as MetricsRecorder } from '../../
|
|
2
|
+
import { d as McpDefinition } from '../../types-CPkhCRxc.js';
|
|
3
|
+
import { M as MetricsRecorder } from '../../base-C9rhAHZ0.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
-
type McpProtocolHandler = (request: Request) => Promise<Response>;
|
|
6
|
+
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
7
7
|
/**
|
|
8
8
|
* Build a Web-Standard request handler that serves the MCP protocol over
|
|
9
9
|
* streamable HTTP. A fresh `McpServer` + transport is constructed per
|
|
10
10
|
* request — the transport is stateless, so this is cheap and there is no
|
|
11
|
-
* cross-request state to leak.
|
|
11
|
+
* cross-request state to leak. The per-request `recorder` is supplied by the
|
|
12
|
+
* caller (the stack handler) so telemetry reads the runtime env in-flight.
|
|
12
13
|
*/
|
|
13
|
-
declare function createMcpProtocolHandler(mcp: McpDefinition, options?: McpRuntimeOptions
|
|
14
|
+
declare function createMcpProtocolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): McpProtocolHandler;
|
|
14
15
|
|
|
15
16
|
export { type McpProtocolHandler, createMcpProtocolHandler };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { M as McpRuntimeOptions } from '../../authorize-BMeXd_Sh.js';
|
|
2
|
-
import { d as McpDefinition } from '../../types-
|
|
3
|
-
import { M as MetricsRecorder } from '../../
|
|
2
|
+
import { d as McpDefinition } from '../../types-CPkhCRxc.js';
|
|
3
|
+
import { M as MetricsRecorder } from '../../base-C9rhAHZ0.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
-
type McpProtocolHandler = (request: Request) => Promise<Response>;
|
|
6
|
+
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
7
7
|
/**
|
|
8
8
|
* Build a Web-Standard request handler that serves the MCP protocol over
|
|
9
9
|
* streamable HTTP. A fresh `McpServer` + transport is constructed per
|
|
10
10
|
* request — the transport is stateless, so this is cheap and there is no
|
|
11
|
-
* cross-request state to leak.
|
|
11
|
+
* cross-request state to leak. The per-request `recorder` is supplied by the
|
|
12
|
+
* caller (the stack handler) so telemetry reads the runtime env in-flight.
|
|
12
13
|
*/
|
|
13
|
-
declare function createMcpProtocolHandler(mcp: McpDefinition, options?: McpRuntimeOptions
|
|
14
|
+
declare function createMcpProtocolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): McpProtocolHandler;
|
|
14
15
|
|
|
15
16
|
export { type McpProtocolHandler, createMcpProtocolHandler };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMcpProtocolHandler
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-CLXKPZZE.js";
|
|
4
4
|
import "../../chunk-MA5H6PSF.js";
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-5FX6IIQ6.js";
|
|
6
|
+
import "../../chunk-H37EB22A.js";
|
|
7
7
|
import "../../chunk-6DXGZZA4.js";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-CDZ7MBXC.js";
|
|
9
9
|
export {
|
|
10
10
|
createMcpProtocolHandler
|
|
11
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as McpRuntimeOptions } from '../authorize-BMeXd_Sh.js';
|
|
2
|
-
import { d as McpDefinition } from '../types-
|
|
2
|
+
import { d as McpDefinition } from '../types-CPkhCRxc.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
type OAuthProtectedResourceMetadataHandler = (request: Request) => Promise<Response>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as McpRuntimeOptions } from '../authorize-BMeXd_Sh.js';
|
|
2
|
-
import { d as McpDefinition } from '../types-
|
|
2
|
+
import { d as McpDefinition } from '../types-CPkhCRxc.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
type OAuthProtectedResourceMetadataHandler = (request: Request) => Promise<Response>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createOAuthProtectedResourceMetadataHandler
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-UEOBGHXF.js";
|
|
4
|
+
import "../chunk-5FX6IIQ6.js";
|
|
5
|
+
import "../chunk-H37EB22A.js";
|
|
6
6
|
import "../chunk-6DXGZZA4.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-CDZ7MBXC.js";
|
|
8
8
|
export {
|
|
9
9
|
createOAuthProtectedResourceMetadataHandler
|
|
10
10
|
};
|