mcp-dbutils 0.9.0__tar.gz → 0.10.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.
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/CHANGELOG.md +25 -0
- mcp_dbutils-0.10.0/PKG-INFO +227 -0
- mcp_dbutils-0.10.0/README.md +205 -0
- mcp_dbutils-0.10.0/README_CN.md +189 -0
- mcp_dbutils-0.10.0/config.yaml.example +44 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/pyproject.toml +1 -1
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/postgres/config.py +80 -19
- mcp_dbutils-0.10.0/tests/integration/test_postgres_config.py +229 -0
- mcp_dbutils-0.9.0/PKG-INFO +0 -392
- mcp_dbutils-0.9.0/README.md +0 -370
- mcp_dbutils-0.9.0/README_CN.md +0 -350
- mcp_dbutils-0.9.0/config.yaml.example +0 -40
- mcp_dbutils-0.9.0/tests/integration/test_postgres_config.py +0 -129
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/.coveragerc +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/.github/workflows/release.yml +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/.github/workflows/test.yml +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/.gitignore +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/Dockerfile +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/LICENSE +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/smithery.yaml +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/__init__.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/base.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/config.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/log.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/postgres/__init__.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/postgres/handler.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/postgres/server.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/sqlite/__init__.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/sqlite/config.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/sqlite/handler.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/sqlite/server.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/src/mcp_dbutils/stats.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/conftest.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_monitoring.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_monitoring_enhanced.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_postgres.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_prompts.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_sqlite.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_sqlite_config.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_tools.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/integration/test_tools_advanced.py +0 -0
- {mcp_dbutils-0.9.0 → mcp_dbutils-0.10.0}/tests/unit/test_stats.py +0 -0
@@ -1,6 +1,31 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
3
|
|
4
|
+
## v0.10.0 (2025-03-12)
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
- Enhance database configuration with SSL support
|
9
|
+
([#22](https://github.com/donghao1393/mcp-dbutils/pull/22),
|
10
|
+
[`4ea4d0b`](https://github.com/donghao1393/mcp-dbutils/commit/4ea4d0b5deb51b8e9202839bd7a8cd5f71463c88))
|
11
|
+
|
12
|
+
* feat: enhance database configuration with SSL support
|
13
|
+
|
14
|
+
- Replace jdbc_url with url for better clarity - Add dedicated SSL configuration support - Update
|
15
|
+
documentation and examples - Update test cases
|
16
|
+
|
17
|
+
BREAKING CHANGE: Remove jdbc_url support as it was just added and not yet in production use
|
18
|
+
|
19
|
+
* docs: update documentation for SSL support and URL configuration
|
20
|
+
|
21
|
+
- Add SSL configuration examples - Update configuration format examples - Add configuration
|
22
|
+
documentation in both English and Chinese - Remove JDBC related content
|
23
|
+
|
24
|
+
### Breaking Changes
|
25
|
+
|
26
|
+
- Remove jdbc_url support as it was just added and not yet in production use
|
27
|
+
|
28
|
+
|
4
29
|
## v0.9.0 (2025-03-09)
|
5
30
|
|
6
31
|
### Documentation
|
@@ -0,0 +1,227 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: mcp-dbutils
|
3
|
+
Version: 0.10.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: psycopg2-binary>=2.9.10
|
11
|
+
Requires-Dist: python-dotenv>=1.0.1
|
12
|
+
Requires-Dist: pyyaml>=6.0.2
|
13
|
+
Provides-Extra: test
|
14
|
+
Requires-Dist: aiosqlite>=0.19.0; extra == 'test'
|
15
|
+
Requires-Dist: docker>=7.0.0; extra == 'test'
|
16
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'test'
|
17
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
|
18
|
+
Requires-Dist: pytest-docker>=2.0.0; extra == 'test'
|
19
|
+
Requires-Dist: pytest>=7.0.0; extra == 'test'
|
20
|
+
Requires-Dist: testcontainers>=3.7.0; extra == 'test'
|
21
|
+
Description-Content-Type: text/markdown
|
22
|
+
|
23
|
+
# MCP Database Utilities
|
24
|
+
|
25
|
+

|
26
|
+

|
27
|
+
[](https://github.com/donghao1393/mcp-dbutils/actions)
|
28
|
+

|
29
|
+

|
30
|
+
[](https://smithery.ai/server/@donghao1393/mcp-dbutils)
|
31
|
+
|
32
|
+
[中文文档](README_CN.md)
|
33
|
+
|
34
|
+
## Overview
|
35
|
+
MCP Database Utilities is a unified database access service that supports multiple database types (PostgreSQL and SQLite). Through its abstraction layer design, it provides a simple and unified database operation interface for MCP servers.
|
36
|
+
|
37
|
+
## Features
|
38
|
+
- Unified database access interface
|
39
|
+
- Support for multiple database configurations
|
40
|
+
- Secure read-only query execution
|
41
|
+
- Table structure and schema information retrieval
|
42
|
+
- Database tables listing via MCP tools
|
43
|
+
- Intelligent connection management and resource cleanup
|
44
|
+
- Debug mode support
|
45
|
+
- SSL/TLS connection support for PostgreSQL
|
46
|
+
|
47
|
+
## Installation and Configuration
|
48
|
+
|
49
|
+
### Installation Methods
|
50
|
+
#### Installing via Smithery
|
51
|
+
|
52
|
+
To install Database Utilities for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@donghao1393/mcp-dbutils):
|
53
|
+
|
54
|
+
```bash
|
55
|
+
npx -y @smithery/cli install @donghao1393/mcp-dbutils --client claude
|
56
|
+
```
|
57
|
+
|
58
|
+
#### Using uvx (Recommended)
|
59
|
+
No installation required, run directly using `uvx`:
|
60
|
+
```bash
|
61
|
+
uvx mcp-dbutils --config /path/to/config.yaml
|
62
|
+
```
|
63
|
+
|
64
|
+
Add to Claude configuration:
|
65
|
+
```json
|
66
|
+
"mcpServers": {
|
67
|
+
"mcp-dbutils": {
|
68
|
+
"command": "uvx",
|
69
|
+
"args": [
|
70
|
+
"mcp-dbutils",
|
71
|
+
"--config",
|
72
|
+
"/path/to/config.yaml"
|
73
|
+
],
|
74
|
+
"env": {
|
75
|
+
"MCP_DEBUG": "1" // Optional: Enable debug mode
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
```
|
80
|
+
|
81
|
+
#### Using pip
|
82
|
+
```bash
|
83
|
+
pip install mcp-dbutils
|
84
|
+
```
|
85
|
+
|
86
|
+
Add to Claude configuration:
|
87
|
+
```json
|
88
|
+
"mcpServers": {
|
89
|
+
"mcp-dbutils": {
|
90
|
+
"command": "python",
|
91
|
+
"args": [
|
92
|
+
"-m",
|
93
|
+
"mcp_dbutils",
|
94
|
+
"--config",
|
95
|
+
"/path/to/config.yaml"
|
96
|
+
],
|
97
|
+
"env": {
|
98
|
+
"MCP_DEBUG": "1" // Optional: Enable debug mode
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
```
|
103
|
+
|
104
|
+
#### Using Docker
|
105
|
+
```bash
|
106
|
+
docker run -i --rm \
|
107
|
+
-v /path/to/config.yaml:/app/config.yaml \
|
108
|
+
-v /path/to/sqlite.db:/app/sqlite.db \ # Optional: for SQLite database
|
109
|
+
-e MCP_DEBUG=1 \ # Optional: Enable debug mode
|
110
|
+
mcp/dbutils --config /app/config.yaml
|
111
|
+
```
|
112
|
+
|
113
|
+
Add to Claude configuration:
|
114
|
+
```json
|
115
|
+
"mcpServers": {
|
116
|
+
"mcp-dbutils": {
|
117
|
+
"command": "docker",
|
118
|
+
"args": [
|
119
|
+
"run",
|
120
|
+
"-i",
|
121
|
+
"--rm",
|
122
|
+
"-v",
|
123
|
+
"/path/to/config.yaml:/app/config.yaml",
|
124
|
+
"-v",
|
125
|
+
"/path/to/sqlite.db:/app/sqlite.db", // Optional: for SQLite database
|
126
|
+
"mcp/dbutils",
|
127
|
+
"--config",
|
128
|
+
"/app/config.yaml"
|
129
|
+
],
|
130
|
+
"env": {
|
131
|
+
"MCP_DEBUG": "1" // Optional: Enable debug mode
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
```
|
136
|
+
|
137
|
+
> **Note for Docker database connections:**
|
138
|
+
> - For SQLite: Mount your database file using `-v /path/to/sqlite.db:/app/sqlite.db`
|
139
|
+
> - For PostgreSQL running on host:
|
140
|
+
> - On Mac/Windows: Use `host.docker.internal` as host in config
|
141
|
+
> - On Linux: Use `172.17.0.1` (docker0 IP) or run with `--network="host"`
|
142
|
+
|
143
|
+
### Requirements
|
144
|
+
- Python 3.10+
|
145
|
+
- PostgreSQL (optional)
|
146
|
+
- SQLite3 (optional)
|
147
|
+
|
148
|
+
### Configuration File
|
149
|
+
The project requires a YAML configuration file, specified via the `--config` parameter. Configuration examples:
|
150
|
+
|
151
|
+
```yaml
|
152
|
+
connections:
|
153
|
+
# SQLite configuration examples
|
154
|
+
dev-db:
|
155
|
+
type: sqlite
|
156
|
+
path: /path/to/dev.db
|
157
|
+
# Password is optional
|
158
|
+
password:
|
159
|
+
|
160
|
+
# PostgreSQL standard configuration
|
161
|
+
test-db:
|
162
|
+
type: postgres
|
163
|
+
host: postgres.example.com
|
164
|
+
port: 5432
|
165
|
+
dbname: test_db
|
166
|
+
user: test_user
|
167
|
+
password: test_pass
|
168
|
+
|
169
|
+
# PostgreSQL URL configuration with SSL
|
170
|
+
prod-db:
|
171
|
+
type: postgres
|
172
|
+
url: postgresql://postgres.example.com:5432/prod-db?sslmode=verify-full
|
173
|
+
user: prod_user
|
174
|
+
password: prod_pass
|
175
|
+
|
176
|
+
# PostgreSQL full SSL configuration example
|
177
|
+
secure-db:
|
178
|
+
type: postgres
|
179
|
+
host: secure-db.example.com
|
180
|
+
port: 5432
|
181
|
+
dbname: secure_db
|
182
|
+
user: secure_user
|
183
|
+
password: secure_pass
|
184
|
+
ssl:
|
185
|
+
mode: verify-full # disable/require/verify-ca/verify-full
|
186
|
+
cert: /path/to/client-cert.pem
|
187
|
+
key: /path/to/client-key.pem
|
188
|
+
root: /path/to/root.crt
|
189
|
+
```
|
190
|
+
|
191
|
+
PostgreSQL SSL Configuration Options:
|
192
|
+
1. Using URL parameters:
|
193
|
+
```
|
194
|
+
postgresql://host:port/dbname?sslmode=verify-full&sslcert=/path/to/cert.pem
|
195
|
+
```
|
196
|
+
2. Using dedicated SSL configuration section:
|
197
|
+
```yaml
|
198
|
+
ssl:
|
199
|
+
mode: verify-full # SSL verification mode
|
200
|
+
cert: /path/to/cert.pem # Client certificate
|
201
|
+
key: /path/to/key.pem # Client private key
|
202
|
+
root: /path/to/root.crt # CA certificate
|
203
|
+
```
|
204
|
+
|
205
|
+
SSL Modes:
|
206
|
+
- disable: No SSL
|
207
|
+
- require: Use SSL but no certificate verification
|
208
|
+
- verify-ca: Verify server certificate is signed by trusted CA
|
209
|
+
- verify-full: Verify server certificate and hostname match
|
210
|
+
|
211
|
+
SQLite Configuration Options:
|
212
|
+
1. Basic configuration with path:
|
213
|
+
```yaml
|
214
|
+
type: sqlite
|
215
|
+
path: /path/to/db.sqlite
|
216
|
+
password: optional_password # Optional encryption
|
217
|
+
```
|
218
|
+
2. Using URI parameters:
|
219
|
+
```yaml
|
220
|
+
type: sqlite
|
221
|
+
path: /path/to/db.sqlite?mode=ro&cache=shared
|
222
|
+
```
|
223
|
+
|
224
|
+
### Debug Mode
|
225
|
+
Set environment variable `MCP_DEBUG=1` to enable debug mode for detailed logging output.
|
226
|
+
|
227
|
+
[Rest of the README content remains unchanged...]
|
@@ -0,0 +1,205 @@
|
|
1
|
+
# MCP Database Utilities
|
2
|
+
|
3
|
+

|
4
|
+

|
5
|
+
[](https://github.com/donghao1393/mcp-dbutils/actions)
|
6
|
+

|
7
|
+

|
8
|
+
[](https://smithery.ai/server/@donghao1393/mcp-dbutils)
|
9
|
+
|
10
|
+
[中文文档](README_CN.md)
|
11
|
+
|
12
|
+
## Overview
|
13
|
+
MCP Database Utilities is a unified database access service that supports multiple database types (PostgreSQL and SQLite). Through its abstraction layer design, it provides a simple and unified database operation interface for MCP servers.
|
14
|
+
|
15
|
+
## Features
|
16
|
+
- Unified database access interface
|
17
|
+
- Support for multiple database configurations
|
18
|
+
- Secure read-only query execution
|
19
|
+
- Table structure and schema information retrieval
|
20
|
+
- Database tables listing via MCP tools
|
21
|
+
- Intelligent connection management and resource cleanup
|
22
|
+
- Debug mode support
|
23
|
+
- SSL/TLS connection support for PostgreSQL
|
24
|
+
|
25
|
+
## Installation and Configuration
|
26
|
+
|
27
|
+
### Installation Methods
|
28
|
+
#### Installing via Smithery
|
29
|
+
|
30
|
+
To install Database Utilities for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@donghao1393/mcp-dbutils):
|
31
|
+
|
32
|
+
```bash
|
33
|
+
npx -y @smithery/cli install @donghao1393/mcp-dbutils --client claude
|
34
|
+
```
|
35
|
+
|
36
|
+
#### Using uvx (Recommended)
|
37
|
+
No installation required, run directly using `uvx`:
|
38
|
+
```bash
|
39
|
+
uvx mcp-dbutils --config /path/to/config.yaml
|
40
|
+
```
|
41
|
+
|
42
|
+
Add to Claude configuration:
|
43
|
+
```json
|
44
|
+
"mcpServers": {
|
45
|
+
"mcp-dbutils": {
|
46
|
+
"command": "uvx",
|
47
|
+
"args": [
|
48
|
+
"mcp-dbutils",
|
49
|
+
"--config",
|
50
|
+
"/path/to/config.yaml"
|
51
|
+
],
|
52
|
+
"env": {
|
53
|
+
"MCP_DEBUG": "1" // Optional: Enable debug mode
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
#### Using pip
|
60
|
+
```bash
|
61
|
+
pip install mcp-dbutils
|
62
|
+
```
|
63
|
+
|
64
|
+
Add to Claude configuration:
|
65
|
+
```json
|
66
|
+
"mcpServers": {
|
67
|
+
"mcp-dbutils": {
|
68
|
+
"command": "python",
|
69
|
+
"args": [
|
70
|
+
"-m",
|
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 Docker
|
83
|
+
```bash
|
84
|
+
docker run -i --rm \
|
85
|
+
-v /path/to/config.yaml:/app/config.yaml \
|
86
|
+
-v /path/to/sqlite.db:/app/sqlite.db \ # Optional: for SQLite database
|
87
|
+
-e MCP_DEBUG=1 \ # Optional: Enable debug mode
|
88
|
+
mcp/dbutils --config /app/config.yaml
|
89
|
+
```
|
90
|
+
|
91
|
+
Add to Claude configuration:
|
92
|
+
```json
|
93
|
+
"mcpServers": {
|
94
|
+
"mcp-dbutils": {
|
95
|
+
"command": "docker",
|
96
|
+
"args": [
|
97
|
+
"run",
|
98
|
+
"-i",
|
99
|
+
"--rm",
|
100
|
+
"-v",
|
101
|
+
"/path/to/config.yaml:/app/config.yaml",
|
102
|
+
"-v",
|
103
|
+
"/path/to/sqlite.db:/app/sqlite.db", // Optional: for SQLite database
|
104
|
+
"mcp/dbutils",
|
105
|
+
"--config",
|
106
|
+
"/app/config.yaml"
|
107
|
+
],
|
108
|
+
"env": {
|
109
|
+
"MCP_DEBUG": "1" // Optional: Enable debug mode
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
```
|
114
|
+
|
115
|
+
> **Note for Docker database connections:**
|
116
|
+
> - For SQLite: Mount your database file using `-v /path/to/sqlite.db:/app/sqlite.db`
|
117
|
+
> - For PostgreSQL running on host:
|
118
|
+
> - On Mac/Windows: Use `host.docker.internal` as host in config
|
119
|
+
> - On Linux: Use `172.17.0.1` (docker0 IP) or run with `--network="host"`
|
120
|
+
|
121
|
+
### Requirements
|
122
|
+
- Python 3.10+
|
123
|
+
- PostgreSQL (optional)
|
124
|
+
- SQLite3 (optional)
|
125
|
+
|
126
|
+
### Configuration File
|
127
|
+
The project requires a YAML configuration file, specified via the `--config` parameter. Configuration examples:
|
128
|
+
|
129
|
+
```yaml
|
130
|
+
connections:
|
131
|
+
# SQLite configuration examples
|
132
|
+
dev-db:
|
133
|
+
type: sqlite
|
134
|
+
path: /path/to/dev.db
|
135
|
+
# Password is optional
|
136
|
+
password:
|
137
|
+
|
138
|
+
# PostgreSQL standard configuration
|
139
|
+
test-db:
|
140
|
+
type: postgres
|
141
|
+
host: postgres.example.com
|
142
|
+
port: 5432
|
143
|
+
dbname: test_db
|
144
|
+
user: test_user
|
145
|
+
password: test_pass
|
146
|
+
|
147
|
+
# PostgreSQL URL configuration with SSL
|
148
|
+
prod-db:
|
149
|
+
type: postgres
|
150
|
+
url: postgresql://postgres.example.com:5432/prod-db?sslmode=verify-full
|
151
|
+
user: prod_user
|
152
|
+
password: prod_pass
|
153
|
+
|
154
|
+
# PostgreSQL full SSL configuration example
|
155
|
+
secure-db:
|
156
|
+
type: postgres
|
157
|
+
host: secure-db.example.com
|
158
|
+
port: 5432
|
159
|
+
dbname: secure_db
|
160
|
+
user: secure_user
|
161
|
+
password: secure_pass
|
162
|
+
ssl:
|
163
|
+
mode: verify-full # disable/require/verify-ca/verify-full
|
164
|
+
cert: /path/to/client-cert.pem
|
165
|
+
key: /path/to/client-key.pem
|
166
|
+
root: /path/to/root.crt
|
167
|
+
```
|
168
|
+
|
169
|
+
PostgreSQL SSL Configuration Options:
|
170
|
+
1. Using URL parameters:
|
171
|
+
```
|
172
|
+
postgresql://host:port/dbname?sslmode=verify-full&sslcert=/path/to/cert.pem
|
173
|
+
```
|
174
|
+
2. Using dedicated SSL configuration section:
|
175
|
+
```yaml
|
176
|
+
ssl:
|
177
|
+
mode: verify-full # SSL verification mode
|
178
|
+
cert: /path/to/cert.pem # Client certificate
|
179
|
+
key: /path/to/key.pem # Client private key
|
180
|
+
root: /path/to/root.crt # CA certificate
|
181
|
+
```
|
182
|
+
|
183
|
+
SSL Modes:
|
184
|
+
- disable: No SSL
|
185
|
+
- require: Use SSL but no certificate verification
|
186
|
+
- verify-ca: Verify server certificate is signed by trusted CA
|
187
|
+
- verify-full: Verify server certificate and hostname match
|
188
|
+
|
189
|
+
SQLite Configuration Options:
|
190
|
+
1. Basic configuration with path:
|
191
|
+
```yaml
|
192
|
+
type: sqlite
|
193
|
+
path: /path/to/db.sqlite
|
194
|
+
password: optional_password # Optional encryption
|
195
|
+
```
|
196
|
+
2. Using URI parameters:
|
197
|
+
```yaml
|
198
|
+
type: sqlite
|
199
|
+
path: /path/to/db.sqlite?mode=ro&cache=shared
|
200
|
+
```
|
201
|
+
|
202
|
+
### Debug Mode
|
203
|
+
Set environment variable `MCP_DEBUG=1` to enable debug mode for detailed logging output.
|
204
|
+
|
205
|
+
[Rest of the README content remains unchanged...]
|
@@ -0,0 +1,189 @@
|
|
1
|
+
# MCP 数据库服务
|
2
|
+
|
3
|
+
## 项目简介
|
4
|
+
MCP数据库服务是一个统一的数据库访问服务,支持多种数据库类型(PostgreSQL和SQLite)。它通过抽象层设计,为MCP服务器提供了简单、统一的数据库操作接口。
|
5
|
+
|
6
|
+
## 功能特性
|
7
|
+
- 统一的数据库访问接口
|
8
|
+
- 支持多个数据库配置
|
9
|
+
- 安全的只读查询执行
|
10
|
+
- 表结构和模式信息查询
|
11
|
+
- 通过MCP工具列出数据库表
|
12
|
+
- 智能的连接管理和资源清理
|
13
|
+
- 支持调试模式
|
14
|
+
- PostgreSQL的SSL/TLS连接支持
|
15
|
+
|
16
|
+
## 安装与配置
|
17
|
+
|
18
|
+
### 安装方式
|
19
|
+
|
20
|
+
#### 使用 uvx 安装(推荐)
|
21
|
+
不需要专门安装,直接使用 `uvx` 运行:
|
22
|
+
```bash
|
23
|
+
uvx mcp-dbutils --config /path/to/config.yaml
|
24
|
+
```
|
25
|
+
|
26
|
+
添加到 Claude 配置:
|
27
|
+
```json
|
28
|
+
"mcpServers": {
|
29
|
+
"mcp-dbutils": {
|
30
|
+
"command": "uvx",
|
31
|
+
"args": [
|
32
|
+
"mcp-dbutils",
|
33
|
+
"--config",
|
34
|
+
"/path/to/config.yaml"
|
35
|
+
],
|
36
|
+
"env": {
|
37
|
+
"MCP_DEBUG": "1" // 可选:启用调试模式
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
```
|
42
|
+
|
43
|
+
#### 使用 pip 安装
|
44
|
+
```bash
|
45
|
+
pip install mcp-dbutils
|
46
|
+
```
|
47
|
+
|
48
|
+
添加到 Claude 配置:
|
49
|
+
```json
|
50
|
+
"mcpServers": {
|
51
|
+
"mcp-dbutils": {
|
52
|
+
"command": "python",
|
53
|
+
"args": [
|
54
|
+
"-m",
|
55
|
+
"mcp_dbutils",
|
56
|
+
"--config",
|
57
|
+
"/path/to/config.yaml"
|
58
|
+
],
|
59
|
+
"env": {
|
60
|
+
"MCP_DEBUG": "1" // 可选:启用调试模式
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
```
|
65
|
+
|
66
|
+
#### 使用 Docker 安装
|
67
|
+
```bash
|
68
|
+
docker run -i --rm \
|
69
|
+
-v /path/to/config.yaml:/app/config.yaml \
|
70
|
+
-v /path/to/sqlite.db:/app/sqlite.db \ # 可选:用于SQLite数据库
|
71
|
+
-e MCP_DEBUG=1 \ # 可选:启用调试模式
|
72
|
+
mcp/dbutils --config /app/config.yaml
|
73
|
+
```
|
74
|
+
|
75
|
+
添加到 Claude 配置:
|
76
|
+
```json
|
77
|
+
"mcpServers": {
|
78
|
+
"mcp-dbutils": {
|
79
|
+
"command": "docker",
|
80
|
+
"args": [
|
81
|
+
"run",
|
82
|
+
"-i",
|
83
|
+
"--rm",
|
84
|
+
"-v",
|
85
|
+
"/path/to/config.yaml:/app/config.yaml",
|
86
|
+
"-v",
|
87
|
+
"/path/to/sqlite.db:/app/sqlite.db", // 可选:用于SQLite数据库
|
88
|
+
"mcp/dbutils",
|
89
|
+
"--config",
|
90
|
+
"/app/config.yaml"
|
91
|
+
],
|
92
|
+
"env": {
|
93
|
+
"MCP_DEBUG": "1" // 可选:启用调试模式
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
```
|
98
|
+
|
99
|
+
> **Docker数据库连接说明:**
|
100
|
+
> - SQLite数据库:使用 `-v /path/to/sqlite.db:/app/sqlite.db` 映射数据库文件
|
101
|
+
> - 主机上运行的PostgreSQL:
|
102
|
+
> - Mac/Windows:配置中使用 `host.docker.internal`
|
103
|
+
> - Linux:使用 `172.17.0.1`(docker0网络IP)或使用 `--network="host"` 运行
|
104
|
+
|
105
|
+
### 环境要求
|
106
|
+
- Python 3.10+
|
107
|
+
- PostgreSQL (可选)
|
108
|
+
- SQLite3 (可选)
|
109
|
+
|
110
|
+
### 配置文件
|
111
|
+
项目运行需要一个YAML格式的配置文件,通过 `--config` 参数指定路径。配置示例:
|
112
|
+
|
113
|
+
```yaml
|
114
|
+
connections:
|
115
|
+
# SQLite配置示例
|
116
|
+
dev-db:
|
117
|
+
type: sqlite
|
118
|
+
path: /path/to/dev.db
|
119
|
+
# 密码是可选的
|
120
|
+
password:
|
121
|
+
|
122
|
+
# PostgreSQL标准配置
|
123
|
+
test-db:
|
124
|
+
type: postgres
|
125
|
+
host: postgres.example.com
|
126
|
+
port: 5432
|
127
|
+
dbname: test_db
|
128
|
+
user: test_user
|
129
|
+
password: test_pass
|
130
|
+
|
131
|
+
# PostgreSQL URL配置(带SSL)
|
132
|
+
prod-db:
|
133
|
+
type: postgres
|
134
|
+
url: postgresql://postgres.example.com:5432/prod-db?sslmode=verify-full
|
135
|
+
user: prod_user
|
136
|
+
password: prod_pass
|
137
|
+
|
138
|
+
# PostgreSQL完整SSL配置示例
|
139
|
+
secure-db:
|
140
|
+
type: postgres
|
141
|
+
host: secure-db.example.com
|
142
|
+
port: 5432
|
143
|
+
dbname: secure_db
|
144
|
+
user: secure_user
|
145
|
+
password: secure_pass
|
146
|
+
ssl:
|
147
|
+
mode: verify-full # disable/require/verify-ca/verify-full
|
148
|
+
cert: /path/to/client-cert.pem
|
149
|
+
key: /path/to/client-key.pem
|
150
|
+
root: /path/to/root.crt
|
151
|
+
```
|
152
|
+
|
153
|
+
PostgreSQL SSL配置选项:
|
154
|
+
1. 使用URL参数:
|
155
|
+
```
|
156
|
+
postgresql://host:port/dbname?sslmode=verify-full&sslcert=/path/to/cert.pem
|
157
|
+
```
|
158
|
+
2. 使用专门的SSL配置部分:
|
159
|
+
```yaml
|
160
|
+
ssl:
|
161
|
+
mode: verify-full # SSL验证模式
|
162
|
+
cert: /path/to/cert.pem # 客户端证书
|
163
|
+
key: /path/to/key.pem # 客户端私钥
|
164
|
+
root: /path/to/root.crt # CA证书
|
165
|
+
```
|
166
|
+
|
167
|
+
SSL模式:
|
168
|
+
- disable: 不使用SSL
|
169
|
+
- require: 使用SSL但不验证证书
|
170
|
+
- verify-ca: 验证服务器证书是由受信任的CA签名
|
171
|
+
- verify-full: 验证服务器证书和主机名匹配
|
172
|
+
|
173
|
+
SQLite配置选项:
|
174
|
+
1. 基本路径配置:
|
175
|
+
```yaml
|
176
|
+
type: sqlite
|
177
|
+
path: /path/to/db.sqlite
|
178
|
+
password: optional_password # 可选的加密密码
|
179
|
+
```
|
180
|
+
2. 使用URI参数:
|
181
|
+
```yaml
|
182
|
+
type: sqlite
|
183
|
+
path: /path/to/db.sqlite?mode=ro&cache=shared
|
184
|
+
```
|
185
|
+
|
186
|
+
### 调试模式
|
187
|
+
设置环境变量 `MCP_DEBUG=1` 启用调试模式,可以看到详细的日志输出。
|
188
|
+
|
189
|
+
[剩余的README内容保持不变...]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
connections:
|
2
|
+
# SQLite configuration examples
|
3
|
+
dev-db:
|
4
|
+
type: sqlite
|
5
|
+
path: /path/to/dev.db
|
6
|
+
# Password is optional
|
7
|
+
password:
|
8
|
+
|
9
|
+
prod-sqlite:
|
10
|
+
type: sqlite
|
11
|
+
path: /path/to/prod.db
|
12
|
+
password: optional_password # Optional
|
13
|
+
|
14
|
+
# PostgreSQL configuration examples
|
15
|
+
# Standard configuration
|
16
|
+
test-db:
|
17
|
+
type: postgres
|
18
|
+
host: postgres.example.com
|
19
|
+
port: 5432
|
20
|
+
dbname: test_db
|
21
|
+
user: test_user
|
22
|
+
password: test_pass
|
23
|
+
|
24
|
+
# URL configuration
|
25
|
+
# Use postgresql://host:port/dbname?sslmode=verify-full&sslcert=/path/to/cert.pem
|
26
|
+
prod-db:
|
27
|
+
type: postgres
|
28
|
+
url: postgresql://postgres.example.com:5432/prod-db?sslmode=verify-full
|
29
|
+
user: prod_user
|
30
|
+
password: prod_pass
|
31
|
+
|
32
|
+
# Full SSL configuration example
|
33
|
+
secure-db:
|
34
|
+
type: postgres
|
35
|
+
host: secure-db.example.com
|
36
|
+
port: 5432
|
37
|
+
dbname: secure_db
|
38
|
+
user: secure_user
|
39
|
+
password: secure_pass
|
40
|
+
ssl:
|
41
|
+
mode: verify-full
|
42
|
+
cert: /path/to/client-cert.pem
|
43
|
+
key: /path/to/client-key.pem
|
44
|
+
root: /path/to/ca.crt
|