Check Server Status
server_statusCheck PricePilot server health and data freshness to verify category seeding is current (within 10 days). Returns degraded status with reason if overdue.
Instructions
Report PricePilot server health, data freshness, and degraded-state reason.
Use to check whether category seeding is current (staleness threshold is 10 days) before trusting downstream tool output. Returns degraded status with reason if data is overdue; healthy otherwise.
Returns: server (name), version, status (healthy / degraded), categories_available, data_freshness (ISO timestamp of last seed), degraded_reason (null if healthy).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- pricepilot_mcp/server.py:560-609 (handler)The server_status() function — the actual tool handler that checks DB for latest category seed, computes freshness/age, and returns health status or degraded reason.
def server_status() -> dict: """Report PricePilot server health, data freshness, and degraded-state reason. Use to check whether category seeding is current (staleness threshold is 10 days) before trusting downstream tool output. Returns degraded status with reason if data is overdue; healthy otherwise. Returns: server (name), version, status (healthy / degraded), categories_available, data_freshness (ISO timestamp of last seed), degraded_reason (null if healthy). """ rate_err = _check_rate_limit() if rate_err: return {"error": rate_err} db = SessionLocal() try: from sqlalchemy import func latest = db.query(func.max(CategoryBenchmark.captured_at)).scalar() categories_with_data = ( db.query(CategoryBenchmark.category_id).distinct().count() ) status = "healthy" degraded_reason = None if latest is None: status = "degraded" degraded_reason = "No category data seeded yet" else: age_days = (datetime.now(timezone.utc) - latest).days if age_days > STALE_THRESHOLD_DAYS: status = "degraded" degraded_reason = f"Category seeding overdue ({age_days} days since last seed)" return { "server": "pricepilot", "version": SERVER_VERSION, "status": status, "categories_available": categories_with_data, "data_freshness": f"Last seeded: {latest.isoformat() if latest else 'never'}", "degraded_reason": degraded_reason, } finally: db.close() - pricepilot_mcp/server.py:227-234 (registration)Tool registration in SERVER_CARD dict — declares the 'server_status' tool name and description for MCP discovery.
{ "name": "server_status", "description": "Server health + data-freshness check (degraded if category seed is stale).", }, ], "resources": [], "prompts": [], } - pricepilot_mcp/server.py:559-559 (registration)@mcp.tool decorator registering server_status as an MCP tool with title 'Check Server Status' and READ_ONLY annotation.
@mcp.tool(title="Check Server Status", annotations=READ_ONLY) - pricepilot_mcp/models.py:16-27 (schema)CategoryBenchmark model — the DB table queried by server_status() to get the latest captured_at timestamp and category count.
from .db import Base def _utcnow() -> datetime: return datetime.now(timezone.utc) def _new_id() -> str: return uuid.uuid4().hex class CategoryBenchmark(Base):