vmoo-mcp-database-server

1.3.2 • Public • Published

vmoo-mcp-database-server

VMOO数据库MCP服务器 - 支持开发和生产环境的安全数据库访问

npm version License: MIT

🚀 快速开始

使用npx直接运行(推荐)

# 开发环境
npx vmoo-mcp-database-server@latest --env=dev

# 生产环境
npx vmoo-mcp-database-server@latest --env=prod

# 配送测试站
npx vmoo-mcp-database-server@latest --env=deliver

# 商户Cookie管理
npx vmoo-mcp-database-server@latest --env=merchant

在Augment中配置

{
  "mcpServers": {
    "vmoo-database-dev": {
      "command": "npx",
      "args": ["vmoo-mcp-database-server@latest", "--env=dev"],
      "env": {
        "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
      }
    },
    "vmoo-database-prod": {
      "command": "npx",
      "args": ["vmoo-mcp-database-server@latest", "--env=prod"],
      "env": {
        "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
      }
    },
    "vmoo-database-deliver": {
      "command": "npx",
      "args": ["vmoo-mcp-database-server@latest", "--env=deliver"],
      "env": {
        "DELIVER_PASSWORD": "xxxxxxxxxxxxx"
      }
    },
    "vmoo-database-merchant": {
      "command": "npx",
      "args": ["vmoo-mcp-database-server@latest", "--env=merchant"],
      "env": {
        "MERCHANT_PASSWORD": "xxxxxxxxxxxxx"
      }
    }
  }
}

1. 安装依赖

npm install

2. 测试数据库连接

npm test

如果看到 ✅ 连接成功,说明配置正确。

3. 启动MCP服务器

npm start

🔧 在Augment中配置

找到Augment配置文件

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

添加MCP服务器配置

在配置文件中添加:

{
  "mcpServers": {
    "vmoo-database-dev": {
      "command": "node",
      "args": ["D:\\代码库\\vmoo-mcp-server\\bin\\vmoo-mcp-dev.js"],
      "env": {
        "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
      }
    },
    "vmoo-database-prod": {
      "command": "node",
      "args": ["D:\\代码库\\vmoo-mcp-server\\bin\\vmoo-mcp-prod.js"],
      "env": {
        "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
      }
    },
    "vmoo-database-deliver": {
      "command": "node",
      "args": ["D:\\代码库\\vmoo-mcp-server\\bin\\vmoo-mcp-deliver.js"],
      "env": {
        "DELIVER_PASSWORD": "xxxxxxxxxxxxx"
      }
    },
    "vmoo-database-merchant": {
      "command": "node",
      "args": ["D:\\代码库\\vmoo-mcp-server\\bin\\vmoo-mcp-merchant.js"],
      "env": {
        "MERCHANT_PASSWORD": "xxxxxxxxxxxxx"
      }
    }
  }
}

注意: 请将路径替换为你的实际路径。

重启Augment

保存配置文件后,重启Augment应用。

🛠️ 可用工具

配置成功后,你可以在Augment中直接询问:

1. 查询数据库

  • "列出所有fanwe_开头的表"
  • "查询最近注册的10个用户"
  • "显示fanwe_menu表中价格最高的商品"

2. 查看表结构

  • "fanwe_user表的结构是什么?"
  • "描述fanwe_order表的字段"

3. 获取示例数据

  • "显示fanwe_menu表的前5条记录"
  • "fanwe_user表的示例数据"

4. 统计信息

  • "fanwe_user表有多少条记录?"
  • "数据库中有多少个表?"

📊 数据库信息

开发环境 (dev) 和生产环境 (prod)

  • 主机: 118.25.190.11:3306
  • 数据库: ceshi_v_moo_com
  • 用户: ceshi_v_moo_com
  • 字符集: utf8mb4

配送测试站 (deliver)

  • 主机: 118.25.190.11:3306
  • 数据库: ceshi_deliver
  • 用户: ceshi_deliver
  • 字符集: utf8mb4

商户Cookie管理 (merchant)

  • 主机: 43.142.37.34:3306
  • 数据库: merchant_cookie_manager
  • 用户: merchant_cookie_manager
  • 字符集: utf8mb4

🔒 安全特性

允许的操作

  • 查询操作: SELECT、SHOW、DESCRIBE、EXPLAIN
  • 数据修改: INSERT、UPDATE(仅限新增和修改)
  • 表结构: CREATE TABLE、ALTER TABLE

安全防护

  • 禁止所有删除操作: 完全阻止DELETE、DROP TABLE、DROP DATABASE等删除操作
  • 测试环境专用: 专为测试环境设计,确保数据安全
  • 查询限制: 自动添加LIMIT防止大量数据返回
  • SQL注入防护: 使用参数化查询
  • 连接池管理: 自动管理数据库连接
  • 错误处理: 完善的错误捕获和提示

📝 使用示例

用户: "VMOO数据库中有哪些用户相关的表?"
AI: 调用list_tables工具,返回包含user的表列表

用户: "fanwe_user表的字段都有什么含义?"
AI: 调用describe_table工具,返回表结构详情

用户: "最近一周注册的用户有多少?"
AI: 调用query_database工具,执行相应SQL查询

🛠️ 开发调试

启用调试模式

npm run dev

这将启用Node.js调试器,可以在Chrome DevTools中调试。

查看日志

MCP服务器的日志会输出到stderr,可以通过以下方式查看:

node mcp-vmoo-database-server.js 2> debug.log

🔧 故障排除

连接问题

  • 检查网络连接
  • 确认数据库服务器可访问
  • 验证防火墙设置

权限问题

  • 确保数据库用户有查询权限
  • 检查表访问权限

配置问题

  • 验证Augment配置文件路径正确
  • 确保Node.js版本 >= 18.0.0

📄 许可证

MIT License

Package Sidebar

Install

npm i vmoo-mcp-database-server

Weekly Downloads

41

Version

1.3.2

License

MIT

Unpacked Size

16.8 MB

Total Files

2245

Last publish

Collaborators

  • jinzong
  • weng23