vmoo-mcp-database-server 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,178 +1,214 @@
1
- # vmoo-mcp-database-server
2
-
3
- VMOO数据库MCP服务器 - 支持开发和生产环境的安全数据库访问
4
-
5
- [![npm version](https://badge.fury.io/js/vmoo-mcp-database-server.svg)](https://badge.fury.io/js/vmoo-mcp-database-server)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
-
8
- ## 🚀 快速开始
9
-
10
- ### 使用npx直接运行(推荐)
11
-
12
- ```bash
13
- # 开发环境
14
- npx vmoo-mcp-database-server@latest --env=dev
15
-
16
- # 生产环境
17
- npx vmoo-mcp-database-server@latest --env=prod
18
- ```
19
-
20
- ### 在Augment中配置
21
-
22
- ```json
23
- {
24
- "mcpServers": {
25
- "vmoo-database-dev": {
26
- "command": "npx",
27
- "args": ["vmoo-mcp-database-server@latest", "--env=dev"]
28
- },
29
- "vmoo-database-prod": {
30
- "command": "npx",
31
- "args": ["vmoo-mcp-database-server@latest", "--env=prod"]
32
- }
33
- }
34
- }
35
- ```
36
-
37
- ### 1. 安装依赖
38
-
39
- ```bash
40
- npm install
41
- ```
42
-
43
- ### 2. 测试数据库连接
44
-
45
- ```bash
46
- npm test
47
- ```
48
-
49
- 如果看到 ✅ 连接成功,说明配置正确。
50
-
51
- ### 3. 启动MCP服务器
52
-
53
- ```bash
54
- npm start
55
- ```
56
-
57
- ## 🔧 在Augment中配置
58
-
59
- ### 找到Augment配置文件
60
-
61
- - **Windows**: `%APPDATA%\Augment\config.json`
62
- - **macOS**: `~/Library/Application Support/Augment/config.json`
63
- - **Linux**: `~/.config/Augment/config.json`
64
-
65
- ### 添加MCP服务器配置
66
-
67
- 在配置文件中添加:
68
-
69
- ```json
70
- {
71
- "mcpServers": {
72
- "vmoo-database": {
73
- "command": "node",
74
- "args": ["D:\\代码库\\vmoo-mcp-server\\mcp-vmoo-database-server.js"],
75
- "env": {}
76
- }
77
- }
78
- }
79
- ```
80
-
81
- **注意**: 请将路径替换为你的实际路径。
82
-
83
- ### 重启Augment
84
-
85
- 保存配置文件后,重启Augment应用。
86
-
87
- ## 🛠️ 可用工具
88
-
89
- 配置成功后,你可以在Augment中直接询问:
90
-
91
- ### 1. 查询数据库
92
- - "列出所有fanwe_开头的表"
93
- - "查询最近注册的10个用户"
94
- - "显示fanwe_menu表中价格最高的商品"
95
-
96
- ### 2. 查看表结构
97
- - "fanwe_user表的结构是什么?"
98
- - "描述fanwe_order表的字段"
99
-
100
- ### 3. 获取示例数据
101
- - "显示fanwe_menu表的前5条记录"
102
- - "fanwe_user表的示例数据"
103
-
104
- ### 4. 统计信息
105
- - "fanwe_user表有多少条记录?"
106
- - "数据库中有多少个表?"
107
-
108
- ## 📊 数据库信息
109
-
110
- - **主机**: 118.25.190.11:3306
111
- - **数据库**: ceshi_v_moo_com
112
- - **表前缀**: fanwe_
113
- - **字符集**: utf8mb4
114
-
115
- ## 🔒 安全特性
116
-
117
- ### 允许的操作
118
- - **查询操作**: SELECT、SHOW、DESCRIBE、EXPLAIN
119
- - **数据修改**: INSERT、UPDATE(仅限新增和修改)
120
- - **表结构**: CREATE TABLE、ALTER TABLE
121
-
122
- ### 安全防护
123
- - **禁止所有删除操作**: 完全阻止DELETE、DROP TABLE、DROP DATABASE等删除操作
124
- - **测试环境专用**: 专为测试环境设计,确保数据安全
125
- - **查询限制**: 自动添加LIMIT防止大量数据返回
126
- - **SQL注入防护**: 使用参数化查询
127
- - **连接池管理**: 自动管理数据库连接
128
- - **错误处理**: 完善的错误捕获和提示
129
-
130
- ## 📝 使用示例
131
-
132
- ```
133
- 用户: "VMOO数据库中有哪些用户相关的表?"
134
- AI: 调用list_tables工具,返回包含user的表列表
135
-
136
- 用户: "fanwe_user表的字段都有什么含义?"
137
- AI: 调用describe_table工具,返回表结构详情
138
-
139
- 用户: "最近一周注册的用户有多少?"
140
- AI: 调用query_database工具,执行相应SQL查询
141
- ```
142
-
143
- ## 🛠️ 开发调试
144
-
145
- ### 启用调试模式
146
-
147
- ```bash
148
- npm run dev
149
- ```
150
-
151
- 这将启用Node.js调试器,可以在Chrome DevTools中调试。
152
-
153
- ### 查看日志
154
-
155
- MCP服务器的日志会输出到stderr,可以通过以下方式查看:
156
-
157
- ```bash
158
- node mcp-vmoo-database-server.js 2> debug.log
159
- ```
160
-
161
- ## 🔧 故障排除
162
-
163
- ### 连接问题
164
- - 检查网络连接
165
- - 确认数据库服务器可访问
166
- - 验证防火墙设置
167
-
168
- ### 权限问题
169
- - 确保数据库用户有查询权限
170
- - 检查表访问权限
171
-
172
- ### 配置问题
173
- - 验证Augment配置文件路径正确
174
- - 确保Node.js版本 >= 18.0.0
175
-
176
- ## 📄 许可证
177
-
178
- MIT License
1
+ # vmoo-mcp-database-server
2
+
3
+ VMOO数据库MCP服务器 - 支持开发和生产环境的安全数据库访问
4
+
5
+ [![npm version](https://badge.fury.io/js/vmoo-mcp-database-server.svg)](https://badge.fury.io/js/vmoo-mcp-database-server)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## 🚀 快速开始
9
+
10
+ ### 使用npx直接运行(推荐)
11
+
12
+ ```bash
13
+ # 开发环境
14
+ npx vmoo-mcp-database-server@latest --env=dev
15
+
16
+ # 生产环境
17
+ npx vmoo-mcp-database-server@latest --env=prod
18
+ ```
19
+
20
+ ### 在Augment中配置
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "vmoo-database-dev": {
26
+ "command": "npx",
27
+ "args": ["vmoo-mcp-database-server@latest", "--env=dev"],
28
+ "env": {
29
+ "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
30
+ }
31
+ },
32
+ "vmoo-database-prod": {
33
+ "command": "npx",
34
+ "args": ["vmoo-mcp-database-server@latest", "--env=prod"],
35
+ "env": {
36
+ "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
37
+ }
38
+ },
39
+ "vmoo-database-deliver": {
40
+ "command": "npx",
41
+ "args": ["vmoo-mcp-database-server@latest", "--env=deliver"],
42
+ "env": {
43
+ "DELIVER_PASSWORD": "xxxxxxxxxxxxx"
44
+ }
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ ### 1. 安装依赖
51
+
52
+ ```bash
53
+ npm install
54
+ ```
55
+
56
+ ### 2. 测试数据库连接
57
+
58
+ ```bash
59
+ npm test
60
+ ```
61
+
62
+ 如果看到 连接成功,说明配置正确。
63
+
64
+ ### 3. 启动MCP服务器
65
+
66
+ ```bash
67
+ npm start
68
+ ```
69
+
70
+ ## 🔧 在Augment中配置
71
+
72
+ ### 找到Augment配置文件
73
+
74
+ - **Windows**: `%APPDATA%\Augment\config.json`
75
+ - **macOS**: `~/Library/Application Support/Augment/config.json`
76
+ - **Linux**: `~/.config/Augment/config.json`
77
+
78
+ ### 添加MCP服务器配置
79
+
80
+ 在配置文件中添加:
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "vmoo-database-dev": {
86
+ "command": "node",
87
+ "args": ["D:\\代码库\\vmoo-mcp-server\\bin\\vmoo-mcp-dev.js"],
88
+ "env": {
89
+ "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
90
+ }
91
+ },
92
+ "vmoo-database-prod": {
93
+ "command": "node",
94
+ "args": ["D:\\代码库\\vmoo-mcp-server\\bin\\vmoo-mcp-prod.js"],
95
+ "env": {
96
+ "V_MOO_PASSWORD": "xxxxxxxxxxxxx"
97
+ }
98
+ },
99
+ "vmoo-database-deliver": {
100
+ "command": "node",
101
+ "args": ["D:\\代码库\\vmoo-mcp-server\\bin\\vmoo-mcp-deliver.js"],
102
+ "env": {
103
+ "DELIVER_PASSWORD": "xxxxxxxxxxxxx"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ **注意**: 请将路径替换为你的实际路径。
111
+
112
+ ### 重启Augment
113
+
114
+ 保存配置文件后,重启Augment应用。
115
+
116
+ ## 🛠️ 可用工具
117
+
118
+ 配置成功后,你可以在Augment中直接询问:
119
+
120
+ ### 1. 查询数据库
121
+ - "列出所有fanwe_开头的表"
122
+ - "查询最近注册的10个用户"
123
+ - "显示fanwe_menu表中价格最高的商品"
124
+
125
+ ### 2. 查看表结构
126
+ - "fanwe_user表的结构是什么?"
127
+ - "描述fanwe_order表的字段"
128
+
129
+ ### 3. 获取示例数据
130
+ - "显示fanwe_menu表的前5条记录"
131
+ - "fanwe_user表的示例数据"
132
+
133
+ ### 4. 统计信息
134
+ - "fanwe_user表有多少条记录?"
135
+ - "数据库中有多少个表?"
136
+
137
+ ## 📊 数据库信息
138
+
139
+ ### 开发环境 (dev) 和生产环境 (prod)
140
+ - **主机**: 118.25.190.11:3306
141
+ - **数据库**: ceshi_v_moo_com
142
+ - **用户**: ceshi_v_moo_com
143
+ - **字符集**: utf8mb4
144
+
145
+ ### 配送测试站 (deliver)
146
+ - **主机**: 118.25.190.11:3306
147
+ - **数据库**: ceshi_deliver
148
+ - **用户**: ceshi_deliver
149
+ - **字符集**: utf8mb4
150
+
151
+ ## 🔒 安全特性
152
+
153
+ ### 允许的操作
154
+ - **查询操作**: SELECT、SHOW、DESCRIBE、EXPLAIN
155
+ - **数据修改**: INSERT、UPDATE(仅限新增和修改)
156
+ - **表结构**: CREATE TABLE、ALTER TABLE
157
+
158
+ ### 安全防护
159
+ - **禁止所有删除操作**: 完全阻止DELETE、DROP TABLE、DROP DATABASE等删除操作
160
+ - **测试环境专用**: 专为测试环境设计,确保数据安全
161
+ - **查询限制**: 自动添加LIMIT防止大量数据返回
162
+ - **SQL注入防护**: 使用参数化查询
163
+ - **连接池管理**: 自动管理数据库连接
164
+ - **错误处理**: 完善的错误捕获和提示
165
+
166
+ ## 📝 使用示例
167
+
168
+ ```
169
+ 用户: "VMOO数据库中有哪些用户相关的表?"
170
+ AI: 调用list_tables工具,返回包含user的表列表
171
+
172
+ 用户: "fanwe_user表的字段都有什么含义?"
173
+ AI: 调用describe_table工具,返回表结构详情
174
+
175
+ 用户: "最近一周注册的用户有多少?"
176
+ AI: 调用query_database工具,执行相应SQL查询
177
+ ```
178
+
179
+ ## 🛠️ 开发调试
180
+
181
+ ### 启用调试模式
182
+
183
+ ```bash
184
+ npm run dev
185
+ ```
186
+
187
+ 这将启用Node.js调试器,可以在Chrome DevTools中调试。
188
+
189
+ ### 查看日志
190
+
191
+ MCP服务器的日志会输出到stderr,可以通过以下方式查看:
192
+
193
+ ```bash
194
+ node mcp-vmoo-database-server.js 2> debug.log
195
+ ```
196
+
197
+ ## 🔧 故障排除
198
+
199
+ ### 连接问题
200
+ - 检查网络连接
201
+ - 确认数据库服务器可访问
202
+ - 验证防火墙设置
203
+
204
+ ### 权限问题
205
+ - 确保数据库用户有查询权限
206
+ - 检查表访问权限
207
+
208
+ ### 配置问题
209
+ - 验证Augment配置文件路径正确
210
+ - 确保Node.js版本 >= 18.0.0
211
+
212
+ ## 📄 许可证
213
+
214
+ MIT License
@@ -1,45 +1,45 @@
1
- #!/usr/bin/env node
2
-
3
- // VMOO配送测试站MCP服务器启动器
4
-
5
- import { spawn } from 'child_process';
6
- import { fileURLToPath } from 'url';
7
- import path from 'path';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
-
12
- // 解析命令行参数
13
- const args = process.argv.slice(2);
14
- const configPath = args.find(arg => arg.startsWith('--config='))?.split('=')[1];
15
-
16
- console.log('🚚 启动VMOO配送测试站MCP服务器...');
17
-
18
- // 服务器文件路径
19
- const serverPath = path.join(__dirname, '../vmoo-database-deliver/server.js');
20
-
21
- // 启动服务器
22
- const serverProcess = spawn('node', [serverPath], {
23
- stdio: 'inherit',
24
- env: {
25
- ...process.env,
26
- ...(configPath && { CONFIG_PATH: configPath })
27
- }
28
- });
29
-
30
- // 处理进程退出
31
- serverProcess.on('close', (code) => {
32
- console.log(`🚚 配送测试站MCP服务器已退出,退出码: ${code}`);
33
- process.exit(code);
34
- });
35
-
36
- // 处理中断信号
37
- process.on('SIGINT', () => {
38
- console.log('\n🛑 正在关闭配送测试站MCP服务器...');
39
- serverProcess.kill('SIGINT');
40
- });
41
-
42
- process.on('SIGTERM', () => {
43
- console.log('\n🛑 正在关闭配送测试站MCP服务器...');
44
- serverProcess.kill('SIGTERM');
45
- });
1
+ #!/usr/bin/env node
2
+
3
+ // VMOO配送测试站MCP服务器启动器
4
+
5
+ import { spawn } from 'child_process';
6
+ import { fileURLToPath } from 'url';
7
+ import path from 'path';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ // 解析命令行参数
13
+ const args = process.argv.slice(2);
14
+ const configPath = args.find(arg => arg.startsWith('--config='))?.split('=')[1];
15
+
16
+ console.log('🚚 启动VMOO配送测试站MCP服务器...');
17
+
18
+ // 服务器文件路径
19
+ const serverPath = path.join(__dirname, '../vmoo-database-deliver/server.js');
20
+
21
+ // 启动服务器
22
+ const serverProcess = spawn('node', [serverPath], {
23
+ stdio: 'inherit',
24
+ env: {
25
+ ...process.env,
26
+ ...(configPath && { CONFIG_PATH: configPath })
27
+ }
28
+ });
29
+
30
+ // 处理进程退出
31
+ serverProcess.on('close', (code) => {
32
+ console.log(`🚚 配送测试站MCP服务器已退出,退出码: ${code}`);
33
+ process.exit(code);
34
+ });
35
+
36
+ // 处理中断信号
37
+ process.on('SIGINT', () => {
38
+ console.log('\n🛑 正在关闭配送测试站MCP服务器...');
39
+ serverProcess.kill('SIGINT');
40
+ });
41
+
42
+ process.on('SIGTERM', () => {
43
+ console.log('\n🛑 正在关闭配送测试站MCP服务器...');
44
+ serverProcess.kill('SIGTERM');
45
+ });
@@ -1,45 +1,45 @@
1
- #!/usr/bin/env node
2
-
3
- // VMOO开发环境MCP服务器启动器
4
-
5
- import { spawn } from 'child_process';
6
- import { fileURLToPath } from 'url';
7
- import path from 'path';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
-
12
- // 解析命令行参数
13
- const args = process.argv.slice(2);
14
- const configPath = args.find(arg => arg.startsWith('--config='))?.split('=')[1];
15
-
16
- console.log('🟡 启动VMOO开发环境MCP服务器...');
17
-
18
- // 服务器文件路径
19
- const serverPath = path.join(__dirname, '../vmoo-database-dev/server.js');
20
-
21
- // 启动服务器
22
- const serverProcess = spawn('node', [serverPath], {
23
- stdio: 'inherit',
24
- env: {
25
- ...process.env,
26
- ...(configPath && { CONFIG_PATH: configPath })
27
- }
28
- });
29
-
30
- // 处理进程退出
31
- serverProcess.on('close', (code) => {
32
- console.log(`🟡 开发环境MCP服务器已退出,退出码: ${code}`);
33
- process.exit(code);
34
- });
35
-
36
- // 处理中断信号
37
- process.on('SIGINT', () => {
38
- console.log('\n🛑 正在关闭开发环境MCP服务器...');
39
- serverProcess.kill('SIGINT');
40
- });
41
-
42
- process.on('SIGTERM', () => {
43
- console.log('\n🛑 正在关闭开发环境MCP服务器...');
44
- serverProcess.kill('SIGTERM');
45
- });
1
+ #!/usr/bin/env node
2
+
3
+ // VMOO开发环境MCP服务器启动器
4
+
5
+ import { spawn } from 'child_process';
6
+ import { fileURLToPath } from 'url';
7
+ import path from 'path';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ // 解析命令行参数
13
+ const args = process.argv.slice(2);
14
+ const configPath = args.find(arg => arg.startsWith('--config='))?.split('=')[1];
15
+
16
+ console.log('🟡 启动VMOO开发环境MCP服务器...');
17
+
18
+ // 服务器文件路径
19
+ const serverPath = path.join(__dirname, '../vmoo-database-dev/server.js');
20
+
21
+ // 启动服务器
22
+ const serverProcess = spawn('node', [serverPath], {
23
+ stdio: 'inherit',
24
+ env: {
25
+ ...process.env,
26
+ ...(configPath && { CONFIG_PATH: configPath })
27
+ }
28
+ });
29
+
30
+ // 处理进程退出
31
+ serverProcess.on('close', (code) => {
32
+ console.log(`🟡 开发环境MCP服务器已退出,退出码: ${code}`);
33
+ process.exit(code);
34
+ });
35
+
36
+ // 处理中断信号
37
+ process.on('SIGINT', () => {
38
+ console.log('\n🛑 正在关闭开发环境MCP服务器...');
39
+ serverProcess.kill('SIGINT');
40
+ });
41
+
42
+ process.on('SIGTERM', () => {
43
+ console.log('\n🛑 正在关闭开发环境MCP服务器...');
44
+ serverProcess.kill('SIGTERM');
45
+ });
@@ -1,45 +1,45 @@
1
- #!/usr/bin/env node
2
-
3
- // VMOO生产环境MCP服务器启动器
4
-
5
- import { spawn } from 'child_process';
6
- import { fileURLToPath } from 'url';
7
- import path from 'path';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
-
12
- // 解析命令行参数
13
- const args = process.argv.slice(2);
14
- const configPath = args.find(arg => arg.startsWith('--config='))?.split('=')[1];
15
-
16
- console.log('🔴 启动VMOO生产环境MCP服务器...');
17
-
18
- // 服务器文件路径
19
- const serverPath = path.join(__dirname, '../vmoo-database-prod/server.js');
20
-
21
- // 启动服务器
22
- const serverProcess = spawn('node', [serverPath], {
23
- stdio: 'inherit',
24
- env: {
25
- ...process.env,
26
- ...(configPath && { CONFIG_PATH: configPath })
27
- }
28
- });
29
-
30
- // 处理进程退出
31
- serverProcess.on('close', (code) => {
32
- console.log(`🔴 生产环境MCP服务器已退出,退出码: ${code}`);
33
- process.exit(code);
34
- });
35
-
36
- // 处理中断信号
37
- process.on('SIGINT', () => {
38
- console.log('\n🛑 正在关闭生产环境MCP服务器...');
39
- serverProcess.kill('SIGINT');
40
- });
41
-
42
- process.on('SIGTERM', () => {
43
- console.log('\n🛑 正在关闭生产环境MCP服务器...');
44
- serverProcess.kill('SIGTERM');
45
- });
1
+ #!/usr/bin/env node
2
+
3
+ // VMOO生产环境MCP服务器启动器
4
+
5
+ import { spawn } from 'child_process';
6
+ import { fileURLToPath } from 'url';
7
+ import path from 'path';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ // 解析命令行参数
13
+ const args = process.argv.slice(2);
14
+ const configPath = args.find(arg => arg.startsWith('--config='))?.split('=')[1];
15
+
16
+ console.log('🔴 启动VMOO生产环境MCP服务器...');
17
+
18
+ // 服务器文件路径
19
+ const serverPath = path.join(__dirname, '../vmoo-database-prod/server.js');
20
+
21
+ // 启动服务器
22
+ const serverProcess = spawn('node', [serverPath], {
23
+ stdio: 'inherit',
24
+ env: {
25
+ ...process.env,
26
+ ...(configPath && { CONFIG_PATH: configPath })
27
+ }
28
+ });
29
+
30
+ // 处理进程退出
31
+ serverProcess.on('close', (code) => {
32
+ console.log(`🔴 生产环境MCP服务器已退出,退出码: ${code}`);
33
+ process.exit(code);
34
+ });
35
+
36
+ // 处理中断信号
37
+ process.on('SIGINT', () => {
38
+ console.log('\n🛑 正在关闭生产环境MCP服务器...');
39
+ serverProcess.kill('SIGINT');
40
+ });
41
+
42
+ process.on('SIGTERM', () => {
43
+ console.log('\n🛑 正在关闭生产环境MCP服务器...');
44
+ serverProcess.kill('SIGTERM');
45
+ });