mcp-dbutils 0.10.0__tar.gz → 0.10.2__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 (53) hide show
  1. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/.github/workflows/release.yml +16 -14
  2. mcp_dbutils-0.10.2/.releaserc.json +26 -0
  3. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/CHANGELOG.md +14 -0
  4. mcp_dbutils-0.10.2/PKG-INFO +487 -0
  5. mcp_dbutils-0.10.2/README.md +464 -0
  6. mcp_dbutils-0.10.2/README_CN.md +442 -0
  7. mcp_dbutils-0.10.2/config.yaml.example +78 -0
  8. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/pyproject.toml +8 -1
  9. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/base.py +69 -12
  10. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/config.py +2 -2
  11. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/log.py +5 -10
  12. mcp_dbutils-0.10.2/src/mcp_dbutils/mysql/__init__.py +6 -0
  13. mcp_dbutils-0.10.2/src/mcp_dbutils/mysql/config.py +219 -0
  14. mcp_dbutils-0.10.2/src/mcp_dbutils/mysql/handler.py +467 -0
  15. mcp_dbutils-0.10.2/src/mcp_dbutils/mysql/server.py +216 -0
  16. mcp_dbutils-0.10.2/tests/integration/__init__.py +0 -0
  17. mcp_dbutils-0.10.2/tests/integration/conftest.py +12 -0
  18. mcp_dbutils-0.10.2/tests/integration/fixtures.py +226 -0
  19. mcp_dbutils-0.10.2/tests/integration/test_logging.py +139 -0
  20. mcp_dbutils-0.10.2/tests/integration/test_mysql.py +89 -0
  21. mcp_dbutils-0.10.2/tests/integration/test_mysql_config.py +201 -0
  22. mcp_dbutils-0.10.2/tests/unit/test_log.py +106 -0
  23. mcp_dbutils-0.10.0/PKG-INFO +0 -227
  24. mcp_dbutils-0.10.0/README.md +0 -205
  25. mcp_dbutils-0.10.0/README_CN.md +0 -189
  26. mcp_dbutils-0.10.0/config.yaml.example +0 -44
  27. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/.coveragerc +0 -0
  28. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/.github/workflows/test.yml +0 -0
  29. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/.gitignore +0 -0
  30. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/Dockerfile +0 -0
  31. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/LICENSE +0 -0
  32. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/smithery.yaml +0 -0
  33. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/__init__.py +0 -0
  34. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/postgres/__init__.py +0 -0
  35. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/postgres/config.py +0 -0
  36. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/postgres/handler.py +0 -0
  37. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/postgres/server.py +0 -0
  38. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/sqlite/__init__.py +0 -0
  39. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/sqlite/config.py +0 -0
  40. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/sqlite/handler.py +0 -0
  41. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/sqlite/server.py +0 -0
  42. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/src/mcp_dbutils/stats.py +0 -0
  43. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/conftest.py +0 -0
  44. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_monitoring.py +0 -0
  45. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_monitoring_enhanced.py +0 -0
  46. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_postgres.py +0 -0
  47. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_postgres_config.py +0 -0
  48. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_prompts.py +0 -0
  49. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_sqlite.py +0 -0
  50. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_sqlite_config.py +0 -0
  51. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_tools.py +0 -0
  52. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/integration/test_tools_advanced.py +0 -0
  53. {mcp_dbutils-0.10.0 → mcp_dbutils-0.10.2}/tests/unit/test_stats.py +0 -0
@@ -2,8 +2,7 @@ name: Release
2
2
 
3
3
  on:
4
4
  push:
5
- branches:
6
- - main
5
+ branches: [ main ]
7
6
 
8
7
  jobs:
9
8
  release:
@@ -15,6 +14,8 @@ jobs:
15
14
  permissions:
16
15
  id-token: write
17
16
  contents: write
17
+ issues: write
18
+ pull-requests: write
18
19
 
19
20
  steps:
20
21
  - uses: actions/checkout@v4
@@ -26,24 +27,25 @@ jobs:
26
27
  with:
27
28
  python-version: '3.10'
28
29
 
29
- - name: Install tools
30
+ - name: Install uv
30
31
  run: |
31
32
  curl -LsSf https://astral.sh/uv/install.sh | sh
