Health Checks
Report whether a dependency is working with @health_check and the health://status resource
A health check is a small method that answers one question: is this dependency working? You write one for the things your server can't run without, such as a database or an upstream API, and NitroStack collects the answers in one place.
Define a health check
Mark a method with @health_check and give the check a name. The method returns True when things are fine and False when they aren't. It can be sync or async.
import time
from nitrostack import health_check
class SystemHealthCheck:
def __init__(self):
self.start_time = time.time()
@health_check("system")
def check_system(self) -> bool:
return time.time() - self.start_time >= 0Register the class as a provider so NitroStack can find its checks:
@module(name="app", providers=[SystemHealthCheck])
class AppModule:
passRead the results
Every registered check runs when a client reads the health://status resource. The result is a JSON object with one entry per check:
{ "system": "healthy" }A check that returns False reports "unhealthy", and a check that raises an error reports "error: <message>".
You can read it from NitroStudio or from any MCP client.
The /mcp/health endpoint
Over HTTP, the server also serves /mcp/health. It tells a load balancer or an orchestrator that the server is up, and reports the transport and protocol version. It doesn't run your health checks; use health://status for those.
