Skip to content

DIST-017 — Try it in 30 seconds: sqlguardllm mcp --demo and one-click install #180

Done

Description

@jmmana

Parent epic: #132
Priority: P1

Objetivo

Let anyone try the MCP server in under a minute, with no database and no policy: sqlguardllm mcp --demo starts the read-only server on a bundled sample database, and the README's Cursor and VS Code buttons install it in one click. Today mcp needs --policy and --db, so most visitors leave before they try it.

Scope

  • --demo flag for sqlguardllm mcp:
    • Creates the sample SQLite database in a new temporary directory at startup, based on examples/demo_data.py (branches, customers with emails, invoices), with a few more rows so the queries are interesting. The package ships the generator, not a .db file.
    • Uses a built-in demo policy: hidden customers.email, a row filter on invoices by branch, max_rows, and a fixed demo context {"user": {"branches": [1, 2]}}.
    • --demo cannot be combined with --db, --policy or --context: usage error with a clear message.
    • Server instructions and tool descriptions say the data is fictional demo data. Read-only and offline, like the normal server.
  • One-click install:
    • README.md, README.es.md and docs/MCP.md: Cursor and VS Code install links that configure uvx sqlguardllm mcp --demo. Verify the current deeplink format in each client's official documentation and link it in the PR. Keep the existing setup guide links.
    • Claude Desktop: document the demo config snippet in docs/MCP.md.
  • "Try these prompts" section (EN and ES): 4–5 prompts to paste in the client, each with the expected outcome. For example: ask for customer emails (hidden column rejected), total revenue (only branches 1 and 2), delete an invoice (rejected).
  • Docs note: --demo reaches PyPI with the next release; until then run it from a checkout with uv run sqlguardllm mcp --demo.

Security impact

The demo writes only its own temporary database and never opens a network connection. It must not weaken the normal mcp path: without --demo nothing changes.

Criterios de aceptación

  • uv run sqlguardllm mcp --demo starts with no other arguments. Test with the MCP Python SDK stdio client: list_tables returns the demo tables, a query on customers.email is rejected with hidden_column, and SELECT SUM(total) FROM invoices sums only branches 1 and 2.
  • --demo combined with --db, --policy or --context exits with a usage error (tests).
  • The database is created fresh on every start and nothing is written outside its temporary directory (test).
  • README.md, README.es.md and docs/MCP.md show the one-click links and the "Try these prompts" section; the PR links the official deeplink documentation of each client.
  • uv run ruff check src tests, uv run ruff format --check src tests, uv run mypy and uv run pytest green; the Docs workflow passes.

Archivos relevantes

  • src/sqlguardllm/cli.py, src/sqlguardllm/mcp_server.py, src/sqlguardllm/demo.py (new)
  • examples/demo_data.py (reuse it without breaking the recipes that import it)
  • tests/test_cli.py, tests/test_mcp.py or a new tests/test_demo.py
  • README.md, README.es.md, docs/MCP.md

Out of scope: package versions, server.json version, .github/workflows/release.yml, PRs #155 and #156.

Claude API proposal (AGENTS.md)

Workflow run: https://github.com/jmmana/sqlguardllm/actions/runs/46439798616 · model claude-sonnet-5-5 · manifest in the run artifact. Review it against the code; model output is not validation evidence.

proposal.md

