12
12
<h3 >A powerful multi-database server implementing the Model Context Protocol (MCP) to provide AI assistants with structured access to databases.</h3 >
13
13
14
14
<div class =" toc " >
15
- <a href =" #what-is-db-mcp-server " >Overview</a > •
15
+ <a href =" #overview " >Overview</a > •
16
16
<a href =" #core-concepts " >Core Concepts</a > •
17
17
<a href =" #features " >Features</a > •
18
- <a href =" #quick-start " >Quick Start </a > •
19
- <a href =" #running-the-server " >Running </a > •
18
+ <a href =" #supported-databases " >Supported Databases </a > •
19
+ <a href =" #deployment-options " >Deployment Options </a > •
20
20
<a href =" #configuration " >Configuration</a > •
21
- <a href =" #available-tools " >Tools</a > •
21
+ <a href =" #available-tools " >Available Tools</a > •
22
22
<a href =" #examples " >Examples</a > •
23
23
<a href =" #troubleshooting " >Troubleshooting</a > •
24
24
<a href =" #contributing " >Contributing</a >
25
25
</div >
26
26
27
27
</div >
28
28
29
- ## What is DB MCP Server?
29
+ ## Overview
30
30
31
31
The DB MCP Server provides a standardized way for AI models to interact with multiple databases simultaneously. Built on the [ FreePeak/cortex] ( https://github.com/FreePeak/cortex ) framework, it enables AI assistants to execute SQL queries, manage transactions, explore schemas, and analyze performance across different database systems through a unified interface.
32
32
@@ -93,58 +93,42 @@ The server follows Clean Architecture principles with these layers:
93
93
- ** Unified Interface** : Consistent interaction patterns across different database types
94
94
- ** Connection Management** : Simple configuration for multiple database connections
95
95
96
- ## Currently Supported Databases
96
+ ## Supported Databases
97
97
98
98
| Database | Status | Features |
99
99
| ---------- | ------------------------- | ------------------------------------------------------------ |
100
100
| MySQL | ✅ Full Support | Queries, Transactions, Schema Analysis, Performance Insights |
101
101
| PostgreSQL | ✅ Full Support (v9.6-17) | Queries, Transactions, Schema Analysis, Performance Insights |
102
102
| TimescaleDB| ✅ Full Support | Hypertables, Time-Series Queries, Continuous Aggregates, Compression, Retention Policies |
103
103
104
- ## Quick Start
104
+ ## Deployment Options
105
105
106
- ### Using Docker
106
+ The DB MCP Server can be deployed in multiple ways to suit different environments and integration needs:
107
+
108
+ ### Docker Deployment
107
109
108
110
``` bash
109
111
# Pull the latest image
110
112
docker pull freepeak/db-mcp-server:latest
111
113
112
- # Run with environment variables
114
+ # Run with mounted config file
113
115
docker run -p 9092:9092 \
114
116
-v $( pwd) /config.json:/app/my-config.json \
115
117
-e TRANSPORT_MODE=sse \
116
118
-e CONFIG_PATH=/app/my-config.json \
117
119
freepeak/db-mcp-server
118
120
```
119
121
120
- > ** Note** : We mount to ` /app/my-config.json ` because the container already has a file at ` /app/config.json ` .
121
-
122
- ### From Source
123
-
124
- ``` bash
125
- # Clone the repository
126
- git clone https://github.com/FreePeak/db-mcp-server.git
127
- cd db-mcp-server
128
-
129
- # Build the server
130
- make build
131
-
132
- # Run the server in SSE mode
133
- ./bin/server -t sse -c config.json
134
- ```
135
-
136
- ## Running the Server
122
+ > ** Note** : Mount to ` /app/my-config.json ` as the container has a default file at ` /app/config.json ` .
137
123
138
- The server supports multiple transport modes:
139
-
140
- ### STDIO Mode (for IDE integration)
124
+ ### STDIO Mode (IDE Integration)
141
125
142
126
``` bash
143
127
# Run the server in STDIO mode
144
- ./server -t stdio -c config.json
128
+ ./bin/ server -t stdio -c config.json
145
129
```
146
130
147
- For Cursor integration, add this to your ` .cursor/mcp.json ` :
131
+ For Cursor IDE integration, add to ` .cursor/mcp.json ` :
148
132
149
133
``` json
150
134
{
@@ -160,18 +144,32 @@ For Cursor integration, add this to your `.cursor/mcp.json`:
160
144
### SSE Mode (Server-Sent Events)
161
145
162
146
``` bash
163
- # Run with default host (localhost) and port ( 9092)
164
- ./server -t sse -c config.json
147
+ # Default configuration (localhost: 9092)
148
+ ./bin/ server -t sse -c config.json
165
149
166
- # Specify a custom host and port
167
- ./server -t sse -host 0.0.0.0 -port 8080 -c config.json
150
+ # Custom host and port
151
+ ./bin/ server -t sse -host 0.0.0.0 -port 8080 -c config.json
168
152
```
169
153
170
- Connect your client to ` http://localhost:9092/sse ` for the event stream.
154
+ Client connection endpoint: ` http://localhost:9092/sse `
155
+
156
+ ### Source Code Installation
157
+
158
+ ``` bash
159
+ # Clone the repository
160
+ git clone https://github.com/FreePeak/db-mcp-server.git
161
+ cd db-mcp-server
162
+
163
+ # Build the server
164
+ make build
165
+
166
+ # Run the server
167
+ ./bin/server -t sse -c config.json
168
+ ```
171
169
172
170
## Configuration
173
171
174
- ### Database Configuration
172
+ ### Database Configuration File
175
173
176
174
Create a ` config.json ` file with your database connections:
177
175
@@ -208,19 +206,18 @@ Create a `config.json` file with your database connections:
208
206
### Command-Line Options
209
207
210
208
``` bash
211
- make build
212
- # Basic options
209
+ # Basic syntax
213
210
./bin/server -t < transport> -c < config-file>
214
211
215
- # For SSE transport, additional options:
212
+ # SSE transport options
216
213
./bin/server -t sse -host < hostname> -port < port> -c < config-file>
217
214
218
- # Direct database configuration:
215
+ # Inline database configuration
219
216
./bin/server -t stdio -db-config ' {"connections":[...]}'
220
217
221
- # Environment variable configuration:
218
+ # Environment variable configuration
222
219
export DB_CONFIG=' {"connections":[...]}'
223
- ./server -t stdio
220
+ ./bin/ server -t stdio
224
221
```
225
222
226
223
## Available Tools
@@ -268,4 +265,71 @@ For detailed documentation on TimescaleDB tools, see [TIMESCALEDB_TOOLS.md](docs
268
265
269
266
### Querying Multiple Databases
270
267
271
- ```
268
+ ``` sql
269
+ -- Query the first database
270
+ query_mysql1(" SELECT * FROM users LIMIT 10" )
271
+
272
+ -- Query the second database in the same context
273
+ query_postgres1(" SELECT * FROM products WHERE price > 100" )
274
+ ```
275
+
276
+ ### Managing Transactions
277
+
278
+ ``` sql
279
+ -- Start a transaction
280
+ transaction_mysql1(" BEGIN" )
281
+
282
+ -- Execute statements within the transaction
283
+ execute_mysql1(" INSERT INTO orders (customer_id, product_id) VALUES (1, 2)" )
284
+ execute_mysql1(" UPDATE inventory SET stock = stock - 1 WHERE product_id = 2" )
285
+
286
+ -- Commit or rollback
287
+ transaction_mysql1(" COMMIT" )
288
+ -- OR
289
+ transaction_mysql1(" ROLLBACK" )
290
+ ```
291
+
292
+ ### Exploring Database Schema
293
+
294
+ ``` sql
295
+ -- Get all tables in the database
296
+ schema_mysql1(" tables" )
297
+
298
+ -- Get columns for a specific table
299
+ schema_mysql1(" columns" , " users" )
300
+
301
+ -- Get constraints
302
+ schema_mysql1(" constraints" , " orders" )
303
+ ```
304
+
305
+ ## Troubleshooting
306
+
307
+ ### Common Issues
308
+
309
+ - ** Connection Failures** : Verify network connectivity and database credentials
310
+ - ** Permission Errors** : Ensure the database user has appropriate permissions
311
+ - ** Timeout Issues** : Check the ` query_timeout ` setting in your configuration
312
+
313
+ ### Logs
314
+
315
+ Enable verbose logging for troubleshooting:
316
+
317
+ ``` bash
318
+ ./bin/server -t sse -c config.json -v
319
+ ```
320
+
321
+ ## Contributing
322
+
323
+ We welcome contributions to the DB MCP Server project! To contribute:
324
+
325
+ 1 . Fork the repository
326
+ 2 . Create a feature branch (` git checkout -b feature/amazing-feature ` )
327
+ 3 . Commit your changes (` git commit -m 'feat: add amazing feature' ` )
328
+ 4 . Push to the branch (` git push origin feature/amazing-feature ` )
329
+ 5 . Open a Pull Request
330
+
331
+ Please see our [ CONTRIBUTING.md] ( docs/CONTRIBUTING.md ) file for detailed guidelines.
332
+
333
+ ## License
334
+
335
+ This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details.
0 commit comments