mcp-dbutils 0.16.0__tar.gz → 0.17.0__tar.gz

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.
Files changed (71) hide show
  1. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/CHANGELOG.md +14 -0
  2. mcp_dbutils-0.17.0/PKG-INFO +308 -0
  3. mcp_dbutils-0.17.0/README.md +283 -0
  4. mcp_dbutils-0.17.0/README_CN.md +294 -0
  5. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/pyproject.toml +1 -1
  6. mcp_dbutils-0.17.0/scripts/run_sonar_analysis.sh +134 -0
  7. mcp_dbutils-0.17.0/src/mcp_dbutils/base.py +817 -0
  8. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/mysql/config.py +122 -54
  9. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/mysql/handler.py +69 -22
  10. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/mysql/server.py +3 -3
  11. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/sqlite/handler.py +66 -24
  12. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/sqlite/server.py +2 -2
  13. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_mysql.py +4 -3
  14. mcp_dbutils-0.17.0/tests/integration/test_mysql_config_helpers.py +296 -0
  15. mcp_dbutils-0.17.0/tests/integration/test_mysql_handler_extended.py +232 -0
  16. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_sqlite.py +4 -3
  17. mcp_dbutils-0.17.0/tests/integration/test_sqlite_handler_extended.py +175 -0
  18. mcp_dbutils-0.17.0/tests/unit/test_base_handlers.py +117 -0
  19. mcp_dbutils-0.17.0/tests/unit/test_base_helpers.py +318 -0
  20. mcp_dbutils-0.17.0/tests/unit/test_base_server.py +1032 -0
  21. mcp_dbutils-0.17.0/tests/unit/test_mysql_handler.py +624 -0
  22. mcp_dbutils-0.16.0/PKG-INFO +0 -572
  23. mcp_dbutils-0.16.0/README.md +0 -547
  24. mcp_dbutils-0.16.0/README_CN.md +0 -525
  25. mcp_dbutils-0.16.0/src/mcp_dbutils/base.py +0 -699
  26. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/.coveragerc +0 -0
  27. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/.github/workflows/code-style.yml +0 -0
  28. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/.github/workflows/quality-assurance.yml +0 -0
  29. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/.github/workflows/release.yml +0 -0
  30. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/.gitignore +0 -0
  31. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/.pre-commit-config.yaml +0 -0
  32. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/.releaserc.json +0 -0
  33. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/Dockerfile +0 -0
  34. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/LICENSE +0 -0
  35. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/config.yaml.example +0 -0
  36. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/scripts/fix_imports.sh +0 -0
  37. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/scripts/fix_remaining_issues.sh +0 -0
  38. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/scripts/sonar-ai-fix.fish +0 -0
  39. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/smithery.yaml +0 -0
  40. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/sonar-project.properties +0 -0
  41. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/__init__.py +0 -0
  42. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/config.py +0 -0
  43. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/log.py +0 -0
  44. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/mysql/__init__.py +0 -0
  45. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/postgres/__init__.py +0 -0
  46. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/postgres/config.py +0 -0
  47. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/postgres/handler.py +0 -0
  48. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/postgres/server.py +0 -0
  49. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/sqlite/__init__.py +0 -0
  50. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/sqlite/config.py +0 -0
  51. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/src/mcp_dbutils/stats.py +0 -0
  52. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/conftest.py +0 -0
  53. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/__init__.py +0 -0
  54. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/conftest.py +0 -0
  55. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/fixtures.py +0 -0
  56. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_logging.py +0 -0
  57. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_monitoring.py +0 -0
  58. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_monitoring_enhanced.py +0 -0
  59. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_mysql_config.py +0 -0
  60. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_postgres.py +0 -0
  61. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_postgres_config.py +0 -0
  62. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_prompts.py +0 -0
  63. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_sqlite_config.py +0 -0
  64. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_tools.py +0 -0
  65. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/integration/test_tools_advanced.py +0 -0
  66. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/unit/test_base.py +0 -0
  67. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/unit/test_log.py +0 -0
  68. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/unit/test_mysql_server.py +0 -0
  69. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/unit/test_postgres_server.py +0 -0
  70. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/unit/test_sqlite_server.py +0 -0
  71. {mcp_dbutils-0.16.0 → mcp_dbutils-0.17.0}/tests/unit/test_stats.py +0 -0
