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 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude-db-mcp-query-skill

v1.0.6

Published

Claude Code Skill - 智能数据库查询助手,通过 MCP 动态连接和查询数据库

Readme

Claude DB Query Skill

智能数据库查询助手 - 与 Claude Code MCP 集成的数据库查询工具

功能特性

  • 🔍 环境自动检测 - 根据 Git 分支自动识别环境(local/test/stage/prod)
  • 📝 配置解析 - 解析 YAML 配置文件中的 MySQL DSN 连接串
  • 🔄 动态 MCP 配置 - 自动管理 Claude Code MCP 数据库连接
  • 📚 查询历史 - 自动保存和搜索查询历史记录
  • 🚀 一键查询 - 简化数据库查询流程

前置要求

在使用此 Skill 之前,请确保已安装以下依赖:

1. Node.js 和 npm

# 检查是否已安装
node --version
npm --version

2. universal-db-mcp(必需)

此 Skill 依赖 universal-db-mcp 来实现数据库连接。

# 全局安装 universal-db-mcp
npm install -g universal-db-mcp

# 验证安装
npx universal-db-mcp --help

3. Claude Code CLI

确保已安装 Claude Code 命令行工具。

快速开始

安装

# 克隆或下载项目
cd claude-db-query-skill

# 安装 Python 依赖
pip3 install -r requirements.txt

# 安装到 Claude Skills 目录
./install.sh

基本使用

1. 环境检测

python3 src/db_query.py env --project /path/to/your/project

输出示例:

{
  "environment": "local",
  "config_file": "conf/application.yml",
  "branch": "feat-new-feature"
}

2. 列出所有数据库

python3 src/db_query.py list --config /path/to/application.yml

3. 获取数据库配置

python3 src/db_query.py config --config /path/to/application.yml --db default

输出示例:

{
  "user": "root",
  "password": "password",
  "host": "localhost",
  "port": "3306",
  "database": "mydb"
}

4. 生成 MCP 配置

python3 src/db_query.py gen-mcp --config /path/to/application.yml --db default

5. 查询历史管理

# 查看最近10条历史
python3 src/db_query.py history

# 搜索历史
python3 src/db_query.py history --search --keyword "users"

# 添加查询到历史
python3 src/db_query.py history --add --db default --query "SELECT * FROM users" --desc "查询用户列表"

配置文件格式

支持的 YAML 配置格式:

mysql:
  default:
    dsn: "user:password@tcp(host:port)/database?charset=utf8mb4"
  jx:
    dsn: "user:password@tcp(host:port)/jx_data?charset=utf8mb4"
  douke:
    dsn: "user:password@tcp(host:port)/douke?charset=utf8mb4"

与 Claude Code MCP 集成

此 Skill 设计为与 Claude Code 的 MCP 工具配合使用:

  1. 使用此 Skill 获取数据库连接信息
  2. 自动添加 MCP 配置到 Claude Code
  3. Claude 使用 MCP MySQL 工具执行 SQL 查询
  4. 查询结果自动保存到历史记录

项目结构

claude-db-query-skill/
├── src/
│   ├── db_query.py          # 主入口脚本
│   ├── parse_config.py      # 配置解析模块
│   ├── env_detector.py      # 环境检测模块
│   ├── query_history.py     # 查询历史管理
│   └── auto_query.py        # 自动化查询工具
├── examples/
│   └── application.yml      # 配置文件示例
├── docs/
│   └── SKILL.md            # Skill 使用文档
├── README.md               # 项目说明
├── requirements.txt        # Python 依赖
├── install.sh             # 安装脚本
└── LICENSE                # 开源协议

依赖项

必需依赖

  • Node.js 14+ 和 npm
  • universal-db-mcp - 数据库 MCP 服务器 (GitHub)
  • Python 3.6+
  • PyYAML - YAML 配置解析
  • Claude Code CLI - Claude 命令行工具

可选依赖

  • Git - 用于环境自动检测功能

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT License

作者

Created for Claude Code community