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

@cmd233/mcp-database-server

v1.1.7

Published

MCP server for interacting with SQLite, SQL Server, PostgreSQL and MySQL databases (Fixed nullable field detection)

Downloads

741

Readme

MseeP.ai Security Assessment Badge

MCP 数据库服务器

本 MCP (Model Context Protocol) 服务器为 Claude 提供数据库访问能力,支持 SQLite、SQL Server、PostgreSQL 和 MySQL 数据库。

安装

  1. 克隆仓库:
git clone https://github.com/executeautomation/mcp-database-server.git
cd mcp-database-server
  1. 安装依赖:
npm install
  1. 构建项目:
npm run build

使用选项

有两种方式可以在 Claude 中使用此 MCP 服务器:

  1. 直接使用: 全局安装包并直接使用
  2. 本地开发: 从本地开发环境运行

使用 NPM 包直接安装

使用此 MCP 服务器最简单的方法是全局安装:

npm install -g @executeautomation/database-server

这允许您直接使用服务器,无需在本地构建。

本地开发设置

如果您想修改代码或在本地环境运行:

  1. 按照安装部分所示克隆并构建仓库
  2. 使用下面使用部分中的命令运行服务器

使用方法

SQLite 数据库

用于 SQLite 数据库:

node dist/src/index.js /path/to/your/database.db

SQL Server 数据库

用于 SQL Server 数据库:

node dist/src/index.js --sqlserver --server <server-name> --database <database-name> [--user <username> --password <password>]

必需参数:

  • --server: SQL Server 主机名或 IP 地址
  • --database: 数据库名称

可选参数:

  • --user: SQL Server 认证的用户名(如果未提供,将使用 Windows 身份验证)
  • --password: SQL Server 认证的密码
  • --port: 端口号(默认: 1433)

PostgreSQL 数据库

用于 PostgreSQL 数据库:

node dist/src/index.js --postgresql --host <host-name> --database <database-name> [--user <username> --password <password>]

必需参数:

  • --host: PostgreSQL 主机名或 IP 地址
  • --database: 数据库名称

可选参数:

  • --user: PostgreSQL 认证的用户名
  • --password: PostgreSQL 认证的密码
  • --port: 端口号(默认: 5432)
  • --ssl: 启用 SSL 连接 (true/false)
  • --connection-timeout: 连接超时时间(毫秒,默认: 30000)

MySQL 数据库

标准认证

用于 MySQL 数据库:

node dist/src/index.js --mysql --host <host-name> --database <database-name> --port <port> [--user <username> --password <password>]

必需参数:

  • --host: MySQL 主机名或 IP 地址
  • --database: 数据库名称
  • --port: 端口号(默认: 3306)

可选参数:

  • --user: MySQL 认证的用户名
  • --password: MySQL 认证的密码
  • --ssl: 启用 SSL 连接 (true/false 或对象)
  • --connection-timeout: 连接超时时间(毫秒,默认: 30000)

AWS IAM 认证

对于支持 IAM 数据库认证的 Amazon RDS MySQL 实例:

前置条件:

  • 必须配置 AWS 凭据(RDS 签名者使用默认凭据提供程序链)
  • 使用以下方法之一配置:
    • aws configure(使用默认配置文件)
    • AWS_PROFILE=myprofile 环境变量
    • AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY 环境变量
    • IAM 角色(如果在 EC2 上运行)
node dist/src/index.js --mysql --aws-iam-auth --host <rds-endpoint> --database <database-name> --user <aws-username> --aws-region <region>

必需参数:

  • --host: RDS 端点主机名
  • --database: 数据库名称
  • --aws-iam-auth: 启用 AWS IAM 认证
  • --user: AWS IAM 用户名(也是数据库用户)
  • --aws-region: RDS 实例所在的 AWS 区域

注意: AWS IAM 认证会自动启用 SSL

配置 Claude Desktop

直接使用配置

如果您全局安装了包,使用以下配置配置 Claude Desktop:

{
  "mcpServers": {
    "sqlite": {
      "command": "npx",
      "args": [
        "-y",
        "@executeautomation/database-server",
        "/path/to/your/database.db"
      ]
    },
    "sqlserver": {
      "command": "npx",
      "args": [
        "-y",
        "@executeautomation/database-server",
        "--sqlserver",
        "--server", "your-server-name",
        "--database", "your-database-name",
        "--user", "your-username",
        "--password", "your-password"
      ]
    },
    "postgresql": {
      "command": "npx",
      "args": [
        "-y",
        "@executeautomation/database-server",
        "--postgresql",
        "--host", "your-host-name",
        "--database", "your-database-name",
        "--user", "your-username",
        "--password", "your-password"
      ]
    },
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@executeautomation/database-server",
        "--mysql",
        "--host", "your-host-name",
        "--database", "your-database-name",
        "--port", "3306",
        "--user", "your-username",
        "--password", "your-password"
      ]
    },
    "mysql-aws": {
      "command": "npx",
      "args": [
        "-y",
        "@executeautomation/database-server",
        "--mysql",
        "--aws-iam-auth",
        "--host", "your-rds-endpoint.region.rds.amazonaws.com",
        "--database", "your-database-name",
        "--user", "your-aws-username",
        "--aws-region", "us-east-1"
      ]
    }
  }
}

本地开发配置

对于本地开发,配置 Claude Desktop 使用您本地构建的版本:

{
  "mcpServers": {
    "sqlite": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-database-server/dist/src/index.js",
        "/path/to/your/database.db"
      ]
    },
    "sqlserver": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-database-server/dist/src/index.js",
        "--sqlserver",
        "--server", "your-server-name",
        "--database", "your-database-name",
        "--user", "your-username",
        "--password", "your-password"
      ]
    },
    "postgresql": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-database-server/dist/src/index.js",
        "--postgresql",
        "--host", "your-host-name",
        "--database", "your-database-name",
        "--user", "your-username",
        "--password", "your-password"
      ]
    },
    "mysql": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-database-server/dist/src/index.js",
        "--mysql",
        "--host", "your-host-name",
        "--database", "your-database-name",
        "--port", "3306",
        "--user", "your-username",
        "--password", "your-password"
      ]
    },
    "mysql-aws": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-database-server/dist/src/index.js",
        "--mysql",
        "--aws-iam-auth",
        "--host", "your-rds-endpoint.region.rds.amazonaws.com",
        "--database", "your-database-name",
        "--user", "your-aws-username",
        "--aws-region", "us-east-1"
      ]
    }
  }
}

Claude Desktop 配置文件通常位于:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

可用的数据库工具

MCP 数据库服务器提供以下可供 Claude 使用的工具:

| 工具 | 描述 | 必需参数 | |------|-------------|---------------------| | read_query | 执行 SELECT 查询以读取数据 | query: SQL SELECT 语句 | | write_query | 执行 INSERT、UPDATE 或 DELETE 查询 | query: SQL 修改语句 | | create_table | 在数据库中创建新表 | query: CREATE TABLE 语句 | | alter_table | 修改现有表架构 | query: ALTER TABLE 语句 | | drop_table | 从数据库中删除表 | table_name: 表名confirm: 安全标志(必须为 true) | | list_tables | 获取所有表的列表 | 无 | | describe_table | 查看表的架构信息 | table_name: 表名 | | export_query | 将查询结果导出为 CSV/JSON | query: SQL SELECT 语句format: "csv" 或 "json" | | append_insight | 添加业务洞察到备忘录 | insight: 洞察文本 | | list_insights | 列出所有业务洞察 | 无 |

有关如何在 Claude 中使用这些工具的实际示例,请参阅使用示例

附加文档

开发

以开发模式运行服务器:

npm run dev

在开发期间监视更改:

npm run watch

系统要求

  • Node.js 18+
  • SQL Server 连接: SQL Server 2012 或更高版本
  • PostgreSQL 连接: PostgreSQL 9.5 或更高版本

许可证

MIT