Skip to main content
Glama
uniquery

uniquery

by yashdhingra0

UniQuery

用自然语言向你的数据库提问——从任何 MCP 客户端,或从 Web UI。

UniQuery 以只读模式连接到 Postgres 或 MongoDB 数据库,并将其作为自然语言查询代理暴露出来。它为同一个引擎提供了两个入口:一个MCP 服务器,可接入 Claude Desktop、Claude Code、Cursor 或任何其他 MCP 客户端;以及一个Next.js Web 应用,用于通过图表探索结果。

有趣的部分不是自然语言到 SQL 的转换步骤——很多工具都能做到。而是围绕它的部分:在行数据到达模型之前进行 PII 脱敏,对行数和查询超时进行硬性限制,在连接器层面强制只读,以及一个语义模式存储,让代理随着时间的推移越来越了解你的模式。

架构

apps/
  web/                 Next.js 16 + React 19 + Recharts UI
packages/
  core/                The engine — connectors, agent loop, guardrails, viz
    connectors/        Postgres (Neon serverless / pg) and MongoDB, read-only
    agent/             Tool-calling loop over Vercel AI Gateway / Google Gemini
    guardrails/        PII masking + row/timeout clamps
    semantic/          Schema knowledge store with SQL migrations
    viz/               Result-shape classifier that picks a chart type
  mcp-server/          MCP server exposing core over @modelcontextprotocol/sdk

Related MCP server: Company Data MCP Server

安全护栏

这些是它不仅仅是一个演示的原因:

安全护栏

行为

只读访问

无论模型生成什么,连接器都不会发出写操作

PII 脱敏

匹配 email、ssn、phone、dob、credit_card、cvv、passport、api_key、password 等列会在代理工具内部被脱敏——脱敏后的值永远不会进入 LLM 上下文。额外的列可以手动标记

行数限制

每个请求都被限制在 [1, 1000] 行,无论代理或 MCP 客户端要求什么

超时限制

每个查询都被限制在 [1s, 30s]

Zod 验证工具

MCP 工具输入在接触连接器之前会经过模式检查

MCP 服务器

MCP 服务器注册了三个工具:

  • connectDatabase — 在你选择的 connectionId 下注册一个 Postgres 或 MongoDB 连接

  • askQuestion — 针对已注册的连接提出自然语言问题;返回一个 Markdown 表格以及一个建议的可视化方案

  • 以及一个连接列表工具,用于查看已注册的内容

结果以 Markdown 表格形式返回(显示上限为 50 行),并附带一个图表建议——bar、line、table 或 none——该建议根据结果的形状推导而来,而非由模型猜测。

在 MCP 客户端中配置

{
  "mcpServers": {
    "uniquery": {
      "command": "node",
      "args": ["/path/to/uniquery/packages/mcp-server/dist/index.js"]
    }
  }
}

然后,在客户端中:

以 analytics 身份连接到 postgres://… 处的 Postgres,然后告诉我上个季度创收最多的五个客户。

快速开始

需要 Node.js >= 20 和 pnpm 11。

pnpm install
pnpm build

# web app
pnpm dev

# MCP server
node packages/mcp-server/dist/index.js

将 .env.example 复制为 .env.local,并填写你的数据库 URL 和 LLM 密钥——可以是 Vercel AI Gateway 密钥(默认)或带有 provider: "google" 的 Google Gemini 密钥。

技术栈

TypeScript · pnpm workspaces · Model Context Protocol SDK · Vercel AI SDK 6 · Google Gemini · Neon serverless Postgres · MongoDB · Zod · Next.js 16 · Recharts · Vitest

状态

可用的原型。引擎、安全护栏和 MCP 服务器均可正常工作;Web 应用覆盖了核心的查询和图表流程。

许可证

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Enables read-only exploration and querying of PostgreSQL or MySQL databases via MCP, with schema discovery, safe SQL validation, natural language to SQL conversion, and CSV export.
      11
      2
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only access to company data across PostgreSQL, MongoDB Atlas, and flat files through MCP tools, allowing AI assistants to query and retrieve information via natural language.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Provides read-only, guarded access to business databases via MCP. Enables natural language querying with built-in security barriers like table allowlists, PII masking, and audit logging.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to query PostgreSQL, MySQL, SQL Server, Oracle, and MongoDB databases through MCP with read-only, audited access.
      3
      AGPL 3.0