mcp-expose 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +21 -0
  3. package/README.md +708 -0
  4. package/dist/adonisjs/index.cjs +708 -0
  5. package/dist/adonisjs/index.cjs.map +1 -0
  6. package/dist/adonisjs/index.d.cts +68 -0
  7. package/dist/adonisjs/index.d.ts +68 -0
  8. package/dist/adonisjs/index.js +684 -0
  9. package/dist/adonisjs/index.js.map +1 -0
  10. package/dist/express/index.cjs +789 -0
  11. package/dist/express/index.cjs.map +1 -0
  12. package/dist/express/index.d.cts +61 -0
  13. package/dist/express/index.d.ts +61 -0
  14. package/dist/express/index.js +763 -0
  15. package/dist/express/index.js.map +1 -0
  16. package/dist/fastify/index.cjs +660 -0
  17. package/dist/fastify/index.cjs.map +1 -0
  18. package/dist/fastify/index.d.cts +42 -0
  19. package/dist/fastify/index.d.ts +42 -0
  20. package/dist/fastify/index.js +635 -0
  21. package/dist/fastify/index.js.map +1 -0
  22. package/dist/hono/index.cjs +656 -0
  23. package/dist/hono/index.cjs.map +1 -0
  24. package/dist/hono/index.d.cts +44 -0
  25. package/dist/hono/index.d.ts +44 -0
  26. package/dist/hono/index.js +630 -0
  27. package/dist/hono/index.js.map +1 -0
  28. package/dist/index.cjs +720 -0
  29. package/dist/index.cjs.map +1 -0
  30. package/dist/index.d.cts +81 -0
  31. package/dist/index.d.ts +81 -0
  32. package/dist/index.js +686 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/koa/index.cjs +739 -0
  35. package/dist/koa/index.cjs.map +1 -0
  36. package/dist/koa/index.d.cts +68 -0
  37. package/dist/koa/index.d.ts +68 -0
  38. package/dist/koa/index.js +709 -0
  39. package/dist/koa/index.js.map +1 -0
  40. package/dist/nestjs/index.cjs +1117 -0
  41. package/dist/nestjs/index.cjs.map +1 -0
  42. package/dist/nestjs/index.d.cts +104 -0
  43. package/dist/nestjs/index.d.ts +104 -0
  44. package/dist/nestjs/index.js +1079 -0
  45. package/dist/nestjs/index.js.map +1 -0
  46. package/dist/server-fzkb-wJo.d.cts +194 -0
  47. package/dist/server-fzkb-wJo.d.ts +194 -0
  48. package/package.json +225 -0