32
33
  echo "$HOME/.cargo/bin" >> $GITHUB_PATH
33
34
 
34
- - name: Determine Version and Create Release
35
- id: version
36
- uses: python-semantic-release/python-semantic-release@master
35
+ - name: Setup Node.js
36
+ uses: actions/setup-node@v4
37
37
  with:
38
- github_token: ${{ secrets.GITHUB_TOKEN }}
39
- build: false
38
+ node-version: 'lts/*'
40
39
 
41
- - name: Build Package
42
- if: steps.version.outputs.released == 'true'
40
+ - name: Install semantic-release
43
41
  run: |
44
- which uv
45
- uv build
46
-
42
+ npm install -g semantic-release @semantic-release/git @semantic-release/changelog @semantic-release/exec
43
+
44
+ - name: Release
45
+ id: semantic-release
46
+ env:
47
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48
+ run: npx semantic-release
49
+
47
50
  - name: Publish to PyPI
48
- if: steps.version.outputs.released == 'true'
49
51
  uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,26 @@
1
+ {
2
+ "branches": ["main"],
3
+ "plugins": [
4
+ "@semantic-release/commit-analyzer",
5
+ "@semantic-release/release-notes-generator",
6
+ "@semantic-release/changelog",
7
+ ["@semantic-release/exec", {
8
+ "verifyConditionsCmd": "uv --version",
9
+ "prepareCmd": "sed -i.bak 's/version = \".*\"/version = \"${nextRelease.version}\"/g' pyproject.toml && rm -f pyproject.toml.bak",
10
+ "publishCmd": "uv build"
11
+ }],
12
+ ["@semantic-release/git", {
13
+ "assets": [
14
+ "pyproject.toml",
15
+ "CHANGELOG.md"
16
+ ],
17
+ "message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
18
+ }],
19
+ ["@semantic-release/github", {
20
+ "assets": [
21
+ {"path": "dist/*.whl", "label": "Python Wheel ${nextRelease.version}"},
22
+ {"path": "dist/*.tar.gz", "label": "Source Distribution ${nextRelease.version}"}
23
+ ]
24
+ }]
25
+ ]
26
+ }
@@ -1,3 +1,17 @@
1
+ ## [0.10.2](https://github.com/donghao1393/mcp-dbutils/compare/v0.10.1...v0.10.2) (2025-03-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * remove conditional check for PyPI publishing ([e714ef8](https://github.com/donghao1393/mcp-dbutils/commit/e714ef89db8dc35eca1a5c2f09f240dee94192eb))
7
+
8
+ ## [0.10.1](https://github.com/donghao1393/mcp-dbutils/compare/v0.10.0...v0.10.1) (2025-03-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update verifyConditionsCmd in semantic-release config ([4271476](https://github.com/donghao1393/mcp-dbutils/commit/42714761d5d8bbbd39b9bae2aa550e1d06aa351c))
14
+
1
15
  # CHANGELOG
2
16
 
3
17
 
