@ivotoby/openapi-mcp-server 1.10.2 → 1.12.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/bundle.js +27 -2
- package/dist/cli.js +27 -2
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -24024,18 +24024,32 @@ import {
|
|
|
24024
24024
|
import * as http2 from "http";
|
|
24025
24025
|
import { randomUUID } from "crypto";
|
|
24026
24026
|
var StreamableHttpServerTransport = class {
|
|
24027
|
+
// Track if using an external server
|
|
24027
24028
|
/**
|
|
24028
24029
|
* Initialize a new StreamableHttpServerTransport
|
|
24029
24030
|
*
|
|
24030
24031
|
* @param port HTTP port to listen on
|
|
24031
24032
|
* @param host Host to bind to (default: 127.0.0.1)
|
|
24032
24033
|
* @param endpointPath Endpoint path (default: /mcp)
|
|
24034
|
+
* @param server Optional HTTP server instance. If not provided, a new server will be created.
|
|
24035
|
+
* If provided, the transport will attach its request handler to the server.
|
|
24036
|
+
* Note: When using an external server, all handlers added via server.on('request', handler)
|
|
24037
|
+
* will be called for every request, in the order they were added. Custom handlers should be
|
|
24038
|
+
* added FIRST and should fully handle their routes (including sending responses) to prevent
|
|
24039
|
+
* further handlers from running for those requests. The MCP handler should be added after
|
|
24040
|
+
* custom handlers and will return early for non-MCP paths.
|
|
24033
24041
|
*/
|
|
24034
|
-
constructor(port, host = "127.0.0.1", endpointPath = "/mcp") {
|
|
24042
|
+
constructor(port, host = "127.0.0.1", endpointPath = "/mcp", server) {
|
|
24035
24043
|
this.port = port;
|
|
24036
24044
|
this.host = host;
|
|
24037
24045
|
this.endpointPath = endpointPath;
|
|
24038
|
-
this.
|
|
24046
|
+
this.isExternalServer = !!server;
|
|
24047
|
+
if (server) {
|
|
24048
|
+
this.server = server;
|
|
24049
|
+
this.server.on("request", this.handleRequest.bind(this));
|
|
24050
|
+
} else {
|
|
24051
|
+
this.server = http2.createServer(this.handleRequest.bind(this));
|
|
24052
|
+
}
|
|
24039
24053
|
}
|
|
24040
24054
|
server;
|
|
24041
24055
|
sessions = /* @__PURE__ */ new Map();
|
|
@@ -24046,6 +24060,7 @@ var StreamableHttpServerTransport = class {
|
|
|
24046
24060
|
requestSessionMap = /* @__PURE__ */ new Map();
|
|
24047
24061
|
// Maps request IDs to session IDs
|
|
24048
24062
|
healthCheckPath = "/health";
|
|
24063
|
+
isExternalServer;
|
|
24049
24064
|
/**
|
|
24050
24065
|
* Callback when message is received
|
|
24051
24066
|
*/
|
|
@@ -24094,6 +24109,13 @@ var StreamableHttpServerTransport = class {
|
|
|
24094
24109
|
}
|
|
24095
24110
|
}
|
|
24096
24111
|
this.sessions.clear();
|
|
24112
|
+
if (this.isExternalServer) {
|
|
24113
|
+
this.started = false;
|
|
24114
|
+
if (this.onclose) {
|
|
24115
|
+
this.onclose();
|
|
24116
|
+
}
|
|
24117
|
+
return;
|
|
24118
|
+
}
|
|
24097
24119
|
return new Promise((resolve5, reject) => {
|
|
24098
24120
|
this.server.close((err) => {
|
|
24099
24121
|
if (err) {
|
|
@@ -24212,6 +24234,9 @@ var StreamableHttpServerTransport = class {
|
|
|
24212
24234
|
return;
|
|
24213
24235
|
}
|
|
24214
24236
|
if (req.url !== this.endpointPath) {
|
|
24237
|
+
if (this.isExternalServer) {
|
|
24238
|
+
return;
|
|
24239
|
+
}
|
|
24215
24240
|
res.writeHead(404);
|
|
24216
24241
|
res.end();
|
|
24217
24242
|
return;
|
package/dist/cli.js
CHANGED
|
@@ -24024,18 +24024,32 @@ import {
|
|
|
24024
24024
|
import * as http2 from "http";
|
|
24025
24025
|
import { randomUUID } from "crypto";
|
|
24026
24026
|
var StreamableHttpServerTransport = class {
|
|
24027
|
+
// Track if using an external server
|
|
24027
24028
|
/**
|
|
24028
24029
|
* Initialize a new StreamableHttpServerTransport
|
|
24029
24030
|
*
|
|
24030
24031
|
* @param port HTTP port to listen on
|
|
24031
24032
|
* @param host Host to bind to (default: 127.0.0.1)
|
|
24032
24033
|
* @param endpointPath Endpoint path (default: /mcp)
|
|
24034
|
+
* @param server Optional HTTP server instance. If not provided, a new server will be created.
|
|
24035
|
+
* If provided, the transport will attach its request handler to the server.
|
|
24036
|
+
* Note: When using an external server, all handlers added via server.on('request', handler)
|
|
24037
|
+
* will be called for every request, in the order they were added. Custom handlers should be
|
|
24038
|
+
* added FIRST and should fully handle their routes (including sending responses) to prevent
|
|
24039
|
+
* further handlers from running for those requests. The MCP handler should be added after
|
|
24040
|
+
* custom handlers and will return early for non-MCP paths.
|
|
24033
24041
|
*/
|
|
24034
|
-
constructor(port, host = "127.0.0.1", endpointPath = "/mcp") {
|
|
24042
|
+
constructor(port, host = "127.0.0.1", endpointPath = "/mcp", server) {
|
|
24035
24043
|
this.port = port;
|
|
24036
24044
|
this.host = host;
|
|
24037
24045
|
this.endpointPath = endpointPath;
|
|
24038
|
-
this.
|
|
24046
|
+
this.isExternalServer = !!server;
|
|
24047
|
+
if (server) {
|
|
24048
|
+
this.server = server;
|
|
24049
|
+
this.server.on("request", this.handleRequest.bind(this));
|
|
24050
|
+
} else {
|
|
24051
|
+
this.server = http2.createServer(this.handleRequest.bind(this));
|
|
24052
|
+
}
|
|
24039
24053
|
}
|
|
24040
24054
|
server;
|
|
24041
24055
|
sessions = /* @__PURE__ */ new Map();
|
|
@@ -24046,6 +24060,7 @@ var StreamableHttpServerTransport = class {
|
|
|
24046
24060
|
requestSessionMap = /* @__PURE__ */ new Map();
|
|
24047
24061
|
// Maps request IDs to session IDs
|
|
24048
24062
|
healthCheckPath = "/health";
|
|
24063
|
+
isExternalServer;
|
|
24049
24064
|
/**
|
|
24050
24065
|
* Callback when message is received
|
|
24051
24066
|
*/
|
|
@@ -24094,6 +24109,13 @@ var StreamableHttpServerTransport = class {
|
|
|
24094
24109
|
}
|
|
24095
24110
|
}
|
|
24096
24111
|
this.sessions.clear();
|
|
24112
|
+
if (this.isExternalServer) {
|
|
24113
|
+
this.started = false;
|
|
24114
|
+
if (this.onclose) {
|
|
24115
|
+
this.onclose();
|
|
24116
|
+
}
|
|
24117
|
+
return;
|
|
24118
|
+
}
|
|
24097
24119
|
return new Promise((resolve5, reject) => {
|
|
24098
24120
|
this.server.close((err) => {
|
|
24099
24121
|
if (err) {
|
|
@@ -24212,6 +24234,9 @@ var StreamableHttpServerTransport = class {
|
|
|
24212
24234
|
return;
|
|
24213
24235
|
}
|
|
24214
24236
|
if (req.url !== this.endpointPath) {
|
|
24237
|
+
if (this.isExternalServer) {
|
|
24238
|
+
return;
|
|
24239
|
+
}
|
|
24215
24240
|
res.writeHead(404);
|
|
24216
24241
|
res.end();
|
|
24217
24242
|
return;
|