Skip to content

Commit 2992aed

Browse files
authored
feat: add health check endpoint for both sse and streamable http server (#31)
1 parent 1792abf commit 2992aed

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ async function main(): Promise<void> {
9191
}
9292
}
9393

94+
// Add health check endpoint to app
95+
function addHealthCheck(app: express.Express): void {
96+
app.get("/health", (_, res) =>
97+
res.json({ status: "healthy", service: "mcp-echarts" }),
98+
);
99+
}
100+
94101
async function runStdioServer(): Promise<void> {
95102
const server = createEChartsServer();
96103
const transport = new StdioServerTransport();
@@ -127,6 +134,8 @@ async function runSSEServer(port: number, endpoint: string): Promise<void> {
127134
res.status(400).send("No transport found for sessionId");
128135
}
129136
});
137+
// Health check endpoint for SSE
138+
addHealthCheck(app);
130139

131140
app.listen(port, () => {
132141
console.log(
@@ -211,6 +220,8 @@ async function runStreamableHTTPServer(
211220
const transport = transports[sessionId];
212221
await transport.handleRequest(req, res);
213222
});
223+
// Health check point for Streamable HTTP
224+
addHealthCheck(app);
214225

215226
app.listen(port, () => {
216227
console.log(

0 commit comments

Comments
 (0)