@@ -0,0 +1,487 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-dbutils
3
+ Version: 0.10.2
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: pytest-asyncio>=0.23.0; extra == 'test'
18
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
19
+ Requires-Dist: pytest-docker>=2.0.0; extra == 'test'
20
+ Requires-Dist: pytest>=7.0.0; extra == 'test'
21
+ Requires-Dist: testcontainers>=3.7.0; extra == 'test'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # MCP Database Utilities
25
+
26
+ ![GitHub Repo stars](https://img.shields.io/github/stars/donghao1393/mcp-dbutils)
27
+ ![PyPI version](https://img.shields.io/pypi/v/mcp-dbutils)
28
+ [![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/donghao1393/bdd0a63ec2a816539ff8c136ceb41e48/raw/coverage.json)](https://github.com/donghao1393/mcp-dbutils/actions)
29
+ ![Python](https://img.shields.io/badge/Python-3.10%2B-blue)
30
+ ![License](https://img.shields.io/github/license/donghao1393/mcp-dbutils)
31
+ [![smithery badge](https://smithery.ai/badge/@donghao1393/mcp-dbutils)](https://smithery.ai/server/@donghao1393/mcp-dbutils)
32
+
33
+ [中文文档](README_CN.md)
34
+
35
+ ## Overview
36
+ MCP Database Utilities is a unified database access service that supports multiple database types (PostgreSQL, SQLite, and MySQL). Through its abstraction layer design, it provides a simple and unified database operation interface for MCP servers.
37
+
38
+ ## Features
39
+ - Unified database access interface
40
+ - Support for multiple database configurations
41
+ - Secure read-only query execution
42
+ - Table structure and schema information retrieval
43
+ - Database tables listing via MCP tools
44
+ - Intelligent connection management and resource cleanup
45
+ - Debug mode support
46
+ - SSL/TLS connection support for PostgreSQL and MySQL
47
+
48
+ ## Installation and Configuration
49
+
50
+ ### Installation Methods
51
+ #### Installing via Smithery
52
+
53
+ To install Database Utilities for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@donghao1393/mcp-dbutils):
54
+
55
+ ```bash
56
+ npx -y @smithery/cli install @donghao1393/mcp-dbutils --client claude
57
+ ```
58
+
59
+ #### Using uvx (Recommended)
60
+ No installation required, run directly using `uvx`:
61
+ ```bash
62
+ uvx mcp-dbutils --config /path/to/config.yaml
63
+ ```
64
+
65
+ Add to Claude configuration:
66
+ ```json
67
+ "mcpServers": {
68
+ "mcp-dbutils": {
69
+ "command": "uvx",
70
+ "args": [
71
+ "mcp-dbutils",
72
+ "--config",
73
+ "/path/to/config.yaml"
74
+ ],
75
+ "env": {
76
+ "MCP_DEBUG": "1" // Optional: Enable debug mode
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ #### Using pip
83
+ ```bash
84
+ pip install mcp-dbutils
85
+ ```
86
+
87
+ Add to Claude configuration:
88
+ ```json
89
+ "mcpServers": {
90
+ "mcp-dbutils": {
91
+ "command": "python",
92
+ "args": [
93
+ "-m",
94
+ "mcp_dbutils",
95
+ "--config",
96
+ "/path/to/config.yaml"
97
+ ],
98
+ "env": {
99
+ "MCP_DEBUG": "1" // Optional: Enable debug mode
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ #### Using Docker
106
+ ```bash
107
+ docker run -i --rm \
108
+ -v /path/to/config.yaml:/app/config.yaml \
109
+ -v /path/to/sqlite.db:/app/sqlite.db \ # Optional: for SQLite database
110
+ -e MCP_DEBUG=1 \ # Optional: Enable debug mode
111
+ mcp/dbutils --config /app/config.yaml
112
+ ```
113
+
114
+ Add to Claude configuration:
115
+ ```json
116
+ "mcpServers": {
117
+ "mcp-dbutils": {
118
+ "command": "docker",
119
+ "args": [
120
+ "run",
121
+ "-i",
122
+ "--rm",
123
+ "-v",
124
+ "/path/to/config.yaml:/app/config.yaml",
125
+ "-v",
126
+ "/path/to/sqlite.db:/app/sqlite.db", // Optional: for SQLite database
127
+ "mcp/dbutils",
128
+ "--config",
129
+ "/app/config.yaml"
130
+ ],
131
+ "env": {
132
+ "MCP_DEBUG": "1" // Optional: Enable debug mode
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ > **Note for Docker database connections:**
139
+ > - For SQLite: Mount your database file using `-v /path/to/sqlite.db:/app/sqlite.db`
140
+ > - For PostgreSQL running on host:
141
+ > - On Mac/Windows: Use `host.docker.internal` as host in config
142
+ > - On Linux: Use `172.17.0.1` (docker0 IP) or run with `--network="host"`
143
+
144
+ ### Requirements
145
+ - Python 3.10+
146
+ - PostgreSQL (optional)
147
+ - SQLite3 (optional)
148
+ - MySQL (optional)
149
+
150
+ ### Configuration File
151
+ The project requires a YAML configuration file, specified via the `--config` parameter. Configuration examples:
152
+
153
+ ```yaml
154
+ connections:
155
+ # SQLite configuration examples
156
+ dev-db:
157
+ type: sqlite
158
+ path: /path/to/dev.db
159
+ # Password is optional
160
+ password:
161
+
162
+ # PostgreSQL standard configuration
163
+ test-db:
164
+ type: postgres
165
+ host: postgres.example.com
166
+ port: 5432
167
+ dbname: test_db
168
+ user: test_user
169
+ password: test_pass
170
+
171
+ # PostgreSQL URL configuration with SSL
172
+ prod-db:
173
+ type: postgres
174
+ url: postgresql://postgres.example.com:5432/prod-db?sslmode=verify-full
175
+ user: prod_user
176
+ password: prod_pass
177
+
178
+ # PostgreSQL full SSL configuration example
179
+ secure-db:
180
+ type: postgres
181
+ host: secure-db.example.com
182
+ port: 5432
183
+ dbname: secure_db
184
+ user: secure_user
185
+ password: secure_pass
186
+ ssl:
187
+ mode: verify-full # disable/require/verify-ca/verify-full
188
+ cert: /path/to/client-cert.pem
189
+ key: /path/to/client-key.pem
190
+ root: /path/to/root.crt
191
+
192
+ # MySQL standard configuration
193
+ sandbox-mysql:
194
+ type: mysql
195
+ host: localhost
196
+ port: 3306
197
+ database: sandbox_db
198
+ user: sandbox_user
199
+ password: sandbox_pass
200
+ charset: utf8mb4
201
+
202
+ # MySQL URL configuration
203
+ integration-mysql:
204
+ type: mysql
205
+ url: mysql://mysql.example.com:3306/integration_db?charset=utf8mb4
206
+ user: integration_user
207
+ password: integration_pass
208
+
209
+ # MySQL with SSL configuration
210
+ secure-mysql:
211
+ type: mysql
212
+ host: secure-mysql.example.com
213
+ port: 3306
214
+ database: secure_db
215
+ user: secure_user
216
+ password: secure_pass
217
+ charset: utf8mb4
218
+ ssl:
219
+ mode: verify_identity
220
+ ca: /path/to/ca.pem
221
+ cert: /path/to/client-cert.pem
222
+ key: /path/to/client-key.pem
223
+ ```
224
+
225
+ Database SSL Configuration Options:
226
+
227
+ PostgreSQL SSL Configuration:
228
+ 1. Using URL parameters:
229
+ ```
230
+ postgresql://host:port/dbname?sslmode=verify-full&sslcert=/path/to/cert.pem
231
+ ```
232
+ 2. Using dedicated SSL configuration section:
233
+ ```yaml
234
+ ssl:
235
+ mode: verify-full # SSL verification mode
236
+ cert: /path/to/cert.pem # Client certificate
237
+ key: /path/to/key.pem # Client private key
238
+ root: /path/to/root.crt # CA certificate
239
+ ```
240
+
241
+ PostgreSQL SSL Modes:
242
+ - disable: No SSL
243
+ - require: Use SSL but no certificate verification
244
+ - verify-ca: Verify server certificate is signed by trusted CA
245
+ - verify-full: Verify server certificate and hostname match
246
+
247
+ MySQL SSL Configuration:
248
+ 1. Using URL parameters:
249
+ ```
250
+ mysql://host:port/dbname?ssl-mode=verify_identity&ssl-ca=/path/to/ca.pem
251
+ ```
252
+ 2. Using dedicated SSL configuration section:
253
+ ```yaml
254
+ ssl:
255
+ mode: verify_identity # SSL verification mode
256
+ ca: /path/to/ca.pem # CA certificate
257
+ cert: /path/to/cert.pem # Client certificate
258
+ key: /path/to/key.pem # Client private key
259
+ ```
260
+
261
+ MySQL SSL Modes:
262
+ - disabled: No SSL
263
+ - preferred: Use SSL if available, but allow unencrypted connection
264
+ - required: Always use SSL, but don't verify server certificate
265
+ - verify_ca: Verify server certificate is signed by trusted CA
266
+ - verify_identity: Verify server certificate and hostname match
267
+
268
+ SQLite Configuration Options:
269
+ 1. Basic configuration with path:
270
+ ```yaml
271
+ type: sqlite
272
+ path: /path/to/db.sqlite
273
+ password: optional_password # Optional encryption
274
+ ```
275
+ 2. Using URI parameters:
276
+ ```yaml
277
+ type: sqlite
278
+ path: /path/to/db.sqlite?mode=ro&cache=shared
279
+ ```
280
+
281
+ ### Debug Mode
282
+ Set environment variable `MCP_DEBUG=1` to enable debug mode for detailed logging output.
283
+
284
+ ## Architecture Design
285
+
286
+ ### Core Concept: Abstraction Layer
287
+
288
+ ```mermaid
289
+ graph TD
290
+ Client[Client] --> DatabaseServer[Database Server]
291
+ subgraph MCP Server
292
+ DatabaseServer
293
+ DatabaseHandler[Database Handler]
294
+ PostgresHandler[PostgreSQL Handler]
295
+ SQLiteHandler[SQLite Handler]
296
+ MySQLHandler[MySQL Handler]
297
+ DatabaseServer --> DatabaseHandler
298
+ DatabaseHandler --> PostgresHandler
299
+ DatabaseHandler --> SQLiteHandler
300
+ DatabaseHandler --> MySQLHandler
301
+ end
302
+ PostgresHandler --> PostgreSQL[(PostgreSQL)]
303
+ SQLiteHandler --> SQLite[(SQLite)]
304
+ MySQLHandler --> MySQL[(MySQL)]
305
+ ```
306
+
307
+ The abstraction layer design is the core architectural concept in MCP Database Utilities. Just like a universal remote control that works with different devices, users only need to know the basic operations without understanding the underlying complexities.
308
+
309
+ #### 1. Simplified User Interaction
310
+ - Users only need to know the database configuration name (e.g., "my_postgres")
311
+ - No need to deal with connection parameters and implementation details
312
+ - MCP server automatically handles database connections and queries
313
+
314
+ #### 2. Unified Interface Design
315
+ - DatabaseHandler abstract class defines unified operation interfaces
316
+ - All specific database implementations (PostgreSQL/SQLite/MySQL) follow the same interface
317
+ - Users interact with different databases in the same way
318
+
319
+ #### 3. Configuration and Implementation Separation
320
+ - Complex database configuration parameters are encapsulated in configuration files
321
+ - Runtime access through simple database names
322
+ - Easy management and modification of database configurations without affecting business code
323
+
324
+ ### System Components
325
+ 1. DatabaseServer
326
+ - Core component of the MCP server
327
+ - Handles resource and tool requests
328
+ - Manages database connection lifecycle
329
+
330
+ 2. DatabaseHandler
331
+ - Abstract base class defining unified interface
332
+ - Includes get_tables(), get_schema(), execute_query(), etc.
333
+ - Implemented by PostgreSQL, SQLite, and MySQL handlers
334
+
335
+ 3. Configuration System
336
+ - YAML-based configuration file
337
+ - Support for multiple database configurations
338
+ - Type-safe configuration validation
339
+
340
+ 4. Error Handling and Logging
341
+ - Unified error handling mechanism
342
+ - Detailed logging output
343
+ - Sensitive information masking
344
+
345
+ ## Usage Examples
346
+
347
+ ### Basic Query
348
+ ```python
349
+ # Access through connection name
350
+ async with server.get_handler("my_postgres") as handler:
351
+ # Execute SQL query
352
+ result = await handler.execute_query("SELECT * FROM users")
353
+ ```
354
+
355
+ ### View Table Structure
356
+ ```python
357
+ # Get all tables
358
+ tables = await handler.get_tables()
359
+
360
+ # Get specific table schema
361
+ schema = await handler.get_schema("users")
362
+ ```
363
+
364
+ ### Error Handling
365
+ ```python
366
+ try:
367
+ async with server.get_handler("my_connection") as handler:
368
+ result = await handler.execute_query("SELECT * FROM users")
369
+ except ValueError as e:
370
+ print(f"Configuration error: {e}")
371
+ except Exception as e:
372
+ print(f"Query error: {e}")
373
+ ```
374
+
375
+ ## Security Notes
376
+ - Supports SELECT queries only to protect database security
377
+ - Automatically masks sensitive information (like passwords) in logs
378
+ - Executes queries in read-only transactions
379
+
380
+ ## API Documentation
381
+
382
+ ### DatabaseServer
383
+ Core server class providing:
384
+ - Resource list retrieval
385
+ - Tool call handling (list_tables, query)
386
+ - Database handler management
387
+
388
+ ### MCP Tools
389
+
390
+ #### dbutils-list-tables
391
+ Lists all tables in the specified database.
392
+ - Parameters:
393
+ * connection: Database connection name
394
+ - Returns: Text content with a list of table names
395
+
396
+ #### dbutils-run-query
397
+ Executes a SQL query on the specified database.
398
+ - Parameters:
399
+ * connection: Database connection name
400
+ * sql: SQL query to execute (SELECT only)
401
+ - Returns: Query results in a formatted text
402
+
403
+ #### dbutils-get-stats
404
+ Get table statistics information.
405
+ - Parameters:
406
+ * connection: Database connection name
407
+ * table: Table name
408
+ - Returns: Statistics including row count, size, column stats
409
+
410
+ #### dbutils-list-constraints
411
+ List table constraints (primary key, foreign keys, etc).
412
+ - Parameters:
413
+ * connection: Database connection name
414
+ * table: Table name
415
+ - Returns: Detailed constraint information
416
+
417
+ #### dbutils-explain-query
418
+ Get query execution plan with cost estimates.
419
+ - Parameters:
420
+ * connection: Database connection name
421
+ * sql: SQL query to explain
422
+ - Returns: Formatted execution plan
423
+
424
+ #### dbutils-get-performance
425
+ Get database performance statistics.
426
+ - Parameters:
427
+ * connection: Database connection name
428
+ - Returns: Detailed performance statistics including query times, query types, error rates, and resource usage
429
+
430
+ #### dbutils-analyze-query
431
+ Analyze a SQL query for performance and provide optimization suggestions.
432
+ - Parameters:
433
+ * connection: Database connection name
434
+ * sql: SQL query to analyze
435
+ - Returns: Query analysis with execution plan, timing information, and optimization suggestions
436
+
437
+ ### DatabaseHandler
438
+ Abstract base class defining interfaces:
439
+ - get_tables(): Get table resource list
440
+ - get_schema(): Get table structure
441
+ - execute_query(): Execute SQL query
442
+ - cleanup(): Resource cleanup
443
+
444
+ ### PostgreSQL Implementation
445
+ Provides PostgreSQL-specific features:
446
+ - Remote connection support
447
+ - Table description information
448
+ - Constraint queries
449
+
450
+ ### SQLite Implementation
451
+ Provides SQLite-specific features:
452
+ - File path handling
453
+ - URI scheme support
454
+ - Password protection support (optional)
455
+
456
+ ### MySQL Implementation
457
+ Provides MySQL-specific features:
458
+ - Remote connection support
459
+ - Character set configuration
460
+ - SSL/TLS secure connection
461
+ - URL and standard connection methods
462
+
463
+ ## Contributing
464
+ Contributions are welcome! Here's how you can help:
465
+
466
+ 1. 🐛 Report bugs: Open an issue describing the bug and how to reproduce it
467
+ 2. 💡 Suggest features: Open an issue to propose new features
468
+ 3. 🛠️ Submit PRs: Fork the repo and create a pull request with your changes
469
+
470
+ ### Development Setup
471
+ 1. Clone the repository
472
+ 2. Create a virtual environment using `uv venv`
473
+ 3. Install dependencies with `uv sync --all-extras`
474
+ 4. Run tests with `pytest`
475
+
476
+ For detailed guidelines, see [CONTRIBUTING.md](.github/CONTRIBUTING.md)
477
+
478
+ ## Acknowledgments
479
+ - [MCP Servers](https://github.com/modelcontextprotocol/servers) for inspiration and demonstration
480
+ - AI Editors:
481
+ * [Claude Desktop](https://claude.ai/download)
482
+ * [Cline](https://cline.bot)
483
+ - [Model Context Protocol](https://modelcontextprotocol.io/) for comprehensive interfaces
484
+
485
+ ## Star History
486
+
487
+ [![Star History Chart](https://api.star-history.com/svg?repos=donghao1393/mcp-dbutils&type=Date)](https://star-history.com/#donghao1393/mcp-dbutils&Date)