import { config } from '../src/config.js';
async function healthCheck(): Promise<void> {
const baseUrl = `http://${config.server.host === '0.0.0.0' ? '127.0.0.1' : config.server.host}:${config.server.port}`;
console.log(`Checking MCP Context Hub at ${baseUrl}...`);
// Check health endpoint
try {
const res = await fetch(`${baseUrl}/health`);
const data = await res.json();
console.log('Health:', JSON.stringify(data, null, 2));
} catch (err) {
console.error('Health check failed:', err instanceof Error ? err.message : err);
process.exit(1);
}
// Check metrics endpoint
try {
const res = await fetch(`${baseUrl}/metrics`);
const data = await res.json();
console.log('Metrics:', JSON.stringify(data, null, 2));
} catch (err) {
console.error('Metrics check failed:', err instanceof Error ? err.message : err);
}
// Check Ollama
try {
const res = await fetch(`${config.ollama.baseUrl}/api/tags`);
const data = (await res.json()) as { models: { name: string }[] };
console.log(
'Ollama models:',
data.models.map((m) => m.name)
);
} catch (err) {
console.error('Ollama check failed:', err instanceof Error ? err.message : err);
}
}
healthCheck();