# quarkd — Machine-Readable Agent Install & MCP Contract # Canonical URL: https://quarkd.dev/llms.txt # Version: v0.5.1 # Repository: https://github.com/gig3m/quarkd # License: AGPL-3.0-only > quarkd is a single-binary (~7.8 MB static musl) Rust web analytics engine running in ~6–10 MiB RAM with embedded WAL SQLite, offline auto-updating DB-IP City + ASN Lite enrichment, 813-byte first-party `/_q.js` beacon, live official AI crawler CIDR verification (454+ CIDRs), and a built-in 13-tool JSON-RPC 2.0 MCP server (`POST /mcp`). ## Docs Index - Quickstart (Standalone): https://quarkd.dev/docs/ - Coding-Agent Install Prompts (all 5 vectors): https://quarkd.dev/docs/agent-install.html - Collection Vectors & First-Party `/_q.js`: https://quarkd.dev/docs/vectors.html - Built-in MCP Server (13 Tools): https://quarkd.dev/docs/mcp.html - Configuration, Goals & Webhooks: https://quarkd.dev/docs/configuration.html - CLI & Operations Reference: https://quarkd.dev/docs/cli.html - Architecture & Traffic Model: https://quarkd.dev/docs/architecture.html ## Install Static Binary (Linux x86_64 musl / macOS arm64) ```sh curl -fsSL https://raw.githubusercontent.com/gig3m/quarkd/main/scripts/install.sh | sh ``` Environment overrides: `QUARKD_VERSION=v0.5.1`, `INSTALL_DIR="$HOME/.local/bin"`. ## Three Modes, Five Collection Vectors 1. `Log-only`: `quarkd agent` tails Nginx (`nginx_combined` | `nginx_json`) or Caddy (`caddy_json`) logs -> Server requests & verified AI crawlers. 2. `JS-only (Hub)`: `` (813 bytes, `fetch keepalive`, `text/plain`). 3. `Hybrid via Hub`: `quarkd agent` + hub `/q.js`, deduplicated into browser-verified views inside a 10s sliding window. 4. `First-Party Agent (Recommended)`: `quarkd agent` with `listen = "127.0.0.1:8091"` (or `unix:/run/quarkd/agent.sock`), Nginx/Caddy proxies `/_q.js` and `/_q` -> zero raw IPs leave the origin server, offline JS spooling during hub outages. 5. `Standalone`: single binary runs local tailers + local `/_q.js`/`/_q` + SQLite + dashboard on one box. ## Deterministic Agent Verification Loop 1. Generate or write TOML (`chmod 600`): `quarkd init --mode standalone|server|agent` 2. Fetch initial DB-IP City + ASN Lite: `quarkd --config geoip-update` 3. Validate config, DB, and log readability: `quarkd --config doctor --json` 4. Print ready-to-paste proxy/service snippets: `quarkd snippet nginx|nginx-proxy|caddy|caddy-proxy|logrotate|systemd-server|systemd-agent|script` 5. Smoke test ingestion & dedup: `quarkd test-hit --url http://127.0.0.1:8090 --site --json` 6. Verify live script installation across all sites: `POST https:///api/v1/probe` (Bearer admin token) 7. Verify webhook delivery: `POST https:///api/v1/webhooks/test` (Bearer admin token) ## Built-in MCP Server (`POST https:///mcp`) Auth header: `Authorization: Bearer ` Protocol: JSON-RPC 2.0 (`initialize`, `tools/list`, `tools/call`) ### Read & Diagnostic Tools - `list_sites(hours?)` - `get_report(site?, hours?, limit?, page?, referrer?, country?, city?, browser?, os?, device?, verified_only?)` - `get_recent_hits(site?, kind?: "human"|"bots"|"all", limit?)` - `get_agents()` - `probe_sites()` - `test_webhooks()` ### Zero-SSH Day-2 Management Tools (`db`-owned entries, zero restart) - `upsert_site(id, domains[])` — fails with conflict if site ID or domain is owned by `server.toml` - `delete_site(id)` — deletes DB site config only (preserves historical analytics rows) - `upsert_goal(site, name, event? | path?)` — works on both `toml` and `db` sites; path must start with `/` - `delete_goal(site, name)` — deletes DB goal only - `add_webhook(url, secret?, events[]?, sites[]?)` — Discord URLs auto-format as embeds; blocks loopback/private/internal SSRF; hot-reloads workers immediately - `delete_webhook(id)` — deletes DB webhook by numeric ID and hot-reloads workers - `create_password_link(ttl_secs?)` — mints a single-use, time-limited (default 120s, 30–600s) `/setup-password?code=...` browser URL so the operator can set or reset their dashboard password without sharing plaintext with the agent; rejected if `admin_password_hash` is set in `server.toml` ## Migrating TOML Sites/Goals/Webhooks to SQLite Run `quarkd --config /etc/quarkd/server.toml config-import`, remove `[[sites]]` and `[[server.webhooks]]` from `server.toml`, and restart once. Boot/auth settings (`bind`, `db_path`, `admin_token`, `agent_tokens`, `trusted_proxies`) always remain read-only in `server.toml`.