Repository navigation
Description
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
--demoflag forsqlguardllm 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.dbfile. - Uses a built-in demo policy: hidden
customers.email, a row filter oninvoicesby branch,max_rows, and a fixed demo context{"user": {"branches": [1, 2]}}. --democannot be combined with--db,--policyor--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.
- Creates the sample SQLite database in a new temporary directory at startup, based on
- 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.
- README.md, README.es.md and docs/MCP.md: Cursor and VS Code install links that configure
- "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:
--demoreaches PyPI with the next release; until then run it from a checkout withuv 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 --demostarts with no other arguments. Test with the MCP Python SDK stdio client:list_tablesreturns the demo tables, a query oncustomers.emailis rejected withhidden_column, andSELECT SUM(total) FROM invoicessums only branches 1 and 2. -
--democombined with--db,--policyor--contextexits 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 mypyanduv run pytestgreen; 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.pyor a newtests/test_demo.pyREADME.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.pyor the MCP tests. Function names below are placeholders to be matched to the real code. - A2.
create_server()(mentioned indocs/MCP.md) accepts a policy, a context and a database URL, so--democan build those three and reuse it unchanged. - A3.
examples/demo_data.pycan be refactored into a function that writes the schema and rows into a given SQLite path, while its current importers keep working. - A4. The
mcpsubparser currently marks--policyas 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
sqlite3for creation. Themcpextra 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
- Add
--demo(store_true) to themcpsubcommand and relax--policyto optional. - After parsing, validate:
--demotogether 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 intest_cli.py.- Without
--demo, keep today's behavior, including the existing error when--policyis missing, with the same message.
- 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 viaPolicy.from_dict(DEMO_POLICY), and hand policy,DEMO_CONTEXTand 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.
- Create the directory with
- Honor
--language,--timeoutand 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.mdanddocs/MCP.md, add Cursor and VS Code install links whose config runsuvx 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:
- List the tables, expecting
branches,customers(withoutemail) andinvoices. - Show customer emails, expecting a
hidden_columnrejection. - Total revenue, expecting only branches 1 and 2 summed.
- Delete an invoice, expecting a
not_a_queryrejection. - Optionally, ask about a table that doesn't exist, expecting
table_not_allowed.
- List the tables, expecting
-
Release note:
--demoreaches PyPI with the next release; until then runuv run sqlguardllm mcp --demofrom 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).
- End to end over stdio: spawn
python -m sqlguardllm mcp --demoand assert:list_tablesreturns the three demo tables and omitscustomers.email;- a query selecting
customers.emailis rejected withhidden_column; SELECT SUM(total) FROM invoicesequals the expected sum for branches 1 and 2 only, computed independently from the seeded data (not from the server).
- Usage errors (
tests/test_cli.py, parametrized):--demowith--db,--policyand--contexteach exit 2 with a message naming the flag, andmcpwith neither--demonor--policystill exits 2 as before. - Fresh each start: two consecutive
build_demo_databasecalls in different temp dirs yield independent files. Mutating one (through a directsqlite3connection in the test) is not visible in the next. - No writes outside the temp dir: run
build_demo_databasewithcwdandHOMEpointed 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. - Read-only still holds in demo:
DELETE FROM invoicesis rejected withnot_a_query. - Regression: the existing
examples/demo_data.pyimporters 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:
--demomust not accept a user-supplied--dbor--policy, so the "demo" label can never front a real database. - No change to the normal
mcpcode path beyond the relaxed--policyrequirement in argument parsing, which is validated manually to preserve the old error.
Open questions
--role: it is meaningless with the built-in single policy. Should--demo --role Xbe a usage error alongside--db/--policy/--context? I'd lean yes, though the issue doesn't list it.- Other flags with
--demo: are--language,--timeoutand the audit flags allowed? I'd allow them, since they don't touch what data or policy is used. - Dependency spelling in install links:
uvx sqlguardllm mcp --demo(as the issue says) versusuvx --from "sqlguardllm[mcp]" ...(as the current docs use). Which is right depends on whether the extra is still needed when the release ships. - Tool descriptions: is there an existing hook in
create_server()to customize them, or is the instructions-only note acceptable? - Row filter column: I assumed the demo
invoicestable hasbranch_id, matchingexamples/policy.yamland the CLI tests. Is thedemo_data.pyschema the same? - Temp directory name or location: is a plain system temp dir fine, or should it honor an env override for sandboxed clients?
Activity
jmmana commentedon Nov 30, 2026
/warcodex proveedor=claude cuenta="Warlock"
jmmana commentedon Nov 30, 2026
WarCodex: encolado, posición 1.
jmmana commentedon Nov 30, 2026
WarCodex: empezó a trabajar en este issue (intento 1).
jmmana commentedon Nov 30, 2026
WarCodex abrió un PR para esta issue: pendiente de revisión.
Base:
main· rama:warcodex/issue-18013 remaining items
style: apply ruff format (#180)
fix(demo): use the injected stderr and the MCP client's instructions (#…
DIST-017 — Try it in 30 seconds: sqlguardllm mcp --demo and one-click…
jmmana commentedon Nov 30, 2026
WarCodex: listo, PR fusionado: #183
jmmana commentedon Nov 30, 2026
#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-mcpbut 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.docs: one-click install of the demo for Cursor and VS Code (#180) (#191)
jmmana commentedon Nov 30, 2026
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 Codevscode:mcp/install?<url-encoded JSON>through the documentedvscode.dev/redirectwrapper (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;--democonfirmed in its --help) because PyPI 0.5.0a8 has no--demo; the links should switch tosqlguardllm[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.
DIST-017 — Try it in 30 seconds: sqlguardllm mcp --demo and one-click…
docs: one-click install of the demo for Cursor and VS Code (#180) (#191)