PlainQuery | MCP DB Agent

io.github.Jarvis-27由 GitHub 账号 Jarvis-27 发布v1.0.1更新于 Oct 24, 2026

Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.

发布方自己的服务:Plain Insurance

已验证Streamable HTTP可网页运行数据库数据与分析

概览

AI 生成的概览

托管型 MCP 服务器,让助手用自然语言向已连接的 PostgreSQL 数据库提问,并返回结构化 JSON 结果。

可以做什么
  • 用自然语言向已连接的 PostgreSQL 数据库提问,获得结构化 JSON 答案。
  • 服务器会读取并缓存表结构,由 LLM 生成 SQL,做安全校验后以只读方式带超时执行,出错时自动重试。
  • 通过 REST API 管理账户:注册、验证邮箱、连接或更新数据库,以及创建、列出、轮换和删除 API 密钥。
  • 生成可直接粘贴的 VS Code、Cursor 和通用 HTTP MCP 客户端配置。
  • 查看用量、仪表盘和账单状态,并发起 Stripe 结账或客户门户会话。
适用场景
适合希望助手直接回答 PostgreSQL 数据问题、而不必自己写 SQL 的场景,例如统计数量、消费最高的客户或按月平均值等临时报表。也适合倾向使用托管服务而非自建查询工具的团队。
运行要求
通过 streamable HTTP 连接 plainquery.in 远程端点,托管方式无需本地安装。需要已验证邮箱的账户、已连接的 PostgreSQL 数据库,以及在 X-API-Key 请求头中发送的 API 密钥(视服务器认证模式也可用 OAuth 2.1 bearer token)。自托管需要 Python 3.12+、uv、Node.js 20+ 与 pnpm,以及 ANTHROPIC_API_KEY 或 GROQ_API_KEY 等 LLM 密钥。
安装前请注意
托管服务会在其服务器上保存你的数据库连接地址和 LLM 密钥(静态加密),并将表结构与问题发送给 LLM 提供商。生成的 SQL 会经过校验且写入被阻止,但结果仍来自真实数据,应确认助手可访问的范围。X-API-Key 中的密钥可访问你的账户和数据库,务必保密,泄露后及时轮换。付费方案通过 Stripe 计费。

安装

在 SourceWeft 中

  1. 打开 控制台中的 PlainQuery | MCP DB Agent,将其添加到工作区。
  2. 连接 X-API-Key 凭据。它们会被私密存储,绝不会在公开页面上展示。
  3. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/io.github.Jarvis-27%2Fmcp-db-agent/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "plainquery-db-agent": {
      "type": "http",
      "url": "https://plainquery.in/mcp/",
      "headers": {
        "X-API-Key": "<YOUR_API_KEY>"
      }
    }
  }
}

README

PlainQuery

Ask your database questions in plain English. PlainQuery connects PostgreSQL databases to Claude, Cursor, or VS Code — and answers with real, structured data instead of guesses.

[MCP Registry] [CI] [Python]

[PlainQuery demo — querying a database in plain English from an MCP client]


What it does

You connect a database once. Then, from any MCP client, you ask questions like:

"How many orders did we ship in March?" "Which 5 customers spent the most last year?" "What's the average order value by month?"

PlainQuery introspects your schema, generates SQL with an LLM, validates it for safety, runs it, and returns structured JSON. If a query fails, it reads the error and retries automatically.

Why PlainQuery

  • Natural language, real answers — no SQL required; results come from your actual data, not a hallucination.
  • Read-only and safe by design — every query is checked before it runs: writes (INSERT/UPDATE/DELETE/DDL) are blocked, dangerous functions and patterns are scanned out, and a LIMIT is injected automatically.
  • Self-correcting — when a generated query errors, the agent feeds the error back to the LLM and retries (up to a configurable limit).
  • Schema-aware — automatically introspects and caches your schema, so questions map to the right tables and columns.
  • Works with any MCP client — Claude Desktop, Cursor, VS Code Copilot, or anything that speaks MCP.
  • Secure multi-tenant hosting — database URLs and LLM keys are Fernet-encrypted at rest; user-supplied connection strings are SSRF-guarded; every request is tenant-scoped.
  • Hosted or self-hosted — use the managed service, or run the whole stack yourself with Docker.
  • Bring your own LLM — Anthropic Claude or Groq.

How it works

Your question   → Schema introspection      (reads tables/columns, cached)   → SQL generation            (schema + question → LLM → SQL)   → Safety validation         (blocks writes, scans dangerous patterns, injects LIMIT)   → Execution                 (runs read-only, with a timeout)   → Self-correction retry     (on error: feed it back to the LLM, fix, re-run)   → Structured JSON result

Architecture

[PlainQuery architecture diagram showing clients, Next.js frontend, Starlette/FastAPI backend, FastMCP endpoint, query pipeline, LLM provider, and customer database]


Quick start

Option 1 — Use the hosted service (no install)

  1. Sign up at https://plainquery.in and verify your email.
  2. Connect your PostgreSQL database and create an API key.
  3. Add the server to your MCP client (see Connect your MCP client).

That's it — start asking questions.

Option 2 — Run it yourself

See Self-hosting & local development below.

Connect your MCP client

PlainQuery is published on the official MCP Registry as io.github.Jarvis-27/mcp-db-agent, so registry-aware clients can discover it directly.

To configure a client manually, point it at the MCP endpoint and pass your API key:

json
{  "mcpServers": {    "plainquery": {      "url": "https://plainquery.in/mcp",      "headers": { "X-API-Key": "mdbk_your_key_here" }    }  }}

The backend can also generate ready-to-paste config for VS Code, Cursor, and generic HTTP clients — call POST /api/v1/account/setup-payloads (see Setup payloads). MCP clients can authenticate with an OAuth 2.1 bearer token or an API key, depending on MCP_AUTH_MODE.


Self-hosting & local development

Prerequisites

  • Python 3.12+
  • uv
  • Node.js 20+ and pnpm for the frontend
  • At least one LLM API key (ANTHROPIC_API_KEY or GROQ_API_KEY)

Backend

bash
uv synccp .env.example .env

Edit .env with at least:

  • CREDENTIAL_ENCRYPTION_KEYS
  • REGISTRATION_OPEN=true
  • one LLM provider key plus LLM_PROVIDER

Run the backend:

bash
uv run uvicorn src.app:app --reload --host 0.0.0.0 --port 8000

The backend mounts:

  • REST API at http://localhost:8000/api
  • MCP endpoint at http://localhost:8000/mcp

Frontend

bash
cd frontendpnpm installpnpm dev

Open http://localhost:3000, sign up, complete setup, link your OAuth identity via account settings, then connect an MCP client at http://localhost:8000/mcp. The client will complete the OAuth flow automatically, or you can use an API key in api_key_only / hybrid mode.

Runtime model

  • Backend API: FastAPI/Starlette at src.app:app
  • Frontend: Next.js app in frontend/
  • Auth: passwordless email verification and login links
  • MCP auth: OAuth 2.1 bearer tokens (oauth_only), API keys (api_key_only), or both (hybrid) — set via MCP_AUTH_MODE
  • Setup payloads: POST /api/v1/account/setup-payloads
  • Billing: Stripe Checkout, Customer Portal, and webhook-confirmed Free/Pro entitlements

The product model is single-account and user-scoped: signup → verify email → connect database → link OAuth identity → use /mcp → upgrade with Stripe

Security

[PlainQuery security diagram showing URL validation, SSRF protection, encrypted credential storage, MCP authentication, per-request isolation, SQL validation, rate limits, and controlled execution]

  • User-supplied database URLs are validated against SSRF, path traversal, private IPs, and DNS rebinding before any connection attempt.
  • Database URLs and LLM keys are Fernet-encrypted at rest, with support for key rotation.
  • Generated SQL is validated before execution: single-statement guard, forbidden-function scan, dangerous-pattern scan, write/DDL block, table-existence check, and automatic LIMIT injection.
  • Per-request context scoping prevents cross-tenant data leaks.
  • Per-user rate limits and fallback-LLM quotas limit cost abuse.

Important environment variables

VariableDescription
AUTH_DATABASE_URLAuth/account database used by the hosted product
CREDENTIAL_ENCRYPTION_KEYSEncrypts stored database URLs and other secrets
REGISTRATION_OPENEnables or disables public signup
ANTHROPIC_API_KEY / GROQ_API_KEYLLM credentials for SQL generation
LLM_PROVIDERActive provider name
APP_BASE_URLBase URL used in setup payloads
FRONTEND_BASE_URLBase URL used in email links
STRIPE_SECRET_KEY / STRIPE_WEBHOOK_SECRETStripe API and webhook credentials
STRIPE_PRO_PRICE_IDStripe Price ID that maps to the Pro plan
STRIPE_CHECKOUT_SUCCESS_URL / STRIPE_CHECKOUT_CANCEL_URLOptional Checkout redirect overrides
STRIPE_CUSTOMER_PORTAL_RETURN_URLOptional Customer Portal return URL override

See .env.example for the current full set.

API surface

Auth

  • POST /api/v1/auth/signup
  • GET /api/v1/auth/verify-email
  • POST /api/v1/auth/request-login-link
  • GET /api/v1/auth/exchange-login-link
  • POST /api/v1/auth/logout

Account (session-authenticated)

All account routes use session token auth (x-session-token: <session-token> or Authorization: Bearer <session-token>):

  • GET /api/v1/account
  • GET /api/v1/account/status
  • PUT /api/v1/account/database
  • GET /api/v1/account/api-keys
  • POST /api/v1/account/api-keys
  • DELETE /api/v1/account/api-keys/{id}
  • POST /api/v1/account/api-keys/{id}/rotate
  • POST /api/v1/account/setup-payloads
  • GET /api/v1/account/dashboard
  • GET /api/v1/account/usage/recent

Billing

  • GET /api/v1/account/billing
  • POST /api/v1/account/billing/checkout-session
  • POST /api/v1/account/billing/portal-session
  • POST /api/v1/billing/webhook

Stripe webhooks are the source of truth for plan transitions. Checkout or subscription activation moves a user to plan_code=pro; canceled, unpaid, or past-due states restrict paid entitlements without deleting database setup.

OAuth MCP account linking (session-authenticated)

  • GET /api/v1/account/mcp-oauth/status
  • POST /api/v1/account/mcp-oauth/start
  • GET /api/v1/account/mcp-oauth/callback
  • DELETE /api/v1/account/mcp-oauth/link

MCP

  • POST /mcp
  • Auth: OAuth 2.1 bearer token, API key, or both — controlled by MCP_AUTH_MODE

Setup payloads

POST /api/v1/account/setup-payloads returns client configuration material for VS Code, Cursor, generic HTTP MCP clients, and the current ChatGPT placeholder.

bash
curl -X POST http://localhost:8000/api/v1/account/setup-payloads \  -H "Authorization: Bearer <session-token>" \  -H "Content-Type: application/json" \  -d '{"raw_api_key":"mdbk_..."}'

The backend never stores raw API keys after creation. A raw key is only embedded in setup payloads when you explicitly send it in the request.

Tests

bash
uv run pytest tests/ -m "not integration"uv run pytest tests/ -m integrationuv run ruff check .uv run mypy src --ignore-missing-imports

Deployment smoke test

After each hosted deploy, verify the public MCP OAuth discovery surface:

bash
uv run python scripts/smoke_mcp_deployment.py \  --mcp-url https://mcp.example.com/mcp \  --issuer-url https://YOUR_DOMAIN.auth0.com/

The smoke test checks the unauthenticated /mcp challenge, protected resource metadata, ChatGPT/Claude well-known discovery routes, and issuer metadata. To also verify authenticated MCP initialize, tools/list, and resources/list, pass a linked user's access token with --access-token or MCP_SMOKE_ACCESS_TOKEN.

Docker

Run the hosted HTTP stack:

bash
docker compose up --build

The container image serves only the hosted HTTP runtime. The MCP endpoint remains http://localhost:8000/mcp.

License

MIT © 2026 PlainQuery

来源:README.md,提交 90db627

工具

0
该服务器需要 API 密钥等凭据,因此 SourceWeft 无法在没有凭据的情况下读取其工具,也未收录。

版本历史

1
  1. v1.0.1最新Sep 16, 2026

评分

已满足适用检查项的 60%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式必需10 分
  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Plain 集成