visum_health_check
Check the health and status of the VisumPy instance to ensure proper functionality and identify any issues.
Instructions
Check the health and status of the VisumPy instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index-backup.ts:714-776 (handler)Primary MCP tool registration and handler implementation for 'visum_health_check'. Calls controller health check and network stats methods, formats detailed health report.server.tool( "visum_health_check", "Check the health and status of the VisumPy instance", {}, async () => { try { // First check persistent process health const healthResult = await visumController.checkInstanceHealth(); const statsResult = await visumController.getNetworkStats(); if (statsResult.success && healthResult.success) { const nodes = statsResult.result?.nodes || 0; const isHealthy = nodes > 0; const isPersistent = statsResult.result?.persistent === true; const queryTime = statsResult.result?.query_time_ms || 0; const performance = queryTime < 50 ? 'Ultra-Veloce ๐' : queryTime < 200 ? 'Veloce โก' : queryTime < 1000 ? 'Normale' : 'Lenta'; return { content: [ { type: "text", text: `${isHealthy ? '๐' : 'โ ๏ธ'} **Controllo Salute Istanza VisumPy PERSISTENTE**\n\n` + `**Stato:** ${isHealthy ? 'ATTIVO e PERSISTENTE โ ' : 'Attenzione โ ๏ธ'}\n` + `**Performance:** ${performance}\n` + `**Tempo Query:** ${queryTime.toFixed(1)}ms\n` + `**Tempo Totale:** ${statsResult.executionTimeMs?.toFixed(3) || 'N/A'}ms\n` + `**Persistente:** ${isPersistent ? 'โ Sร' : 'โ NO'}\n\n` + `**Dettagli Istanza:**\n` + `โข **Nodi Disponibili:** ${nodes.toLocaleString()}\n` + `โข **Link Disponibili:** ${statsResult.result?.links?.toLocaleString() || 'N/A'}\n` + `โข **Zone Disponibili:** ${statsResult.result?.zones?.toLocaleString() || 'N/A'}\n` + `โข **Richieste Processate:** ${healthResult.result?.requestCount || 0}\n` + `โข **Progetto Caricato:** ${healthResult.result?.projectLoaded ? 'โ Sร' : 'โ NO'}\n\n` + `*${isHealthy && isPersistent ? '๐ Istanza persistente pronta - Performance ultra-veloce garantita!' : 'Istanza potrebbe necessitare reinizializzazione'}*` } ] }; } else { return { content: [ { type: "text", text: `โ **Istanza VisumPy Non Sana**\n\n` + `L'istanza VisumPy non risponde o non รจ inizializzata.\n` + `Prova a eseguire visum_network_stats per inizializzare l'istanza.` } ] }; } } catch (error) { return { content: [ { type: "text", text: `โ **Errore controllo salute:**\n\n${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- Helper method getNetworkStats() called by the visum_health_check handler to retrieve ultra-fast network statistics from the persistent VisumPy instance.public async getNetworkStats(): Promise<VisumResponse> { const code = ` # Ultra-fast network statistics from persistent instance start_time = time.time() nodes = visum.Net.Nodes.Count links = visum.Net.Links.Count zones = visum.Net.Zones.Count elapsed = time.time() - start_time result = { 'nodes': nodes, 'links': links, 'zones': zones, 'query_time_ms': round(elapsed * 1000, 3), 'persistent': True } `; return this.sendCommandToPersistentProcess(code, "Network statistics (persistent)"); }
- Core helper method checkInstanceHealth() that pings the persistent VisumPy process via stdin to verify instance health and responsiveness.public async checkInstanceHealth(): Promise<VisumResponse> { if (!this.isInstanceActive || !this.persistentProcess || this.persistentProcess.killed) { return { success: false, error: "Persistent process not running" }; } const requestId = (++this.requestCounter).toString(); return new Promise((resolve, reject) => { // Store the request this.pendingRequests.set(requestId, { resolve, reject }); // Send ping command const pingCommand = { type: 'ping', id: requestId, timestamp: Date.now() }; const commandJson = JSON.stringify(pingCommand) + '\n'; console.error(`๐ฉบ Sending health check ${requestId}`); this.persistentProcess?.stdin?.write(commandJson); // Set timeout for ping setTimeout(() => { if (this.pendingRequests.has(requestId)) { this.pendingRequests.delete(requestId); resolve({ success: false, error: "Health check timeout" }); } }, 5000); // 5 second timeout for ping }); }
- src/index-backup.ts:715-715 (registration)Tool name registration in server.tool call."visum_health_check",
- src/index-backup.ts:717-717 (schema)Empty input schema (no parameters required).{},