A robust multi-database implementation of the Database Model Context Protocol (DB MCP). This server provides AI assistants with structured access to multiple databases simultaneously, following Clean Architecture principles for maintainability and testability.
The DB MCP Server offers a standardized way for AI models to interact with databases. It enables them to execute SQL queries, manage transactions, explore schemas, and analyze performance across different database systems concurrently. Built on the mark3labs/mcp-go framework, it ensures modularity and testability.
Database | Status | Features |
---|---|---|
MySQL | ✅ Full Support | Queries, Transactions, Schema Analysis, Performance Insights |
PostgreSQL | ✅ Full Support | Queries, Transactions, Schema Analysis, Performance Insights |
# Clone the repository
git clone https://github.com/FreePeak/db-mcp-server.git
cd db-mcp-server
# Build the server
make build
Configure your database connections in a config.json
file:
{
"connections": [
{
"id": "mysql1",
"type": "mysql",
"host": "localhost",
"port": 13306,
"name": "db1",
"user": "user1",
"password": "password1"
},
{
"id": "postgres1",
"type": "postgres",
"host": "localhost",
"port": 15432,
"name": "db2",
"user": "user2",
"password": "password2"
}
]
}
# Run with default host (localhost) and port (9092)
./server -t sse -config config.json
# Specify host and port for external access
./server -t sse -host example.com -port 8080 -config config.json
# Run in STDIO mode (e.g., for Cursor integration)
<path-to-db-mcp-server>/server -t stdio -c <path-to-your-db-config>config.json
{
"mcpServers": {
"stdio-db-mcp-server": {
"command": "<path-to-dir>/db-mcp-server/server",
"args": [
"-t",
"stdio",
"-c",
"<your-dir>/database_config.json"
]
}
}
}
query_mysql1
: Execute SQL queries on mysql1 database.query_postgres1
: Execute SQL queries on postgres1 database.execute_mysql1
: Run data modification statements on mysql1.execute_postgres1
: Run data modification statements on postgres1.transaction_mysql1
: Manage transactions on mysql1.transaction_postgres1
: Manage transactions on postgres1.performance_mysql1
: Analyze query performance on mysql1.performance_postgres1
: Analyze query performance on postgres1.schema_mysql1
: Explore database schema on mysql1.schema_postgres1
: Explore database schema on postgres1.list_databases
: Show all available database connections.The server follows Clean Architecture principles with these layers:
1. Domain Layer: Core business entities and interfaces.
2. Repository Layer: Data access implementations.
3. Use Case Layer: Application business logic.
4. Delivery Layer: External interfaces (MCP tools).
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Here's how you can help:
1. Fork the repository.
2. Create a feature branch: git checkout -b new-feature
.
3. Commit your changes: git commit -am 'Add new feature'
.
4. Push to the branch: git push origin new-feature
.
5. Submit a pull request.
This project depends on github.com/mark3labs/mcp-go
. For local development, use the patched version in the hack/mcp-go
directory.
# Clone the dependency and fix the Go version
mkdir -p hack/mcp-go
git clone https://github.com/mark3labs/mcp-go.git hack/mcp-go
cd hack/mcp-go
sed -i 's/go 1.23/go 1.22/' go.mod
cd ../..
# Update your go.mod to use the local copy
go mod edit -go=1.22
go mod edit -replace=github.com/mark3labs/mcp-go=./hack/mcp-go
go mod tidy