freepeak_db_mcp_server

freepeak_db_mcp_server

by FreePeak
A server enabling AI models to interact with multiple databases simultaneously for querying, transactions, and schema exploration.

Multi-Database Model Context Protocol Server

License: MIT
Go Report Card
Go Reference
Contributors

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.


Overview

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.


Features

  • Simultaneous Multi-Database Support: Connect to and interact with multiple MySQL and PostgreSQL databases concurrently.
  • Database-Specific Tool Generation: Auto-creates specialized tools for each connected database.
  • Clean Architecture: Modular design with clear separation of concerns.
  • Dynamic Database Tools:
  • Execute SQL queries with parameters.
  • Run data modification statements with proper error handling.
  • Manage database transactions across sessions.
  • Explore database schemas and relationships.
  • Analyze query performance and receive optimization suggestions.
  • Unified Interface: Consistent interaction patterns across different database types.
  • Connection Management: Simple configuration for multiple database connections.

Currently Supported Databases

Database Status Features
MySQL ✅ Full Support Queries, Transactions, Schema Analysis, Performance Insights
PostgreSQL ✅ Full Support Queries, Transactions, Schema Analysis, Performance Insights

Roadmap

Q3 2025

  • MongoDB: Support for document-oriented database operations, schema exploration, and query optimization.
  • SQLite: Lightweight embedded database integration with full transaction support.
  • MariaDB: Complete feature parity with MySQL implementation.

Q4 2025

  • Microsoft SQL Server: Enterprise database support with specialized T-SQL capabilities.
  • Oracle Database: Enterprise-grade integration with Oracle-specific optimizations.
  • Redis: Key-value store operations and performance analysis.

2026

  • Cassandra: Distributed NoSQL database support for high-scale operations.
  • Elasticsearch: Specialized search and analytics capabilities.
  • CockroachDB: Distributed SQL database for global-scale applications.
  • DynamoDB: AWS-native NoSQL database integration.
  • Neo4j: Graph database support with specialized query capabilities.
  • ClickHouse: Analytics database support with column-oriented optimizations.

Installation

Prerequisites

  • Go 1.18 or later.
  • Supported databases: MySQL, PostgreSQL.

Quick Start

# Clone the repository
git clone https://github.com/FreePeak/db-mcp-server.git
cd db-mcp-server

# Build the server
make build

Configuration

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"
    }
  ]
}

Usage

SSE Mode (Server-Sent Events)

# 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

STDIO Mode (for IDE integration)

# 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

Example config for Cursor

{
    "mcpServers": {
        "stdio-db-mcp-server": {
            "command": "<path-to-dir>/db-mcp-server/server",
            "args": [
                "-t",
                "stdio",
                "-c",
                "<your-dir>/database_config.json"
            ]
        }
    }
}

Available Tools

Query Tools

  • query_mysql1: Execute SQL queries on mysql1 database.
  • query_postgres1: Execute SQL queries on postgres1 database.

Execute Tools

  • execute_mysql1: Run data modification statements on mysql1.
  • execute_postgres1: Run data modification statements on postgres1.

Transaction Tools

  • transaction_mysql1: Manage transactions on mysql1.
  • transaction_postgres1: Manage transactions on postgres1.

Performance Tools

  • performance_mysql1: Analyze query performance on mysql1.
  • performance_postgres1: Analyze query performance on postgres1.

Schema Tools

  • schema_mysql1: Explore database schema on mysql1.
  • schema_postgres1: Explore database schema on postgres1.

Global Tools

  • list_databases: Show all available database connections.

Architecture

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).


License

This project is licensed under the MIT License. See the LICENSE file for details.


🤝 Contributing

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.


📧 Support & Contact


Development Notes

Dependencies

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

Features & Capabilities

Categories
mcp_server model_context_protocol go database_integration mysql postgresql clean_architecture api_integration docker

Implementation Details

Stats

0 Views
43 GitHub Stars

Repository Info

FreePeak Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300