Add mcpg --demo: a curated demo dataset with a captured walkthrough#220
Merged
Conversation
New-user onboarding: `mcpg --demo` seeds a small, deterministic, deliberately curated e-commerce dataset (400 customers, 120 products, 3,000 orders, 900 reviews) into an mcpg_demo schema in the configured database, so the first five minutes with MCPg run against data the tools can actually show off. `mcpg --demo-drop` removes it. The dataset plants specific teaching moments: - orders.customer_id is an FK with no index — analyze_query_plan shows the seq scan, recommend_indexes catches it - customers.email/phone bait find_sensitive_columns; a camelCase reviews."reviewSource" column trips lint_naming_conventions - review prose is per-product-type plausible (a yoga mat is never praised for its battery life) and FTS-searchable - products.embedding (pgvector, 8-dim) is added only when the vector extension is already installed — never created by the seeder Safety: single-transaction seed, refuses to touch an existing schema, and --demo-drop only drops a schema carrying the MCPg ownership marker comment. CLI-only surface — no new MCP tools, snapshot unchanged. docs/demo.md is captured, not written: every output block is a real tool run against the seeded dataset (tools/generate_demo_walkthrough.py regenerates it), and tests/integration/test_demo_integration.py pins every planted finding so the walkthrough can't silently rot. Roadmap row 17.1.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new onboarding and demo feature for MCPg, allowing users to seed and drop a curated, deterministic e-commerce dataset using the mcpg --demo and mcpg --demo-drop CLI commands. The dataset is specifically engineered with planted flaws (such as an un-indexed foreign key, PII-shaped columns, and naming violations) to showcase the capabilities of MCPg's analysis, indexing, search, and auditing tools. The PR includes comprehensive unit and integration tests, updated documentation, and a script to automatically generate a walkthrough of the demo. No review comments were provided, so there is no additional feedback to address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New-user onboarding (roadmap 17.1): previously, a new user's first five minutes with MCPg ran against whatever data they happened to have — often an empty scratch database that shows off none of the 250+ tool surface. This PR gives every user (and every future screenshot/recording) the same rich first experience:
The dataset is curated, not random
A small, fully deterministic e-commerce schema (400 customers / 120 products / 3,000 orders / ~7,400 order items / 900 reviews) engineered so the pivotal tools all have something real to find:
orders.customer_idis an FK with no index —analyze_query_planshows the sequential scan, andrecommend_indexesgenuinely flags the table (the sibling tables do carry FK indexes, so it reads as a finding, not a theme).customers.email/customers.phonebaitfind_sensitive_columns; a camelCasereviews."reviewSource"column tripslint_naming_conventions.full_text_searchquery.products.embedding(pgvector, 8-dim, deterministic) is added only when thevectorextension is already installed — the seeder never creates extensions; everything else works without it.Safety
mcpg --demo-dropfirst").--demo-dropchecks the ownership marker (schema comment) and refuses to drop a schema MCPg didn't create; dropping a non-existent schema is a no-op, not an error.The captured walkthrough (
docs/demo.md)Captured, not written: every output block is a real tool run against the seeded dataset, rendered by
tools/generate_demo_walkthrough.py(7 sections: table summary → SQL analytics → slow-query diagnosis → index advisor → FTS → PII/naming audit → graph projection). Because the dataset is deterministic, the numbers in the doc are the numbers users get.tests/integration/test_demo_integration.pypins every planted finding, so the walkthrough can't silently rot when a helper changes.One non-obvious bit worth flagging for review: the index-advisor section resets
pg_statbefore replaying the workload — seeding itself generates ~7,400 FK-check index scans onorders' PK, which drowns the advisor'sseq_scan > idx_scansignal; and since a backend's pending stats only flush at transaction end, the wait is a poll (which itself drives flushes), not a sleep. Both the generator and the integration test do this identically.Docs
README quick-start section,
docs/index.mdlink, CHANGELOG[Unreleased], and roadmap section 17 (shipped).Test plan
tests/unit/test_demo.py): determinism, row counts, referential integrity, order totals = sum of items, unique emails, planted-flaw pinning (the missing index and camelCase column are asserted present in the DDL so nobody "fixes" them), per-type feature plausibility.tests/unit/test_main.py):--demoseeds and prints the summary + suggested prompts,--demo-dropreports,DemoError→ exit 1.pg_extension→ re-seed refusal → all planted findings via the real tools → drop → double-drop no-op) and foreign-schema drop refusal. Skipped on the WarehousePG lane (demo targets stock PostgreSQL).mcpg --demoCLI, generateddocs/demo.mdfrom live runs, and ran the full suite: 2735 passed, coverage 90.08% (gate: 90%).ruff format --check/ruff check/mypy src/mcpg(strict) /banditall clean.Generated by Claude Code