npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

polyquery-mcp

v1.1.0

Published

Multi-database query MCP tool supporting PostgreSQL, MySQL, MongoDB, Redis, and Oracle

Downloads

166

Readme

PolyQuery MCP

npm version Node.js 18+ License: MIT

一个支持多种数据库的 MCP (Model Context Protocol) 服务器,让 AI 助手能够安全地查询和探索数据库。

支持 MySQL | PostgreSQL | MongoDB | Redis | Oracle

🚀 快速开始

安装

npm install -g polyquery-mcp

配置 MCP 客户端

在 Claude Desktop 或 Cursor 等 MCP 客户端中添加配置:

{
  "mcpServers": {
    "polyquery": {
      "command": "polyquery-mcp",
      "env": {
        "MYSQL_URL": "mysql://user:pass@localhost:3306/mydb",
        "POSTGRES_URL": "postgresql://username:password@localhost:5432/database",
        "MONGODB_URL": "mongodb://username:password@localhost:27017/database",
        "REDIS_URL": "redis://:password@localhost:6379/0",
        "SQLITE_PATH": "/path/to/database.db",
        "ORACLE_URL": "oracle://username:password@localhost:1521/ORCL",
        "READ_ONLY_MODE": "true",
        "MAX_ROWS": "1000",
        "QUERY_TIMEOUT": "30000",
        "LOG_LEVEL": "INFO"
      }
    }
  }
}

或者使用 npx:

{
  "mcpServers": {
    "polyquery": {
      "command": "npx",
      "args": ["-y", "polyquery-mcp"],
      "env": {
        "MYSQL_URL": "mysql://user:pass@localhost:3306/mydb",
        "POSTGRES_URL": "postgresql://username:password@localhost:5432/database",
        "MONGODB_URL": "mongodb://username:password@localhost:27017/database",
        "REDIS_URL": "redis://:password@localhost:6379/0",
        "SQLITE_PATH": "/path/to/database.db",
        "ORACLE_URL": "oracle://username:password@localhost:1521/ORCL",
        "READ_ONLY_MODE": "true",
        "MAX_ROWS": "1000",
        "QUERY_TIMEOUT": "30000",
        "LOG_LEVEL": "INFO"
      }
    }
  }
}

📝 配置说明

数据库连接 URL

| 数据库 | 环境变量 | 格式 | |--------|----------|------| | MySQL | MYSQL_URL | mysql://user:pass@host:3306/db | | PostgreSQL | POSTGRES_URL | postgresql://user:pass@host:5432/db | | MongoDB | MONGODB_URL | mongodb://user:pass@host:27017/db | | Redis | REDIS_URL | redis://:password@host:6379/0 | | Oracle | ORACLE_URL | oracle://user:pass@host:1521/service |

安全配置

| 环境变量 | 默认值 | 说明 | |----------|--------|------| | READ_ONLY_MODE | true | 只读模式,禁止 INSERT/UPDATE/DELETE | | MAX_ROWS | 1000 | 查询返回的最大行数 | | QUERY_TIMEOUT | 30000 | 查询超时时间(毫秒) |

🔧 可用工具

| 工具 | 说明 | |------|------| | query_database | 执行数据库查询 | | list_tables | 列出所有表/集合 | | describe_table | 获取表结构信息 | | test_connection | 测试数据库连接 | | list_databases | 列出已配置的数据库 |

💡 使用示例

SQL 数据库

"查询 users 表中年龄大于 18 的用户"
→ query_database(db_type="mysql", query="SELECT * FROM users WHERE age > 18")

MongoDB

"查询 orders 集合中状态为 pending 的订单"
→ query_database(db_type="mongodb", query='{"collection":"orders","filter":{"status":"pending"}}')

Redis

"获取 user:123 的所有字段"
→ query_database(db_type="redis", query="HGETALL user:123")

🔒 安全特性

  • ✅ 默认只读模式,禁止写操作 INSERT/UPDATE/DELETE
  • ✅ 自动添加 LIMIT 防止返回过多数据
  • ✅ 查询超时保护
  • ✅ SQL 注入防护
  • ✅ 敏感信息脱敏

🛠 本地开发

git clone https://github.com/yourusername/polyquery-mcp.git
cd polyquery-mcp
npm install
npm run build

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License