
Queryshield
io.github.bch1212Published by GitHub account bch1212v1.0.1Updated Oct 24, 2026
Secure SQL proxy for AI agents — NL→SQL, AST safety, per-agent RLS, audit log.
Overview
A secure SQL proxy that lets an assistant ask enterprise databases questions in plain English or pre-built SELECT statements.
- What you can do
- QueryShield sits between an AI agent and a customer database. The agent calls query_database with a natural-language question or query_database_sql with a pre-built SELECT, and the proxy translates, validates and executes it. Validation is AST-based: only SELECT is allowed, stacked statements and denied functions are rejected, and a LIMIT is required. Per-agent row-level security applies schema and table whitelists plus injected WHERE filters, and get_audit_log returns recent attempts for the calling agent.
- When to use it
- Use it when an assistant needs read-only access to a production or internal SQL database but should not hold connection strings or be trusted to write. It suits teams that want per-agent scoping, row filters and an audit trail over agent database access.
- Requirements
- Runs as a local stdio process installed from the PyPI package queryshield-mcp. It needs the QUERYSHIELD_API_KEY environment variable, an agent API key issued by QueryShield, and optionally QUERYSHIELD_BASE_URL to override the default endpoint. The QueryShield service itself needs its own deployment with an Anthropic key, a database URL and a vault key.
Installation
In SourceWeft
- Open Queryshield in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
QueryShield
Agent security suite. QueryShield is the lead product: a secure SQL proxy and a named credential vault, one qs_ API key, one Stripe customer, and this docs site.
Agents call a single endpoint in plain English (or structured SQL). QueryShield:
- Translates natural language → SQL via Claude with prompt caching.
- Validates every query at the AST level — only
SELECTis allowed, no stacked statements, no forbidden functions, LIMIT required. - Applies per-agent row-level security: schema/table whitelists and
WHEREclause injection. - Executes against the customer DB and returns rows.
- Logs every attempt to an append-only audit table — metadata only, never row contents.
Agents never see connection strings.
The credential vault stores other secrets (API tokens the agent is allowed to use). It is the AgentVault product, folded into this service. Permission patterns decide which names an agent can read. Database connection strings stay in a separate encrypted store and are not readable through the vault.
Free tier / funnel: InjectShield scans untrusted text for prompt injection. It stays in its own repository (bch1212/injectshield) and its own API (api.injectshield.dev). Start there, then create one QueryShield workspace when an agent needs a database or a vault. Docs: injectshield.dev/docs. Suite page on this service: /suite.
Quickstart
Generate a Fernet key for VAULT_KEY once and never lose it. Credential
encryption and session signing both require VAULT_KEY (or SESSION_KEY
for cookies). If it is unset, those operations fail instead of using a
built-in key:
End-to-end flow (curl)
MCP integration
Listed in the official MCP Registry as io.github.bch1212/queryshield.
Install the client:
Then drop this into your Claude Desktop / Cursor / agent config:
Source for the standalone PyPI package lives in packages/queryshield-mcp/.
For MCP directory evaluators such as Glama, the repository root also includes a slim Dockerfile that launches the published queryshield-mcp stdio server for tool introspection. The container does not need QUERYSHIELD_API_KEY for MCP initialization/tool discovery; the key is only required when a discovered tool is actually invoked against a QueryShield API tenant.
MCP integration (legacy)
Drop this into any MCP-aware client (Claude Desktop, Cursor, custom agents):
Tools exposed:
query_database(database_alias, question, max_rows)— natural-languagequery_database_sql(database_alias, sql, max_rows)— pre-built SELECTlist_credentials()— names this agent may readget_credential(name, cost)— one permitted secret, same API keyget_audit_log(limit)— recent attempts for the calling agent
The PyPI package queryshield-mcp picks up the vault tools on its next release. Until then, python -m queryshield.mcp_server from this repo already exposes them.
Security model
safety.py is the single most important module. Every additional check
that lands there should ship with a test in tests/test_safety.py.
Pricing
QueryShield tiers are one Stripe customer. InjectShield sign-up stays on injectshield.dev until that billing is folded in. Targets $32.5K MRR @ 15 customers (10 Pro + 5 Enterprise).
Deploy
The repo is Railway-ready. python -m queryshield.start is the entrypoint
(reads PORT via os.getenv, since Railway exec's the start command without
a shell). Provision Postgres + (optionally) Redis from Railway's marketplace
and the rest is env vars.
/health is the liveness check. /ready returns 503 if the control-plane
DB is unreachable.
Tests
102 tests cover the original safety, RLS, proxy, and HTTP suites plus the credential vault (encryption, qs_ key hashing, permission checks, budgets, tenant isolation, and the column migration for existing databases) and fail-closed VAULT_KEY / SESSION_KEY checks. The original cases:
- AST safety (24 cases — direct DDL, comments, encoded keywords, multiple statements, forbidden functions, missing LIMIT)
- RLS engine (6 cases — whitelist enforcement, WHERE injection, conjunction with existing predicates)
- Proxy end-to-end against a SQLite "customer DB" (5 cases — happy path, blocked DML, RLS row filtering, table whitelist, cache hit)
- HTTP integration via FastAPI TestClient (7 cases — full provisioning → query flow, scoped agent with RLS, auth failures)
Source: README.md at commit 462a237
Tools
0Version history
1- v1.0.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts