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 整合