vite-plugin-swagger-mcp 0.0.19 → 0.0.20

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.
@@ -1,5 +1,6 @@
1
1
  import type { Plugin } from "vite";
2
2
  import { SchemaObject } from "./type";
3
+ export declare const isInitializeRequest: (value: unknown) => boolean;
3
4
  export declare class SwaggerMcpServer {
4
5
  private swaggerUrl;
5
6
  private token?;
package/dist/cjs/index.js CHANGED
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
22
  SwaggerMcpServer: () => SwaggerMcpServer,
23
- default: () => vitePluginSwaggerMcp
23
+ default: () => vitePluginSwaggerMcp,
24
+ isInitializeRequest: () => isInitializeRequest
24
25
  });
25
26
  module.exports = __toCommonJS(src_exports);
26
27
  var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
@@ -34,6 +35,7 @@ async function readJsonBody(req) {
34
35
  body += chunk;
35
36
  return JSON.parse(body || "{}");
36
37
  }
38
+ var isInitializeRequest = (value) => import_types.InitializeRequestParamsSchema.safeParse(value).success;
37
39
  var SwaggerMcpServer = class {
38
40
  constructor(swaggerUrl, token) {
39
41
  this.swaggerUrl = swaggerUrl;
@@ -190,7 +192,7 @@ function vitePluginSwaggerMcp({
190
192
  let transport;
191
193
  if (sessionId && transports[sessionId]) {
192
194
  transport = transports[sessionId];
193
- } else if (!sessionId && (0, import_types.isInitializeRequest)(json)) {
195
+ } else if (!sessionId && isInitializeRequest(json)) {
194
196
  transport = new import_streamableHttp.StreamableHTTPServerTransport({
195
197
  sessionIdGenerator: () => (0, import_node_crypto.randomUUID)(),
196
198
  // 如果你的编辑器不支持 SSE 只能接收 JSON 响应,可以设为 true
@@ -240,5 +242,6 @@ function vitePluginSwaggerMcp({
240
242
  }
241
243
  // Annotate the CommonJS export names for ESM import in node:
242
244
  0 && (module.exports = {
243
- SwaggerMcpServer
245
+ SwaggerMcpServer,
246
+ isInitializeRequest
244
247
  });
@@ -1,5 +1,6 @@
1
1
  import type { Plugin } from "vite";
2
2
  import { SchemaObject } from "./type";
3
+ export declare const isInitializeRequest: (value: unknown) => boolean;
3
4
  export declare class SwaggerMcpServer {
4
5
  private swaggerUrl;
5
6
  private token?;
package/dist/esm/index.js CHANGED
@@ -14,7 +14,7 @@ function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symb
14
14
  function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function _throw(r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
15
15
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
16
16
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
17
- import { isInitializeRequest } from "@modelcontextprotocol/sdk/types";
17
+ import { InitializeRequestParamsSchema } from "@modelcontextprotocol/sdk/types";
18
18
  import { randomUUID } from "node:crypto";
19
19
  import { z } from "zod/v4";
20
20
  // --- 辅助函数:解析 JSON Body ---
@@ -84,6 +84,9 @@ function _readJsonBody() {
84
84
  }));
85
85
  return _readJsonBody.apply(this, arguments);
86
86
  }
87
+ export var isInitializeRequest = function isInitializeRequest(value) {
88
+ return InitializeRequestParamsSchema.safeParse(value).success;
89
+ };
87
90
  export var SwaggerMcpServer = /*#__PURE__*/function () {
88
91
  function SwaggerMcpServer(swaggerUrl, token) {
89
92
  _classCallCheck(this, SwaggerMcpServer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-swagger-mcp",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "vite plugin for swagger mcp",
5
5
  "homepage": "https://github.com/mmdctjj/vite-plugin-swagger-mcp",
6
6
  "repository": {