@@ -1,3 +1,17 @@
1
+ # [0.17.0](https://github.com/donghao1393/mcp-dbutils/compare/v0.16.1...v0.17.0) (2025-03-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * 添加本地SonarQube分析脚本 ([65326a3](https://github.com/donghao1393/mcp-dbutils/commit/65326a3aa3a61db353fd3c399a3c808e9a07e332))
7
+
8
+ ## [0.16.1](https://github.com/donghao1393/mcp-dbutils/compare/v0.16.0...v0.16.1) (2025-03-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * some SonarCloud issues ([#51](https://github.com/donghao1393/mcp-dbutils/issues/51)) ([4df99de](https://github.com/donghao1393/mcp-dbutils/commit/4df99de5d7d12c018aa5e28e9f785e5f0828543d))
14
+
1
15
  # [0.16.0](https://github.com/donghao1393/mcp-dbutils/compare/v0.15.5...v0.16.0) (2025-03-15)
2
16
 
3
17
 
@@ -0,0 +1,308 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-dbutils
3
+ Version: 0.17.0
4
+ Summary: MCP Database Utilities Service
5
+ Author: Dong Hao
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: mcp>=1.2.1
10
+ Requires-Dist: mysql-connector-python>=8.2.0
11
+ Requires-Dist: psycopg2-binary>=2.9.10
12
+ Requires-Dist: python-dotenv>=1.0.1
13
+ Requires-Dist: pyyaml>=6.0.2
14
+ Provides-Extra: test
15
+ Requires-Dist: aiosqlite>=0.19.0; extra == 'test'
16
+ Requires-Dist: docker>=7.0.0; extra == 'test'
17
+ Requires-Dist: pre-commit>=3.6.0; extra == 'test'
18
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'test'
19
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
20
+ Requires-Dist: pytest-docker>=2.0.0; extra == 'test'
21
+ Requires-Dist: pytest>=7.0.0; extra == 'test'
22
+ Requires-Dist: ruff>=0.3.0; extra == 'test'
23
+ Requires-Dist: testcontainers>=3.7.0; extra == 'test'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # MCP Database Utilities
27
+
28
+ <!-- 项目状态徽章 -->
29
+ [![Build Status](https://img.shields.io/github/workflow/status/donghao1393/mcp-dbutils/Quality%20Assurance?label=tests)](https://github.com/donghao1393/mcp-dbutils/actions)
30
+ [![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/donghao1393/bdd0a63ec2a816539ff8c136ceb41e48/raw/coverage.json)](https://github.com/donghao1393/mcp-dbutils/actions)
31
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=donghao1393_mcp-dbutils&metric=alert_status)](https://sonarcloud.io/dashboard?id=donghao1393_mcp-dbutils)
32
+
33
+ <!-- 版本和安装徽章 -->
34
+ [![PyPI version](https://img.shields.io/pypi/v/mcp-dbutils)](https://pypi.org/project/mcp-dbutils/)
35
+ [![PyPI downloads](https://img.shields.io/pypi/dm/mcp-dbutils)](https://pypi.org/project/mcp-dbutils/)
36
+ [![Smithery](https://smithery.ai/badge/@donghao1393/mcp-dbutils)](https://smithery.ai/server/@donghao1393/mcp-dbutils)
37
+
38
+ <!-- 技术规格徽章 -->
39
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-blue)](https://www.python.org/)
40
+ [![License](https://img.shields.io/github/license/donghao1393/mcp-dbutils)](LICENSE)
41
+ [![GitHub Stars](https://img.shields.io/github/stars/donghao1393/mcp-dbutils?style=social)](https://github.com/donghao1393/mcp-dbutils/stargazers)
42
+
43
+ [中文文档](README_CN.md) | [Technical Guide](docs/technical-guide.md)
44
+
45
+ ## What is MCP Database Utilities?
46
+
47
+ MCP Database Utilities is an all-in-one MCP service that enables your AI to do data analysis by accessing versatile types of database (SQLite, MySQL, PostgreSQL, and more) within a unified connection configuration in a safe way.
48
+
49
+ Think of it as a secure bridge between AI systems and your databases, allowing AI to read and analyze your data without direct database access or risking data modifications.
50
+
51
+ ## Security and Privacy: Our Top Priority
52
+
53
+ MCP Database Utilities is built with a **security-first architecture**, making it ideal for businesses, startups, and individuals who value data protection. Our comprehensive security measures include:
54
+
55
+ ### Data Protection
56
+
57
+ - **Strictly Read-Only**: All operations are limited to SELECT queries only - data cannot be modified
58
+ - **No Direct Database Access**: AI interacts with your database through our secure service, never directly
59
+ - **Isolated Connections**: Each database connection is managed separately and strictly isolated
60
+ - **On-Demand Connectivity**: Connects only when needed and disconnects immediately after task completion
61
+ - **Automatic Timeouts**: Long-running operations are automatically terminated to prevent resource abuse
62
+
63
+ ### Privacy Safeguards
64
+
65
+ - **Local Processing**: All data processing occurs on your local machine - no data sent to external servers
66
+ - **Minimal Data Exposure**: Only requested data is returned, limiting exposure scope
67
+ - **Credential Protection**: Connection credentials are never exposed to the AI model
68
+ - **Sensitive Data Masking**: Passwords and connection details are automatically hidden in logs
69
+
70
+ ### Enterprise-Ready Security
71
+
72
+ - **SSL/TLS Support**: Encrypted connections to remote databases
73
+ - **Configuration Separation**: YAML configuration files eliminate interpretation risks
74
+ - **User-Controlled Access**: You decide which databases are accessible
75
+ - **Secure Default Settings**: Secure by default with no additional configuration needed
76
+
77
+ For technical details about our security architecture, see the [Technical Guide](docs/technical-guide.md#通信模式与安全架构).
78
+
79
+ ## Why Use MCP Database Utilities?
80
+
81
+ - **Universal AI Support**: Works with any AI system that supports the MCP protocol
82
+ - **Multiple Database Support**: Connect to SQLite, MySQL, PostgreSQL with the same interface
83
+ - **Simple Configuration**: Single YAML file for all your database connections
84
+ - **Advanced Capabilities**: Table exploration, schema analysis, and query execution
85
+
86
+ ## System Requirements
87
+
88
+ - Python 3.10 or higher
89
+ - One of the following:
90
+ - **For uvx installation**: uv package manager
91
+ - **For Docker installation**: Docker Desktop
92
+ - **For Smithery installation**: Node.js 14+
93
+ - Supported databases:
94
+ - SQLite 3.x
95
+ - PostgreSQL 12+
96
+ - MySQL 8+
97
+ - Supported AI clients:
98
+ - Claude Desktop
99
+ - Cursor
100
+ - Any MCP-compatible client
101
+
102
+ ## Getting Started
103
+
104
+ ### 1. Installation Guide
105
+
106
+ Choose **ONE** of the following methods to install:
107
+
108
+ #### Option A: Using uvx (Recommended)
109
+
110
+ This method uses `uvx`, which is part of the Python package manager tool called "uv". Here's how to set it up:
111
+
112
+ 1. **Install uv and uvx first:**
113
+
114
+ **On macOS or Linux:**
115
+ ```bash
116
+ curl -LsSf https://astral.sh/uv/install.sh | sh
117
+ ```
118
+
119
+ **On Windows:**
120
+ ```powershell
121
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
122
+ ```
123
+
124
+ After installation, verify that uv is installed correctly:
125
+ ```bash
126
+ uv --version
127
+ # Should display something like: uv 0.5.5 (Homebrew 2024-11-27)
128
+ ```
129
+
130
+ 2. **Create a configuration file** named `config.yaml` with your database connection details:
131
+
132
+ ```yaml
133
+ connections:
134
+ my-sqlite:
135
+ type: sqlite
136
+ path: /path/to/my-database.db
137
+
138
+ my-postgres:
139
+ type: postgres
140
+ host: localhost
141
+ port: 5432
142
+ dbname: my_database
143
+ user: my_user
144
+ password: my_password
145
+ ```
146
+
147
+ > For advanced configuration options (SSL connections, connection pooling, etc.),
148
+ > please refer to the [Configuration System Details](docs/technical-guide.md#configuration-system-details) section in our technical guide.
149
+
150
+ 3. **Add this configuration to your AI client:**
151
+
152
+ **For JSON-based MCP clients:**
153
+ - Locate and edit your client's MCP configuration file:
154
+ - **Claude Desktop (Mac)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
155
+ - **Cline (Mac)**: `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
156
+ - **Other clients**: Refer to your client's documentation for the MCP configuration file location
157
+ - Add the following configuration to the JSON file:
158
+
159
+ ```json
160
+ "dbutils": {
161
+ "command": "uvx",
162
+ "args": [
163
+ "mcp-dbutils",
164
+ "--config",
165
+ "/full/path/to/your/config.yaml"
166
+ ]
167
+ }
168
+ ```
169
+
170
+ **For Cursor:**
171
+ - Open Cursor
172
+ - Go to Settings → MCP
173
+ - Click "Add MCP Server" and fill in:
174
+ - Name: `Database Utility MCP`
175
+ - Type: `Command` (default)
176
+ - Command: `uvx mcp-dbutils --config /full/path/to/your/config.yaml`
177
+
178
+ > **Important Notes for uvx Setup:**
179
+ > - Replace `/full/path/to/your/config.yaml` with the actual full path to your config file
180
+ > - If you get an error about uvx not being found, make sure step 1 was completed successfully
181
+ > - You can verify uvx is installed by typing `uvx --version` in your terminal
182
+
183
+ #### Option B: Manual Installation with Docker
184
+
185
+ 1. Install Docker from [docker.com](https://www.docker.com/products/docker-desktop/) if you don't have it
186
+
187
+ 2. Create a configuration file (see next section for details)
188
+
189
+ 3. Add this configuration to your AI client:
190
+
191
+ **For JSON-based MCP clients:**
192
+ - Locate and edit your client's MCP configuration file:
193
+ - **Claude Desktop (Mac)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
194
+ - **Cline (Mac)**: `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
195
+ - **Other clients**: Refer to your client's documentation for the MCP configuration file location
196
+ - Add the following configuration to the JSON file:
197
+
198
+ ```json
199
+ "dbutils": {
200
+ "command": "docker",
201
+ "args": [
202
+ "run",
203
+ "-i",
204
+ "--rm",
205
+ "-v",
206
+ "/full/path/to/your/config.yaml:/app/config.yaml",
207
+ "-v",
208
+ "/full/path/to/your/sqlite.db:/app/sqlite.db", // Only needed for SQLite
209
+ "mcp/dbutils",
210
+ "--config",
211
+ "/app/config.yaml"
212
+ ]
213
+ }
214
+ ```
215
+
216
+ **For Cursor:**
217
+ - Open Cursor
218
+ - Go to Settings → MCP
219
+ - Click "Add MCP Server" and fill in:
220
+ - Name: `Database Utility MCP`
221
+ - Type: `Command` (default)
222
+ - Command: `docker run -i --rm -v /full/path/to/your/config.yaml:/app/config.yaml -v /full/path/to/your/sqlite.db:/app/sqlite.db mcp/dbutils --config /app/config.yaml`
223
+
224
+ > **Important Notes for Docker:**
225
+ > - Replace `/full/path/to/your/config.yaml` with the actual full path to your config file
226
+ > - For SQLite databases, also replace the sqlite.db path with your actual database path
227
+ > - For other database types, remove the SQLite volume line entirely
228
+
229
+ #### Option C: Using Smithery (One-Click for Claude)
230
+
231
+ This method automatically installs AND configures the service for Claude:
232
+
233
+ ```bash
234
+ npx -y @smithery/cli install @donghao1393/mcp-dbutils --client claude
235
+ ```
236
+
237
+ After installation completes, skip to the "Using the Service" section.
238
+
239
+ ### 4. Using the Service
240
+
241
+ Once installed and configured properly, your AI can now:
242
+ - List tables in your database
243
+ - View table structures
244
+ - Execute SQL queries safely
245
+ - Analyze data across multiple databases
246
+
247
+ **To verify everything is working:**
248
+
249
+ 1. Ask your AI something like: "Can you check if you're able to connect to my database?"
250
+ 2. If properly configured, the AI should reply that it can connect to the database specified in your config file
251
+ 3. Try a simple command like: "List the tables in my database"
252
+
253
+ If you encounter any issues, check:
254
+ - Your configuration file syntax is correct
255
+ - The database connection details are accurate
256
+ - Your AI client has the MCP server properly configured
257
+ - Your database is accessible from your computer
258
+
259
+ ## Example Interactions
260
+
261
+ **You**: "Can you list all the tables in my my-postgres database?"
262
+
263
+ **AI**: "I'll check that for you. Here are the tables in your my-postgres database:
264
+ - customers
265
+ - products
266
+ - orders
267
+ - inventory
268
+ - employees"
269
+
270
+ **You**: "What does the customers table look like?"
271
+
272
+ **AI**: "The customers table has the following structure:
273
+ - id (integer, primary key)
274
+ - name (text)
275
+ - email (text)
276
+ - registration_date (date)
277
+ - last_purchase (date)
278
+ - total_spent (numeric)"
279
+
280
+ **You**: "How many customers made purchases in the last month?"
281
+
282
+ **AI**: "Let me run a query to find out... According to the data, 128 customers made purchases in the last month. The total value of these purchases was $25,437.82."
283
+
284
+ ## Available Tools
285
+
286
+ MCP Database Utilities provides several tools that your AI can use:
287
+
288
+ - **dbutils-list-tables**: Lists all tables in a database
289
+ - **dbutils-run-query**: Executes a SQL query (SELECT only)
290
+ - **dbutils-get-stats**: Gets statistics about a table
291
+ - **dbutils-list-constraints**: Lists table constraints
292
+ - **dbutils-explain-query**: Gets query execution plan
293
+ - **dbutils-get-performance**: Gets database performance metrics
294
+ - **dbutils-analyze-query**: Analyzes queries for optimization
295
+
296
+ ## Need More Help?
297
+
298
+ - [Technical Documentation](docs/technical-guide.md) - For developers and advanced users
299
+ - [GitHub Issues](https://github.com/donghao1393/mcp-dbutils/issues) - Report bugs or request features
300
+ - [Smithery](https://smithery.ai/server/@donghao1393/mcp-dbutils) - Simplified installation and updates
301
+
302
+ ## Star History
303
+
304
+ [![Star History Chart](https://api.star-history.com/svg?repos=donghao1393/mcp-dbutils&type=Date)](https://star-history.com/#donghao1393/mcp-dbutils&Date)
305
+
306
+ ## License
307
+
308
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,283 @@
1
+ # MCP Database Utilities
2
+
3
+ <!-- 项目状态徽章 -->
4
+ [![Build Status](https://img.shields.io/github/workflow/status/donghao1393/mcp-dbutils/Quality%20Assurance?label=tests)](https://github.com/donghao1393/mcp-dbutils/actions)
5
+ [![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/donghao1393/bdd0a63ec2a816539ff8c136ceb41e48/raw/coverage.json)](https://github.com/donghao1393/mcp-dbutils/actions)
6
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=donghao1393_mcp-dbutils&metric=alert_status)](https://sonarcloud.io/dashboard?id=donghao1393_mcp-dbutils)
7
+
8
+ <!-- 版本和安装徽章 -->
9
+ [![PyPI version](https://img.shields.io/pypi/v/mcp-dbutils)](https://pypi.org/project/mcp-dbutils/)
10
+ [![PyPI downloads](https://img.shields.io/pypi/dm/mcp-dbutils)](https://pypi.org/project/mcp-dbutils/)
11
+ [![Smithery](https://smithery.ai/badge/@donghao1393/mcp-dbutils)](https://smithery.ai/server/@donghao1393/mcp-dbutils)
12
+
13
+ <!-- 技术规格徽章 -->
14
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-blue)](https://www.python.org/)
15
+ [![License](https://img.shields.io/github/license/donghao1393/mcp-dbutils)](LICENSE)
16
+ [![GitHub Stars](https://img.shields.io/github/stars/donghao1393/mcp-dbutils?style=social)](https://github.com/donghao1393/mcp-dbutils/stargazers)
17
+
18
+ [中文文档](README_CN.md) | [Technical Guide](docs/technical-guide.md)
19
+
20
+ ## What is MCP Database Utilities?
21
+
22
+ MCP Database Utilities is an all-in-one MCP service that enables your AI to do data analysis by accessing versatile types of database (SQLite, MySQL, PostgreSQL, and more) within a unified connection configuration in a safe way.
23
+
24
+ Think of it as a secure bridge between AI systems and your databases, allowing AI to read and analyze your data without direct database access or risking data modifications.
25
+
26
+ ## Security and Privacy: Our Top Priority
27
+
28
+ MCP Database Utilities is built with a **security-first architecture**, making it ideal for businesses, startups, and individuals who value data protection. Our comprehensive security measures include:
29
+
30
+ ### Data Protection
31
+
32
+ - **Strictly Read-Only**: All operations are limited to SELECT queries only - data cannot be modified
33
+ - **No Direct Database Access**: AI interacts with your database through our secure service, never directly
34
+ - **Isolated Connections**: Each database connection is managed separately and strictly isolated
35
+ - **On-Demand Connectivity**: Connects only when needed and disconnects immediately after task completion
36
+ - **Automatic Timeouts**: Long-running operations are automatically terminated to prevent resource abuse
37
+
38
+ ### Privacy Safeguards
39
+
40
+ - **Local Processing**: All data processing occurs on your local machine - no data sent to external servers
41
+ - **Minimal Data Exposure**: Only requested data is returned, limiting exposure scope
42
+ - **Credential Protection**: Connection credentials are never exposed to the AI model
43
+ - **Sensitive Data Masking**: Passwords and connection details are automatically hidden in logs
44
+
45
+ ### Enterprise-Ready Security
46
+
47
+ - **SSL/TLS Support**: Encrypted connections to remote databases
48
+ - **Configuration Separation**: YAML configuration files eliminate interpretation risks
49
+ - **User-Controlled Access**: You decide which databases are accessible
50
+ - **Secure Default Settings**: Secure by default with no additional configuration needed
51
+
52
+ For technical details about our security architecture, see the [Technical Guide](docs/technical-guide.md#通信模式与安全架构).
53
+
54
+ ## Why Use MCP Database Utilities?
55
+
56
+ - **Universal AI Support**: Works with any AI system that supports the MCP protocol
57
+ - **Multiple Database Support**: Connect to SQLite, MySQL, PostgreSQL with the same interface
58
+ - **Simple Configuration**: Single YAML file for all your database connections
59
+ - **Advanced Capabilities**: Table exploration, schema analysis, and query execution
60
+
61
+ ## System Requirements
62
+
63
+ - Python 3.10 or higher
64
+ - One of the following:
65
+ - **For uvx installation**: uv package manager
66
+ - **For Docker installation**: Docker Desktop
67
+ - **For Smithery installation**: Node.js 14+
68
+ - Supported databases:
69
+ - SQLite 3.x
70
+ - PostgreSQL 12+
71
+ - MySQL 8+
72
+ - Supported AI clients:
73
+ - Claude Desktop
74
+ - Cursor
75
+ - Any MCP-compatible client
76
+
77
+ ## Getting Started
78
+
79
+ ### 1. Installation Guide
80
+
81
+ Choose **ONE** of the following methods to install:
82
+
83
+ #### Option A: Using uvx (Recommended)
84
+
85
+ This method uses `uvx`, which is part of the Python package manager tool called "uv". Here's how to set it up:
86
+
87
+ 1. **Install uv and uvx first:**
88
+
89
+ **On macOS or Linux:**
90
+ ```bash
91
+ curl -LsSf https://astral.sh/uv/install.sh | sh
92
+ ```
93
+
94
+ **On Windows:**
95
+ ```powershell
96
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
97
+ ```
98
+
99
+ After installation, verify that uv is installed correctly:
100
+ ```bash
101
+ uv --version
102
+ # Should display something like: uv 0.5.5 (Homebrew 2024-11-27)
103
+ ```
104
+
105
+ 2. **Create a configuration file** named `config.yaml` with your database connection details:
106
+
107
+ ```yaml
108
+ connections:
109
+ my-sqlite:
110
+ type: sqlite
111
+ path: /path/to/my-database.db
112
+
113
+ my-postgres:
114
+ type: postgres
115
+ host: localhost
116
+ port: 5432
117
+ dbname: my_database
118
+ user: my_user
119
+ password: my_password
120
+ ```
121
+
122
+ > For advanced configuration options (SSL connections, connection pooling, etc.),
123
+ > please refer to the [Configuration System Details](docs/technical-guide.md#configuration-system-details) section in our technical guide.
124
+
125
+ 3. **Add this configuration to your AI client:**
126
+
127
+ **For JSON-based MCP clients:**
128
+ - Locate and edit your client's MCP configuration file:
129
+ - **Claude Desktop (Mac)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
130
+ - **Cline (Mac)**: `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
131
+ - **Other clients**: Refer to your client's documentation for the MCP configuration file location
132
+ - Add the following configuration to the JSON file:
133
+
134
+ ```json
135
+ "dbutils": {
136
+ "command": "uvx",
137
+ "args": [
138
+ "mcp-dbutils",
139
+ "--config",
140
+ "/full/path/to/your/config.yaml"
141
+ ]
142
+ }
143
+ ```
144
+
145
+ **For Cursor:**
146
+ - Open Cursor
147
+ - Go to Settings → MCP
148
+ - Click "Add MCP Server" and fill in:
149
+ - Name: `Database Utility MCP`
150
+ - Type: `Command` (default)
151
+ - Command: `uvx mcp-dbutils --config /full/path/to/your/config.yaml`
152
+
153
+ > **Important Notes for uvx Setup:**
154
+ > - Replace `/full/path/to/your/config.yaml` with the actual full path to your config file
155
+ > - If you get an error about uvx not being found, make sure step 1 was completed successfully
156
+ > - You can verify uvx is installed by typing `uvx --version` in your terminal
157
+
158
+ #### Option B: Manual Installation with Docker
159
+
160
+ 1. Install Docker from [docker.com](https://www.docker.com/products/docker-desktop/) if you don't have it
161
+
162
+ 2. Create a configuration file (see next section for details)
163
+
164
+ 3. Add this configuration to your AI client:
165
+
166
+ **For JSON-based MCP clients:**
167
+ - Locate and edit your client's MCP configuration file:
168
+ - **Claude Desktop (Mac)**: `~/Library/Application Support/Claude/claude_desktop_config.json`
169
+ - **Cline (Mac)**: `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
170
+ - **Other clients**: Refer to your client's documentation for the MCP configuration file location
171
+ - Add the following configuration to the JSON file:
172
+
173
+ ```json
174
+ "dbutils": {
175
+ "command": "docker",
176
+ "args": [
177
+ "run",
178
+ "-i",
179
+ "--rm",
180
+ "-v",
181
+ "/full/path/to/your/config.yaml:/app/config.yaml",
182
+ "-v",
183
+ "/full/path/to/your/sqlite.db:/app/sqlite.db", // Only needed for SQLite
184
+ "mcp/dbutils",
185
+ "--config",
186
+ "/app/config.yaml"
187
+ ]
188
+ }
189
+ ```
190
+
191
+ **For Cursor:**
192
+ - Open Cursor
193
+ - Go to Settings → MCP
194
+ - Click "Add MCP Server" and fill in:
195
+ - Name: `Database Utility MCP`
196
+ - Type: `Command` (default)
197
+ - Command: `docker run -i --rm -v /full/path/to/your/config.yaml:/app/config.yaml -v /full/path/to/your/sqlite.db:/app/sqlite.db mcp/dbutils --config /app/config.yaml`
198
+
199
+ > **Important Notes for Docker:**
200
+ > - Replace `/full/path/to/your/config.yaml` with the actual full path to your config file
201
+ > - For SQLite databases, also replace the sqlite.db path with your actual database path
202
+ > - For other database types, remove the SQLite volume line entirely
203
+
204
+ #### Option C: Using Smithery (One-Click for Claude)
205
+
206
+ This method automatically installs AND configures the service for Claude:
207
+
208
+ ```bash
209
+ npx -y @smithery/cli install @donghao1393/mcp-dbutils --client claude
210
+ ```
211
+
212
+ After installation completes, skip to the "Using the Service" section.
213
+
214
+ ### 4. Using the Service
215
+
216
+ Once installed and configured properly, your AI can now:
217
+ - List tables in your database
218
+ - View table structures
219
+ - Execute SQL queries safely
220
+ - Analyze data across multiple databases
221
+
222
+ **To verify everything is working:**
223
+
224
+ 1. Ask your AI something like: "Can you check if you're able to connect to my database?"
225
+ 2. If properly configured, the AI should reply that it can connect to the database specified in your config file
226
+ 3. Try a simple command like: "List the tables in my database"
227
+
228
+ If you encounter any issues, check:
229
+ - Your configuration file syntax is correct
230
+ - The database connection details are accurate
231
+ - Your AI client has the MCP server properly configured
232
+ - Your database is accessible from your computer
233
+
234
+ ## Example Interactions
235
+
236
+ **You**: "Can you list all the tables in my my-postgres database?"
237
+
238
+ **AI**: "I'll check that for you. Here are the tables in your my-postgres database:
239
+ - customers
240
+ - products
241
+ - orders
242
+ - inventory
243
+ - employees"
244
+
245
+ **You**: "What does the customers table look like?"
246
+
247
+ **AI**: "The customers table has the following structure:
248
+ - id (integer, primary key)
249
+ - name (text)
250
+ - email (text)
251
+ - registration_date (date)
252
+ - last_purchase (date)
253
+ - total_spent (numeric)"
254
+
255
+ **You**: "How many customers made purchases in the last month?"
256
+
257
+ **AI**: "Let me run a query to find out... According to the data, 128 customers made purchases in the last month. The total value of these purchases was $25,437.82."
258
+
259
+ ## Available Tools
260
+
261
+ MCP Database Utilities provides several tools that your AI can use:
262
+
263
+ - **dbutils-list-tables**: Lists all tables in a database
264
+ - **dbutils-run-query**: Executes a SQL query (SELECT only)
265
+ - **dbutils-get-stats**: Gets statistics about a table
266
+ - **dbutils-list-constraints**: Lists table constraints
267
+ - **dbutils-explain-query**: Gets query execution plan
268
+ - **dbutils-get-performance**: Gets database performance metrics
269
+ - **dbutils-analyze-query**: Analyzes queries for optimization
270
+
271
+ ## Need More Help?
272
+
273
+ - [Technical Documentation](docs/technical-guide.md) - For developers and advanced users
274
+ - [GitHub Issues](https://github.com/donghao1393/mcp-dbutils/issues) - Report bugs or request features
275
+ - [Smithery](https://smithery.ai/server/@donghao1393/mcp-dbutils) - Simplified installation and updates
276
+
277
+ ## Star History
278
+
279
+ [![Star History Chart](https://api.star-history.com/svg?repos=donghao1393/mcp-dbutils&type=Date)](https://star-history.com/#donghao1393/mcp-dbutils&Date)
280
+
281
+ ## License
282
+
283
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.