Proposal: sqlguardllm mcp --demo and one-click install (#180)

Goal

Let a visitor run the MCP server with zero setup: sqlguardllm mcp --demo builds a fresh sample SQLite database in a temp directory, applies a built-in demo policy and context, and serves read-only over stdio. The READMEs and docs/MCP.md get one-click install links and a "Try these prompts" section. The normal mcp path stays untouched.

Assumptions

Labeled because I could only see docs/MCP.md, docs/SERVER.md, docs/quickstart.md, tests/test_cli.py, tests/test_engine_stdio.py and src/sqlguardllm/__init__.py.

  • A1. I have not seen cli.py, mcp_server.py, examples/demo_data.py or the MCP tests. Function names below are placeholders to be matched to the real code.
  • A2. create_server() (mentioned in docs/MCP.md) accepts a policy, a context and a database URL, so --demo can build those three and reuse it unchanged.
  • A3. examples/demo_data.py can be refactored into a function that writes the schema and rows into a given SQLite path, while its current importers keep working.
  • A4. The mcp subparser currently marks --policy as required. The "requires --policy or --demo" rule therefore has to move into post-parse validation.
  • A5. The demo should use the same single-policy shape as examples/policy.yaml (the one the CLI tests already pair with {"user": {"branches": [1, 2]}}), expressed as a Python dict so no data file ships.

Files to change

File Change
src/sqlguardllm/demo.py (new) DEMO_POLICY, DEMO_CONTEXT, DEMO_INSTRUCTIONS, build_demo_database(dir) -> str returning the SQLAlchemy URL
src/sqlguardllm/cli.py --demo flag on mcp; mutual-exclusion and "requires" validation; temp dir lifecycle
src/sqlguardllm/mcp_server.py Only if needed: a way to pass extra server instructions (A2). Otherwise untouched
examples/demo_data.py Refactor so the generator is importable by demo.py and still works for the existing recipes (A3)
tests/test_demo.py (new) Behavior, exclusion and cleanliness tests
tests/test_cli.py Usage-error cases, next to the existing parametrized one
README.md, README.es.md, docs/MCP.md Install links, prompts section, release note, Claude Desktop snippet

One packaging detail: the package must ship the generator, so the demo data code lives in src/sqlguardllm/demo.py. It must not be imported from examples/, which is not part of the wheel. Have examples/demo_data.py import from the package (or keep thin duplication) rather than the reverse.

Proposed implementation

demo.py

DEMO_POLICY = {
    "dialect": "sqlite",
    "tables": ["branches", "customers", "invoices"],
    "hidden_columns": ["customers.email"],
    "row_filters": {"invoices": "branch_id IN ({user.branches})"},
    "max_rows": 100,
}
DEMO_CONTEXT = {"user": {"branches": [1, 2]}}

def build_demo_database(directory: Path) -> str:
    """Create demo.db inside directory, return a sqlite:/// URL."""
  • Use the stdlib sqlite3 for creation. The mcp extra already provides SQLAlchemy for serving.
  • Seed a few more rows than today, with branches 1, 2 and at least a third branch so the row filter visibly changes SUM(total).
  • Use deterministic data (no randomness) so tests can assert exact sums.

CLI

  1. Add --demo (store_true) to the mcp subcommand and relax --policy to optional.
  2. After parsing, validate:
    • --demo together with --db, --policy, --context (or --role, which only makes sense with a policy; see Open questions) exits 2 with one clear message naming the offending flags. This matches the existing exit-2 usage-error convention in test_cli.py.
    • Without --demo, keep today's behavior, including the existing error when --policy is missing, with the same message.
  3. Demo path:
    • Create the directory with tempfile.TemporaryDirectory(prefix="sqlguardllm-demo-"). Keep the object alive for the server's lifetime so it is removed on exit.
    • Call build_demo_database, build the policy via Policy.from_dict(DEMO_POLICY), and hand policy, DEMO_CONTEXT and URL to the existing server factory.
    • Print one stderr line, e.g. sqlguardllm demo: fictional sample data in <tmpdir>. Stdout stays reserved for the MCP protocol.
  4. Honor --language, --timeout and the audit options as in the normal path. Only the three inputs listed in the issue are fixed. The cost-guard flags are ignored on SQLite with the existing warning.

Instructions and tool descriptions

Append a fixed sentence such as "This is a demo on fictional sample data; nothing here is real." to the server instructions. Tool descriptions get the same note only if the factory already allows description customization (A2). If not, instructions alone satisfy the intent, and the difference is flagged in the PR.

Docs

  • One-click links: in README.md, README.es.md and docs/MCP.md, add Cursor and VS Code install links whose config runs uvx sqlguardllm mcp --demo. I'll confirm each client's current deeplink format in its official docs before writing the URLs and link those pages in the PR, as the issue requires. I won't guess the encoding here. Keep the existing setup-guide links.

  • Claude Desktop: add a demo snippet to docs/MCP.md.

    { "mcpServers": { "sqlguard-demo": { "command": "uvx", "args": ["sqlguardllm", "mcp", "--demo"] } } }

    Whether the extra needs spelling out (--from "sqlguardllm[mcp]") depends on how the published package declares dependencies. The current docs use --from "sqlguardllm[mcp]", so the snippet and links should probably follow that for consistency until the release (see Open questions).

  • Prompts: a "Try these prompts" section in EN and ES with 4-5 prompts and expected outcomes:

    1. List the tables, expecting branches, customers (without email) and invoices.
    2. Show customer emails, expecting a hidden_column rejection.
    3. Total revenue, expecting only branches 1 and 2 summed.
    4. Delete an invoice, expecting a not_a_query rejection.
    5. Optionally, ask about a table that doesn't exist, expecting table_not_allowed.
  • Release note: --demo reaches PyPI with the next release; until then run uv run sqlguardllm mcp --demo from a checkout.

Tests

tests/test_demo.py unless noted. Reuse whatever pattern tests/test_mcp.py uses for the MCP Python SDK stdio client (A1).

  1. End to end over stdio: spawn python -m sqlguardllm mcp --demo and assert:
    • list_tables returns the three demo tables and omits customers.email;
    • a query selecting customers.email is rejected with hidden_column;
    • SELECT SUM(total) FROM invoices equals the expected sum for branches 1 and 2 only, computed independently from the seeded data (not from the server).
  2. Usage errors (tests/test_cli.py, parametrized): --demo with --db, --policy and --context each exit 2 with a message naming the flag, and mcp with neither --demo nor --policy still exits 2 as before.
  3. Fresh each start: two consecutive build_demo_database calls in different temp dirs yield independent files. Mutating one (through a direct sqlite3 connection in the test) is not visible in the next.
  4. No writes outside the temp dir: run build_demo_database with cwd and HOME pointed at empty temp directories, then assert both are unchanged apart from the target directory. A simple before/after listing is enough. Also assert the directory is removed after the server exits.
  5. Read-only still holds in demo: DELETE FROM invoices is rejected with not_a_query.
  6. Regression: the existing examples/demo_data.py importers still work (run their tests unchanged).

Standard gate: uv run ruff check src tests, uv run ruff format --check src tests, uv run mypy, uv run pytest.

Security notes

  • The demo performs no network access and writes only inside its own TemporaryDirectory.
  • The server still opens the database in a read-only transaction and enforces the guard, exactly as in the normal path.
  • Mutual exclusion matters for safety: --demo must not accept a user-supplied --db or --policy, so the "demo" label can never front a real database.
  • No change to the normal mcp code path beyond the relaxed --policy requirement in argument parsing, which is validated manually to preserve the old error.

Open questions

  1. --role: it is meaningless with the built-in single policy. Should --demo --role X be a usage error alongside --db/--policy/--context? I'd lean yes, though the issue doesn't list it.
  2. Other flags with --demo: are --language, --timeout and the audit flags allowed? I'd allow them, since they don't touch what data or policy is used.
  3. Dependency spelling in install links: uvx sqlguardllm mcp --demo (as the issue says) versus uvx --from "sqlguardllm[mcp]" ... (as the current docs use). Which is right depends on whether the extra is still needed when the release ships.
  4. Tool descriptions: is there an existing hook in create_server() to customize them, or is the instructions-only note acceptable?
  5. Row filter column: I assumed the demo invoices table has branch_id, matching examples/policy.yaml and the CLI tests. Is the demo_data.py schema the same?
  6. Temp directory name or location: is a plain system temp dir fine, or should it honor an env override for sandboxed clients?

Activity

  1. added
    type:feature
    area:cli
    area:integrations
    size:m
    lang:python
    p1
    on Nov 30, 2026
  2. jmmana commented on Nov 30, 2026

    @jmmana
    OwnerAuthor

    /warcodex proveedor=claude cuenta="Warlock"

  3. jmmana commented on Nov 30, 2026

    @jmmana
    OwnerAuthor

    WarCodex: encolado, posición 1.

  4. jmmana commented on Nov 30, 2026

    @jmmana
    OwnerAuthor

    WarCodex: empezó a trabajar en este issue (intento 1).

  5. jmmana commented on Nov 30, 2026

    @jmmana
    OwnerAuthor

    WarCodex abrió un PR para esta issue: pendiente de revisión.

    Base: main · rama: warcodex/issue-180

  6. 13 remaining items

  7. jmmana commented on Nov 30, 2026

    @jmmana
    OwnerAuthor

    WarCodex: listo, PR fusionado: #183

  8. reopened this on Nov 30, 2026
  9. jmmana commented on Nov 30, 2026

    @jmmana
    OwnerAuthor

    #183 merged: sqlguardllm mcp --demo, the 'Try these prompts' section and the docs (EN/ES) are on main, with all PR checks green (I fixed two failing tests in the PR: the demo notice now uses main()'s stderr, and the stdio test used a client attribute that does not exist in mcp 2.3.0).

    Reopened because one acceptance criterion is still open: the one-click Cursor and VS Code install links. Neither client's official documentation I could fetch documents the link format (Cursor's deeplink reference page listed in its sitemap returns 404; VS Code's MCP pages describe MCP: Add Server and code --add-mcp but no install URL). Links will not be written from memory. Next step: find the format in an official source (Cursor help center, VS Code release notes or source) and cite it in the PR. Until then the README keeps the existing setup-guide badges.

  10. jmmana commented on Nov 30, 2026

    @jmmana
    OwnerAuthor

    Delivered: #183 (sqlguardllm mcp --demo, 'Try these prompts', docs) and #191 (one-click links), all checks green; the Docs deploy passed and https://jmmana.github.io/sqlguardllm/MCP/ now carries the links.

    One-click links use the official formats, cited in #191: Cursor cursor://anysphere.cursor-deeplink/mcp/install?name=&config=<base64 of the server config> (Cursor install links) and VS Code vscode:mcp/install?<url-encoded JSON> through the documented vscode.dev/redirect wrapper (VS Code docs). READMEs (EN/ES) and docs/MCP.md have them. The command runs from GitHub (uvx --from "sqlguardllm[mcp] @ git+https://github.com/jmmana/sqlguardllm" sqlguardllm mcp --demo; --demo confirmed in its --help) because PyPI 0.5.0a8 has no --demo; the links should switch to sqlguardllm[mcp] once a release includes it.

    Not verified: clicking the links inside the real Cursor and VS Code apps (not possible from this environment). Closing since every acceptance criterion is met.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:integrationslang:pythonp1size:mtype:featurewarcodex:listo

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions