
Queryshield
io.github.bch1212由 GitHub 账号 bch1212 发布v1.0.1更新于 Oct 24, 2026
Secure SQL proxy for AI agents — NL→SQL, AST safety, per-agent RLS, audit log.
概览
一个安全的 SQL 代理,让助手用自然语言或预构建的 SELECT 语句查询企业数据库。
- 可以做什么
- QueryShield 位于 AI 代理与客户数据库之间。代理调用 query_database 提交自然语言问题,或调用 query_database_sql 提交预构建的 SELECT,由代理完成翻译、校验与执行。校验基于 AST:只允许 SELECT,拒绝堆叠语句和被禁函数,并要求带 LIMIT。按代理的行级安全会应用模式与表白名单并注入 WHERE 过滤条件,get_audit_log 返回调用代理的近期尝试记录。
- 适用场景
- 当助手需要只读访问生产或内部 SQL 数据库,但不该持有连接字符串、也不应被信任执行写入时适用。适合希望对代理的数据库访问实施按代理范围限制、行过滤和审计追踪的团队。
- 运行要求
- 作为本地 stdio 进程运行,从 PyPI 包 queryshield-mcp 安装。需要环境变量 QUERYSHIELD_API_KEY,即 QueryShield 签发的代理 API 密钥,可选 QUERYSHIELD_BASE_URL 覆盖默认端点。QueryShield 服务本身需要单独部署,并配置 Anthropic 密钥、数据库 URL 和保险库密钥。
安装
在 SourceWeft 中
- 打开 控制台中的 Queryshield,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
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)
来源:README.md,提交 462a237
工具
0版本历史
1- v1.0.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分