Generation Tracker & Community Settings
Overview
A local SQLite database that tracks every generation’s settings, counts reuse, and optionally shares anonymized public-LoRA settings to a Cloudflare backend. The MCP server queries the local DB to suggest “what worked before” when building new workflows, and can also fetch community-aggregated settings.Architecture
Local Database: generations.db
Location: <comfyui_path>/comfyui-mcp/generations.db
(Lives alongside the user’s ComfyUI data, gitignored.)
Schema
Settings Hash
Thesettings_hash is a SHA256 of a canonical JSON string containing only
the settings identity fields, sorted alphabetically. This is what defines
“the same combo” — resolution is intentionally excluded because the same
sampler/steps/CFG combo works across resolutions and we want those to count
together.
Models and LoRAs are identified by their AutoV2 content hash (first 10 chars
of SHA256), not filenames. This means renamed files, different quantizations of
the same weights, or the same model downloaded from different sources all map to
the same identity.
width,height— resolution is a per-generation choicemodel_name,lora_name— display names, not identitypreset_name— informational onlyneg_prompt_hash— prompt content is never part of settings identity
settings_hash, we UPDATE
reuse_count += 1 and created_at to the latest timestamp instead of inserting
a duplicate row. This keeps the DB compact and gives us a natural popularity signal.
File Identification Flow
All models (checkpoints, UNETs) and LoRAs go through the same hashing pipeline. Thefile_hashes table caches results so we only compute SHA256 once per file version.
lora_civitai_id IS NOT NULL (or no LoRA)
are eligible for community sharing. Private LoRAs never leave the machine.
Hashing note: SHA256 of large safetensors files (2-12GB) takes 5-20 seconds.
We run this in a worker thread and cache aggressively. The cache invalidates only
when file size or mtime changes (renamed files keep their hash).
Settings Advisor (MCP Hook)
When building a new workflow, the MCP server queries the local DB:NPM Scripts
npm run generations:review
Interactive CLI that shows what would be shared:
npm run generations:stats
Local-only stats view:
Community Backend (Cloudflare)
Stack
- Cloudflare Workers — API endpoints (free tier: 100k req/day)
- Cloudflare D1 — SQLite-compatible edge database (free tier: 5M reads/day, 100k writes/day)
- Rate limiting — Cloudflare’s built-in rate limiting rules
Endpoints
POST /api/v1/settings/submit
Submit anonymized generation settings.
GET /api/v1/settings/search
Query community-aggregated settings.
model_family, model_hash, model_civitai_id, model_name,
lora_hash, lora_civitai_id, lora_name, sampler, scheduler.
All filters are AND-combined. Name fields support LIKE / substring matching
(e.g. ?model_name=copax matches “CopaxTimelessV11.safetensors”).
Rate limit: 60 req/min per IP.
GET /api/v1/settings/popular
Top settings across all users, filterable.
D1 Schema (Cloudflare)
settings_hash:
- If new: INSERT with
total_uses = reuse_count,unique_users = 1 - If exists:
total_uses += reuse_count,unique_users += 1
MCP Tools (New)
generation_log
Called automatically when enqueue_workflow is invoked.
Extracts settings from the executed workflow and logs to SQLite.
Not exposed to the user — internal hook.
get_history — the suggest job
get_history — the stats job
Implementation Order
Phase 1: Local tracking (no network)
- Add
better-sqlite3dependency - Create
src/services/generation-tracker.ts— DB init, log, query - Create
src/services/lora-identifier.ts— SHA256 hashing + cache - Hook into workflow executor — log after successful run
- Add the settings-suggestion MCP surface
- Add
npm run generations:statsscript
Phase 2: CivitAI identification
- Add CivitAI hash lookup in lora-identifier
- Cache results in
lora_hashestable - Filter shareable vs private in generation log
Phase 3: Community sharing
- Stand up Cloudflare Worker + D1
- Add
npm run generations:reviewscript (preview + confirm) - Add submit endpoint client in MCP server
- Add
search_community_settingsMCP tool - Rate limiting + privacy review
Privacy Guarantees
- Opt-in only — Nothing is shared without explicit
npm run generations:reviewconfirmation - No prompts — Text prompts and negative prompts are never stored in shareable form
- No images — No generated images or thumbnails
- No private LoRAs — Only LoRAs with a verified CivitAI hash are included
- No PII — No usernames, paths, IPs stored server-side (Cloudflare Workers don’t log by default)
- Local-first — The local DB works fully offline; community features are additive
- Reviewable — Users see exactly what will be sent before confirming
- No tracking — No analytics cookies, no device fingerprinting, no session tracking