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.
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +6 -3
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +4 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
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 &&
|
|
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
|
});
|
package/dist/esm/index.d.ts
CHANGED
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 {
|
|
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);
|