Skip to content

Commit ed4aecb

Browse files
committed
health endpoint added
1 parent 70cefee commit ed4aecb

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

mock-client/test-health.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env node
2+
3+
import http from 'http';
4+
5+
const port = process.env.MCP_PORT || 3000;
6+
7+
// Simple health check test
8+
const options = {
9+
hostname: 'localhost',
10+
port: port,
11+
path: '/health',
12+
method: 'GET'
13+
};
14+
15+
const req = http.request(options, (res) => {
16+
console.log(`Health check status: ${res.statusCode}`);
17+
console.log(`Headers:`, res.headers);
18+
19+
let data = '';
20+
res.on('data', (chunk) => {
21+
data += chunk;
22+
});
23+
24+
res.on('end', () => {
25+
try {
26+
const response = JSON.parse(data);
27+
console.log('Health response:', JSON.stringify(response, null, 2));
28+
} catch (e) {
29+
console.log('Raw response:', data);
30+
}
31+
process.exit(0);
32+
});
33+
});
34+
35+
req.on('error', (err) => {
36+
console.error('Health check failed:', err.message);
37+
process.exit(1);
38+
});
39+
40+
req.end();

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ if (useHttp) {
256256

257257
const url = new URL(req.url!, `http://localhost:${port}`);
258258

259+
// Health check endpoint for K8s/Docker
260+
if (url.pathname === '/health') {
261+
res.writeHead(200, { 'Content-Type': 'application/json' });
262+
res.end(JSON.stringify({
263+
status: 'healthy',
264+
service: 'socket-mcp',
265+
version: VERSION,
266+
timestamp: new Date().toISOString()
267+
}));
268+
return;
269+
}
270+
259271
if (url.pathname === '/mcp') {
260272
if (req.method === 'POST') {
261273
// Handle JSON-RPC messages

0 commit comments

Comments
 (0)