$git clone https://github.com/FreePeak/db-mcp-server</div>
| 1 | <div align="center"> |
| 2 | |
| 3 | <img src="assets/logo.svg" alt="DB MCP Server Logo" width="300" /> |
| 4 | |
| 5 | # Multi Database MCP Server |
| 6 | |
| 7 | [](https://opensource.org/licenses/MIT) |
| 8 | [](https://goreportcard.com/report/github.com/FreePeak/db-mcp-server) |
| 9 | [](https://pkg.go.dev/github.com/FreePeak/db-mcp-server) |
| 10 | [](https://github.com/FreePeak/db-mcp-server/graphs/contributors) |
| 11 | |
| 12 | <h3>A powerful multi-database server implementing the Model Context Protocol (MCP) to provide AI assistants with structured access to databases.</h3> |
| 13 | |
| 14 | <div class="toc"> |
| 15 | <a href="#overview">Overview</a> • |
| 16 | <a href="#core-concepts">Core Concepts</a> • |
| 17 | <a href="#features">Features</a> • |
| 18 | <a href="#supported-databases">Supported Databases</a> • |
| 19 | <a href="#deployment-options">Deployment Options</a> • |
| 20 | <a href="#configuration">Configuration</a> • |
| 21 | <a href="#available-tools">Available Tools</a> • |
| 22 | <a href="#examples">Examples</a> • |
| 23 | <a href="#troubleshooting">Troubleshooting</a> • |
| 24 | <a href="#contributing">Contributing</a> |
| 25 | </div> |
| 26 | |
| 27 | </div> |
| 28 | |
| 29 | ## Overview |
| 30 | |
| 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 | |
| 33 | ## Core Concepts |
| 34 | |
| 35 | ### Multi-Database Support |
| 36 | |
| 37 | Unlike traditional database connectors, DB MCP Server can connect to and interact with multiple databases concurrently: |
| 38 | |
| 39 | ```json |
| 40 | { |
| 41 | "connections": [ |
| 42 | { |
| 43 | "id": "mysql1", |
| 44 | "type": "mysql", |
| 45 | "host": "localhost", |
| 46 | "port": 3306, |
| 47 | "name": "db1", |
| 48 | "user": "user1", |
| 49 | "password": "password1" |
| 50 | }, |
| 51 | { |
| 52 | "id": "postgres1", |
| 53 | "type": "postgres", |
| 54 | "host": "localhost", |
| 55 | "port": 5432, |
| 56 | "name": "db2", |
| 57 | "user": "user2", |
| 58 | "password": "password2" |
| 59 | }, |
| 60 | { |
| 61 | "id": "oracle1", |
| 62 | "type": "oracle", |
| 63 | "host": "localhost", |
| 64 | "port": 1521, |
| 65 | "service_name": "XEPDB1", |
| 66 | "user": "user3", |
| 67 | "password": "password3" |
| 68 | } |
| 69 | ] |
| 70 | } |
| 71 | ``` |
| 72 | |
| 73 | ### Dynamic Tool Generation |
| 74 | |
| 75 | For each connected database, the server automatically generates specialized tools: |
| 76 | |
| 77 | ```go |
| 78 | // For a database with ID "mysql1", these tools are generated: |
| 79 | query_mysql1 // Execute SQL queries |
| 80 | execute_mysql1 // Run data modification statements |
| 81 | transaction_mysql1 // Manage transactions |
| 82 | schema_mysql1 // Explore database schema |
| 83 | performance_mysql1 // Analyze query performance |
| 84 | ``` |
| 85 | |
| 86 | ### Clean Architecture |
| 87 | |
| 88 | The server follows Clean Architecture principles with these layers: |
| 89 | |
| 90 | 1. **Domain Layer**: Core business entities and interfaces |
| 91 | 2. **Repository Layer**: Data access implementations |
| 92 | 3. **Use Case Layer**: Application business logic |
| 93 | 4. **Delivery Layer**: External interfaces (MCP tools) |
| 94 | |
| 95 | ## Features |
| 96 | |
| 97 | - **Simultaneous Multi-Database Support**: Connect to multiple MySQL, PostgreSQL, SQLite, and Oracle databases concurrently |
| 98 | - **Lazy Loading Mode**: Defer connection establishment until first use - perfect for setups with 10+ databases (enable with `--lazy-loading` flag) |
| 99 | - **Database-Specific Tool Generation**: Auto-creates specialized tools for each connected database |
| 100 | - **Clean Architecture**: Modular design with clear separation of concerns |
| 101 | - **OpenAI Agents SDK Compatibility**: Full compatibility for seamless AI assistant integration |
| 102 | - **Dynamic Database Tools**: Execute queries, run statements, manage transactions, explore schemas, analyze performance |
| 103 | - **Unified Interface**: Consistent interaction patterns across different database types |
| 104 | - **Connection Management**: Simple configuration |