@@ -0,0 +1,635 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/core/dispatch.ts
5
+ function buildUrl(base, req) {
6
+ const url = new URL(base.replace(/\/+$/, "") + req.path);
7
+ for (const [k, v] of Object.entries(req.query)) {
8
+ for (const item of Array.isArray(v) ? v : [
9
+ v
10
+ ]) url.searchParams.append(k, item);
11
+ }
12
+ return url.toString();
13
+ }
14
+ __name(buildUrl, "buildUrl");
15
+
16
+ // src/core/node.ts
17
+ function normalizeHeaders(headers) {
18
+ const out = {};
19
+ for (const [k, v] of Object.entries(headers)) {
20
+ if (v === void 0) continue;
21
+ out[k.toLowerCase()] = Array.isArray(v) ? v.join(", ") : String(v);
22
+ }
23
+ return out;
24
+ }
25
+ __name(normalizeHeaders, "normalizeHeaders");
26
+
27
+ // src/core/schema.ts
28
+ function isStandard(s) {
29
+ return typeof s === "object" && s !== null && "~standard" in s;
30
+ }
31
+ __name(isStandard, "isStandard");
32
+ function toJsonSchema(schema) {
33
+ if (schema === void 0 || schema === null) return void 0;
34
+ let out;
35
+ if (isStandard(schema) && typeof schema["~standard"].jsonSchema?.input === "function") {
36
+ out = schema["~standard"].jsonSchema.input({
37
+ target: "draft-2020-12"
38
+ });
39
+ } else if (typeof schema.toJSONSchema === "function") {
40
+ out = schema.toJSONSchema();
41
+ } else if (isStandard(schema)) {
42
+ throw new Error("mcp-expose: this schema library does not support JSON Schema export. Pass a plain JSON Schema instead.");
43
+ } else {
44
+ out = schema;
45
+ }
46
+ const { $schema: _ignored, ...rest } = out;
47
+ return rest;
48
+ }
49
+ __name(toJsonSchema, "toJsonSchema");
50
+ function toValidator(schema) {
51
+ if (!isStandard(schema) || typeof schema["~standard"].validate !== "function") return void 0;
52
+ const validate = schema["~standard"].validate;
53
+ return async (value) => {
54
+ const result = await validate(value);
55
+ if (!result.issues) return {
56
+ ok: true,
57
+ value: result.value
58
+ };
59
+ const message = result.issues.map((i) => {
60
+ const path = (i.path ?? []).map((p) => typeof p === "object" ? String(p.key) : String(p)).join(".");
61
+ return path ? `${path}: ${i.message}` : i.message;
62
+ }).join("; ");
63
+ return {
64
+ ok: false,
65
+ message
66
+ };
67
+ };
68
+ }
69
+ __name(toValidator, "toValidator");
70
+ function checkRequired(schema, args) {
71
+ const missing = (schema.required ?? []).filter((k) => args[k] === void 0);
72
+ return missing.length ? `Missing required argument(s): ${missing.join(", ")}` : void 0;
73
+ }
74
+ __name(checkRequired, "checkRequired");
75
+
76
+ // src/core/route-tool.ts
77
+ var DEFAULT_FORWARD_HEADERS = [
78
+ "authorization",
79
+ "cookie",
80
+ "x-api-key",
81
+ "accept-language"
82
+ ];
83
+ var BODY_METHODS = /* @__PURE__ */ new Set([
84
+ "POST",
85
+ "PUT",
86
+ "PATCH"
87
+ ]);
88
+ var PARAM_RE = /:([A-Za-z0-9_]+)\??|\{([A-Za-z0-9_]+)\}/g;
89
+ function pathParams(path) {
90
+ return [
91
+ ...path.matchAll(PARAM_RE)
92
+ ].map((m) => m[1] ?? m[2]);
93
+ }
94
+ __name(pathParams, "pathParams");
95
+ function encodeSegment(name, value) {
96
+ const raw = String(value);
97
+ if (raw === "" || raw === "." || raw === "..") {
98
+ throw new Error(`Invalid value for path parameter "${name}": ${JSON.stringify(raw)}`);
99
+ }
100
+ return encodeURIComponent(raw);
101
+ }
102
+ __name(encodeSegment, "encodeSegment");
103
+ function interpolatePath(path, values) {
104
+ return path.replace(/\/:([A-Za-z0-9_]+)\?/g, (_, k) => values[k] === void 0 ? "" : `/${encodeSegment(k, values[k])}`).replace(PARAM_RE, (_, a, b) => {
105
+ const k = a ?? b;
106
+ return encodeSegment(k, values[k]);
107
+ });
108
+ }
109
+ __name(interpolatePath, "interpolatePath");
110
+ function toolNameFromRoute(method, path) {
111
+ const segments = path.split("/").filter(Boolean).map((s) => {
112
+ const m = /^(?::([A-Za-z0-9_]+)\??|\{([A-Za-z0-9_]+)\})$/.exec(s);
113
+ return m ? `by_${m[1] ?? m[2]}` : s;
114
+ });
115
+ return sanitizeToolName([
116
+ method.toLowerCase(),
117
+ ...segments
118
+ ].join("_"));
119
+ }
120
+ __name(toolNameFromRoute, "toolNameFromRoute");
121
+ function sanitizeToolName(name) {
122
+ return name.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").slice(0, 64);
123
+ }
124
+ __name(sanitizeToolName, "sanitizeToolName");
125
+ function defaultAnnotations(method) {
126
+ switch (method) {
127
+ case "GET":
128
+ case "HEAD":
129
+ return {
130
+ readOnlyHint: true,
131
+ openWorldHint: false
132
+ };
133
+ case "DELETE":
134
+ return {
135
+ readOnlyHint: false,
136
+ destructiveHint: true,
137
+ idempotentHint: true,
138
+ openWorldHint: false
139
+ };
140
+ case "PUT":
141
+ return {
142
+ readOnlyHint: false,
143
+ destructiveHint: false,
144
+ idempotentHint: true,
145
+ openWorldHint: false
146
+ };
147
+ default:
148
+ return {
149
+ readOnlyHint: false,
150
+ destructiveHint: false,
151
+ openWorldHint: false
152
+ };
153
+ }
154
+ }
155
+ __name(defaultAnnotations, "defaultAnnotations");
156
+ function buildInputSchema(route, opts) {
157
+ const method = route.method.toUpperCase();
158
+ const params = pathParams(route.path);
159
+ const mapping = {
160
+ params,
161
+ query: /* @__PURE__ */ new Set(),
162
+ body: /* @__PURE__ */ new Set(),
163
+ wholeBody: false,
164
+ bodyMethod: BODY_METHODS.has(method)
165
+ };
166
+ if (opts.input) {
167
+ const schema2 = toJsonSchema(opts.input);
168
+ return {
169
+ schema: {
170
+ type: "object",
171
+ ...schema2
172
+ },
173
+ mapping
174
+ };
175
+ }
176
+ const properties = {};
177
+ const required = /* @__PURE__ */ new Set();
178
+ const paramSchema = toJsonSchema(opts.params);
179
+ for (const p of params) {
180
+ properties[p] = paramSchema?.properties?.[p] ?? {
181
+ type: "string",
182
+ description: `Path parameter "${p}"`
183
+ };
184
+ if (!route.path.includes(`:${p}?`)) required.add(p);
185
+ }
186
+ const querySchema = toJsonSchema(opts.query);
187
+ for (const [k, v] of Object.entries(querySchema?.properties ?? {})) {
188
+ properties[k] = v;
189
+ mapping.query.add(k);
190
+ }
191
+ for (const k of querySchema?.required ?? []) required.add(k);
192
+ const bodySchema = toJsonSchema(opts.body);
193
+ if (bodySchema) {
194
+ if (bodySchema.properties && (bodySchema.type === void 0 || bodySchema.type === "object")) {
195
+ for (const [k, v] of Object.entries(bodySchema.properties)) {
196
+ properties[k] = v;
197
+ mapping.body.add(k);
198
+ }
199
+ for (const k of bodySchema.required ?? []) required.add(k);
200
+ } else {
201
+ properties.body = bodySchema;
202
+ required.add("body");
203
+ mapping.wholeBody = true;
204
+ }
205
+ }
206
+ const schema = {
207
+ type: "object",
208
+ properties
209
+ };
210
+ if (required.size) schema.required = [
211
+ ...required
212
+ ];
213
+ return {
214
+ schema,
215
+ mapping
216
+ };
217
+ }
218
+ __name(buildInputSchema, "buildInputSchema");
219
+ function splitArgs(args, mapping) {
220
+ const pathValues = {};
221
+ const query = {};
222
+ let body;
223
+ for (const [k, v] of Object.entries(args)) {
224
+ if (v === void 0) continue;
225
+ if (mapping.params.includes(k)) {
226
+ pathValues[k] = v;
227
+ } else if (mapping.wholeBody && k === "body") {
228
+ body = v;
229
+ } else if (mapping.query.has(k) || !mapping.body.has(k) && !mapping.bodyMethod) {
230
+ query[k] = Array.isArray(v) ? v.map(String) : typeof v === "object" && v !== null ? JSON.stringify(v) : String(v);
231
+ } else {
232
+ body = {
233
+ ...body ?? {},
234
+ [k]: v
235
+ };
236
+ }
237
+ }
238
+ if (body === void 0 && mapping.bodyMethod) body = {};
239
+ return {
240
+ pathValues,
241
+ query,
242
+ body
243
+ };
244
+ }
245
+ __name(splitArgs, "splitArgs");
246
+ function responseToResult(res, maxChars) {
247
+ let text = res.body;
248
+ if (text.length > maxChars) text = `${text.slice(0, maxChars)}
249
+ \u2026[truncated ${text.length - maxChars} chars]`;
250
+ const isError = res.status >= 400;
251
+ const result = {
252
+ content: [
253
+ {
254
+ type: "text",
255
+ text: isError ? `HTTP ${res.status}
256
+ ${text}` : text || `HTTP ${res.status}`
257
+ }
258
+ ]
259
+ };
260
+ if (isError) {
261
+ result.isError = true;
262
+ return result;
263
+ }
264
+ if ((res.headers["content-type"] ?? "").includes("json") && text === res.body) {
265
+ try {
266
+ const parsed = JSON.parse(res.body);
267
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) result.structuredContent = parsed;
268
+ } catch {
269
+ }
270
+ }
271
+ return result;
272
+ }
273
+ __name(responseToResult, "responseToResult");
274
+ function pickForwardHeaders(ctx, names) {
275
+ const out = {};
276
+ for (const name of names) {
277
+ const v = ctx.headers[name.toLowerCase()];
278
+ if (v !== void 0) out[name.toLowerCase()] = v;
279
+ }
280
+ return out;
281
+ }
282
+ __name(pickForwardHeaders, "pickForwardHeaders");
283
+ function createRouteTool(route, opts, dispatch, serverOpts = {}) {
284
+ const method = route.method.toUpperCase();
285
+ const name = sanitizeToolName(opts.name ?? toolNameFromRoute(method, route.path));
286
+ const { schema, mapping } = buildInputSchema(route, opts);
287
+ const forward = serverOpts.forwardHeaders ?? DEFAULT_FORWARD_HEADERS;
288
+ const maxChars = serverOpts.maxResponseChars ?? 1e5;
289
+ return {
290
+ name,
291
+ title: opts.title,
292
+ description: opts.description ?? `${method} ${route.path}`,
293
+ inputSchema: schema,
294
+ annotations: {
295
+ ...defaultAnnotations(method),
296
+ ...opts.annotations
297
+ },
298
+ validate: toValidator(opts.input),
299
+ async handler(args, ctx) {
300
+ const missing = opts.input ? void 0 : checkRequired(schema, args);
301
+ if (missing) return {
302
+ isError: true,
303
+ content: [
304
+ {
305
+ type: "text",
306
+ text: missing
307
+ }
308
+ ]
309
+ };
310
+ const { pathValues, query, body } = splitArgs(args, mapping);
311
+ const headers = {
312
+ accept: "application/json",
313
+ ...pickForwardHeaders(ctx, forward),
314
+ ...opts.headers,
315
+ "x-mcp-tool": name
316
+ };
317
+ if (ctx.clientIp) headers["x-forwarded-for"] = ctx.clientIp;
318
+ if (body !== void 0) headers["content-type"] = "application/json";
319
+ let path;
320
+ try {
321
+ path = interpolatePath(route.path, pathValues);
322
+ } catch (err) {
323
+ return {
324
+ isError: true,
325
+ content: [
326
+ {
327
+ type: "text",
328
+ text: err.message
329
+ }
330
+ ]
331
+ };
332
+ }
333
+ const res = await dispatch({
334
+ method,
335
+ path,
336
+ query,
337
+ body,
338
+ headers
339
+ }, ctx);
340
+ return responseToResult(res, maxChars);
341
+ }
342
+ };
343
+ }
344
+ __name(createRouteTool, "createRouteTool");
345
+
346
+ // src/core/server.ts
347
+ var SUPPORTED_PROTOCOL_VERSIONS = [
348
+ "2025-11-25",
349
+ "2025-06-18",
350
+ "2025-03-26",
351
+ "2024-11-05"
352
+ ];
353
+ var LATEST_PROTOCOL_VERSION = SUPPORTED_PROTOCOL_VERSIONS[0];
354
+ var PARSE_ERROR = -32700;
355
+ var INVALID_REQUEST = -32600;
356
+ var METHOD_NOT_FOUND = -32601;
357
+ var INVALID_PARAMS = -32602;
358
+ var ok = /* @__PURE__ */ __name((id, result) => ({
359
+ jsonrpc: "2.0",
360
+ id,
361
+ result
362
+ }), "ok");
363
+ var fail = /* @__PURE__ */ __name((id, code, message) => ({
364
+ jsonrpc: "2.0",
365
+ id,
366
+ error: {
367
+ code,
368
+ message
369
+ }
370
+ }), "fail");
371
+ var McpServer = class {
372
+ static {
373
+ __name(this, "McpServer");
374
+ }
375
+ options;
376
+ tools = /* @__PURE__ */ new Map();
377
+ loaders = [];
378
+ constructor(options) {
379
+ this.options = options;
380
+ }
381
+ /** Register a tool. Throws on duplicate names. */
382
+ addTool(tool) {
383
+ if (this.tools.has(tool.name)) {
384
+ throw new Error(`mcp-expose: duplicate tool name "${tool.name}". Set an explicit \`name\`.`);
385
+ }
386
+ this.tools.set(tool.name, tool);
387
+ return this;
388
+ }
389
+ /** Register a function that adds tools lazily, right before the first MCP request is served. */
390
+ onLoad(loader) {
391
+ this.loaders.push(loader);
392
+ return this;
393
+ }
394
+ async listTools() {
395
+ await this.load();
396
+ return [
397
+ ...this.tools.values()
398
+ ];
399
+ }
400
+ async load() {
401
+ if (!this.loaders.length) return;
402
+ const loaders = this.loaders;
403
+ this.loaders = [];
404
+ for (const l of loaders) await l();
405
+ }
406
+ /** Handle one JSON-RPC message (or a batch). Returns null when no response is due. */
407
+ async handleMessage(message, ctx) {
408
+ if (Array.isArray(message)) {
409
+ const results = (await Promise.all(message.map((m) => this.handleOne(m, ctx)))).filter((r) => r !== null);
410
+ return results.length ? results : null;
411
+ }
412
+ return this.handleOne(message, ctx);
413
+ }
414
+ async handleOne(message, ctx) {
415
+ const msg = message;
416
+ if (!msg || typeof msg !== "object" || msg.jsonrpc !== "2.0") {
417
+ return fail(null, INVALID_REQUEST, "Invalid JSON-RPC message");
418
+ }
419
+ if (typeof msg.method !== "string" || msg.id === void 0) return null;
420
+ const id = msg.id;
421
+ const params = msg.params ?? {};
422
+ await this.load();
423
+ switch (msg.method) {
424
+ case "initialize": {
425
+ const requested = params.protocolVersion;
426
+ const protocolVersion = requested && SUPPORTED_PROTOCOL_VERSIONS.includes(requested) ? requested : LATEST_PROTOCOL_VERSION;
427
+ return ok(id, {
428
+ protocolVersion,
429
+ capabilities: {
430
+ tools: {
431
+ listChanged: false
432
+ }
433
+ },
434
+ serverInfo: {
435
+ name: this.options.name,
436
+ version: this.options.version ?? "1.0.0"
437
+ },
438
+ ...this.options.instructions ? {
439
+ instructions: this.options.instructions
440
+ } : {}
441
+ });
442
+ }
443
+ case "ping":
444
+ return ok(id, {});
445
+ case "tools/list":
446
+ return ok(id, {
447
+ tools: [
448
+ ...this.tools.values()
449
+ ].map((t) => ({
450
+ name: t.name,
451
+ ...t.title ? {
452
+ title: t.title
453
+ } : {},
454
+ description: t.description,
455
+ inputSchema: t.inputSchema,
456
+ ...t.annotations ? {
457
+ annotations: t.annotations
458
+ } : {}
459
+ }))
460
+ });
461
+ case "tools/call": {
462
+ const tool = this.tools.get(params.name);
463
+ if (!tool) return fail(id, INVALID_PARAMS, `Unknown tool: ${String(params.name)}`);
464
+ return ok(id, await this.callTool(tool, params.arguments ?? {}, ctx));
465
+ }
466
+ case "resources/list":
467
+ return ok(id, {
468
+ resources: []
469
+ });
470
+ case "prompts/list":
471
+ return ok(id, {
472
+ prompts: []
473
+ });
474
+ default:
475
+ return fail(id, METHOD_NOT_FOUND, `Method not found: ${msg.method}`);
476
+ }
477
+ }
478
+ async callTool(tool, args, ctx) {
479
+ try {
480
+ if (tool.validate) {
481
+ const v = await tool.validate(args);
482
+ if (!v.ok) return {
483
+ isError: true,
484
+ content: [
485
+ {
486
+ type: "text",
487
+ text: `Invalid arguments: ${v.message}`
488
+ }
489
+ ]
490
+ };
491
+ args = v.value;
492
+ }
493
+ return await tool.handler(args, ctx);
494
+ } catch (err) {
495
+ return {
496
+ isError: true,
497
+ content: [
498
+ {
499
+ type: "text",
500
+ text: `Tool error: ${err.message}`
501
+ }
502
+ ]
503
+ };
504
+ }
505
+ }
506
+ /** Check the Origin header (DNS rebinding protection). */
507
+ isOriginAllowed(origin) {
508
+ if (!origin) return true;
509
+ const allowed = this.options.allowedOrigins;
510
+ if (allowed === "*") return true;
511
+ return (allowed ?? []).includes(origin);
512
+ }
513
+ /**
514
+ * Framework-neutral Streamable HTTP handler. Adapters convert their request
515
+ * into McpHttpRequest, call this, and write the McpHttpResponse back.
516
+ */
517
+ async handleHttp(req, ctx) {
518
+ const json = {
519
+ "content-type": "application/json"
520
+ };
521
+ if (!this.isOriginAllowed(req.headers.origin)) {
522
+ return {
523
+ status: 403,
524
+ headers: json,
525
+ body: JSON.stringify(fail(null, INVALID_REQUEST, "Origin not allowed"))
526
+ };
527
+ }
528
+ if (req.method.toUpperCase() !== "POST") {
529
+ return {
530
+ status: 405,
531
+ headers: {
532
+ allow: "POST"
533
+ }
534
+ };
535
+ }
536
+ let body = req.body;
537
+ if (typeof body === "string" || body instanceof Uint8Array) {
538
+ try {
539
+ body = JSON.parse(typeof body === "string" ? body : new TextDecoder().decode(body));
540
+ } catch {
541
+ return {
542
+ status: 400,
543
+ headers: json,
544
+ body: JSON.stringify(fail(null, PARSE_ERROR, "Parse error"))
545
+ };
546
+ }
547
+ }
548
+ const response = await this.handleMessage(body, ctx);
549
+ if (response === null) return {
550
+ status: 202,
551
+ headers: {}
552
+ };
553
+ return {
554
+ status: 200,
555
+ headers: json,
556
+ body: JSON.stringify(response)
557
+ };
558
+ }
559
+ };
560
+
561
+ // src/fastify/index.ts
562
+ var fastifyMcp = /* @__PURE__ */ __name((instance, options, done) => {
563
+ const fastify = instance;
564
+ const server = new McpServer(options);
565
+ const path = options.path ?? "/mcp";
566
+ const dispatch = /* @__PURE__ */ __name(async (req, ctx) => {
567
+ const url = new URL(buildUrl("http://localhost", req));
568
+ const res = await fastify.inject({
569
+ method: req.method,
570
+ url: url.pathname + url.search,
571
+ headers: req.headers,
572
+ payload: req.body === void 0 ? void 0 : JSON.stringify(req.body),
573
+ remoteAddress: ctx.clientIp
574
+ });
575
+ return {
576
+ status: res.statusCode,
577
+ headers: normalizeHeaders(res.headers),
578
+ body: res.body
579
+ };
580
+ }, "dispatch");
581
+ for (const t of options.tools ?? []) server.addTool(t);
582
+ fastify.addHook("onRoute", (route) => {
583
+ const mcp = route.config?.mcp;
584
+ if (!mcp) return;
585
+ const opts = mcp === true ? {} : mcp;
586
+ const methods = (Array.isArray(route.method) ? route.method : [
587
+ route.method
588
+ ]).filter((m) => m !== "HEAD");
589
+ for (const method of methods) {
590
+ server.addTool(createRouteTool({
591
+ method,
592
+ path: route.url
593
+ }, {
594
+ params: route.schema?.params,
595
+ query: route.schema?.querystring ?? route.schema?.query,
596
+ body: route.schema?.body,
597
+ ...opts
598
+ }, dispatch, options));
599
+ }
600
+ });
601
+ fastify.decorate("mcpServer", server);
602
+ fastify.route({
603
+ method: [
604
+ "GET",
605
+ "POST",
606
+ "DELETE"
607
+ ],
608
+ url: path,
609
+ ...options.routeOptions,
610
+ handler: /* @__PURE__ */ __name(async (request, reply) => {
611
+ const ctx = {
612
+ headers: normalizeHeaders(request.headers),
613
+ clientIp: request.ip,
614
+ raw: request
615
+ };
616
+ const out = await server.handleHttp({
617
+ method: request.method,
618
+ headers: ctx.headers,
619
+ body: request.body
620
+ }, ctx);
621
+ reply.code(out.status);
622
+ reply.headers(out.headers);
623
+ return reply.send(out.body);
624
+ }, "handler")
625
+ });
626
+ done();
627
+ }, "fastifyMcp");
628
+ fastifyMcp[/* @__PURE__ */ Symbol.for("skip-override")] = true;
629
+ fastifyMcp[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "mcp-expose";
630
+ var fastify_default = fastifyMcp;
631
+ export {
632
+ fastify_default as default,
633
+ fastifyMcp
634
+ };
635
+ //# sourceMappingURL=index.js.map