vite-plugin-swagger-mcp 0.0.3 → 0.0.5
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.js +8 -4
- package/dist/esm/index.js +3 -3
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -125,7 +125,7 @@ var SwaggerMcpServer = class {
|
|
|
125
125
|
const op = (_a = doc.paths[path]) == null ? void 0 : _a[method.toLowerCase()];
|
|
126
126
|
if (!op)
|
|
127
127
|
throw new Error("接口不存在");
|
|
128
|
-
const originalRef = (_d = (_c = (_b = doc.paths[path][method].responses) == null ? void 0 : _b["200"]) == null ? void 0 : _c.schema) == null ? void 0 : _d.originalRef;
|
|
128
|
+
const originalRef = (_d = (_c = (_b = doc.paths[path][method.toLowerCase()].responses) == null ? void 0 : _b["200"]) == null ? void 0 : _c.schema) == null ? void 0 : _d.originalRef;
|
|
129
129
|
const resolvedDefinition = this.resolveRef(doc, originalRef);
|
|
130
130
|
return {
|
|
131
131
|
path,
|
|
@@ -144,6 +144,7 @@ function vitePluginSwaggerMcp({
|
|
|
144
144
|
name: "vite-plugin-swagger-mcp",
|
|
145
145
|
enforce: "pre",
|
|
146
146
|
async configureServer(server) {
|
|
147
|
+
var _a, _b;
|
|
147
148
|
try {
|
|
148
149
|
let transport = new import_streamableHttp.StreamableHTTPServerTransport({
|
|
149
150
|
sessionIdGenerator: () => (0, import_node_crypto.randomUUID)(),
|
|
@@ -211,11 +212,14 @@ function vitePluginSwaggerMcp({
|
|
|
211
212
|
})
|
|
212
213
|
);
|
|
213
214
|
await mcpServer.connect(transport);
|
|
214
|
-
console.log(
|
|
215
|
+
console.log(
|
|
216
|
+
"MCP server connected:",
|
|
217
|
+
`http://localhost:${(_b = (_a = server.config) == null ? void 0 : _a.server) == null ? void 0 : _b.port}/_mcp/sse/swagger`
|
|
218
|
+
);
|
|
215
219
|
server.middlewares.use(
|
|
216
220
|
async (req, res, next) => {
|
|
217
|
-
var
|
|
218
|
-
if (req.method === "POST" && ((
|
|
221
|
+
var _a2;
|
|
222
|
+
if (req.method === "POST" && ((_a2 = req.url) == null ? void 0 : _a2.startsWith("/_mcp/sse/swagger"))) {
|
|
219
223
|
if (!req.headers["mcp-session-id"] && transport.sessionId) {
|
|
220
224
|
req.headers["mcp-session-id"] = transport.sessionId;
|
|
221
225
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -204,7 +204,7 @@ export var SwaggerMcpServer = /*#__PURE__*/function () {
|
|
|
204
204
|
}
|
|
205
205
|
throw new Error("接口不存在");
|
|
206
206
|
case 6:
|
|
207
|
-
originalRef = (_doc$paths$path$metho3 = doc.paths[path][method].responses) === null || _doc$paths$path$metho3 === void 0 || (_doc$paths$path$metho3 = _doc$paths$path$metho3["200"]) === null || _doc$paths$path$metho3 === void 0 || (_doc$paths$path$metho3 = _doc$paths$path$metho3.schema) === null || _doc$paths$path$metho3 === void 0 ? void 0 : _doc$paths$path$metho3.originalRef;
|
|
207
|
+
originalRef = (_doc$paths$path$metho3 = doc.paths[path][method.toLowerCase()].responses) === null || _doc$paths$path$metho3 === void 0 || (_doc$paths$path$metho3 = _doc$paths$path$metho3["200"]) === null || _doc$paths$path$metho3 === void 0 || (_doc$paths$path$metho3 = _doc$paths$path$metho3.schema) === null || _doc$paths$path$metho3 === void 0 ? void 0 : _doc$paths$path$metho3.originalRef;
|
|
208
208
|
resolvedDefinition = this.resolveRef(doc, originalRef);
|
|
209
209
|
return _context4.abrupt("return", _objectSpread(_objectSpread({
|
|
210
210
|
path: path,
|
|
@@ -237,7 +237,7 @@ export default function vitePluginSwaggerMcp(_ref) {
|
|
|
237
237
|
enforce: "pre",
|
|
238
238
|
configureServer: function configureServer(server) {
|
|
239
239
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
240
|
-
var transport, swaggerServer, mcpServer;
|
|
240
|
+
var _server$config, transport, swaggerServer, mcpServer;
|
|
241
241
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
242
242
|
while (1) switch (_context9.prev = _context9.next) {
|
|
243
243
|
case 0:
|
|
@@ -372,7 +372,7 @@ export default function vitePluginSwaggerMcp(_ref) {
|
|
|
372
372
|
_context9.next = 10;
|
|
373
373
|
return mcpServer.connect(transport);
|
|
374
374
|
case 10:
|
|
375
|
-
console.log("MCP server connected");
|
|
375
|
+
console.log("MCP server connected:", "http://localhost:".concat((_server$config = server.config) === null || _server$config === void 0 || (_server$config = _server$config.server) === null || _server$config === void 0 ? void 0 : _server$config.port, "/_mcp/sse/swagger"));
|
|
376
376
|
server.middlewares.use( /*#__PURE__*/function () {
|
|
377
377
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, res, next) {
|
|
378
378
|
var _req$url;
|