@leanmcp/core 0.3.7 → 0.3.8
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/index.js +29 -4
- package/dist/index.mjs +29 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -812,8 +812,29 @@ async function createHTTPServer(serverInput, options) {
|
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
}, "handleMCPRequestStateless");
|
|
815
|
-
|
|
816
|
-
|
|
815
|
+
app.get("/mcp", async (req, res) => {
|
|
816
|
+
const acceptHeader = req.headers["accept"] || "";
|
|
817
|
+
if (acceptHeader.includes("text/event-stream")) {
|
|
818
|
+
if (!isStateless) {
|
|
819
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
820
|
+
if (sessionId && transports[sessionId]) {
|
|
821
|
+
const transport = transports[sessionId];
|
|
822
|
+
logger.info(`GET /mcp SSE request (session: ${sessionId.substring(0, 8)}...)`);
|
|
823
|
+
await transport.handleRequest(req, res);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
res.status(405).json({
|
|
828
|
+
jsonrpc: "2.0",
|
|
829
|
+
error: {
|
|
830
|
+
code: -32e3,
|
|
831
|
+
message: "SSE streaming not supported in stateless mode or invalid session"
|
|
832
|
+
},
|
|
833
|
+
id: null
|
|
834
|
+
});
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
if (isDashboardEnabled) {
|
|
817
838
|
try {
|
|
818
839
|
const html = await fetchDashboard();
|
|
819
840
|
res.setHeader("Content-Type", "text/html");
|
|
@@ -821,8 +842,12 @@ async function createHTTPServer(serverInput, options) {
|
|
|
821
842
|
} catch (error) {
|
|
822
843
|
res.status(500).send("<h1>Dashboard temporarily unavailable</h1><p>Please try again later.</p>");
|
|
823
844
|
}
|
|
824
|
-
}
|
|
825
|
-
|
|
845
|
+
} else {
|
|
846
|
+
res.status(404).json({
|
|
847
|
+
error: "Dashboard disabled"
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
});
|
|
826
851
|
if (isStateless) {
|
|
827
852
|
app.post("/mcp", handleMCPRequestStateless);
|
|
828
853
|
app.delete("/mcp", (_req, res) => {
|
package/dist/index.mjs
CHANGED
|
@@ -774,8 +774,29 @@ async function createHTTPServer(serverInput, options) {
|
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
776
|
}, "handleMCPRequestStateless");
|
|
777
|
-
|
|
778
|
-
|
|
777
|
+
app.get("/mcp", async (req, res) => {
|
|
778
|
+
const acceptHeader = req.headers["accept"] || "";
|
|
779
|
+
if (acceptHeader.includes("text/event-stream")) {
|
|
780
|
+
if (!isStateless) {
|
|
781
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
782
|
+
if (sessionId && transports[sessionId]) {
|
|
783
|
+
const transport = transports[sessionId];
|
|
784
|
+
logger.info(`GET /mcp SSE request (session: ${sessionId.substring(0, 8)}...)`);
|
|
785
|
+
await transport.handleRequest(req, res);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
res.status(405).json({
|
|
790
|
+
jsonrpc: "2.0",
|
|
791
|
+
error: {
|
|
792
|
+
code: -32e3,
|
|
793
|
+
message: "SSE streaming not supported in stateless mode or invalid session"
|
|
794
|
+
},
|
|
795
|
+
id: null
|
|
796
|
+
});
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
if (isDashboardEnabled) {
|
|
779
800
|
try {
|
|
780
801
|
const html = await fetchDashboard();
|
|
781
802
|
res.setHeader("Content-Type", "text/html");
|
|
@@ -783,8 +804,12 @@ async function createHTTPServer(serverInput, options) {
|
|
|
783
804
|
} catch (error) {
|
|
784
805
|
res.status(500).send("<h1>Dashboard temporarily unavailable</h1><p>Please try again later.</p>");
|
|
785
806
|
}
|
|
786
|
-
}
|
|
787
|
-
|
|
807
|
+
} else {
|
|
808
|
+
res.status(404).json({
|
|
809
|
+
error: "Dashboard disabled"
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
});
|
|
788
813
|
if (isStateless) {
|
|
789
814
|
app.post("/mcp", handleMCPRequestStateless);
|
|
790
815
|
app.delete("/mcp", (_req, res) => {
|