We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/DiegoNogueiraDev/mcp-context-hub'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import { Router } from 'express';
import { statSync } from 'node:fs';
import type Database from 'better-sqlite3';
import { config } from '../config.js';
import { logger } from '../utils/logger.js';
const startTime = Date.now();
export function systemRoutes(db: Database.Database): Router {
const router = Router();
router.get('/', async (_req, res) => {
try {
// DB size
let dbSizeBytes = 0;
try {
const stat = statSync(config.db.path);
dbSizeBytes = stat.size;
} catch {
// DB might be :memory: in tests
}
// Uptime
const uptimeMs = Date.now() - startTime;
// Ollama health check
let ollamaHealthy = false;
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);
const resp = await fetch(`${config.ollama.baseUrl}/api/tags`, {
signal: controller.signal,
});
clearTimeout(timeout);
ollamaHealthy = resp.ok;
} catch {
ollamaHealthy = false;
}
// Table row counts
const tableStats = {
documents: (db.prepare('SELECT COUNT(*) as c FROM documents').get() as any).c,
chunks: (db.prepare('SELECT COUNT(*) as c FROM chunks').get() as any).c,
audit_log: (db.prepare('SELECT COUNT(*) as c FROM audit_log').get() as any).c,
dashboard_users: (db.prepare('SELECT COUNT(*) as c FROM dashboard_users').get() as any).c,
dashboard_sessions: (
db.prepare('SELECT COUNT(*) as c FROM dashboard_sessions').get() as any
).c,
metrics_history: (db.prepare('SELECT COUNT(*) as c FROM metrics_history').get() as any).c,
};
res.json({
uptimeMs,
uptimeFormatted: formatUptime(uptimeMs),
dbSizeBytes,
dbSizeFormatted: formatBytes(dbSizeBytes),
ollamaHealthy,
ollamaUrl: config.ollama.baseUrl,
tableStats,
nodeVersion: process.version,
platform: process.platform,
memoryUsage: process.memoryUsage(),
});
} catch (err) {
logger.error({ err }, 'Failed to fetch system info');
res.status(500).json({ error: 'Failed to fetch system info' });
}
});
return router;
}
function formatUptime(ms: number): string {
const seconds = Math.floor(ms / 1000);
const days = Math.floor(seconds / 86400);
const hours = Math.floor((seconds % 86400) / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const parts: string[] = [];
if (days > 0) parts.push(`${days}d`);
if (hours > 0) parts.push(`${hours}h`);
if (minutes > 0) parts.push(`${minutes}m`);
if (parts.length === 0) parts.push(`${seconds}s`);
return parts.join(' ');
}
function formatBytes(bytes: number): string {
if (bytes === 0) return '0 B';
const k = 1024;
const sizes = ['B', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
}