Appearance
Health Check โ
Health check endpoint for monitoring Gnosari MCP server status and uptime.
Use cases:
- Integration into monitoring systems (Datadog, New Relic, etc.)
- Kubernetes liveness/readiness probes
- Simple uptime checks
- Verify server connectivity before operations
Key features:
- No authentication required
- Fast, lightweight response
- Returns server version and API URL
gnosari_health โ
Health check for monitoring Gnosari MCP server status.
Annotations: readOnlyHint: true ยท destructiveHint: false ยท idempotentHint: true ยท openWorldHint: false
Parameters โ
None. This endpoint requires no parameters.
Returns โ
typescript
{
status: "healthy",
server: "gnosari-mcp",
version: string,
api_url: string
}Response fields:
status: Always "healthy" if server is respondingserver: Server name identifierversion: Current MCP server versionapi_url: Backend API URL the server connects to
Examples โ
Basic health check:
python
health = gnosari_health()
print(f"Status: {health['status']}")
print(f"Version: {health['version']}")
print(f"API: {health['api_url']}")Monitoring integration:
python
def check_server_health():
try:
health = gnosari_health()
if health["status"] == "healthy":
return True
else:
return False
except Exception as e:
print(f"Health check failed: {e}")
return False
# Use in monitoring loop
import time
while True:
if not check_server_health():
print("ALERT: Server unhealthy!")
time.sleep(60) # Check every minutePre-flight check before operations:
python
# Verify connectivity before heavy operations
health = gnosari_health()
if health["status"] == "healthy":
print(f"Server ready (version {health['version']})")
# Proceed with operations
agents = gnosari_search(query="", entity="agents")
# ...
else:
print("Server not available. Aborting.")Kubernetes readiness probe:
yaml
readinessProbe:
exec:
command:
- /bin/sh
- -c
- |
python -c "
from tools.utility import gnosari_health
health = gnosari_health()
exit(0 if health['status'] == 'healthy' else 1)
"
initialDelaySeconds: 5
periodSeconds: 10HTTP Endpoint โ
The health check is also available as an HTTP endpoint for non-MCP clients:
Endpoint: GET /health
Response:
json
{
"status": "healthy",
"server": "gnosari-mcp",
"version": "0.3.0",
"api_url": "https://api.gnosari.com"
}Use cases:
- Kubernetes HTTP probes
- Load balancer health checks
- External monitoring services
Example with curl:
bash
curl http://localhost:8080/healthBest Practices โ
- No authentication - Health check doesn't require credentials for monitoring simplicity
- Fast response - Designed to return quickly for monitoring systems
- Use for uptime checks - Perfect for simple "is it alive?" checks
- Check before batch operations - Verify connectivity before starting long-running tasks
- Monitor API URL - Track if server is connecting to expected backend
Common Patterns โ
Retry Logic with Health Check โ
python
import time
def call_with_retry(operation, max_retries=3):
for attempt in range(max_retries):
# Check health first
health = gnosari_health()
if health["status"] != "healthy":
print(f"Server unhealthy, attempt {attempt + 1}/{max_retries}")
time.sleep(2)
continue
# Attempt operation
try:
return operation()
except Exception as e:
print(f"Operation failed: {e}")
time.sleep(2)
raise Exception("Max retries exceeded")
# Usage
agents = call_with_retry(lambda: gnosari_search(query="", entity="agents"))Version Tracking โ
python
# Track server version for compatibility
health = gnosari_health()
server_version = health["version"]
REQUIRED_VERSION = "0.3.0"
if server_version < REQUIRED_VERSION:
print(f"Warning: Server version {server_version} is below required {REQUIRED_VERSION}")Environment Verification โ
python
# Verify connecting to correct environment
health = gnosari_health()
api_url = health["api_url"]
EXPECTED_API = "https://api.gnosari.com"
if api_url != EXPECTED_API:
print(f"WARNING: Connected to {api_url}, expected {EXPECTED_API}")Response Status โ
The health check always returns "healthy" if the server is running and can respond. If the server is down or unreachable, the call will fail with an exception rather than returning an unhealthy status.
This means:
- Response received = server is healthy
- Exception/timeout = server is unhealthy
Example:
python
try:
health = gnosari_health()
# If we get here, server is healthy
print("โ Server healthy")
except Exception:
# Connection failed = server unhealthy
print("โ Server unreachable")Next Steps โ
- API Overview - Tool relationships and common patterns
- Agent Management Tools - Create, update, delete operations