Get Monitor Statistics
get_monitor_statsRetrieve internal statistics and database activity metrics from the health monitor to assess its own performance and operational status.
Instructions
Get statistics about the health monitor itself, including database activity.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/app.ts:755-775 (handler)The handler function for the 'get_monitor_stats' tool. It queries the SQLite database for total health checks, total registered servers, and the timestamp of the oldest health check, then returns those statistics along with the resolved database path.
async () => { const db = getDb(); const totalChecks = ( db.prepare('SELECT COUNT(*) AS count FROM health_checks').get() as { count: number } ).count; const totalServers = ( db.prepare('SELECT COUNT(*) AS count FROM servers').get() as { count: number } ).count; const oldestCheck = ( db.prepare('SELECT MIN(timestamp) AS timestamp FROM health_checks').get() as { timestamp: number | null; } ).timestamp; return formatResponse({ total_servers_registered: totalServers, total_checks_performed: totalChecks, monitoring_since: oldestCheck ? new Date(oldestCheck).toISOString() : null, db_path: getResolvedDbPath() }); } - src/app.ts:743-776 (registration)Registration of the 'get_monitor_stats' tool with its title, description, input schema (EmptySchema), annotations, and the handler function.
server.registerTool( 'get_monitor_stats', { title: 'Get Monitor Statistics', description: 'Get statistics about the health monitor itself, including database activity.', inputSchema: EmptySchema, annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false } }, async () => { const db = getDb(); const totalChecks = ( db.prepare('SELECT COUNT(*) AS count FROM health_checks').get() as { count: number } ).count; const totalServers = ( db.prepare('SELECT COUNT(*) AS count FROM servers').get() as { count: number } ).count; const oldestCheck = ( db.prepare('SELECT MIN(timestamp) AS timestamp FROM health_checks').get() as { timestamp: number | null; } ).timestamp; return formatResponse({ total_servers_registered: totalServers, total_checks_performed: totalChecks, monitoring_since: oldestCheck ? new Date(oldestCheck).toISOString() : null, db_path: getResolvedDbPath() }); } ); - src/types.ts:78-78 (schema)EmptySchema definition (z.object({})) used as the input schema for 'get_monitor_stats' — no inputs required.
export const EmptySchema = z.object({}); - src/db.ts:58-60 (helper)getResolvedDbPath() helper returns the resolved database path, used in the handler to report db_path.
export function getResolvedDbPath(): string { return resolveDbPath(); } - src/app.ts:81-90 (helper)formatResponse helper wraps the payload in a ToolResponse with JSON text content, used to return the monitor stats.
function formatResponse(payload: unknown): ToolResponse { return { content: [ { type: 'text', text: JSON.stringify(payload, null, 2) } ] }; }