(defcomp (&key (title "Services") &rest extra)
  (~docs/page :title title
    (p (~tw :tokens "text-stone-500 text-sm italic mb-8")
      "Python-based MCP server for understanding the rose-ash microservice topology. Static analysis — works without running services.")
    (~docs/section :title "Service introspection" :id "introspection"
      (p "The rose-ash-services MCP server provides 12 tools for exploring the microservice architecture. Every tool operates via static analysis of the codebase — no running containers needed.")
      (table (~tw :tokens "min-w-full text-sm mb-6")
        (thead
          (tr
            (th (~tw :tokens "text-left pr-4 pb-2 font-semibold text-stone-700") "Tool")
            (th (~tw :tokens "text-left pb-2 font-semibold text-stone-700") "Purpose")))
        (tbody (~tw :tokens "text-stone-600")
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_status")
            (td (~tw :tokens "py-1") "Docker container status for all rose-ash services."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_routes")
            (td (~tw :tokens "py-1") "List all HTTP routes for a service by scanning blueprints."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_calls")
            (td (~tw :tokens "py-1") "Map inter-service calls: fetch_data, call_action, send_internal_activity, fetch_fragment."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_config")
            (td (~tw :tokens "py-1") "Environment variables and config for a service."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_models")
            (td (~tw :tokens "py-1") "SQLAlchemy models, columns, and relationships for a service."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_schema")
            (td (~tw :tokens "py-1") "Live defquery/defaction manifest from a running service."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_queries")
            (td (~tw :tokens "py-1") "List all defquery definitions from queries.sx files."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_actions")
            (td (~tw :tokens "py-1") "List all defaction definitions from actions.sx files."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "alembic_status")
            (td (~tw :tokens "py-1") "Migration count and latest migration per service."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_logs")
            (td (~tw :tokens "py-1") "Recent Docker logs for a service."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_start")
            (td (~tw :tokens "py-1") "Start services via dev.sh."))
          (tr
            (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "svc_stop")
            (td (~tw :tokens "py-1") "Stop all services.")))))
    (~docs/section :title "Service topology" :id "topology"
      (p "The rose-ash platform runs as independent Quart microservices, each with its own database. Services communicate via HMAC-signed internal HTTP and ActivityPub events.")
      (table (~tw :tokens "min-w-full text-sm mb-6")
        (thead
          (tr
            (th (~tw :tokens "text-left pr-4 pb-2 font-semibold text-stone-700") "Service")
            (th (~tw :tokens "text-left pr-4 pb-2 font-semibold text-stone-700") "Domain")
            (th (~tw :tokens "text-left pb-2 font-semibold text-stone-700") "Port")))
        (tbody (~tw :tokens "text-stone-600")
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "blog") (td (~tw :tokens "pr-4 py-1") "Content management, Ghost CMS sync") (td (~tw :tokens "py-1") "8001"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "market") (td (~tw :tokens "pr-4 py-1") "Product catalog, marketplace") (td (~tw :tokens "py-1") "8002"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "cart") (td (~tw :tokens "pr-4 py-1") "Shopping cart, checkout") (td (~tw :tokens "py-1") "8003"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "events") (td (~tw :tokens "pr-4 py-1") "Calendar, ticketing") (td (~tw :tokens "py-1") "8004"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "federation") (td (~tw :tokens "pr-4 py-1") "ActivityPub social hub") (td (~tw :tokens "py-1") "8005"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "account") (td (~tw :tokens "pr-4 py-1") "OAuth2, user dashboard") (td (~tw :tokens "py-1") "8006"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "orders") (td (~tw :tokens "pr-4 py-1") "Order history, SumUp payments") (td (~tw :tokens "py-1") "8010"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "relations") (td (~tw :tokens "pr-4 py-1") "Cross-domain relationship tracking (internal)") (td (~tw :tokens "py-1") "8008"))
          (tr (td (~tw :tokens "pr-4 py-1 font-mono text-xs") "likes") (td (~tw :tokens "pr-4 py-1") "Unified like/favourite tracking (internal)") (td (~tw :tokens "py-1") "8009")))))
    (~docs/section :title "Inter-service communication" :id "communication"
      (p "Services communicate through three mechanisms, all HMAC-signed:")
      (h4 (~tw :tokens "font-semibold text-stone-700 mt-6 mb-2") "Data queries")
      (p "Read-only cross-service data via GET /internal/data/{query}. 3-second timeout. Used for fetching data owned by another service.")
      (~docs/code :src ";; Example: blog fetching product data from market\nfetch_data(\"market\", \"products-by-category\", {\"category\": \"prints\"})")
      (h4 (~tw :tokens "font-semibold text-stone-700 mt-6 mb-2") "Actions")
      (p "Write operations via POST /internal/actions/{action}. 5-second timeout. Used when one service needs to trigger a state change in another.")
      (~docs/code :src ";; Example: cart creating an order in the orders service\ncall_action(\"orders\", \"create-order\", {\"items\": [...], \"customer\": ...})")
      (h4 (~tw :tokens "font-semibold text-stone-700 mt-6 mb-2") "ActivityPub inbox")
      (p "AP-shaped activities via POST /internal/inbox. Used for cross-service writes that follow the ActivityPub pattern — Create, Update, Delete activities with typed objects."))))
